diff --git a/Authors b/Authors index 77af5d0..6cea566 100644 --- a/Authors +++ b/Authors @@ -20,4 +20,4 @@ Richard Clamp, richardc@unixbeard.net Boost-related fixes Lars Immisch, lars@ibp.de - noboost branch + noboost branch diff --git a/examples/custom_schema.cpp b/examples/custom_schema.cpp index aa7f6be..0305871 100644 --- a/examples/custom_schema.cpp +++ b/examples/custom_schema.cpp @@ -210,7 +210,7 @@ int main(int argc, char *argv[]) while (results.popError(error)) { cerr << "Error #" << errorNum << std::endl; cerr << " "; - for( const std::string contextElement : error.context ) { + for (const std::string &contextElement : error.context) { cerr << contextElement << " "; } cerr << endl; diff --git a/include/valijson/adapters/basic_adapter.hpp b/include/valijson/adapters/basic_adapter.hpp index b807beb..8e74387 100644 --- a/include/valijson/adapters/basic_adapter.hpp +++ b/include/valijson/adapters/basic_adapter.hpp @@ -25,15 +25,25 @@ namespace adapters { * See http://www.stlsoft.org/doc-1.9/group__group____pattern____dereference__proxy.html * for motivation * - * @tparam Value Name of the value type + * @tparam Value Name of the value type */ template struct DerefProxy { - explicit DerefProxy(const Value& x) : m_ref(x) {} - Value* operator->() { return std::addressof(m_ref); } - operator Value*() { return std::addressof(m_ref); } + explicit DerefProxy(const Value& x) + : m_ref(x) { } + Value* operator->() + { + return std::addressof(m_ref); + } + + operator Value*() + { + return std::addressof(m_ref); + } + +private: Value m_ref; }; @@ -239,7 +249,7 @@ public: // definitely an array. if (value.isArray()) { const opt::optional array = value.getArrayOptional(); - for( const AdapterType element : *array ) { + for (const AdapterType element : *array) { if (!fn(element)) { return false; } @@ -257,7 +267,7 @@ public: if (value.isObject()) { const opt::optional object = value.getObjectOptional(); - for( const ObjectMemberType member : *object ) { + for (const ObjectMemberType member : *object) { if (!fn(member.first, AdapterType(member.second))) { return false; } diff --git a/include/valijson/constraints/concrete_constraints.hpp b/include/valijson/constraints/concrete_constraints.hpp index 7ada085..d6b7a5a 100644 --- a/include/valijson/constraints/concrete_constraints.hpp +++ b/include/valijson/constraints/concrete_constraints.hpp @@ -57,7 +57,7 @@ public: void applyToSubschemas(const FunctorType &fn) const { unsigned int index = 0; - for( const Subschema *subschema : subschemas ) { + for (const Subschema *subschema : subschemas) { if (!fn(index, subschema)) { return; } @@ -100,7 +100,7 @@ public: void applyToSubschemas(const FunctorType &fn) const { unsigned int index = 0; - for( const Subschema *subschema : subschemas ) { + for (const Subschema *subschema : subschemas) { if (!fn(index, subschema)) { return; } @@ -167,7 +167,7 @@ public: } typedef typename ContainerType::value_type ValueType; - for( const ValueType &dependencyName : dependencyNames ) { + for (const ValueType &dependencyName : dependencyNames) { itr->second.insert(String(dependencyName.c_str(), allocator)); } @@ -193,8 +193,7 @@ public: template void applyToPropertyDependencies(const FunctorType &fn) const { - for( const PropertyDependencies::value_type &v : - propertyDependencies ) { + for (const PropertyDependencies::value_type &v : propertyDependencies) { if (!fn(v.first, v.second)) { return; } @@ -204,8 +203,7 @@ public: template void applyToSchemaDependencies(const FunctorType &fn) const { - for( const SchemaDependencies::value_type &v : - schemaDependencies ) { + for (const SchemaDependencies::value_type &v : schemaDependencies) { if (!fn(v.first, v.second)) { return; } @@ -251,7 +249,7 @@ public: { try { // Clone individual enum values - for( const EnumValue *otherValue : other.enumValues ) { + for (const EnumValue *otherValue : other.enumValues) { const EnumValue *value = otherValue->clone(); try { enumValues.push_back(value); @@ -263,7 +261,7 @@ public: } catch (...) { // Delete values already added to constraint - for( const EnumValue *value : enumValues ) { + for (const EnumValue *value : enumValues) { delete value; } throw; @@ -272,7 +270,7 @@ public: virtual ~EnumConstraint() { - for( const EnumValue *value : enumValues ) { + for (const EnumValue *value : enumValues) { delete value; } } @@ -292,7 +290,7 @@ public: template void applyToValues(const FunctorType &fn) const { - for( const EnumValue *value : enumValues ) { + for (const EnumValue *value : enumValues) { if (!fn(*value)) { return; } diff --git a/include/valijson/internal/json_pointer.hpp b/include/valijson/internal/json_pointer.hpp index fcb6b4e..fc126db 100644 --- a/include/valijson/internal/json_pointer.hpp +++ b/include/valijson/internal/json_pointer.hpp @@ -29,7 +29,6 @@ namespace json_pointer { * @param search string to search * @param replace replacement string */ - inline void replace_all_inplace(std::string& subject, const char* search, const char* replace) { diff --git a/include/valijson/schema_parser.hpp b/include/valijson/schema_parser.hpp index 68e8c9e..999a662 100644 --- a/include/valijson/schema_parser.hpp +++ b/include/valijson/schema_parser.hpp @@ -174,7 +174,7 @@ private: { typedef typename DocumentCache::Type DocCacheType; - for( const typename DocCacheType::value_type &v : docCache ) { + for (const typename DocCacheType::value_type &v : docCache) { freeDoc(v.second); } } @@ -314,7 +314,7 @@ private: const std::vector &keysToCreate, const Subschema *schema) { - for( const std::string &keyToCreate : keysToCreate ) { + for (const std::string &keyToCreate : keysToCreate) { const SchemaCache::value_type value(keyToCreate, schema); if (!schemaCache.insert(value).second) { throw std::logic_error( @@ -1180,7 +1180,7 @@ private: if (member.second.maybeArray()) { // Parse an array of dependency names std::vector dependentPropertyNames; - for( const AdapterType dependencyName : member.second.asArray() ) { + for (const AdapterType dependencyName : member.second.asArray()) { if (dependencyName.maybeString()) { dependentPropertyNames.push_back(dependencyName.getString()); } else { @@ -1237,7 +1237,7 @@ private: { // Make a copy of each value in the enum array constraints::EnumConstraint constraint; - for( const AdapterType value : node.getArray() ) { + for (const AdapterType value : node.getArray()) { constraint.addValue(value); } @@ -1335,7 +1335,7 @@ private: // validate the values at the corresponding indexes in a target // array. int index = 0; - for( const AdapterType v : items->getArray() ) { + for (const AdapterType v : items->getArray()) { const std::string childPath = itemsPath + "/" + std::to_string(index); const Subschema *subschema = makeOrReuseSchema( @@ -1861,7 +1861,7 @@ private: // Create subschemas for 'properties' constraint if (properties) { - for( const Member m : properties->getObject() ) { + for (const Member m : properties->getObject()) { const std::string &property = m.first; const std::string childPath = propertiesPath + "/" + property; const Subschema *subschema = makeOrReuseSchema( @@ -1874,7 +1874,7 @@ private: // Create subschemas for 'patternProperties' constraint if (patternProperties) { - for( const Member m : patternProperties->getObject() ) { + for (const Member m : patternProperties->getObject()) { const std::string &pattern = m.first; const std::string childPath = patternPropertiesPath + "/" + pattern; @@ -1973,7 +1973,7 @@ private: { constraints::RequiredConstraint constraint; - for( const AdapterType v : node.getArray() ) { + for (const AdapterType v : node.getArray()) { if (!v.isString()) { throw std::runtime_error("Expected required property name to " "be a string value"); @@ -2030,7 +2030,7 @@ private: } else if (node.isArray()) { int index = 0; - for( const AdapterType v : node.getArray() ) { + for (const AdapterType v : node.getArray()) { if (v.isString()) { const TypeConstraint::JsonType type = TypeConstraint::jsonTypeFromString(v.getString()); diff --git a/include/valijson/subschema.hpp b/include/valijson/subschema.hpp index f80dadf..11254a7 100644 --- a/include/valijson/subschema.hpp +++ b/include/valijson/subschema.hpp @@ -121,7 +121,7 @@ public: bool apply(ApplyFunction &applyFunction) const { bool allTrue = true; - for( const Constraint *constraint : constraints ) { + for (const Constraint *constraint : constraints) { allTrue = allTrue && applyFunction(*constraint); } @@ -140,7 +140,7 @@ public: */ bool applyStrict(ApplyFunction &applyFunction) const { - for( const Constraint *constraint : constraints ) { + for (const Constraint *constraint : constraints) { if (!applyFunction(*constraint)) { return false; } diff --git a/include/valijson/validation_visitor.hpp b/include/valijson/validation_visitor.hpp index b8e1b61..ba9756d 100644 --- a/include/valijson/validation_visitor.hpp +++ b/include/valijson/validation_visitor.hpp @@ -875,7 +875,7 @@ public: return validated; } - for( const typename AdapterType::ObjectMember m : object ) { + for (const typename AdapterType::ObjectMember m : object) { if (propertiesMatched.find(m.first) == propertiesMatched.end()) { // Update context std::vector newContext = context; @@ -956,7 +956,7 @@ public: bool validated = true; unsigned int index = 0; - for( const AdapterType &item : target.getArray() ) { + for (const AdapterType &item : target.getArray()) { // Update context for current array item std::vector newContext = context; newContext.push_back("[" + @@ -1199,7 +1199,7 @@ private: } typedef typename ContainerType::value_type ValueType; - for( const ValueType &dependencyName : dependencyNames ) { + for (const ValueType &dependencyName : dependencyNames) { const std::string dependencyNameKey(dependencyName.c_str()); if (object.find(dependencyNameKey) == object.end()) { if (validated) { @@ -1411,7 +1411,7 @@ private: // Recursively validate all matching properties typedef const typename AdapterType::ObjectMember ObjectMember; - for( const ObjectMember m : object ) { + for (const ObjectMember m : object) { if (std::regex_search(m.first, r)) { matchFound = true; if (propertiesMatched) { diff --git a/tests/test_json11_adapter.cpp b/tests/test_json11_adapter.cpp index dfc5464..9250a03 100644 --- a/tests/test_json11_adapter.cpp +++ b/tests/test_json11_adapter.cpp @@ -35,7 +35,7 @@ TEST_F(TestJson11Adapter, BasicArrayIteration) // Ensure that the elements are returned in the order they were inserted unsigned int expectedValue = 0; - for( const valijson::adapters::Json11Adapter value : adapter.getArray() ) { + for (const valijson::adapters::Json11Adapter value : adapter.getArray()) { ASSERT_TRUE( value.isNumber() ); EXPECT_EQ( double(expectedValue), value.getDouble() ); expectedValue++; @@ -72,7 +72,7 @@ TEST_F(TestJson11Adapter, BasicObjectIteration) // Ensure that the members are returned in the order they were inserted unsigned int expectedValue = 0; - for( const valijson::adapters::Json11Adapter::ObjectMember member : adapter.getObject() ) { + for (const valijson::adapters::Json11Adapter::ObjectMember member : adapter.getObject()) { ASSERT_TRUE( member.second.isNumber() ); EXPECT_EQ( std::to_string(expectedValue), member.first ); EXPECT_EQ( double(expectedValue), member.second.getDouble() ); diff --git a/tests/test_jsoncpp_adapter.cpp b/tests/test_jsoncpp_adapter.cpp index 5784347..bd088df 100644 --- a/tests/test_jsoncpp_adapter.cpp +++ b/tests/test_jsoncpp_adapter.cpp @@ -32,7 +32,7 @@ TEST_F(TestJsonCppAdapter, BasicArrayIteration) // Ensure that the elements are returned in the order they were inserted unsigned int expectedValue = 0; - for( const valijson::adapters::JsonCppAdapter value : adapter.getArray() ) { + for (const valijson::adapters::JsonCppAdapter value : adapter.getArray()) { ASSERT_TRUE( value.isNumber() ); EXPECT_EQ( double(expectedValue), value.getNumber() ); expectedValue++; @@ -68,7 +68,7 @@ TEST_F(TestJsonCppAdapter, BasicObjectIteration) // Ensure that the members are returned in the order they were inserted unsigned int expectedValue = 0; - for( const valijson::adapters::JsonCppAdapter::ObjectMember member : adapter.getObject() ) { + for (const valijson::adapters::JsonCppAdapter::ObjectMember member : adapter.getObject()) { ASSERT_TRUE( member.second.isNumber() ); EXPECT_EQ( std::to_string(expectedValue), member.first ); EXPECT_EQ( double(expectedValue), member.second.getDouble() ); diff --git a/tests/test_nlohmann_json_adapter.cpp b/tests/test_nlohmann_json_adapter.cpp index f736042..075710e 100644 --- a/tests/test_nlohmann_json_adapter.cpp +++ b/tests/test_nlohmann_json_adapter.cpp @@ -34,7 +34,7 @@ TEST_F(TestNlohmannJsonAdapter, BasicArrayIteration) // Ensure that the elements are returned in the order they were inserted unsigned int expectedValue = 0; - for( const valijson::adapters::NlohmannJsonAdapter value : adapter.getArray() ) { + for (const valijson::adapters::NlohmannJsonAdapter value : adapter.getArray()) { ASSERT_TRUE( value.isNumber() ); EXPECT_EQ( double(expectedValue), value.getDouble() ); expectedValue++; @@ -69,7 +69,7 @@ TEST_F(TestNlohmannJsonAdapter, BasicObjectIteration) // Ensure that the members are returned in the order they were inserted unsigned int expectedValue = 0; - for( const valijson::adapters::NlohmannJsonAdapter::ObjectMember member : adapter.getObject() ) { + for (const valijson::adapters::NlohmannJsonAdapter::ObjectMember member : adapter.getObject()) { ASSERT_TRUE( member.second.isNumber() ); EXPECT_EQ( std::to_string(expectedValue), member.first ); EXPECT_EQ( double(expectedValue), member.second.getDouble() ); diff --git a/tests/test_picojson_adapter.cpp b/tests/test_picojson_adapter.cpp index 15fde4b..398d1f9 100644 --- a/tests/test_picojson_adapter.cpp +++ b/tests/test_picojson_adapter.cpp @@ -35,7 +35,7 @@ TEST_F(TestPicoJsonAdapter, BasicArrayIteration) // Ensure that the elements are returned in the order they were inserted unsigned int expectedValue = 0; - for( const valijson::adapters::PicoJsonAdapter value : adapter.getArray() ) { + for (const valijson::adapters::PicoJsonAdapter value : adapter.getArray()) { ASSERT_TRUE( value.isNumber() ); EXPECT_EQ( double(expectedValue), value.getDouble() ); expectedValue++; @@ -72,7 +72,7 @@ TEST_F(TestPicoJsonAdapter, BasicObjectIteration) // Ensure that the members are returned in the order they were inserted unsigned int expectedValue = 0; - for( const valijson::adapters::PicoJsonAdapter::ObjectMember member : adapter.getObject() ) { + for (const valijson::adapters::PicoJsonAdapter::ObjectMember member : adapter.getObject()) { ASSERT_TRUE( member.second.isNumber() ); EXPECT_EQ( std::to_string(expectedValue), member.first ); EXPECT_EQ( double(expectedValue), member.second.getDouble() ); diff --git a/tests/test_property_tree_adapter.cpp b/tests/test_property_tree_adapter.cpp index fc6c3b1..eba84b2 100644 --- a/tests/test_property_tree_adapter.cpp +++ b/tests/test_property_tree_adapter.cpp @@ -34,7 +34,7 @@ TEST_F(TestPropertyTreeAdapter, BasicArrayIteration) // Ensure that the elements are returned in the order they were inserted unsigned int expectedValue = 0; - for( const valijson::adapters::PropertyTreeAdapter value : adapter.getArray() ) { + for (const valijson::adapters::PropertyTreeAdapter value : adapter.getArray()) { ASSERT_TRUE( value.isString() ); ASSERT_FALSE( value.isNumber() ); ASSERT_TRUE( value.maybeDouble() ); @@ -73,7 +73,7 @@ TEST_F(TestPropertyTreeAdapter, BasicObjectIteration) // Ensure that the members are returned in the order they were inserted unsigned int expectedValue = 0; - for( const valijson::adapters::PropertyTreeAdapter::ObjectMember member : adapter.getObject() ) { + for (const valijson::adapters::PropertyTreeAdapter::ObjectMember member : adapter.getObject()) { ASSERT_TRUE( member.second.isString() ); ASSERT_FALSE( member.second.isNumber() ); ASSERT_TRUE( member.second.maybeDouble() ); diff --git a/tests/test_rapidjson_adapter.cpp b/tests/test_rapidjson_adapter.cpp index a04f0cc..bd583ea 100644 --- a/tests/test_rapidjson_adapter.cpp +++ b/tests/test_rapidjson_adapter.cpp @@ -37,7 +37,7 @@ void testBasicArrayIteration() // Ensure that the elements are returned in the order they were inserted unsigned int expectedValue = 0; - for( const valijson::adapters::RapidJsonAdapter value : adapter.getArray() ) { + for (const valijson::adapters::RapidJsonAdapter value : adapter.getArray()) { ASSERT_TRUE( value.isNumber() ); EXPECT_EQ( double(expectedValue), value.getDouble() ); expectedValue++; @@ -77,7 +77,7 @@ void testBasicObjectIteration() // Ensure that the members are returned in the order they were inserted unsigned int expectedValue = 0; - for( const valijson::adapters::RapidJsonAdapter::ObjectMember member : adapter.getObject() ) { + for (const valijson::adapters::RapidJsonAdapter::ObjectMember member : adapter.getObject()) { ASSERT_TRUE( member.second.isNumber() ); EXPECT_EQ( std::to_string(expectedValue), member.first ); EXPECT_EQ( double(expectedValue), member.second.getDouble() ); diff --git a/tests/test_validator.cpp b/tests/test_validator.cpp index 4fde7ef..7fe9bf2 100644 --- a/tests/test_validator.cpp +++ b/tests/test_validator.cpp @@ -96,7 +96,7 @@ protected: ASSERT_TRUE( testCases.isArray() ); // Process each test case in the file - for( const AdapterType testCase : testCases.getArray() ) { + for (const AdapterType testCase : testCases.getArray()) { currentTestCase.clear(); currentTest.clear(); @@ -124,7 +124,7 @@ protected: itr = object.find("tests"); ASSERT_NE( object.end(), itr ); ASSERT_TRUE( itr->second.isArray() ); - for( const AdapterType test : itr->second.getArray() ) { + for (const AdapterType test : itr->second.getArray()) { const bool strict = itr->second.hasStrictTypes();