Skip to content

Commit f89e75a

Browse files
author
Steve Hanson
committed
remove C++ 11 std::string to_string() syntax
1 parent c491dd5 commit f89e75a

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

example/schemavalidator/schemavalidator.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "rapidjson/prettywriter.h"
1010
#include <string>
1111
#include <iostream>
12+
#include <sstream>
1213

1314
using namespace rapidjson;
1415

@@ -19,27 +20,26 @@ static void CreateErrorMessages(const ValueType& errors, size_t depth, const cha
1920

2021
// Convert GenericValue to std::string
2122
static std::string GetString(const ValueType& val) {
22-
std::string str("");
23-
if (val.IsString())
24-
str = val.GetString();
25-
else if (val.IsDouble())
26-
str = std::to_string(val.GetDouble());
27-
else if (val.IsUint())
28-
str = std::to_string(val.GetUint());
29-
else if (val.IsInt())
30-
str = std::to_string(val.GetInt());
31-
else if (val.IsUint64())
32-
str = std::to_string(val.GetUint64());
33-
else if (val.IsInt64())
34-
str = std::to_string(val.GetInt64());
35-
else if (val.IsBool() && val.GetBool())
36-
str = "true";
37-
else if (val.IsBool())
38-
str = "false";
39-
else if (val.IsFloat())
40-
str = std::to_string(val.GetFloat());
41-
return str;
42-
}
23+
std::ostringstream s;
24+
if (val.IsString())
25+
s << val.GetString();
26+
else if (val.IsDouble())
27+
s << val.GetDouble();
28+
else if (val.IsUint())
29+
s << val.GetUint();
30+
else if (val.IsInt())
31+
s << val.GetInt();
32+
else if (val.IsUint64())
33+
s << val.GetUint64();
34+
else if (val.IsInt64())
35+
s << val.GetInt64();
36+
else if (val.IsBool() && val.GetBool())
37+
s << "true";
38+
else if (val.IsBool())
39+
s << "false";
40+
else if (val.IsFloat())
41+
s << val.GetFloat();
42+
return s.str();}
4343

4444
// Create the error message for a named error
4545
// The error object can either be empty or contain at least member properties:

0 commit comments

Comments
 (0)