libzypp 17.37.17
json.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_CORE_PARSER_JSON_PARSER_H
13#define ZYPP_CORE_PARSER_JSON_PARSER_H
14
15#include <optional>
20#include "json/JsonValue.h"
21
22namespace zypp::json {
23
24 class Parser : private base::NonCopyable
25 {
26 public:
28 Parser() = default;
29 Parser(const Parser &) = delete;
30 Parser(Parser &&) = delete;
31 Parser &operator=(const Parser &) = delete;
32 Parser &operator=(Parser &&) = delete;
33
35 virtual ~Parser(){}
36
40 zyppng::expected<Value> parse( const InputStream & input_r );
41
42
68
70
71 private:
72
77
78
83
84
85 std::istream::char_type popChar();
86 std::istream::char_type peekChar();
87 void consumeChar();
88
89 zyppng::expected<void> consumeString( const std::string &str );
90
91 static inline std::istream::char_type eofChar() {
92 return std::istream::traits_type::eof();
93 }
94
95 template <typename T = Token>
100
101 std::optional<InputStream> _stream;
102 int _nestingDepth = 0; //< how deep is the nesting ( prevent memory overflow by too deep nesting )
103 };
104}
105#endif
Helper to create and pass std::istream.
Definition inputstream.h:57
zyppng::expected< Token > parseNullToken()
Definition json.cc:293
zyppng::expected< Token > parseBoolToken()
Definition json.cc:302
zyppng::expected< Value > finishParseValue(Token begin)
Definition json.cc:265
zyppng::expected< Object > parseObject()
Definition json.cc:87
zyppng::expected< Token > parseNumberToken()
Definition json.cc:323
Parser & operator=(const Parser &)=delete
zyppng::expected< void > consumeString(const std::string &str)
Definition json.cc:496
zyppng::expected< Value > parseValue()
Definition json.cc:252
zyppng::expected< Value > parse(const InputStream &input_r)
Parse the stream.
Definition json.cc:37
zyppng::expected< Token > nextToken()
Definition json.cc:508
zyppng::expected< Array > parseArray()
Definition json.cc:184
Parser(Parser &&)=delete
virtual ~Parser()
Dtor.
Definition json.h:35
Parser()=default
Default ctor.
Parser(const Parser &)=delete
static std::istream::char_type eofChar()
Definition json.h:91
void consumeChar()
Definition json.cc:490
zyppng::expected< Token > parseStringToken()
Definition json.cc:594
std::istream::char_type popChar()
Definition json.cc:466
std::istream::char_type peekChar()
Definition json.cc:478
std::optional< InputStream > _stream
Definition json.h:101
zyppng::expected< T > makeParseError(const std::string &message, exception_detail::CodeLocation &&loc)
Definition json.h:96
Parser & operator=(Parser &&)=delete
String related utilities and Regular expression matching.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition NonCopyable.h:26
std::exception_ptr do_ZYPP_EXCPT_PTR(TExcpt &&excpt_r, CodeLocation &&where_r)
Helper for ZYPP_EXCPT_PTR( Exception ).
Definition Exception.h:435
Keep FILE, FUNCTION and LINE.
Definition Exception.h:36
static Token eof()
Definition json.cc:752
std::string _token
Definition json.h:64