我有以下 yaml 文件:
Pantalla:
ancho: 640
alto: 480
Configuracion:
vel_personaje: 3
merge_scroll: 30
Tipos:
- nombre: arbol
imagen: img/tree
ancho_base: 2
alto_base: 2
pixel_ref_x: 30
pixel_ref_y: 40
fps: 10
delay: 5
- nombre: casa
imagen: img/house
- nombre: auto
imagen: img/car
ancho_base: 5
alto_base: 5
Escenario:
- nombre: principal
size_x: 100
size_y: 100
entidades:
- {x: 10, y: 15, tipo: tierra}
- {x: 15, y: 20, tipo: tierra}
- {x: 10, y: 15, tipo: agua}
- {x: 30, y: 55, tipo: castillo}
protagonista:
- tipo: principal
x: 50
y: 50
当我尝试阅读不同的“entidades”时,yaml-cpp 显示以下内容:
terminate called after throwing an instance of 'YAML::ParserException' what(): yaml-cpp: error at line 32, column 25: illegal map value
第 32 行第 25 列就在“y:”之后。我不知道我做错了。感谢您的帮助!
最佳答案
第 28 行的破折号是 \u00ad
,即“软连字符”。我觉得应该是这样的:
Escenario:
nombre: principal
size_x: 100
size_y: 100
entidades:
- {x: 10, y: 15, tipo: tierra}
- {x: 15, y: 20, tipo: tierra}
- {x: 10, y: 15, tipo: agua}
- {x: 30, y: 55, tipo: castillo}
protagonista:
- tipo: principal
x: 50
y: 50
y: 50
关于c++ - 在 yaml-cpp 中读取 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32511710/