mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-13 18:27:10 +01:00
parent
a8104a8035
commit
42d7e59fe0
@ -17,6 +17,7 @@
|
|||||||
#include <cpptl/conststring.h>
|
#include <cpptl/conststring.h>
|
||||||
#endif
|
#endif
|
||||||
#include <cstddef> // size_t
|
#include <cstddef> // size_t
|
||||||
|
#include <algorithm> // min()
|
||||||
|
|
||||||
#define JSON_ASSERT_UNREACHABLE assert(false)
|
#define JSON_ASSERT_UNREACHABLE assert(false)
|
||||||
|
|
||||||
@ -325,19 +326,19 @@ Value::Value(double value) {
|
|||||||
|
|
||||||
Value::Value(const char* value) {
|
Value::Value(const char* value) {
|
||||||
initBasic(stringValue, true);
|
initBasic(stringValue, true);
|
||||||
value_.string_ = duplicateAndPrefixStringValue(value, strlen(value));
|
value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(strlen(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::Value(const char* beginValue, const char* endValue) {
|
Value::Value(const char* beginValue, const char* endValue) {
|
||||||
initBasic(stringValue, true);
|
initBasic(stringValue, true);
|
||||||
value_.string_ =
|
value_.string_ =
|
||||||
duplicateAndPrefixStringValue(beginValue, (unsigned int)(endValue - beginValue));
|
duplicateAndPrefixStringValue(beginValue, static_cast<unsigned>(endValue - beginValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::Value(const std::string& value) {
|
Value::Value(const std::string& value) {
|
||||||
initBasic(stringValue, true);
|
initBasic(stringValue, true);
|
||||||
value_.string_ =
|
value_.string_ =
|
||||||
duplicateAndPrefixStringValue(value.data(), (unsigned int)value.length());
|
duplicateAndPrefixStringValue(value.data(), static_cast<unsigned>(value.length()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::Value(const StaticString& value) {
|
Value::Value(const StaticString& value) {
|
||||||
@ -348,7 +349,7 @@ Value::Value(const StaticString& value) {
|
|||||||
#ifdef JSON_USE_CPPTL
|
#ifdef JSON_USE_CPPTL
|
||||||
Value::Value(const CppTL::ConstString& value) {
|
Value::Value(const CppTL::ConstString& value) {
|
||||||
initBasic(stringValue, true);
|
initBasic(stringValue, true);
|
||||||
value_.string_ = duplicateAndPrefixStringValue(value, value.length());
|
value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(value.length()));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -937,7 +938,7 @@ Value& Value::resolveReference(const char* key) {
|
|||||||
if (type_ == nullValue)
|
if (type_ == nullValue)
|
||||||
*this = Value(objectValue);
|
*this = Value(objectValue);
|
||||||
CZString actualKey(
|
CZString actualKey(
|
||||||
key, strlen(key), CZString::noDuplication); // NOTE!
|
key, static_cast<unsigned>(strlen(key)), CZString::noDuplication); // NOTE!
|
||||||
ObjectValues::iterator it = value_.map_->lower_bound(actualKey);
|
ObjectValues::iterator it = value_.map_->lower_bound(actualKey);
|
||||||
if (it != value_.map_->end() && (*it).first == actualKey)
|
if (it != value_.map_->end() && (*it).first == actualKey)
|
||||||
return (*it).second;
|
return (*it).second;
|
||||||
@ -957,7 +958,7 @@ Value& Value::resolveReference(char const* key, char const* end)
|
|||||||
if (type_ == nullValue)
|
if (type_ == nullValue)
|
||||||
*this = Value(objectValue);
|
*this = Value(objectValue);
|
||||||
CZString actualKey(
|
CZString actualKey(
|
||||||
key, (end-key), CZString::duplicateOnCopy);
|
key, static_cast<unsigned>(end-key), CZString::duplicateOnCopy);
|
||||||
ObjectValues::iterator it = value_.map_->lower_bound(actualKey);
|
ObjectValues::iterator it = value_.map_->lower_bound(actualKey);
|
||||||
if (it != value_.map_->end() && (*it).first == actualKey)
|
if (it != value_.map_->end() && (*it).first == actualKey)
|
||||||
return (*it).second;
|
return (*it).second;
|
||||||
@ -981,7 +982,7 @@ Value const* Value::find(char const* key, char const* end) const
|
|||||||
type_ == nullValue || type_ == objectValue,
|
type_ == nullValue || type_ == objectValue,
|
||||||
"in Json::Value::find(key, end, found): requires objectValue or nullValue");
|
"in Json::Value::find(key, end, found): requires objectValue or nullValue");
|
||||||
if (type_ == nullValue) return NULL;
|
if (type_ == nullValue) return NULL;
|
||||||
CZString actualKey(key, end-key, CZString::noDuplication);
|
CZString actualKey(key, static_cast<unsigned>(end-key), CZString::noDuplication);
|
||||||
ObjectValues::const_iterator it = value_.map_->find(actualKey);
|
ObjectValues::const_iterator it = value_.map_->find(actualKey);
|
||||||
if (it == value_.map_->end()) return NULL;
|
if (it == value_.map_->end()) return NULL;
|
||||||
return &(*it).second;
|
return &(*it).second;
|
||||||
@ -1045,7 +1046,7 @@ bool Value::removeMember(const char* key, const char* end, Value* removed)
|
|||||||
if (type_ != objectValue) {
|
if (type_ != objectValue) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CZString actualKey(key, end-key, CZString::noDuplication);
|
CZString actualKey(key, static_cast<unsigned>(end-key), CZString::noDuplication);
|
||||||
ObjectValues::iterator it = value_.map_->find(actualKey);
|
ObjectValues::iterator it = value_.map_->find(actualKey);
|
||||||
if (it == value_.map_->end())
|
if (it == value_.map_->end())
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user