Class Acts::GeometryHierarchyMapJsonConverter¶
-
template<typename value_t, class decorator_t = void>
class GeometryHierarchyMapJsonConverter¶ Convert a geometry hierarchy map to/from Json.
The value type is expected to be directly convertible to/from a Json object. It has to be either a fundamental type or appropriate
to_json(json&, const value_t&)
andfrom_json(const json&, value_t&)
functions must be available. See the relevant nlohmann::json documentation for further information.A user-defined identifier is stored in the encoded Json object that is used to identify which value type is stored in the file. The identifier is checked for consistency when decoding the Json object.
- Template Parameters
value_t – value type stored in the geometry hierarchy map
Public Functions
-
inline GeometryHierarchyMapJsonConverter(std::string valueIdentifier)¶
Construct the converter.
- Parameters
valueIdentifier – user-defined identifier for the stored value
-
Container fromJson(const nlohmann::json &encoded) const¶
Decode a Json object into a geometry hierarchy map.
- Parameters
encoded – Json object that should be decoded
- Throws
std::invalid_argument – in case of format errors
- Returns
Decoded geometry hierarchy map
-
nlohmann::json toJson(const Container &container, const decorator_t *decorator) const¶
Encode the geometry hierarchy map into a Json object.
- Parameters
container – Geometry hierarchy map that should be encoded
decorator – nullptr or a decorator to add extra values to the json output
- Returns
Encoded Json object