Skip to content

Commit 83915b5

Browse files
committed
Compile-fix for g++ 6.3.0 (Debian 9)
1 parent 9a28ade commit 83915b5

File tree

1 file changed

+53
-47
lines changed

1 file changed

+53
-47
lines changed

src/json/json.cpp

Lines changed: 53 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -285,41 +285,43 @@ const Json::Array& Json::Value::getArray() const{
285285
return *_array;
286286
}
287287

288-
std::ostream& Json::operator<<(std::ostream& os, const Json::Value& value){
288+
namespace Json {
289+
std::ostream& operator<<(std::ostream& os, const Value& value){
289290

290-
if(value._type == Value::objectType){
291-
assert(value._object != 0);
292-
os << *(value._object);
293-
return os;
294-
}
291+
if(value._type == Value::objectType){
292+
assert(value._object != 0);
293+
os << *(value._object);
294+
return os;
295+
}
295296

296-
if(value._type == Value::arrayType){
297-
assert(value._array != 0);
298-
os << *(value._array);
299-
return os;
300-
}
297+
if(value._type == Value::arrayType){
298+
assert(value._array != 0);
299+
os << *(value._array);
300+
return os;
301+
}
301302

302-
if(value._type == Value::nullType){
303-
os << "null";
304-
return os;
305-
}
303+
if(value._type == Value::nullType){
304+
os << "null";
305+
return os;
306+
}
306307

307-
if(value._type == Value::booleanType){
308-
if(value)
309-
os << "true";
310-
else
311-
os << "false";
312-
return os;
313-
}
308+
if(value._type == Value::booleanType){
309+
if(value)
310+
os << "true";
311+
else
312+
os << "false";
313+
return os;
314+
}
315+
316+
if(value._type == Value::stringType){
317+
os << "\"" << value._data << "\"";
318+
return os;
319+
}
314320

315-
if(value._type == Value::stringType){
316-
os << "\"" << value._data << "\"";
321+
assert(value._type == Value::numberType);
322+
os << value._data;
317323
return os;
318324
}
319-
320-
assert(value._type == Value::numberType);
321-
os << value._data;
322-
return os;
323325
}
324326

325327
// Set this value as a boolean.
@@ -852,17 +854,19 @@ bool Json::Object::operator==(const Object& o) const {
852854
}
853855

854856
// Output in Json format
855-
ostream& Json::operator<<(ostream& os, const Json::Object& obj){
856-
os << "{";
857-
for(std::map< Key, Value >::const_iterator it = obj._memberMap.begin(); it != obj._memberMap.end(); ){
858-
os << "\"" << it->first << "\":" << it->second;
859-
++it;
860-
if(it != obj._memberMap.end())
861-
os << ",";
862-
}
863-
os << "}";
857+
namespace Json {
858+
std::ostream& operator<<(std::ostream& os, const Object& obj){
859+
os << "{";
860+
for(std::map< Key, Value >::const_iterator it = obj._memberMap.begin(); it != obj._memberMap.end(); ){
861+
os << "\"" << it->first << "\":" << it->second;
862+
++it;
863+
if(it != obj._memberMap.end())
864+
os << ",";
865+
}
866+
os << "}";
864867

865-
return os;
868+
return os;
869+
}
866870
}
867871

868872
/*------------------- Json Array ------------------*/
@@ -941,20 +945,22 @@ bool Json::Array::operator==(const Array& a) const {
941945
}
942946

943947
// Output in Json pretty format
944-
ostream& Json::operator<<(ostream& os, const Json::Array& array){
948+
namespace Json {
949+
std::ostream& operator<<(std::ostream& os, const Array& array){
945950

946-
os << "[";
951+
os << "[";
947952

948-
list<Value>::const_iterator it = array._elementList.begin();
949-
if(it != array._elementList.end())
950-
os << *it;
953+
list<Value>::const_iterator it = array._elementList.begin();
954+
if(it != array._elementList.end())
955+
os << *it;
951956

952-
for(++it; it != array._elementList.end(); ++it)
953-
os << "," << *it;
957+
for(++it; it != array._elementList.end(); ++it)
958+
os << "," << *it;
954959

955-
os << ']';
960+
os << ']';
956961

957-
return os;
962+
return os;
963+
}
958964
}
959965

960966
// Returns the data in Json Format.

0 commit comments

Comments
 (0)