/usr/include/cereal/external/rapidjson/genericstream.h is in libcereal-dev 1.1.2-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | // Generic*Stream code from https://code.google.com/p/rapidjson/issues/detail?id=20
#ifndef RAPIDJSON_GENERICSTREAM_H_
#define RAPIDJSON_GENERICSTREAM_H_
#include "rapidjson.h"
#include <iostream>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4127) // conditional expression is constant
#pragma warning(disable: 4512) // assignment operator could not be generated
#pragma warning(disable: 4100) // unreferenced formal parameter
#endif
namespace rapidjson {
//! Wrapper of std::istream for input.
class GenericReadStream {
public:
typedef char Ch; //!< Character type (byte).
//! Constructor.
/*!
\param is Input stream.
*/
GenericReadStream(std::istream & is) : is_(&is) {
}
Ch Peek() const {
if(is_->eof()) return '\0';
return static_cast<char>(is_->peek());
}
Ch Take() {
if(is_->eof()) return '\0';
return static_cast<char>(is_->get());
}
size_t Tell() const {
return (int)is_->tellg();
}
// Not implemented
void Put(Ch) { RAPIDJSON_ASSERT(false); }
void Flush() { RAPIDJSON_ASSERT(false); }
Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }
std::istream * is_;
};
//! Wrapper of std::ostream for output.
class GenericWriteStream {
public:
typedef char Ch; //!< Character type. Only support char.
//! Constructor
/*!
\param os Output stream.
*/
GenericWriteStream(std::ostream& os) : os_(os) {
}
void Put(char c) {
os_.put(c);
}
void PutN(char c, size_t n) {
for (size_t i = 0; i < n; ++i) {
Put(c);
}
}
void Flush() {
os_.flush();
}
size_t Tell() const {
return (int)os_.tellp();
}
// Not implemented
char Peek() const { RAPIDJSON_ASSERT(false); }
char Take() { RAPIDJSON_ASSERT(false); }
char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; }
private:
std::ostream& os_;
};
template<>
inline void PutN(GenericWriteStream& stream, char c, size_t n) {
stream.PutN(c, n);
}
} // namespace rapidjson
// On MSVC, restore warnings state
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif // RAPIDJSON_GENERICSTREAM_H_
|