# TOML or not to TOML?

**URL:** <https://corryvreckan-forum.web.cern.ch/t/toml-or-not-to-toml/70>\
**Category:** Uncategorized\
**Created:** [May 18, 2023, 7:32pm UTC](https://corryvreckan-forum.web.cern.ch/t/toml-or-not-to-toml/70 "2023-05-18T19:32:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hessey](https://corryvreckan-forum.web.cern.ch/user_avatar/corryvreckan-forum.web.cern.ch/hessey/32/30_2.png) [@hessey](https://corryvreckan-forum.web.cern.ch/u/hessey)\
**Post date:** [May 18, 2023, 7:32pm UTC](https://corryvreckan-forum.web.cern.ch/t/toml-or-not-to-toml/70/1 "2023-05-18T19:32:00Z")

</div>

I wanted to parse and alter geomtry files with TOML, in a stand-alone C++ program. I tried to parse one of my geometry files with TOML11, a header only C++ TOML package. It throws many errors: arrays need to be in [], 0mm is not allowed for a number (so would have to be quoted, read as a string, then parsed to a numeric + units), and so on.

Does this mean Corryvreckan is not actually using TOML, but something like it?

(Use case:Exploring alignment strategies, I would like to produce a succession of geometry files, with a small number of values changed, leaving everything else unchanged. I have a “bad” C++ code to do this (it assumes a specific order of mimosa’s in the file for example). I would like to do something more correct, based on this TOML 11 package.)

---

<div class="post-metadata">

**Author:** ![simonspa](https://corryvreckan-forum.web.cern.ch/letter_avatar_proxy/v4/letter/s/f04885/32.png) [@simonspa](https://corryvreckan-forum.web.cern.ch/u/simonspa)\
**Post date:** [May 20, 2023, 10:16am UTC](https://corryvreckan-forum.web.cern.ch/t/toml-or-not-to-toml/70/2 "2023-05-20T10:16:32Z")

</div>

Hi @hessey ,

You are right in your assessment that we are not using standard TOML. While it has a nice syntax that is easy to read and understand, it comes with limitations (such as the ones you post above - no units possible with numbers etc) Hence we have defined or own format.

If you’re using C++ I think the easiest would be to use the configuration classes of corryvreckan directly.

Best regards  
Sinon

---

<div class="post-metadata">

**Author:** ![hessey](https://corryvreckan-forum.web.cern.ch/user_avatar/corryvreckan-forum.web.cern.ch/hessey/32/30_2.png) [@hessey](https://corryvreckan-forum.web.cern.ch/u/hessey)\
**Post date:** [May 23, 2023, 5:07pm UTC](https://corryvreckan-forum.web.cern.ch/t/toml-or-not-to-toml/70/3 "2023-05-23T17:07:31Z")

</div>

Thanks for the clarification. I can look into using the corryvreckan configuration classes.  
In the meantime, I found I can modify my config files slightly:

All strings in quotes  
Use standard units, so no need to add um, mm etc.  
Use [] for arrays  
Add a digit before and after all decimal points (which seems an odd requirement of TOML, but is in the strict definition, I checked)

With this, TOML11 parses, can modify, and can write out the config files.  
And equally importantly, Corryvreckan config classes can process such a TOML file correctly.  
Two drawbacks with this:

1. You can’t choose your units
2. By default, TOML11 writes output in a pseudo random order. There are fixes for this. I use a container which at least writes the tables in alphabetical order, with each table’s content also in alphabetical order. There is a non-STL FIFO container available in Gitlab that will maintain order, I didn’t try it.
