Files
reflect-cpp/docs/README.md
T

4.3 KiB

Documentation

image

1) The basics

1.1) Structs - Recaps the motivating example in the README. A struct is the equivalent of an AND statement or a product type in type theory.

1.2) Optional fields - For defining fields in your serialized format that might be absent in some cases.

1.3) Struct flattening - For making struct A "inherit" the fields of struct B.

1.4) The rfl::Field-syntax - Describes an alternative syntax which requires slightly more effort, but allows for some powerful functionalities.

1.5) String literals - For representing strings that can only assume a limited number of enumerated values.

1.6) Enums - Describes how reflect-cpp handles C++ enums.

1.7) std::variant and rfl::TaggedUnion - For structs that can be one of several formats. This is the equivalent of an OR statement or a sum type in type theory.

1.8) rfl::Box and rfl::Ref - For defining recursive structures.

1.9) rfl::Timestamp - For serializing and deserializing timestamps.

1.10) rfl::Result - For error handling without exceptions.

1.11) Standard containers - Describes how reflect-cpp treats containers in the standard library.

2) Validation

2.1) Regex patterns - For requiring that strings follow used-defined regex patterns.

2.2) Validating numbers - For imposing constraints on numbers.

2.3) Composing validators - For defining more complex validators using operators such as rfl::AllOf or rfl::AnyOf.

2.4) Size validation - For imposing size constraints on containers such as std::vector or std::string.

3) Custom classes

3.1) Custom classes - For custom classes with private fields.

3.2) Custom parsers for your classes - For custom classes with private fields that you want to leave absolutely untouched.

4) Useful helper functions and classes

4.1) rfl::replace - For replacing one or several fields in a struct.

4.2) rfl::as - For casting structs as other structs.

4.3) rfl::NamedTuple - For structural typing.

4.4) rfl::to_view - For accessing fields of a struct by index or name.

5) Supported formats

5.1) JSON

5.2) BSON

5.3) CBOR

5.4) flexbuffers

5.5) XML

5.6) YAML

6) Advanced topics

6.1) Supporting your own format - For supporting your own serialization and deserialization formats.

6.2) Maintaining backwards compatability - Instructions on how to ensure that your API is backwards-compatible with older versions.