| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
#ifndef CEREAL_RAPIDJSON_OSTREAMWRAPPER_H_ |
| 16 |
#define CEREAL_RAPIDJSON_OSTREAMWRAPPER_H_ |
| 17 |
|
| 18 |
#include "stream.h" |
| 19 |
#include <iosfwd> |
| 20 |
|
| 21 |
#ifdef __clang__ |
| 22 |
CEREAL_RAPIDJSON_DIAG_PUSH |
| 23 |
CEREAL_RAPIDJSON_DIAG_OFF(padded) |
| 24 |
#endif |
| 25 |
|
| 26 |
CEREAL_RAPIDJSON_NAMESPACE_BEGIN |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
template <typename StreamType> |
| 45 |
class BasicOStreamWrapper { |
| 46 |
public: |
| 47 |
typedef typename StreamType::char_type Ch; |
| 48 |
BasicOStreamWrapper(StreamType& stream) : stream_(stream) {} |
| 49 |
|
| 50 |
void Put(Ch c) { |
| 51 |
stream_.put(c); |
| 52 |
} |
| 53 |
|
| 54 |
void Flush() { |
| 55 |
stream_.flush(); |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
char Peek() const { CEREAL_RAPIDJSON_ASSERT(false); return 0; } |
| 60 |
char Take() { CEREAL_RAPIDJSON_ASSERT(false); return 0; } |
| 61 |
size_t Tell() const { CEREAL_RAPIDJSON_ASSERT(false); return 0; } |
| 62 |
char* PutBegin() { CEREAL_RAPIDJSON_ASSERT(false); return 0; } |
| 63 |
size_t PutEnd(char*) { CEREAL_RAPIDJSON_ASSERT(false); return 0; } |
| 64 |
|
| 65 |
private: |
| 66 |
BasicOStreamWrapper(const BasicOStreamWrapper&); |
| 67 |
BasicOStreamWrapper& operator=(const BasicOStreamWrapper&); |
| 68 |
|
| 69 |
StreamType& stream_; |
| 70 |
}; |
| 71 |
|
| 72 |
typedef BasicOStreamWrapper<std::ostream> OStreamWrapper; |
| 73 |
typedef BasicOStreamWrapper<std::wostream> WOStreamWrapper; |
| 74 |
|
| 75 |
#ifdef __clang__ |
| 76 |
CEREAL_RAPIDJSON_DIAG_POP |
| 77 |
#endif |
| 78 |
|
| 79 |
CEREAL_RAPIDJSON_NAMESPACE_END |
| 80 |
|
| 81 |
#endif |