Files
reflect-cpp/docs/docs-readme.md
T

4.2 KiB

hide
hide
navigation

image

Documentation

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) Processors - For modifying the structs before serialization and deserialization. For instance, processors can be used to transform all field names from snake_case to camelCase.

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

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

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

1.8) 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.9) rfl::Box and rfl::Ref - For defining recursive structures.

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

1.11) rfl::Skip - For skipping fields during serialization and/or deserialization.

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

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

1.14) C arrays and inheritance - Describes how reflect-cpp handles C arrays and inheritance.

1.15) rfl::Bytestring - Describes how reflect-cpp handles binary strings for formats that support them.

1.16) rfl::Binary, rfl::Hex and rfl::Oct- For expressing numbers in different formats.

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.

2.5) JSON schema - For validating your schema before you even send it to your C++ backend.

3) Generic elements

3.1) rfl::Object - A map-like type representing a object with field names that are unknown at compile time.

3.2) rfl::Generic - A catch-all type that can represent (almost) anything.

3.3) rfl::ExtraFields - For adding extra fields to your structs, the names of which are unknown at compile time.

4) Custom classes

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

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

5) Useful helper functions and classes

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

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

5.3) rfl::NamedTuple - For structural typing.

5.4) rfl::Tuple - An alternative to std::tuple that compiles more quickly.

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

7) Advanced topics

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

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