Skip to content

Commit 42d7e59

Browse files
committed
fix compiler-error and warnings for VS2013
fix issue open-source-parsers#200
1 parent a8104a8 commit 42d7e59

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/lib_json/json_value.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <cpptl/conststring.h>
1818
#endif
1919
#include <cstddef> // size_t
20+
#include <algorithm> // min()
2021

2122
#define JSON_ASSERT_UNREACHABLE assert(false)
2223

@@ -325,19 +326,19 @@ Value::Value(double value) {
325326

326327
Value::Value(const char* value) {
327328
initBasic(stringValue, true);
328-
value_.string_ = duplicateAndPrefixStringValue(value, strlen(value));
329+
value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(strlen(value)));
329330
}
330331

331332
Value::Value(const char* beginValue, const char* endValue) {
332333
initBasic(stringValue, true);
333334
value_.string_ =
334-
duplicateAndPrefixStringValue(beginValue, (unsigned int)(endValue - beginValue));
335+
duplicateAndPrefixStringValue(beginValue, static_cast<unsigned>(endValue - beginValue));
335336
}
336337

337338
Value::Value(const std::string& value) {
338339
initBasic(stringValue, true);
339340
value_.string_ =
340-
duplicateAndPrefixStringValue(value.data(), (unsigned int)value.length());
341+
duplicateAndPrefixStringValue(value.data(), static_cast<unsigned>(value.length()));
341342
}
342343

343344
Value::Value(const StaticString& value) {
@@ -348,7 +349,7 @@ Value::Value(const StaticString& value) {
348349
#ifdef JSON_USE_CPPTL
349350
Value::Value(const CppTL::ConstString& value) {
350351
initBasic(stringValue, true);
351-
value_.string_ = duplicateAndPrefixStringValue(value, value.length());
352+
value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(value.length()));
352353
}
353354
#endif
354355

@@ -937,7 +938,7 @@ Value& Value::resolveReference(const char* key) {
937938
if (type_ == nullValue)
938939
*this = Value(objectValue);
939940
CZString actualKey(
940-
key, strlen(key), CZString::noDuplication); // NOTE!
941+
key, static_cast<unsigned>(strlen(key)), CZString::noDuplication); // NOTE!
941942
ObjectValues::iterator it = value_.map_->lower_bound(actualKey);
942943
if (it != value_.map_->end() && (*it).first == actualKey)
943944
return (*it).second;
@@ -957,7 +958,7 @@ Value& Value::resolveReference(char const* key, char const* end)
957958
if (type_ == nullValue)
958959
*this = Value(objectValue);
959960
CZString actualKey(
960-
key, (end-key), CZString::duplicateOnCopy);
961+
key, static_cast<unsigned>(end-key), CZString::duplicateOnCopy);
961962
ObjectValues::iterator it = value_.map_->lower_bound(actualKey);
962963
if (it != value_.map_->end() && (*it).first == actualKey)
963964
return (*it).second;
@@ -981,7 +982,7 @@ Value const* Value::find(char const* key, char const* end) const
981982
type_ == nullValue || type_ == objectValue,
982983
"in Json::Value::find(key, end, found): requires objectValue or nullValue");
983984
if (type_ == nullValue) return NULL;
984-
CZString actualKey(key, end-key, CZString::noDuplication);
985+
CZString actualKey(key, static_cast<unsigned>(end-key), CZString::noDuplication);
985986
ObjectValues::const_iterator it = value_.map_->find(actualKey);
986987
if (it == value_.map_->end()) return NULL;
987988
return &(*it).second;
@@ -1045,7 +1046,7 @@ bool Value::removeMember(const char* key, const char* end, Value* removed)
10451046
if (type_ != objectValue) {
10461047
return false;
10471048
}
1048-
CZString actualKey(key, end-key, CZString::noDuplication);
1049+
CZString actualKey(key, static_cast<unsigned>(end-key), CZString::noDuplication);
10491050
ObjectValues::iterator it = value_.map_->find(actualKey);
10501051
if (it == value_.map_->end())
10511052
return false;

0 commit comments

Comments
 (0)