mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-12 18:10:27 +01:00
JSONCPP_OSTRINGSTREAM
This commit is contained in:
parent
724ba29bd3
commit
38bb491400
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
# define JSON_FAIL_MESSAGE(message) \
|
# define JSON_FAIL_MESSAGE(message) \
|
||||||
{ \
|
{ \
|
||||||
std::ostringstream oss; oss << message; \
|
JSONCPP_OSTRINGSTREAM oss; oss << message; \
|
||||||
Json::throwLogicError(oss.str()); \
|
Json::throwLogicError(oss.str()); \
|
||||||
abort(); \
|
abort(); \
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@
|
|||||||
// release builds we abort, for a core-dump or debugger.
|
// release builds we abort, for a core-dump or debugger.
|
||||||
# define JSON_FAIL_MESSAGE(message) \
|
# define JSON_FAIL_MESSAGE(message) \
|
||||||
{ \
|
{ \
|
||||||
std::ostringstream oss; oss << message; \
|
JSONCPP_OSTRINGSTREAM oss; oss << message; \
|
||||||
assert(false && oss.str().c_str()); \
|
assert(false && oss.str().c_str()); \
|
||||||
abort(); \
|
abort(); \
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ static std::string useStyledStreamWriter(
|
|||||||
Json::Value const& root)
|
Json::Value const& root)
|
||||||
{
|
{
|
||||||
Json::StyledStreamWriter writer;
|
Json::StyledStreamWriter writer;
|
||||||
std::ostringstream sout;
|
JSONCPP_OSTRINGSTREAM sout;
|
||||||
writer.write(sout, root);
|
writer.write(sout, root);
|
||||||
return sout.str();
|
return sout.str();
|
||||||
}
|
}
|
||||||
|
@ -2010,7 +2010,7 @@ bool parseFromStream(
|
|||||||
CharReader::Factory const& fact, std::istream& sin,
|
CharReader::Factory const& fact, std::istream& sin,
|
||||||
Value* root, std::string* errs)
|
Value* root, std::string* errs)
|
||||||
{
|
{
|
||||||
std::ostringstream ssin;
|
JSONCPP_OSTRINGSTREAM ssin;
|
||||||
ssin << sin.rdbuf();
|
ssin << sin.rdbuf();
|
||||||
std::string doc = ssin.str();
|
std::string doc = ssin.str();
|
||||||
char const* begin = doc.data();
|
char const* begin = doc.data();
|
||||||
|
@ -217,7 +217,7 @@ std::string valueToQuotedString(const char* value) {
|
|||||||
// sequence from occurring.
|
// sequence from occurring.
|
||||||
default:
|
default:
|
||||||
if (isControlCharacter(*c)) {
|
if (isControlCharacter(*c)) {
|
||||||
std::ostringstream oss;
|
JSONCPP_OSTRINGSTREAM oss;
|
||||||
oss << "\\u" << std::hex << std::uppercase << std::setfill('0')
|
oss << "\\u" << std::hex << std::uppercase << std::setfill('0')
|
||||||
<< std::setw(4) << static_cast<int>(*c);
|
<< std::setw(4) << static_cast<int>(*c);
|
||||||
result += oss.str();
|
result += oss.str();
|
||||||
@ -295,7 +295,7 @@ static std::string valueToQuotedStringN(const char* value, unsigned length) {
|
|||||||
// sequence from occurring.
|
// sequence from occurring.
|
||||||
default:
|
default:
|
||||||
if ((isControlCharacter(*c)) || (*c == 0)) {
|
if ((isControlCharacter(*c)) || (*c == 0)) {
|
||||||
std::ostringstream oss;
|
JSONCPP_OSTRINGSTREAM oss;
|
||||||
oss << "\\u" << std::hex << std::uppercase << std::setfill('0')
|
oss << "\\u" << std::hex << std::uppercase << std::setfill('0')
|
||||||
<< std::setw(4) << static_cast<int>(*c);
|
<< std::setw(4) << static_cast<int>(*c);
|
||||||
result += oss.str();
|
result += oss.str();
|
||||||
@ -1200,7 +1200,7 @@ void StreamWriterBuilder::setDefaults(Json::Value* settings)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string writeString(StreamWriter::Factory const& builder, Value const& root) {
|
std::string writeString(StreamWriter::Factory const& builder, Value const& root) {
|
||||||
std::ostringstream sout;
|
JSONCPP_OSTRINGSTREAM sout;
|
||||||
StreamWriterPtr const writer(builder.newStreamWriter());
|
StreamWriterPtr const writer(builder.newStreamWriter());
|
||||||
writer->write(root, &sout);
|
writer->write(root, &sout);
|
||||||
return sout.str();
|
return sout.str();
|
||||||
|
@ -82,7 +82,7 @@ public:
|
|||||||
|
|
||||||
// Generic operator that will work with anything ostream can deal with.
|
// Generic operator that will work with anything ostream can deal with.
|
||||||
template <typename T> TestResult& operator<<(const T& value) {
|
template <typename T> TestResult& operator<<(const T& value) {
|
||||||
std::ostringstream oss;
|
JSONCPP_OSTRINGSTREAM oss;
|
||||||
oss.precision(16);
|
oss.precision(16);
|
||||||
oss.setf(std::ios_base::floatfield);
|
oss.setf(std::ios_base::floatfield);
|
||||||
oss << value;
|
oss << value;
|
||||||
|
@ -2480,13 +2480,13 @@ JSONTEST_FIXTURE(IteratorTest, const) {
|
|||||||
|
|
||||||
for(int i = 9; i < 12; ++i)
|
for(int i = 9; i < 12; ++i)
|
||||||
{
|
{
|
||||||
std::ostringstream out;
|
JSONCPP_OSTRINGSTREAM out;
|
||||||
out << std::setw(2) << i;
|
out << std::setw(2) << i;
|
||||||
std::string str = out.str();
|
std::string str = out.str();
|
||||||
value[str] = str;
|
value[str] = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostringstream out;
|
JSONCPP_OSTRINGSTREAM out;
|
||||||
//in old code, this will get a compile error
|
//in old code, this will get a compile error
|
||||||
Json::Value::const_iterator iter = value.begin();
|
Json::Value::const_iterator iter = value.begin();
|
||||||
for(; iter != value.end(); ++iter)
|
for(; iter != value.end(); ++iter)
|
||||||
|
Loading…
Reference in New Issue
Block a user