TOML or not to TOML?

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.)

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

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.