-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathStringStream.hpp
More file actions
38 lines (33 loc) · 1.41 KB
/
Copy pathStringStream.hpp
File metadata and controls
38 lines (33 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
namespace rapidjson
{
namespace extend
{
// StringStream
// Support Constructs StringStream with the first count characters of the character array starting with the element pointed by src
//! Read-only string stream.
/*! \note implements Stream concept
*/
template <typename Encoding>
struct GenericStringStream {
typedef typename Encoding::Ch Ch;
GenericStringStream(const Ch *src, const size_t count) : src_(src), head_(src), count_(count){}
Ch Peek() const { return Tell()< count_?*src_:'\0'; }
Ch Take() { return *src_++; }
size_t Tell() const { return static_cast<size_t>(src_ - head_); }
Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
void Put(Ch) { RAPIDJSON_ASSERT(false); }
void Flush() { RAPIDJSON_ASSERT(false); }
size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }
const Ch* src_; //!< Current read position.
const Ch* head_; //!< Original head of the string.
size_t count_; //!< Original head of the string.
};
//! String stream with UTF8 encoding.
typedef GenericStringStream<UTF8<> > StringStream;
}
template <typename Encoding>
struct StreamTraits<extend::GenericStringStream<Encoding> > {
enum { copyOptimization = 1 };
};
}