yaml-cpp format maps with whitespaces

179 views Asked by At

Using the yaml-cpp library, is it possible to format YAML::Emitter with whitespaces? For example if I have a structure that emits something like this:

    Fruit:
     - {Name: Apple, Number: 32}
     - {Name: Oranges, Number: 64}
     - {Name: Pineapple, Number: 128}

Can I output something like this:

    Fruit:
     - {Name: Apple,      Number: 32}
     - {Name: Oranges,    Number: 64}
     - {Name: Pineapple,  Number: 128}

The motivation for this is that I have really large maps that would be easier to read if there was a way to format them so keys lined up column-wise. And the reason I'm using YAML::Flow instead of YAML::Block for the map format is because with the block formatting the file becomes long and tough to read. Any thoughts on how to achieve this or something similar?

Thanks!

1

There are 1 answers

0
Jesse Beder On BEST ANSWER

You can't do that; it's not a feature of yaml-cpp. You'll have to decide between block and flow formatting.