30 #ifndef PT_JSON_JSON_READER_H
31 #define PT_JSON_JSON_READER_H
33 #include <Pt/Json/Api.h>
34 #include <Pt/Json/Node.h>
35 #include <Pt/IOStream.h>
36 #include <Pt/String.h>
37 #include <Pt/NonCopyable.h>
67 std::basic_istream<Pt::Char>*
input();
71 void attach(std::basic_istream<Pt::Char>& is);
86 void reset(std::basic_istream<Pt::Char>& is);
132 JsonReaderImpl* impl()
136 JsonReaderImpl* _impl;
156 { _node = &_stream->
get(); }
161 : _stream(it._stream), _node(it._node)
173 _stream = it._stream;
192 if(_node->
type() == Node::EndDocument)
195 _node = &_stream->
next();
203 {
return _node == it._node; }
208 {
return _node != it._node; }
231 #endif // include guard
Core module.
Definition: Allocator.h:33
JsonReader()
Default Constructor.
void reset()
Clears the reader state and input.
Node & next()
Get next node.
Node & get()
Get current node.
JSON document node.
Definition: Node.h:52
void attach(std::basic_istream< Pt::Char > &is)
Sets the input source.
Reads JSON as a Stream of Nodes.
Definition: JsonReader.h:51
Node * advance()
Process availabe data from underlying input source.
void reset(std::basic_istream< Pt::Char > &is)
Starts parsing with an input source.
std::size_t usedSize() const
Returns the number of characters the parser has allocated.
JsonReader(std::basic_istream< Pt::Char > &is)
Construct with input source.
std::size_t maxSize() const
Returns the number of characters the parser may allocate.
InputIterator end() const
Returns an iterator to the end of the document.
Definition: JsonReader.h:222
std::size_t line() const
Returns the current line of the primary input source.
void setChunkSize(std::size_t n)
Sets the max size of a characters block.
InputIterator current()
Returns an iterator to the current node.
Definition: JsonReader.h:216
Protects derived classes from being copied.
Definition: NonCopyable.h:54
void setMaxSize(std::size_t n)
Sets the max number of characters the parser may allocate.
std::basic_istream< Pt::Char > * input()
Returns the current input source or nullptr if none is set.
Type type() const
Returns the type of the node.
Definition: Node.h:77