【发布时间】:2015-10-18 15:07:57
【问题描述】:
我想创建一个 (json) 文件 manuyll(使用 python)并将其与谷物一起加载到我的 c++ 应用程序中。
使用 ceral 进行保存和加载工作正常。但是,我不清楚json文件中的polymorphic_ids。
这里有一个更清晰的例子: 这是由谷物框架生成的对象: ```
{
"array1": [
{
"key": 0,
"value": {
"ptr_wrapper": {
"id": 2147483649, //!-- ID1
"data": {
...some float fields...
}
}
}
},
{
"key": 1,
"value": {
"ptr_wrapper": {
"id": 2147483650, //!-- This is previous ID+1 and so on...
"data": {
... some float fields...
}
}
}
}
],
"array2": [
{
"key": 0,
"value": {
"polymorphic_id": 2147483649, //!-- this is the very first ID from array 1.
"polymorphic_name": "my_struct_name",
"ptr_wrapper": {
"id": 2147483651, //this ID1+N Elements from array1
"data": {
... also some float stuff...
}
}
}
}
]
}
```
当我观察到数字生成时,第一个 ID 增加了。第二个数组使用第一个ID作为其多态ID,并进一步增加数字。
那么为什么使用这些数字有什么逻辑吗? 一直使用它们会省钱吗?或者当我在另一台机器上运行我的 c++ 导入器时这些会改变吗?
【问题讨论】:
标签: c++ serialization cereal