| 20 | #include "encodings.h" |
| 21 | |
| 22 | RAPIDJSON_NAMESPACE_BEGIN |
| 23 | |
| 24 | /////////////////////////////////////////////////////////////////////////////// |
| 25 | // Stream |
| 26 | |
| 27 | /*! \class rapidjson::Stream |
| 28 | \brief Concept for reading and writing characters. |
| 29 | |
| 30 | For read-only stream, no need to implement PutBegin(), Put(), Flush() and PutEnd(). |
| 31 | |
| 32 | For write-only stream, only need to implement Put() and Flush(). |
| 33 | |
| 34 | \code |
| 35 | concept Stream { |
| 36 | typename Ch; //!< Character type of the stream. |
| 37 | |
| 38 | //! Read the current character from stream without moving the read cursor. |
| 39 | Ch Peek() const; |
| 40 | |
| 41 | //! Read the current character from stream and moving the read cursor to next character. |
| 42 | Ch Take(); |
| 43 | |
| 44 | //! Get the current read cursor. |
| 45 | //! \return Number of characters read from start. |
| 46 | size_t Tell(); |
| 47 | |
| 48 | //! Begin writing operation at the current read pointer. |
| 49 | //! \return The begin writer pointer. |
| 50 | Ch* PutBegin(); |
| 51 | |
| 52 | //! Write a character. |
| 53 | void Put(Ch c); |
| 54 | |
| 55 | //! Flush the buffer. |
| 56 | void Flush(); |
| 57 | |
| 58 | //! End the writing operation. |
| 59 | //! \param begin The begin write pointer returned by PutBegin(). |
| 60 | //! \return Number of characters written. |
| 61 | size_t PutEnd(Ch* begin); |
| 62 | } |
| 63 | \endcode |
| 64 | */ |
| 65 | |
| 66 | //! Provides additional information for stream. |
| 67 | /*! |
| 68 | By using traits pattern, this type provides a default configuration for stream. |
| 69 | For custom stream, this type can be specialized for other configuration. |
| 70 | See TEST(Reader, CustomStringStream) in readertest.cpp for example. |
| 71 | */ |
| 72 | template<typename Stream> |
| 73 | struct StreamTraits { |
| 74 | //! Whether to make local copy of stream for optimization during parsing. |
| 75 | /*! |
| 76 | By default, for safety, streams do not use local copy optimization. |
| 77 | Stream that can be copied fast should specialize this, like StreamTraits<StringStream>. |
| 78 | */ |
| 79 | enum { copyOptimization = 0 }; |
no outgoing calls
no test coverage detected