#ifndef RFL_PARSING_ISWRITER_HPP_ #define RFL_PARSING_ISWRITER_HPP_ #include #include #include #include "../Result.hpp" namespace rfl { namespace parsing { template concept IsWriter = requires(W w, T t, std::string_view name, std::string basic_value, typename W::OutputArrayType arr, typename W::OutputObjectType obj, typename W::OutputVarType var, size_t size) { /// Sets an empty array as the root element of the document. /// Some serialization formats require you to pass the expected size in /// advance. If you are not working with such a format, you can ignore the /// parameter `size`. Returns the new array for further modification. { w.array_as_root(size) } -> std::same_as; /// Sets an empty object as the root element of the document. /// Some serialization formats require you to pass the expected size in /// advance. If you are not working with such a format, you can ignore the /// parameter `size`. /// Returns the new object for further modification. { w.object_as_root(size) } -> std::same_as; /// Sets a null as the root element of the document. Returns OutputVarType /// containing the null value. { w.null_as_root() } -> std::same_as; /// Sets a basic value (bool, numeric, string) as the root element of the /// document. Returns an OutputVarType containing the new value. { w.value_as_root(basic_value) } -> std::same_as; /// Adds an empty array to an existing array. Returns the new /// array for further modification. { w.add_array_to_array(size, &arr) } -> std::same_as; /// Adds an empty object to an existing array. Returns the new /// object for further modification. { w.add_object_to_array(size, &arr) } -> std::same_as; /// Adds an empty array to an existing object. The key or name of the field is /// signified by `name`. Returns the new array for further modification. { w.add_array_to_object(name, size, &obj) } -> std::same_as; /// Adds an empty object to an existing object. The key or name of the field /// is signified by `name`. Returns the new object for further modification. { w.add_object_to_object(name, size, &obj) } -> std::same_as; /// Adds a basic value (bool, numeric, string) to an array. Returns an /// OutputVarType containing the new value. { w.add_value_to_array(basic_value, &arr) } -> std::same_as; /// Adds a basic value (bool, numeric, string) to an existing object. The key /// or name of the field is signified by `name`. Returns an /// OutputVarType containing the new value. { w.add_value_to_object(name, basic_value, &obj) } -> std::same_as; /// Adds a null value to an array. Returns an /// OutputVarType containing the null value. { w.add_null_to_array(&arr) } -> std::same_as; /// Adds a null value to an existing object. The key /// or name of the field is signified by `name`. Returns an /// OutputVarType containing the null value. { w.add_null_to_object(name, &obj) } -> std::same_as; /// Signifies to the writer that we do not want to add any further elements to /// this array. Some serialization formats require this. If you are working /// with a serialization format that doesn't, just leave the function empty. { w.end_array(&arr) } -> std::same_as; /// Signifies to the writer that we do not want to add any further elements to /// this object. Some serialization formats require this. If you are working /// with a serialization format that doesn't, just leave the function empty. { w.end_object(&obj) } -> std::same_as; }; } // namespace parsing } // namespace rfl #endif