简体   繁体   中英

Yaml-Cpp find out if value was quoted

I'm reading in a yaml file with a big map which looks like this:

test_value: '123'
test_value2: 123
test_value3: 1.0
test_value4: true
test_value5: 'some information'

I can parse it to get the values but I want to know the type of the value. I have specified that a double is always written as a double and boolean are always true or false and also that strings have to be always quoted.

Now the problem is that if I want to read it out again with yaml-cpp I don't get the '123' but rather 123 which I then interpret as a int rather then the string it should be.

Is there any possibility that I overlooked to figure out if there where some quotes around it?

I found a way to figure out if it quoted. In a node there is a tag which you can get with node.Tag() this will in my usecase return me a ! or a ? since the ! is only returned on a former string it can be destingueshed like this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM