diff --git a/src/jsontestrunner/main.cpp b/src/jsontestrunner/main.cpp index 5449299..6e0c004 100644 --- a/src/jsontestrunner/main.cpp +++ b/src/jsontestrunner/main.cpp @@ -56,7 +56,7 @@ static JSONCPP_STRING readInputTestFile(const char* path) { return JSONCPP_STRING(""); fseek(file, 0, SEEK_END); long const size = ftell(file); - unsigned long const usize = static_cast(size); + size_t const usize = static_cast(size); fseek(file, 0, SEEK_SET); JSONCPP_STRING text; char* buffer = new char[size + 1]; diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp index 077da1b..ce4aac4 100644 --- a/src/lib_json/json_reader.cpp +++ b/src/lib_json/json_reader.cpp @@ -577,7 +577,7 @@ bool Reader::decodeNumber(Token& token, Value& decoded) { Char c = *current++; if (c < '0' || c > '9') return decodeDouble(token, decoded); - Value::UInt digit(static_cast(c - '0')); + auto digit(static_cast(c - '0')); if (value >= threshold) { // We've hit or exceeded the max value divided by 10 (rounded down). If // a) we've only just touched the limit, b) this is the last digit, and @@ -1569,7 +1569,7 @@ bool OurReader::decodeNumber(Token& token, Value& decoded) { Char c = *current++; if (c < '0' || c > '9') return decodeDouble(token, decoded); - Value::UInt digit(static_cast(c - '0')); + auto digit(static_cast(c - '0')); if (value >= threshold) { // We've hit or exceeded the max value divided by 10 (rounded down). If // a) we've only just touched the limit, b) this is the last digit, and @@ -1611,7 +1611,7 @@ bool OurReader::decodeDouble(Token& token, Value& decoded) { if (length < 0) { return addError("Unable to parse token length", token); } - size_t const ulength = static_cast(length); + auto const ulength = static_cast(length); // Avoid using a string constant for the format control string given to // sscanf, as this can cause hard to debug crashes on OS X. See here for more diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp index 5e83239..ef95117 100644 --- a/src/lib_json/json_value.cpp +++ b/src/lib_json/json_value.cpp @@ -990,7 +990,7 @@ Value& Value::operator[](ArrayIndex index) { if (type_ == nullValue) *this = Value(arrayValue); CZString key(index); - ObjectValues::iterator it = value_.map_->lower_bound(key); + auto it = value_.map_->lower_bound(key); if (it != value_.map_->end() && (*it).first == key) return (*it).second; @@ -1113,7 +1113,7 @@ Value& Value::resolveReference(const char* key) { *this = Value(objectValue); CZString actualKey(key, static_cast(strlen(key)), CZString::noDuplication); // NOTE! - ObjectValues::iterator it = value_.map_->lower_bound(actualKey); + auto it = value_.map_->lower_bound(actualKey); if (it != value_.map_->end() && (*it).first == actualKey) return (*it).second; @@ -1132,7 +1132,7 @@ Value& Value::resolveReference(char const* key, char const* end) { *this = Value(objectValue); CZString actualKey(key, static_cast(end - key), CZString::duplicateOnCopy); - ObjectValues::iterator it = value_.map_->lower_bound(actualKey); + auto it = value_.map_->lower_bound(actualKey); if (it != value_.map_->end() && (*it).first == actualKey) return (*it).second; @@ -1226,7 +1226,7 @@ bool Value::removeMember(const char* begin, const char* end, Value* removed) { } CZString actualKey(begin, static_cast(end - begin), CZString::noDuplication); - ObjectValues::iterator it = value_.map_->find(actualKey); + auto it = value_.map_->find(actualKey); if (it == value_.map_->end()) return false; if (removed) @@ -1262,7 +1262,7 @@ bool Value::removeIndex(ArrayIndex index, Value* removed) { return false; } CZString key(index); - ObjectValues::iterator it = value_.map_->find(key); + auto it = value_.map_->find(key); if (it == value_.map_->end()) { return false; } @@ -1276,7 +1276,7 @@ bool Value::removeIndex(ArrayIndex index, Value* removed) { } // erase the last one ("leftover") CZString keyLast(oldSize - 1); - ObjectValues::iterator itLast = value_.map_->find(keyLast); + auto itLast = value_.map_->find(keyLast); value_.map_->erase(itLast); return true; } @@ -1608,7 +1608,7 @@ Path::Path(const JSONCPP_STRING& path, void Path::makePath(const JSONCPP_STRING& path, const InArgs& in) { const char* current = path.c_str(); const char* end = current + path.length(); - InArgs::const_iterator itInArg = in.begin(); + auto itInArg = in.begin(); while (current != end) { if (*current == '[') { ++current; diff --git a/src/lib_json/json_writer.cpp b/src/lib_json/json_writer.cpp index 7138b7a..993001c 100644 --- a/src/lib_json/json_writer.cpp +++ b/src/lib_json/json_writer.cpp @@ -147,7 +147,7 @@ JSONCPP_STRING valueToString(double value, (precisionType == PrecisionType::significantDigits) ? "%.*g" : "%.*f", precision, value); assert(len >= 0); - size_t wouldPrint = static_cast(len); + auto wouldPrint = static_cast(len); if (wouldPrint >= buffer.size()) { buffer.resize(wouldPrint + 1); continue; @@ -409,7 +409,7 @@ void FastWriter::writeValue(const Value& value) { case objectValue: { Value::Members members(value.getMemberNames()); document_ += '{'; - for (Value::Members::iterator it = members.begin(); it != members.end(); + for (auto it = members.begin(); it != members.end(); ++it) { const JSONCPP_STRING& name = *it; if (it != members.begin()) @@ -479,7 +479,7 @@ void StyledWriter::writeValue(const Value& value) { else { writeWithIndent("{"); indent(); - Value::Members::iterator it = members.begin(); + auto it = members.begin(); for (;;) { const JSONCPP_STRING& name = *it; const Value& childValue = value[name]; @@ -699,7 +699,7 @@ void StyledStreamWriter::writeValue(const Value& value) { else { writeWithIndent("{"); indent(); - Value::Members::iterator it = members.begin(); + auto it = members.begin(); for (;;) { const JSONCPP_STRING& name = *it; const Value& childValue = value[name]; @@ -979,7 +979,7 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) { else { writeWithIndent("{"); indent(); - Value::Members::iterator it = members.begin(); + auto it = members.begin(); for (;;) { JSONCPP_STRING const& name = *it; Value const& childValue = value[name]; diff --git a/src/test_lib_json/jsontest.cpp b/src/test_lib_json/jsontest.cpp index f661505..03703c9 100644 --- a/src/test_lib_json/jsontest.cpp +++ b/src/test_lib_json/jsontest.cpp @@ -278,7 +278,7 @@ bool Runner::runAllTest(bool printSummary) const { } if (printSummary) { - unsigned int failedCount = static_cast(failures.size()); + auto failedCount = static_cast(failures.size()); unsigned int passedCount = count - failedCount; printf("%u/%u tests passed (%u failure(s))\n", passedCount, count, failedCount); diff --git a/src/test_lib_json/main.cpp b/src/test_lib_json/main.cpp index 8b21547..d0315d7 100644 --- a/src/test_lib_json/main.cpp +++ b/src/test_lib_json/main.cpp @@ -1036,7 +1036,7 @@ JSONTEST_FIXTURE(ValueTest, integers) { normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString()))); // 10^19 - const Json::UInt64 ten_to_19 = static_cast(1e19); + const auto ten_to_19 = static_cast(1e19); val = Json::Value(Json::UInt64(ten_to_19)); JSONTEST_ASSERT_EQUAL(Json::uintValue, val.type());