| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- //
- // json_binder.h
- // json
- //
- // Created by Sam Jaffe on 1/31/16.
- // Copyright © 2016 Sam Jaffe. All rights reserved.
- //
- #ifndef json_parser_h
- #define json_parser_h
- #pragma once
- #include <iostream>
- #include <memory>
- namespace json {
- class value;
-
- namespace binder { template <typename, typename> class visitor; }
-
- namespace parser {
- template <typename T, typename S>
- void parse(binder::visitor<T, S>&, char const*, options opts = allow_all);
-
- template <typename T, typename S>
- void parse(binder::visitor<T, S>&& v, std::string const& s, options opts = allow_all) {
- parse(static_cast<binder::visitor<T, S>&>(v), s.c_str(), opts);
- }
-
- template <typename T, typename S>
- void parse(binder::visitor<T, S>&& v, std::istream & in, options opts = allow_all) {
- if (!in) return;
- in.seekg(0, std::ios_base::end);
- std::istream::pos_type end = in.tellg();
- std::unique_ptr<char[]> data{new char[end]};
- in.seekg(0);
- in.read(data.get(), end);
- parse(static_cast<binder::visitor<T, S>&>(v), data.get(), opts);
- }
- }
- }
- #endif /* json_parser_h */
|