【问题标题】:Reading maps in yaml-cpp在 yaml-cpp 中读取地图
【发布时间】:2015-09-10 21:14:29
【问题描述】:

我有以下 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 会显示以下内容:

在抛出 'YAML::ParserException' 实例后调用终止 what(): yaml-cpp: error at line 32, column 25: 非法映射值

第 32 行第 25 列就在“y:”之后。我不知道我做错了。感谢您的帮助!

【问题讨论】:

    标签: c++ yaml yaml-cpp


    【解决方案1】:

    第 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
    

    【讨论】:

    • 感谢您的回答,但这不是问题所在。我删除了该连字符,但错误仍在发生。另外,我使用了yaml-online-parser.appspot.com,上面写着“这里不允许映射值”但仍然不知道为什么..感谢您以后的帮助! @jesse-beder
    • @user2566343 你的文件中有很多奇怪的字符。找一个十六进制编辑器,确保空格真的是空格,连字符真的是连字符。
    猜你喜欢
    • 1970-01-01
    • 2014-12-05
    • 2022-01-01
    • 1970-01-01
    • 2016-04-14
    • 2013-11-28
    • 1970-01-01
    • 2015-12-06
    • 1970-01-01
    相关资源
    最近更新 更多