diff options
Diffstat (limited to 'src/json.hh')
| -rw-r--r-- | src/json.hh | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/json.hh b/src/json.hh new file mode 100644 index 0000000..d872dde --- /dev/null +++ b/src/json.hh @@ -0,0 +1,46 @@ +#ifndef JSON_HH +#define JSON_HH + +#include <cstdint> +#include <iosfwd> +#include <memory> +#include <string> +#include <string_view> + +namespace json { + +class Writer { + public: + virtual ~Writer() = default; + + virtual void value(std::string_view value) = 0; + virtual void value(int64_t value) = 0; + virtual void value(uint64_t value) = 0; + virtual void value(float value) = 0; + virtual void value(double value) = 0; + virtual void value(bool value) = 0; + + void value(char const* value); + void value(int value); + + virtual void start_array() = 0; + virtual void end_array() = 0; + + virtual void start_object() = 0; + virtual void key(std::string_view name) = 0; + virtual void end_object() = 0; + + virtual void clear() = 0; + + protected: + Writer() = default; + Writer(Writer const&) = delete; + Writer& operator=(Writer const&) = delete; +}; + +std::unique_ptr<Writer> writer(std::string& out); +std::unique_ptr<Writer> writer(std::ostream& out); + +} // namespace json + +#endif // JSON_HH |
