rossvideo / Catena

Other
6 stars 2 forks source link

codegen STRUCT_ARRAY #218

Closed mejohnnaylor closed 6 days ago

mejohnnaylor commented 1 month ago

add codegen support for STRUCT_ARRAY type.

hopefully, we're all familiar with the location struct so I don't need to repeat it here...

...
  "params": {
    "football_grounds": {
      "type": "STRUCT_ARRAY",
      "template_oid": "/location",
      "value": {
        "struct_array_values": {
          "struct_values": [
            {"fields": {
               "latitude": {"value": {"float32_value": 1.0},
               "longitude": {"value": {"float32_value": 2.0},
             }},
             {"fields": {
               "latitude": {"value": {"float32_value": 3.0},
               "longitude": {"value": {"float32_value": 4.0},
             }}
          ]
        }
      }
    }
  },
...

body file

std::vector<Location> football_grounds {{1.0,2.0},{3.0,4.0}};
mejohnnaylor commented 1 month ago

what's interesting about this example is that, if we want to use a STRUCT template_oid for a parameter that's a STRUCT_ARRAY, we need both the type and the template_oid fields to be present, and to validate that the template_oid maps to a STRUCT definition.