Some small optimizations, added reference functions to JSON lib, fixed config commandline options.
This commit is contained in:
parent
0c059f0ca3
commit
ea71dd2d5c
7 changed files with 38 additions and 10 deletions
23
lib/json.cpp
23
lib/json.cpp
|
@ -380,6 +380,29 @@ const bool JSON::Value::asBool(){
|
|||
return (bool) *this;
|
||||
}
|
||||
|
||||
/// Explicit conversion to std::string reference.
|
||||
/// Returns a direct reference for string type JSON::Value objects,
|
||||
/// but a reference to a static empty string otherwise.
|
||||
/// \warning Only save to use when the JSON::Value is a string type!
|
||||
const std::string & JSON::Value::asStringRef(){
|
||||
static std::string ugly_buffer;
|
||||
if (myType == STRING){
|
||||
return strVal;
|
||||
}
|
||||
return ugly_buffer;
|
||||
}
|
||||
|
||||
/// Explicit conversion to c-string.
|
||||
/// Returns a direct reference for string type JSON::Value objects,
|
||||
/// a reference to an empty string otherwise.
|
||||
/// \warning Only save to use when the JSON::Value is a string type!
|
||||
const char * JSON::Value::c_str(){
|
||||
if (myType == STRING){
|
||||
return strVal.c_str();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/// Retrieves or sets the JSON::Value at this position in the object.
|
||||
/// Converts destructively to object if not already an object.
|
||||
JSON::Value & JSON::Value::operator[](const std::string i){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue