-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[struct_xml] struct_xml::to_xml一个包含std::map<int, int>的对象,执行struct_xml::to_xml时崩溃。且不能支持struct_pack::compatible做成员变量 #780
Comments
xml是不支持map的,没有xml结构可以和map对应,map只是用来保存属性才能用而不是直接作为成员,可以看看struct_xml 的例子,如果字段中有map类型则会抛出一个bad function call的异常。 https://github.com/qicosmos/iguana/blob/master/test/test_xml.cpp#L774 |
这个对象to_json 是没问题的,因为json支持map结构。 |
感谢答复!
boost测试代码产生的xml文件内容如下
如果xml能支持std::map就好了,这样与使用更方便,不用考虑json转xml时还要修改结构体数据类型。 |
代码如下
问题1,因为person里有成员变量std::map<int, int> idx2Int,所以执行到struct_xml::to_xml(p, str);时崩溃。崩溃如下图
问题2,如果打开struct_pack::compatible<int, 114514> c1;相关的注释,编译不通过,编译报错如下图
因为我想让结构体person同时使用struct_pack、struct_xml、struct_json,且想保证不同版本的前后兼容性。且能支持std常用的容器,如std::map。谢谢!
The text was updated successfully, but these errors were encountered: