All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
genericreadstream.h
1
#ifndef RAPIDJSON_GENERICREADSTREAM_H_
2
#define RAPIDJSON_GENERICREADSTREAM_H_
3
4
#include "
rapidjson.h
"
5
#include <iostream>
6
7
namespace
rapidjson {
8
9
//! Wrapper of std::istream for input.
10
class
GenericReadStream
{
11
public
:
12
typedef
char
Ch
;
//!< Character type (byte).
13
14
//! Constructor.
15
/*!
16
\param is Input stream.
17
*/
18
GenericReadStream
(std::istream& is) : is_(is) {
19
}
20
21
Ch
Peek()
const
{
22
return
static_cast<
char
>
(is_.peek());
23
}
24
25
Ch
Take() {
26
return
static_cast<
char
>
(is_.get());
27
}
28
29
size_t
Tell()
const
{
30
return
(
int
)is_.tellg();
31
}
32
33
// Not implemented
34
void
Put(
Ch
c) {
RAPIDJSON_ASSERT
(
false
); }
35
void
Flush() {
RAPIDJSON_ASSERT
(
false
); }
36
Ch
* PutBegin() {
RAPIDJSON_ASSERT
(
false
);
return
0; }
37
size_t
PutEnd(
Ch
*) {
RAPIDJSON_ASSERT
(
false
);
return
0; }
38
39
std::istream& is_;
40
};
41
42
}
// namespace rapidjson
43
44
#endif // RAPIDJSON_GENERICREADSTREAM_H_
include
rapidjson
genericreadstream.h