#include #include #include #include #include #include #include #include namespace Lml { /// /// Tree leaf composed of zero or more values. /// using Scalar = std::vector; /// /// Content body capable of holding Scalars as properties and other child Documents as elements. /// struct Document final { /// /// Custom hashing mechanism used by properties to support lookups with string types other than std::string. /// struct PropertyHash { using HashType = std::hash; using is_transparent = void; size_t operator()(const char* str) const { return HashType{}(str); } size_t operator()(std::string_view str) const { return HashType{}(str); } size_t operator()(std::string const& str) const { return HashType{}(str); } }; /// /// Map of property names and their associated Scalar. /// using PropertyMap = std::unordered_map>; /// /// List of associated element names and Documents. /// using ElementList = std::vector>; /// /// All live property Scalars belonging to the Document. /// PropertyMap properties {}; /// /// All live element Documents belonging to the Document. /// ElementList elements {}; /// /// Attempts to parse the provided data into the live Document object model, returning true if it was /// successful, otherwise false. /// bool Parse(std::string_view const & data); /// /// Attempts to retrieve a single string value from a Scalar defined under the provided property name, /// returning it or null if no such property exists. /// std::optional Property(std::string_view const & property); /// /// Serializes the live Document object model to the provided string with the specified indentation level. /// void SerializeTo(std::string & string, size_t indentation) const; }; }