c++ - 在 yaml-cpp 中读取 map

标签 c++ yaml yaml-cpp

我有以下 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/

相关文章:

jackson YAML : support for tags

java - 使用 Jackson 将 Java 对象实例写入 YAML

yaml - 如何在 YAML 中连接字符串?

c++ - 如何使用 qtcreator 链接到 Arch Linux 上的 yaml-cpp?

c++ - 在 YAML 文件中将项目附加到 map

yaml-cpp - 使用YAML-CPP将YAML发射器内容保存到文件中

C++ 纸牌使用 vector<Card*> 错误与 vector.erase 函数

C++ : const declrations duplicate symbols issue

c++ - 如何返回对 'empty' 对象的引用

c++ - 使用 Visual Studio C++ 进行单元测试时链接器错误