diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-02-06 07:21:53 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-02-06 07:21:53 +0100 |
commit | 189918f5acd3bc1bee7a8a90f18ba29d0fe2c759 (patch) | |
tree | bcfacd3d6eddb30f0f877b2286d13e8d1b375c2f /unoidl | |
parent | 5e971b274922f9713aefcd5f612459ffced84845 (diff) |
Clean up for loops in unoidl
Change-Id: I9c2e0a10699580026fbf38f0c857ac148de74f9c
Diffstat (limited to 'unoidl')
-rw-r--r-- | unoidl/source/legacyprovider.cxx | 6 | ||||
-rw-r--r-- | unoidl/source/sourcefileprovider.cxx | 22 | ||||
-rw-r--r-- | unoidl/source/sourceprovider-parser.y | 260 | ||||
-rw-r--r-- | unoidl/source/unoidl-check.cxx | 188 | ||||
-rw-r--r-- | unoidl/source/unoidl-read.cxx | 362 | ||||
-rw-r--r-- | unoidl/source/unoidl-write.cxx | 413 | ||||
-rw-r--r-- | unoidl/source/unoidl.cxx | 14 |
7 files changed, 442 insertions, 823 deletions
diff --git a/unoidl/source/legacyprovider.cxx b/unoidl/source/legacyprovider.cxx index 7b2d45babdf1..7edcdb6b2279 100644 --- a/unoidl/source/legacyprovider.cxx +++ b/unoidl/source/legacyprovider.cxx @@ -384,7 +384,7 @@ rtl::Reference< Entity > readEntity( } std::vector< PlainStructTypeEntity::Member > mems; n = reader.getFieldCount(); - for (sal_uInt16 j = 0; j < n; ++j) { + for (sal_uInt16 j = 0; j != n; ++j) { mems.emplace_back( reader.getFieldName(j), reader.getFieldTypeName(j).replace('/', '.'), @@ -403,13 +403,13 @@ rtl::Reference< Entity > readEntity( " with key " + sub.getName())); } std::vector< OUString > params; - for (sal_uInt16 j = 0; j < n; ++j) { + for (sal_uInt16 j = 0; j != n; ++j) { params.push_back( reader.getReferenceTypeName(j).replace('/', '.')); } std::vector< PolymorphicStructTypeTemplateEntity::Member > mems; n = reader.getFieldCount(); - for (sal_uInt16 j = 0; j < n; ++j) { + for (sal_uInt16 j = 0; j != n; ++j) { mems.emplace_back( reader.getFieldName(j), reader.getFieldTypeName(j).replace('/', '.'), diff --git a/unoidl/source/sourcefileprovider.cxx b/unoidl/source/sourcefileprovider.cxx index 18a6d666cf02..3a3d639bb05e 100644 --- a/unoidl/source/sourcefileprovider.cxx +++ b/unoidl/source/sourcefileprovider.cxx @@ -63,11 +63,8 @@ private: std::vector<rtl::OUString> Module::getMemberNames() const { std::vector<rtl::OUString> names; - for (std::map< OUString, rtl::Reference<Entity> >::const_iterator i( - map.begin()); - i != map.end(); ++i) - { - names.push_back(i->first); + for (auto & i: map) { + names.push_back(i.first); } return names; } @@ -81,18 +78,15 @@ SourceFileProvider::SourceFileProvider( if (!parse(uri, &data)) { throw NoSuchFileException(uri); } - for (std::map<OUString, SourceProviderEntity>::iterator i( - data.entities.begin()); - i != data.entities.end(); ++i) - { - if (i->second.kind == SourceProviderEntity::KIND_LOCAL) { - assert(i->second.entity.is()); - assert(i->second.entity->getSort() != Entity::SORT_MODULE); + for (auto & i: data.entities) { + if (i.second.kind == SourceProviderEntity::KIND_LOCAL) { + assert(i.second.entity.is()); + assert(i.second.entity->getSort() != Entity::SORT_MODULE); std::map< OUString, rtl::Reference<Entity> > * map = &rootMap_; for (sal_Int32 j = 0;;) { - OUString id(i->first.getToken(0, '.', j)); + OUString id(i.first.getToken(0, '.', j)); if (j == -1) { - map->insert(std::make_pair(id, i->second.entity)); + map->insert(std::make_pair(id, i.second.entity)); break; } std::map< OUString, rtl::Reference<Entity> >::const_iterator k( diff --git a/unoidl/source/sourceprovider-parser.y b/unoidl/source/sourceprovider-parser.y index 945ebea0f488..1a662d7f2e0b 100644 --- a/unoidl/source/sourceprovider-parser.y +++ b/unoidl/source/sourceprovider-parser.y @@ -262,9 +262,7 @@ unoidl::detail::SourceProviderEntity * findEntity_( assert(name != 0); OUString n; if (!name->startsWith(".", &n)) { - for (std::vector<OUString>::reverse_iterator i(data->modules.rbegin()); - i != data->modules.rend(); ++i) - { + for (auto i(data->modules.rbegin()); i != data->modules.rend(); ++i) { n = *i + "." + *name; std::map<OUString, unoidl::detail::SourceProviderEntity>::iterator j( data->entities.find(n)); @@ -837,12 +835,9 @@ bool checkInstantiatedPolymorphicStructTypeArgument( if (type.type == unoidl::detail::SourceProviderType::TYPE_INSTANTIATED_POLYMORPHIC_STRUCT) { - for (std::vector<unoidl::detail::SourceProviderType>::const_iterator i( - type.subtypes.begin()); - i != type.subtypes.end(); ++i) - { - if (checkInstantiatedPolymorphicStructTypeArgument(*i, name) - || i->getName() == name) // no need to worry about typedef + for (auto & i: type.subtypes) { + if (checkInstantiatedPolymorphicStructTypeArgument(i, name) + || i.getName() == name) // no need to worry about typedef { return true; } @@ -1329,11 +1324,8 @@ structMember: dynamic_cast<unoidl::detail::SourceProviderPlainStructTypeEntityPad *>( ent->pad.get()); if (p1 != 0) { - for (std::vector<unoidl::PlainStructTypeEntity::Member>::iterator i( - p1->members.begin()); - i != p1->members.end(); ++i) - { - if (id == i->name) { + for (auto & i: p1->members) { + if (id == i.name) { error( @3, yyscanner, ("plain struct type " + data->currentName @@ -1344,9 +1336,7 @@ structMember: } if (p1->baseEntity.is()) { OUString baseName(p1->baseName); - for (rtl::Reference<unoidl::PlainStructTypeEntity> baseEnt( - p1->baseEntity);;) - { + for (auto baseEnt(p1->baseEntity);;) { if (nameHasSameIdentifierAs(baseName, id)) { error( @3, yyscanner, @@ -1356,11 +1346,8 @@ structMember: + baseName)); YYERROR; } - for (std::vector<unoidl::PlainStructTypeEntity::Member>::const_iterator i( - baseEnt->getDirectMembers().begin()); - i != baseEnt->getDirectMembers().end(); ++i) - { - if (id == i->name) { + for (auto & i: baseEnt->getDirectMembers()) { + if (id == i.name) { error( @3, yyscanner, ("plain struct type " + data->currentName @@ -1403,11 +1390,8 @@ structMember: p2 = dynamic_cast<unoidl::detail::SourceProviderPolymorphicStructTypeTemplateEntityPad *>( ent->pad.get()); if (p2 != 0) { - for (std::vector<unoidl::PolymorphicStructTypeTemplateEntity::Member>::iterator i( - p2->members.begin()); - i != p2->members.end(); ++i) - { - if (id == i->name) { + for (auto & i: p2->members) { + if (id == i.name) { error( @3, yyscanner, ("polymorphic struct type template " @@ -1425,11 +1409,8 @@ structMember: = dynamic_cast<unoidl::detail::SourceProviderExceptionTypeEntityPad *>( ent->pad.get()); assert(p3 != 0); - for (std::vector<unoidl::ExceptionTypeEntity::Member>::iterator i( - p3->members.begin()); - i != p3->members.end(); ++i) - { - if (id == i->name) { + for (auto & i: p3->members) { + if (id == i.name) { error( @3, yyscanner, ("exception type " + data->currentName @@ -1440,9 +1421,7 @@ structMember: } if (p3->baseEntity.is()) { OUString baseName(p3->baseName); - for (rtl::Reference<unoidl::ExceptionTypeEntity> baseEnt( - p3->baseEntity);;) - { + for (auto baseEnt(p3->baseEntity);;) { if (nameHasSameIdentifierAs(baseName, id)) { error( @3, yyscanner, @@ -1452,11 +1431,8 @@ structMember: + baseName)); YYERROR; } - for (std::vector<unoidl::ExceptionTypeEntity::Member>::const_iterator i( - baseEnt->getDirectMembers().begin()); - i != baseEnt->getDirectMembers().end(); ++i) - { - if (id == i->name) { + for (auto & i: baseEnt->getDirectMembers()) { + if (id == i.name) { error( @3, yyscanner, ("exception type " + data->currentName @@ -1613,18 +1589,12 @@ interfaceDefn: } } std::vector<unoidl::AnnotatedReference> mbases; - for (std::vector<unoidl::detail::SourceProviderInterfaceTypeEntityPad::DirectBase>::const_iterator - i(pad->directMandatoryBases.begin()); - i != pad->directMandatoryBases.end(); ++i) - { - mbases.emplace_back(i->name, i->annotations); + for (auto & i: pad->directMandatoryBases) { + mbases.emplace_back(i.name, i.annotations); } std::vector<unoidl::AnnotatedReference> obases; - for (std::vector<unoidl::detail::SourceProviderInterfaceTypeEntityPad::DirectBase>::const_iterator - i(pad->directOptionalBases.begin()); - i != pad->directOptionalBases.end(); ++i) - { - obases.emplace_back(i->name, i->annotations); + for (auto & i: pad->directOptionalBases) { + obases.emplace_back(i.name, i.annotations); } ent->entity = new unoidl::InterfaceTypeEntity( pad->isPublished(), mbases, obases, pad->directAttributes, @@ -1886,11 +1856,8 @@ methodParam: default: break; } - for (std::vector<unoidl::InterfaceTypeEntity::Method::Parameter>::iterator - i(pad->directMethods.back().parameters.begin()); - i != pad->directMethods.back().parameters.end(); ++i) - { - if (id == i->name) { + for (auto & i: pad->directMethods.back().parameters) { + if (id == i.name) { error( @5, yyscanner, ("interface type " + data->currentName + " direct method " @@ -2374,20 +2341,14 @@ singleInterfaceBasedServiceDefn: assert(pad != 0); std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor> ctors; if ($7) { - for (std::vector<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad::Constructor>::iterator - i(pad->constructors.begin()); - i != pad->constructors.end(); ++i) - { + for (auto & i: pad->constructors) { std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter> parms; - for (std::vector<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad::Constructor::Parameter>::iterator - j(i->parameters.begin()); - j != i->parameters.end(); ++j) - { - parms.emplace_back(j->name, j->type.getName(), j->rest); + for (auto & j: i.parameters) { + parms.emplace_back(j.name, j.type.getName(), j.rest); } ctors.push_back( unoidl::SingleInterfaceBasedServiceEntity::Constructor( - i->name, parms, i->exceptions, i->annotations)); + i.name, parms, i.exceptions, i.annotations)); } } else { assert(pad->constructors.empty()); @@ -2419,11 +2380,8 @@ ctor: rtl::Reference<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad> pad(getCurrentPad<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad>( data)); - for (std::vector<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad::Constructor>::iterator - i(pad->constructors.begin()); - i != pad->constructors.end(); ++i) - { - if (id == i->name) { + for (auto & i: pad->constructors) { + if (id == i.name) { error( @2, yyscanner, ("single-interface--based service " + data->currentName @@ -2447,15 +2405,14 @@ ctor: pad->constructors.back().exceptions = *$7; delete $7; } - for (std::vector<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad::Constructor>::iterator - i(pad->constructors.begin()); - i != pad->constructors.end() - 1; ++i) + for (auto i(pad->constructors.begin()); i != pad->constructors.end() - 1; + ++i) { if (i->parameters.size() == pad->constructors.back().parameters.size()) { bool same = true; - for (std::vector<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad::Constructor::Parameter>::iterator + for (auto j(i->parameters.begin()), k(pad->constructors.back().parameters.begin()); j != i->parameters.end(); ++j, ++k) @@ -2549,11 +2506,8 @@ ctorParam: + " rest parameter must be last parameter")); YYERROR; } - for (std::vector<unoidl::detail::SourceProviderSingleInterfaceBasedServiceEntityPad::Constructor::Parameter>::iterator - i(pad->constructors.back().parameters.begin()); - i != pad->constructors.back().parameters.end(); ++i) - { - if (id == i->name) { + for (auto & i: pad->constructors.back().parameters) { + if (id == i.name) { error( @6, yyscanner, ("single-interface--based service " + data->currentName @@ -2665,10 +2619,8 @@ serviceBase: std::vector<unoidl::AnnotatedReference> & v( opt ? pad->directOptionalBaseServices : pad->directMandatoryBaseServices); - for (std::vector<unoidl::AnnotatedReference>::iterator i(v.begin()); - i != v.end(); ++i) - { - if (name == i->name) { + for (auto & i: v) { + if (name == i.name) { error( @4, yyscanner, ("accumulation-based service " + data->currentName @@ -2744,10 +2696,8 @@ serviceInterfaceBase: opt ? pad->directOptionalBaseInterfaces : pad->directMandatoryBaseInterfaces); - for (std::vector<unoidl::AnnotatedReference>::iterator i(v.begin()); - i != v.end(); ++i) - { - if (name == i->name) { + for (auto & i: v) { + if (name == i.name) { error( @4, yyscanner, ("accumulation-based service " + data->currentName @@ -2833,11 +2783,8 @@ serviceProperty: rtl::Reference<unoidl::detail::SourceProviderAccumulationBasedServiceEntityPad> pad(getCurrentPad<unoidl::detail::SourceProviderAccumulationBasedServiceEntityPad>( data)); - for (std::vector<unoidl::AccumulationBasedServiceEntity::Property>::iterator - i(pad->directProperties.begin()); - i != pad->directProperties.end(); ++i) - { - if (id == i->name) { + for (auto & i: pad->directProperties) { + if (id == i.name) { error( @4, yyscanner, ("accumulation-based service " + data->currentName @@ -3522,12 +3469,9 @@ primaryExpr: unoidl::detail::SourceProviderEnumTypeEntityPad * p1 = dynamic_cast< unoidl::detail::SourceProviderEnumTypeEntityPad *>(pad.get()); if (p1 != 0) { - for (std::vector<unoidl::EnumTypeEntity::Member>::const_iterator - j(p1->members.begin()); - j != p1->members.end(); ++j) - { - if (j->name == name) { - v = unoidl::ConstantValue(j->value); + for (auto & j: p1->members) { + if (j.name == name) { + v = unoidl::ConstantValue(j.value); found = true; break; } @@ -3538,12 +3482,9 @@ primaryExpr: unoidl::detail::SourceProviderConstantGroupEntityPad *>( pad.get()); if (p2 != 0) { - for (std::vector<unoidl::ConstantGroupEntity::Member>::const_iterator - j(p2->members.begin()); - j != p2->members.end(); ++j) - { - if (j->name == name) { - v = j->value; + for (auto & j: p2->members) { + if (j.name == name) { + v = j.value; found = true; break; } @@ -3571,12 +3512,9 @@ primaryExpr: static_cast<unoidl::ConstantGroupEntity *>( ent->entity.get())-> getMembers()); - for (std::vector<unoidl::ConstantGroupEntity::Member>::const_iterator j( - mems.begin()); - j != mems.end(); ++j) - { - if (j->name == id) { - v = j->value; + for (auto & j: mems) { + if (j.name == id) { + v = j.value; found = true; unpub = !static_cast<unoidl::ConstantGroupEntity *>( @@ -3591,12 +3529,9 @@ primaryExpr: unoidl::detail::SourceProviderConstantGroupEntityPad *>( ent->pad.get()); if (pad != 0) { - for (std::vector<unoidl::ConstantGroupEntity::Member>::const_iterator j( - pad->members.begin()); - j != pad->members.end(); ++j) - { - if (j->name == id) { - v = j->value; + for (auto & j: pad->members) { + if (j.name == id) { + v = j.value; found = true; unpub = !ent->pad->isPublished(); break; @@ -4083,10 +4018,7 @@ OUString SourceProviderType::getName() const { case unoidl::detail::SourceProviderType::TYPE_INSTANTIATED_POLYMORPHIC_STRUCT: { OUString n(name + "<"); - for (std::vector<SourceProviderType>::const_iterator i( - subtypes.begin()); - i != subtypes.end(); ++i) - { + for (auto i(subtypes.begin()); i != subtypes.end(); ++i) { if (i != subtypes.begin()) { n += ","; } @@ -4105,8 +4037,7 @@ bool SourceProviderType::equals(SourceProviderType const & other) const { { return false; } - for (std::vector<SourceProviderType>::const_iterator - i(subtypes.begin()), j(other.subtypes.begin()); + for (auto i(subtypes.begin()), j(other.subtypes.begin()); i != subtypes.end(); ++i, ++j) { if (!i->equals(*j)) { @@ -4204,11 +4135,8 @@ bool SourceProviderInterfaceTypeEntityPad::checkBaseClashes( } } if (direct || !optional) { - for (std::vector<unoidl::AnnotatedReference>::const_iterator j( - entity->getDirectMandatoryBases().begin()); - j != entity->getDirectMandatoryBases().end(); ++j) - { - OUString n("." + j->name); + for (auto & j: entity->getDirectMandatoryBases()) { + OUString n("." + j.name); unoidl::detail::SourceProviderEntity const * p; if (findEntity(location, yyscanner, data, true, &n, &p, 0, 0) == FOUND_ERROR) @@ -4235,11 +4163,8 @@ bool SourceProviderInterfaceTypeEntityPad::checkBaseClashes( return false; } } - for (std::vector<unoidl::AnnotatedReference>::const_iterator j( - entity->getDirectOptionalBases().begin()); - j != entity->getDirectOptionalBases().end(); ++j) - { - OUString n("." + j->name); + for (auto & j: entity->getDirectOptionalBases()) { + OUString n("." + j.name); unoidl::detail::SourceProviderEntity const * p; if (findEntity(location, yyscanner, data, true, &n, &p, 0, 0) == FOUND_ERROR) @@ -4266,23 +4191,17 @@ bool SourceProviderInterfaceTypeEntityPad::checkBaseClashes( return false; } } - for (std::vector<unoidl::InterfaceTypeEntity::Attribute>::const_iterator - j(entity->getDirectAttributes().begin()); - j != entity->getDirectAttributes().end(); ++j) - { + for (auto & j: entity->getDirectAttributes()) { if (!checkMemberClashes( - location, yyscanner, data, name, j->name, + location, yyscanner, data, name, j.name, !outerOptional)) { return false; } } - for (std::vector<unoidl::InterfaceTypeEntity::Method>::const_iterator - j(entity->getDirectMethods().begin()); - j != entity->getDirectMethods().end(); ++j) - { + for (auto & j: entity->getDirectMethods()) { if (!checkMemberClashes( - location, yyscanner, data, name, j->name, + location, yyscanner, data, name, j.name, !outerOptional)) { return false; @@ -4311,11 +4230,8 @@ bool SourceProviderInterfaceTypeEntityPad::checkMemberClashes( return false; } } else if (checkOptional) { - for (std::set<OUString>::const_iterator j( - i->second.optional.begin()); - j != i->second.optional.end(); ++j) - { - if (*j != interfaceName) { + for (auto & j: i->second.optional) { + if (j != interfaceName) { error( location, yyscanner, ("interface type " + data->currentName @@ -4347,11 +4263,8 @@ bool SourceProviderInterfaceTypeEntityPad::addBase( p.first->second = kind; } if (!optional && !seen) { - for (std::vector<unoidl::AnnotatedReference>::const_iterator i( - entity->getDirectMandatoryBases().begin()); - i != entity->getDirectMandatoryBases().end(); ++i) - { - OUString n("." + i->name); + for (auto & i: entity->getDirectMandatoryBases()) { + OUString n("." + i.name); unoidl::detail::SourceProviderEntity const * q; if (findEntity(location, yyscanner, data, true, &n, &q, 0, 0) == FOUND_ERROR) @@ -4376,11 +4289,9 @@ bool SourceProviderInterfaceTypeEntityPad::addBase( return false; } } - for (std::vector<unoidl::AnnotatedReference>::const_iterator i( - entity->getDirectOptionalBases().begin()); - i != entity->getDirectOptionalBases().end(); ++i) + for (auto & i: entity->getDirectOptionalBases()) { - OUString n("." + i->name); + OUString n("." + i.name); unoidl::detail::SourceProviderEntity const * q; if (findEntity(location, yyscanner, data, true, &n, &q, 0, 0) == FOUND_ERROR) @@ -4405,19 +4316,13 @@ bool SourceProviderInterfaceTypeEntityPad::addBase( return false; } } - for (std::vector<unoidl::InterfaceTypeEntity::Attribute>::const_iterator - i(entity->getDirectAttributes().begin()); - i != entity->getDirectAttributes().end(); ++i) - { + for (auto & i: entity->getDirectAttributes()) { allMembers.insert( - std::map<OUString, Member>::value_type(i->name, Member(name))); + std::map<OUString, Member>::value_type(i.name, Member(name))); } - for (std::vector<unoidl::InterfaceTypeEntity::Method>::const_iterator i( - entity->getDirectMethods().begin()); - i != entity->getDirectMethods().end(); ++i) - { + for (auto & i: entity->getDirectMethods()) { allMembers.insert( - std::map<OUString, Member>::value_type(i->name, Member(name))); + std::map<OUString, Member>::value_type(i.name, Member(name))); } } return true; @@ -4429,11 +4334,8 @@ bool SourceProviderInterfaceTypeEntityPad::addOptionalBaseMembers( rtl::Reference<unoidl::InterfaceTypeEntity> const & entity) { assert(entity.is()); - for (std::vector<unoidl::AnnotatedReference>::const_iterator i( - entity->getDirectMandatoryBases().begin()); - i != entity->getDirectMandatoryBases().end(); ++i) - { - OUString n("." + i->name); + for (auto & i: entity->getDirectMandatoryBases()) { + OUString n("." + i.name); unoidl::detail::SourceProviderEntity const * p; if (findEntity(location, yyscanner, data, true, &n, &p, 0, 0) == FOUND_ERROR) @@ -4457,27 +4359,19 @@ bool SourceProviderInterfaceTypeEntityPad::addOptionalBaseMembers( return false; } } - for (std::vector<unoidl::InterfaceTypeEntity::Attribute>::const_iterator i( - entity->getDirectAttributes().begin()); - i != entity->getDirectAttributes().end(); ++i) - { + for (auto & i: entity->getDirectAttributes()) { Member & m( allMembers.insert( - std::map<OUString, Member>::value_type( - i->name, Member(""))) + std::map<OUString, Member>::value_type(i.name, Member(""))) .first->second); if (m.mandatory.isEmpty()) { m.optional.insert(name); } } - for (std::vector<unoidl::InterfaceTypeEntity::Method>::const_iterator i( - entity->getDirectMethods().begin()); - i != entity->getDirectMethods().end(); ++i) - { + for (auto & i: entity->getDirectMethods()) { Member & m( allMembers.insert( - std::map<OUString, Member>::value_type( - i->name, Member(""))) + std::map<OUString, Member>::value_type(i.name, Member(""))) .first->second); if (m.mandatory.isEmpty()) { m.optional.insert(name); diff --git a/unoidl/source/unoidl-check.cxx b/unoidl/source/unoidl-check.cxx index b54aeaeb697f..e5f8bb0f68c6 100644 --- a/unoidl/source/unoidl-check.cxx +++ b/unoidl/source/unoidl-check.cxx @@ -225,7 +225,7 @@ void checkMap( << ent2B->getMembers().size() << std::endl; std::exit(EXIT_FAILURE); } - for (std::vector<unoidl::EnumTypeEntity::Member>::const_iterator + for (auto i(ent2A->getMembers().begin()), j(ent2B->getMembers().begin()); i != ent2A->getMembers().end(); ++i, ++j) @@ -272,7 +272,7 @@ void checkMap( << ent2B->getDirectMembers().size() << std::endl; std::exit(EXIT_FAILURE); } - for (std::vector<unoidl::PlainStructTypeEntity::Member>::const_iterator + for (auto i(ent2A->getDirectMembers().begin()), j(ent2B->getDirectMembers().begin()); i != ent2A->getDirectMembers().end(); ++i, ++j) @@ -310,7 +310,7 @@ void checkMap( << ent2B->getTypeParameters().size() << std::endl; std::exit(EXIT_FAILURE); } - for (std::vector<OUString>::const_iterator + for (auto i(ent2A->getTypeParameters().begin()), j(ent2B->getTypeParameters().begin()); i != ent2A->getTypeParameters().end(); ++i, ++j) @@ -335,7 +335,7 @@ void checkMap( << ent2B->getMembers().size() << std::endl; std::exit(EXIT_FAILURE); } - for (std::vector<unoidl::PolymorphicStructTypeTemplateEntity::Member>::const_iterator + for (auto i(ent2A->getMembers().begin()), j(ent2B->getMembers().begin()); i != ent2A->getMembers().end(); ++i, ++j) @@ -389,7 +389,7 @@ void checkMap( << ent2B->getDirectMembers().size() << std::endl; std::exit(EXIT_FAILURE); } - for (std::vector<unoidl::ExceptionTypeEntity::Member>::const_iterator + for (auto i(ent2A->getDirectMembers().begin()), j(ent2B->getDirectMembers().begin()); i != ent2A->getDirectMembers().end(); ++i, ++j) @@ -424,7 +424,7 @@ void checkMap( << std::endl; std::exit(EXIT_FAILURE); } - for (std::vector<unoidl::AnnotatedReference>::const_iterator + for (auto i(ent2A->getDirectMandatoryBases().begin()), j(ent2B->getDirectMandatoryBases().begin()); i != ent2A->getDirectMandatoryBases().end(); ++i, ++j) @@ -451,7 +451,7 @@ void checkMap( << std::endl; std::exit(EXIT_FAILURE); } - for (std::vector<unoidl::AnnotatedReference>::const_iterator + for (auto i(ent2A->getDirectOptionalBases().begin()), j(ent2B->getDirectOptionalBases().begin()); i != ent2A->getDirectOptionalBases().end(); ++i, ++j) @@ -477,7 +477,7 @@ void checkMap( << ent2B->getDirectAttributes().size() << std::endl; std::exit(EXIT_FAILURE); } - for (std::vector<unoidl::InterfaceTypeEntity::Attribute>::const_iterator + for (auto i(ent2A->getDirectAttributes().begin()), j(ent2B->getDirectAttributes().begin()); i != ent2A->getDirectAttributes().end(); ++i, ++j) @@ -516,7 +516,7 @@ void checkMap( << ent2B->getDirectMethods().size() << std::endl; std::exit(EXIT_FAILURE); } - for (std::vector<unoidl::InterfaceTypeEntity::Method>::const_iterator + for (auto i(ent2A->getDirectMethods().begin()), j(ent2B->getDirectMethods().begin()); i != ent2A->getDirectMethods().end(); ++i, ++j) @@ -543,7 +543,7 @@ void checkMap( << j->parameters.size() << std::endl; std::exit(EXIT_FAILURE); } - for (std::vector<unoidl::InterfaceTypeEntity::Method::Parameter>::const_iterator + for (auto k(i->parameters.begin()), l(j->parameters.begin()); k != i->parameters.end(); ++k, ++l) @@ -597,20 +597,14 @@ void checkMap( static_cast<unoidl::ConstantGroupEntity *>(entA.get())); rtl::Reference<unoidl::ConstantGroupEntity> ent2B( static_cast<unoidl::ConstantGroupEntity *>(entB.get())); - for (std::vector<unoidl::ConstantGroupEntity::Member>::const_iterator - i(ent2A->getMembers().begin()); - i != ent2A->getMembers().end(); ++i) - { + for (auto & i: ent2A->getMembers()) { bool found = false; - for (std::vector<unoidl::ConstantGroupEntity::Member>::const_iterator - j(ent2B->getMembers().begin()); - j != ent2B->getMembers().end(); ++j) - { - if (i->name == j->name) { - if (i->value != j->value) { + for (auto & j: ent2B->getMembers()) { + if (i.name == j.name) { + if (i.value != j.value) { std::cerr << "constant group " << name - << " member " << i->name + << " member " << i.name << " changed value" << std::endl; std::exit(EXIT_FAILURE); } @@ -621,7 +615,7 @@ void checkMap( if (!found) { std::cerr << "A constant group " << name << " member " - << i->name << " is not present in B" + << i.name << " is not present in B" << std::endl; std::exit(EXIT_FAILURE); } @@ -656,7 +650,7 @@ void checkMap( << ent2B->getConstructors().size() << std::endl; std::exit(EXIT_FAILURE); } - for (std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor>::const_iterator + for (auto i(ent2A->getConstructors().begin()), j(ent2B->getConstructors().begin()); i != ent2A->getConstructors().end(); ++i, ++j) @@ -704,7 +698,7 @@ void checkMap( << std::endl; std::exit(EXIT_FAILURE); } - for (std::vector<unoidl::AnnotatedReference>::const_iterator + for (auto i(ent2A->getDirectMandatoryBaseServices().begin()), j(ent2B->getDirectMandatoryBaseServices().begin()); i != ent2A->getDirectMandatoryBaseServices().end(); @@ -736,20 +730,16 @@ void checkMap( << std::endl; std::exit(EXIT_FAILURE); } - for (std::vector<unoidl::AnnotatedReference>::const_iterator - i(ent2A->getDirectOptionalBaseServices().begin()); - i != ent2A->getDirectOptionalBaseServices().end(); - ++i) - { + for (auto & i: ent2A->getDirectOptionalBaseServices()) { if (std::find_if( ent2B->getDirectOptionalBaseServices().begin(), ent2B->getDirectOptionalBaseServices().end(), - EqualsAnnotation(i->name)) + EqualsAnnotation(i.name)) == ent2B->getDirectOptionalBaseServices().end()) { std::cerr << "accumulation-based service " << name - << " direct optional base service " << i->name + << " direct optional base service " << i.name << " was removed" << std::endl; std::exit(EXIT_FAILURE); } @@ -767,7 +757,7 @@ void checkMap( << std::endl; std::exit(EXIT_FAILURE); } - for (std::vector<unoidl::AnnotatedReference>::const_iterator + for (auto i(ent2A->getDirectMandatoryBaseInterfaces() .begin()), j(ent2B->getDirectMandatoryBaseInterfaces() @@ -801,22 +791,17 @@ void checkMap( << std::endl; std::exit(EXIT_FAILURE); } - for (std::vector<unoidl::AnnotatedReference>::const_iterator - i(ent2A->getDirectOptionalBaseInterfaces() - .begin()); - i != ent2A->getDirectOptionalBaseInterfaces().end(); - ++i) - { + for (auto & i: ent2A->getDirectOptionalBaseInterfaces()) { if (std::find_if( (ent2B->getDirectOptionalBaseInterfaces() .begin()), ent2B->getDirectOptionalBaseInterfaces().end(), - EqualsAnnotation(i->name)) + EqualsAnnotation(i.name)) == ent2B->getDirectOptionalBaseInterfaces().end()) { std::cerr << "accumulation-based service " << name - << " direct optional base interface " << i->name + << " direct optional base interface " << i.name << " was removed" << std::endl; std::exit(EXIT_FAILURE); } @@ -831,7 +816,7 @@ void checkMap( << ent2B->getDirectProperties().size() << std::endl; std::exit(EXIT_FAILURE); } - for (std::vector<unoidl::AccumulationBasedServiceEntity::Property>::const_iterator + for (auto i(ent2A->getDirectProperties().begin()), j(ent2B->getDirectProperties().begin()); i != ent2A->getDirectProperties().end(); ++i, ++j) @@ -851,7 +836,7 @@ void checkMap( std::exit(EXIT_FAILURE); } } - for (std::vector<unoidl::AccumulationBasedServiceEntity::Property>::const_iterator + for (auto i(ent2B->getDirectProperties().begin() + ent2A->getDirectProperties().size()); i != ent2B->getDirectProperties().end(); ++i) @@ -948,13 +933,10 @@ void checkIds( if (!entA.is()) { rtl::Reference<unoidl::EnumTypeEntity> ent2B( static_cast<unoidl::EnumTypeEntity *>(entB.get())); - for (std::vector<unoidl::EnumTypeEntity::Member>::const_iterator - i(ent2B->getMembers().begin()); - i != ent2B->getMembers().end(); ++i) - { - if (!valid(i->name)) { + for (auto & i: ent2B->getMembers()) { + if (!valid(i.name)) { std::cerr - << "enum type " << name << " member " << i->name + << "enum type " << name << " member " << i.name << " uses an invalid identifier" << std::endl; std::exit(EXIT_FAILURE); } @@ -966,14 +948,11 @@ void checkIds( rtl::Reference<unoidl::PlainStructTypeEntity> ent2B( static_cast<unoidl::PlainStructTypeEntity *>( entB.get())); - for (std::vector<unoidl::PlainStructTypeEntity::Member>::const_iterator - i(ent2B->getDirectMembers().begin()); - i != ent2B->getDirectMembers().end(); ++i) - { - if (!valid(i->name)) { + for (auto & i: ent2B->getDirectMembers()) { + if (!valid(i.name)) { std::cerr << "plain struct type " << name << " direct member " - << i->name << " uses an invalid identifier" + << i.name << " uses an invalid identifier" << std::endl; std::exit(EXIT_FAILURE); } @@ -987,26 +966,20 @@ void checkIds( static_cast< unoidl::PolymorphicStructTypeTemplateEntity *>( entB.get())); - for (std::vector<OUString>::const_iterator i( - ent2B->getTypeParameters().begin()); - i != ent2B->getTypeParameters().end(); ++i) - { - if (!valid(*i)) { + for (auto & i: ent2B->getTypeParameters()) { + if (!valid(i)) { std::cerr << "polymorphic struct type template " << name - << " type parameter " << *i + << " type parameter " << i << " uses an invalid identifier" << std::endl; std::exit(EXIT_FAILURE); } } - for (std::vector<unoidl::PolymorphicStructTypeTemplateEntity::Member>::const_iterator - i(ent2B->getMembers().begin()); - i != ent2B->getMembers().end(); ++i) - { - if (!valid(i->name)) { + for (auto & i: ent2B->getMembers()) { + if (!valid(i.name)) { std::cerr << "polymorphic struct type template " << name - << " member " << i->name + << " member " << i.name << " uses an invalid identifier" << std::endl; std::exit(EXIT_FAILURE); } @@ -1017,14 +990,11 @@ void checkIds( if (!entA.is()) { rtl::Reference<unoidl::ExceptionTypeEntity> ent2B( static_cast<unoidl::ExceptionTypeEntity *>(entB.get())); - for (std::vector<unoidl::ExceptionTypeEntity::Member>::const_iterator - i(ent2B->getDirectMembers().begin()); - i != ent2B->getDirectMembers().end(); ++i) - { - if (!valid(i->name)) { + for (auto & i: ent2B->getDirectMembers()) { + if (!valid(i.name)) { std::cerr << "exception type " << name << " direct member " - << i->name << " uses an invalid identifier" + << i.name << " uses an invalid identifier" << std::endl; std::exit(EXIT_FAILURE); } @@ -1035,38 +1005,29 @@ void checkIds( if (!entA.is()) { rtl::Reference<unoidl::InterfaceTypeEntity> ent2B( static_cast<unoidl::InterfaceTypeEntity *>(entB.get())); - for (std::vector<unoidl::InterfaceTypeEntity::Attribute>::const_iterator - i(ent2B->getDirectAttributes().begin()); - i != ent2B->getDirectAttributes().end(); ++i) - { - if (!valid(i->name)) { + for (auto & i: ent2B->getDirectAttributes()) { + if (!valid(i.name)) { std::cerr << "interface type " << name << " direct attribute " - << i->name << " uses an invalid identifier" + << i.name << " uses an invalid identifier" << std::endl; std::exit(EXIT_FAILURE); } } - for (std::vector<unoidl::InterfaceTypeEntity::Method>::const_iterator - i(ent2B->getDirectMethods().begin()); - i != ent2B->getDirectMethods().end(); ++i) - { - if (!valid(i->name)) { + for (auto & i: ent2B->getDirectMethods()) { + if (!valid(i.name)) { std::cerr << "interface type " << name << " direct method " - << i->name << " uses an invalid identifier" + << i.name << " uses an invalid identifier" << std::endl; std::exit(EXIT_FAILURE); } - for (std::vector<unoidl::InterfaceTypeEntity::Method::Parameter>::const_iterator - j(i->parameters.begin()); - j != i->parameters.end(); ++j) - { - if (!valid(j->name)) { + for (auto & j: i.parameters) { + if (!valid(j.name)) { std::cerr << "interface type " << name - << " direct method " << i->name << " parameter " - << j->name << " uses an invalid identifier" + << " direct method " << i.name << " parameter " + << j.name << " uses an invalid identifier" << std::endl; std::exit(EXIT_FAILURE); } @@ -1082,29 +1043,23 @@ void checkIds( { rtl::Reference<unoidl::ConstantGroupEntity> ent2B( static_cast<unoidl::ConstantGroupEntity *>(entB.get())); - for (std::vector<unoidl::ConstantGroupEntity::Member>::const_iterator - i(ent2B->getMembers().begin()); - i != ent2B->getMembers().end(); ++i) - { + for (auto & i: ent2B->getMembers()) { bool found = false; if (entA.is()) { rtl::Reference<unoidl::ConstantGroupEntity> ent2A( static_cast<unoidl::ConstantGroupEntity *>( entA.get())); - for (std::vector<unoidl::ConstantGroupEntity::Member>::const_iterator - j(ent2A->getMembers().begin()); - j != ent2A->getMembers().end(); ++j) - { - if (i->name == j->name) { + for (auto & j: ent2A->getMembers()) { + if (i.name == j.name) { found = true; break; } } } - if (!(found || valid(i->name))) { + if (!(found || valid(i.name))) { std::cerr << "Constant group " << name << " member " - << i->name << " uses an invalid identifier" + << i.name << " uses an invalid identifier" << std::endl; std::exit(EXIT_FAILURE); } @@ -1117,26 +1072,20 @@ void checkIds( ent2B( static_cast<unoidl::SingleInterfaceBasedServiceEntity *>( entB.get())); - for (std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor>::const_iterator - i(ent2B->getConstructors().begin()); - i != ent2B->getConstructors().end(); ++i) - { - if (!valid(i->name)) { + for (auto & i: ent2B->getConstructors()) { + if (!valid(i.name)) { std::cerr << "single-interface--based service " << name - << " constructor " << i->name + << " constructor " << i.name << " uses an invalid identifier" << std::endl; std::exit(EXIT_FAILURE); } - for (std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter>::const_iterator - j(i->parameters.begin()); - j != i->parameters.end(); ++j) - { - if (!valid(j->name)) { + for (auto & j: i.parameters) { + if (!valid(j.name)) { std::cerr << "single-interface--based service " << name - << " constructor " << i->name << " parameter " - << j->name << " uses an invalid identifier" + << " constructor " << i.name << " parameter " + << j.name << " uses an invalid identifier" << std::endl; std::exit(EXIT_FAILURE); } @@ -1156,14 +1105,11 @@ void checkIds( ->getDirectProperties().size()) : 0); assert(n <= ent2B->getDirectProperties().size()); - for (std::vector<unoidl::AccumulationBasedServiceEntity::Property>::const_iterator - i(ent2B->getDirectProperties().begin() + n); - i != ent2B->getDirectProperties().end(); ++i) - { - if (!valid(i->name)) { + for (auto & i: ent2B->getDirectProperties()) { + if (!valid(i.name)) { std::cerr << "accumulation-based service " << name - << " direct property " << i->name + << " direct property " << i.name << " uses an invalid identifier" << std::endl; std::exit(EXIT_FAILURE); } diff --git a/unoidl/source/unoidl-read.cxx b/unoidl/source/unoidl-read.cxx index e0ea73f4e13a..32bd012d8bac 100644 --- a/unoidl/source/unoidl-read.cxx +++ b/unoidl/source/unoidl-read.cxx @@ -180,10 +180,8 @@ void insertEntityDependencies( std::map<OUString, Entity>::iterator const & iterator, std::vector<OUString> const & names) { - for (std::vector<OUString>::const_iterator i(names.begin()); - i != names.end(); ++i) - { - insertEntityDependency(manager, iterator, *i); + for (auto & i: names) { + insertEntityDependency(manager, iterator, i); } } @@ -192,11 +190,8 @@ void insertEntityDependencies( std::map<OUString, Entity>::iterator const & iterator, std::vector<unoidl::AnnotatedReference> const & references) { - for (std::vector<unoidl::AnnotatedReference>::const_iterator i( - references.begin()); - i != references.end(); ++i) - { - insertEntityDependency(manager, iterator, i->name); + for (auto & i: references) { + insertEntityDependency(manager, iterator, i.name); } } @@ -211,10 +206,8 @@ void insertTypeDependency( OUString nucl(decomposeType(type, &rank, &args, &entity)); if (entity) { insertEntityDependency(manager, iterator, nucl, true); - for (std::vector<OUString>::iterator i(args.begin()); i != args.end(); - ++i) - { - insertTypeDependency(manager, iterator, *i); + for (auto & i: args) { + insertTypeDependency(manager, iterator, i); } } } @@ -264,11 +257,8 @@ void scanMap( insertEntityDependency( manager, i, ent2->getDirectBase()); } - for (std::vector<unoidl::PlainStructTypeEntity::Member>::const_iterator - j(ent2->getDirectMembers().begin()); - j != ent2->getDirectMembers().end(); ++j) - { - insertTypeDependency(manager, i, j->type); + for (auto & j: ent2->getDirectMembers()) { + insertTypeDependency(manager, i, j.type); } break; } @@ -278,12 +268,9 @@ void scanMap( ent2( static_cast<unoidl::PolymorphicStructTypeTemplateEntity *>( ent.get())); - for (std::vector<unoidl::PolymorphicStructTypeTemplateEntity::Member>::const_iterator - j(ent2->getMembers().begin()); - j != ent2->getMembers().end(); ++j) - { - if (!j->parameterized) { - insertTypeDependency(manager, i, j->type); + for (auto & j: ent2->getMembers()) { + if (!j.parameterized) { + insertTypeDependency(manager, i, j.type); } } break; @@ -296,11 +283,8 @@ void scanMap( insertEntityDependency( manager, i, ent2->getDirectBase()); } - for (std::vector<unoidl::ExceptionTypeEntity::Member>::const_iterator - j(ent2->getDirectMembers().begin()); - j != ent2->getDirectMembers().end(); ++j) - { - insertTypeDependency(manager, i, j->type); + for (auto & j: ent2->getDirectMembers()) { + insertTypeDependency(manager, i, j.type); } break; } @@ -313,24 +297,15 @@ void scanMap( manager, i, ent2->getDirectMandatoryBases()); insertEntityDependencies( manager, i, ent2->getDirectOptionalBases()); - for (std::vector<unoidl::InterfaceTypeEntity::Attribute>::const_iterator - j(ent2->getDirectAttributes().begin()); - j != ent2->getDirectAttributes().end(); ++j) - { - insertTypeDependency(manager, i, j->type); + for (auto & j: ent2->getDirectAttributes()) { + insertTypeDependency(manager, i, j.type); } - for (std::vector<unoidl::InterfaceTypeEntity::Method>::const_iterator - j(ent2->getDirectMethods().begin()); - j != ent2->getDirectMethods().end(); ++j) - { - insertTypeDependency(manager, i, j->returnType); - for (std::vector<unoidl::InterfaceTypeEntity::Method::Parameter>::const_iterator - k(j->parameters.begin()); - k != j->parameters.end(); ++k) - { - insertTypeDependency(manager, i, k->type); + for (auto & j: ent2->getDirectMethods()) { + insertTypeDependency(manager, i, j.returnType); + for (auto & k: j.parameters) { + insertTypeDependency(manager, i, k.type); } - insertEntityDependencies(manager, i, j->exceptions); + insertEntityDependencies(manager, i, j.exceptions); } break; } @@ -348,17 +323,11 @@ void scanMap( static_cast<unoidl::SingleInterfaceBasedServiceEntity *>( ent.get())); insertEntityDependency(manager, i, ent2->getBase()); - for (std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor>::const_iterator - j(ent2->getConstructors().begin()); - j != ent2->getConstructors().end(); ++j) - { - for (std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter>::const_iterator - k(j->parameters.begin()); - k != j->parameters.end(); ++k) - { - insertTypeDependency(manager, i, k->type); + for (auto & j: ent2->getConstructors()) { + for (auto & k: j.parameters) { + insertTypeDependency(manager, i, k.type); } - insertEntityDependencies(manager, i, j->exceptions); + insertEntityDependencies(manager, i, j.exceptions); } break; } @@ -375,11 +344,8 @@ void scanMap( manager, i, ent2->getDirectMandatoryBaseInterfaces()); insertEntityDependencies( manager, i, ent2->getDirectOptionalBaseInterfaces()); - for (std::vector<unoidl::AccumulationBasedServiceEntity::Property>::const_iterator - j(ent2->getDirectProperties().begin()); - j != ent2->getDirectProperties().end(); ++j) - { - insertTypeDependency(manager, i, j->type); + for (auto & j: ent2->getDirectProperties()) { + insertTypeDependency(manager, i, j.type); } break; } @@ -408,10 +374,8 @@ void propagateRelevant(std::map<OUString, Entity> & entities, Entity & entity) { if (!entity.relevant) { entity.relevant = true; if (entity.sorted != Entity::Sorted::YES) { - for (std::set<OUString>::iterator i(entity.dependencies.begin()); - i != entity.dependencies.end(); ++i) - { - std::map<OUString, Entity>::iterator j(entities.find(*i)); + for (auto & i: entity.dependencies) { + std::map<OUString, Entity>::iterator j(entities.find(i)); if (j != entities.end()) { propagateRelevant(entities, j->second); } @@ -428,11 +392,8 @@ void visit( switch (iterator->second.sorted) { case Entity::Sorted::NO: iterator->second.sorted = Entity::Sorted::ACTIVE; - for (std::set<OUString>::iterator i( - iterator->second.dependencies.begin()); - i != iterator->second.dependencies.end(); ++i) - { - std::map<OUString, Entity>::iterator j(entities.find(*i)); + for (auto & i: iterator->second.dependencies) { + std::map<OUString, Entity>::iterator j(entities.find(i)); if (j != entities.end()) { if (iterator->second.relevant) { propagateRelevant(entities, j->second); @@ -456,9 +417,7 @@ void visit( std::vector<OUString> sort(std::map<OUString, Entity> & entities) { std::vector<OUString> res; - for (std::map<OUString, Entity>::iterator i(entities.begin()); - i != entities.end(); ++i) - { + for (auto i(entities.begin()); i != entities.end(); ++i) { visit(entities, i, res); } return res; @@ -474,7 +433,8 @@ void indent(std::vector<OUString> const & modules, unsigned int extra = 0) { } void closeModules( - std::vector<OUString> & modules, std::vector<OUString>::size_type n) { + std::vector<OUString> & modules, std::vector<OUString>::size_type n) +{ for (std::vector<OUString>::size_type i = 0; i != n; ++i) { assert(!modules.empty()); modules.pop_back(); @@ -521,11 +481,9 @@ void writeName(OUString const & name) { void writeAnnotations(std::vector<OUString> const & annotations) { if (!annotations.empty()) { std::cout << "/**"; - for (std::vector<OUString>::const_iterator i(annotations.begin()); - i != annotations.end(); ++i) - { - //TODO: i->indexOf("*/") == -1 - std::cout << " @" << *i; + for (auto & i: annotations) { + //TODO: i.indexOf("*/") == -1 + std::cout << " @" << i; } std::cout << " */ "; } @@ -561,9 +519,7 @@ void writeType(OUString const & type) { } if (!args.empty()) { std::cout << "< "; - for (std::vector<OUString>::iterator i(args.begin()); i != args.end(); - ++i) - { + for (auto i(args.begin()); i != args.end(); ++i) { if (i != args.begin()) { std::cout << ", "; } @@ -579,9 +535,7 @@ void writeType(OUString const & type) { void writeExceptionSpecification(std::vector<OUString> const & exceptions) { if (!exceptions.empty()) { std::cout << " raises ("; - for (std::vector<OUString>::const_iterator i(exceptions.begin()); - i != exceptions.end(); ++i) - { + for (auto i(exceptions.begin()); i != exceptions.end(); ++i) { if (i != exceptions.begin()) { std::cout << ", "; } @@ -599,18 +553,15 @@ void writeEntity( if (i != entities.end() && i->second.relevant) { assert(!i->second.written); i->second.written = true; - for (std::set<OUString>::iterator j( - i->second.interfaceDependencies.begin()); - j != i->second.interfaceDependencies.end(); ++j) - { - std::map<OUString, Entity>::iterator k(entities.find(*j)); + for (auto & j: i->second.interfaceDependencies) { + std::map<OUString, Entity>::iterator k(entities.find(j)); if (k != entities.end() && !k->second.written) { - OUString id(openModulesFor(modules, *j)); + OUString id(openModulesFor(modules, j)); if (k->second.entity->getSort() != unoidl::Entity::SORT_INTERFACE_TYPE) { std::cerr - << "Entity " << *j << " should be an interface type" + << "Entity " << j << " should be an interface type" << std::endl; std::exit(EXIT_FAILURE); } @@ -633,8 +584,7 @@ void writeEntity( static_cast<unoidl::EnumTypeEntity *>(ent.get())); writeAnnotationsPublished(ent); std::cout << "enum " << id << " {\n"; - for (std::vector<unoidl::EnumTypeEntity::Member>::const_iterator - j(ent2->getMembers().begin()); + for (auto j(ent2->getMembers().begin()); j != ent2->getMembers().end(); ++j) { indent(modules, 1); @@ -660,14 +610,11 @@ void writeEntity( writeName(ent2->getDirectBase()); } std::cout << " {\n"; - for (std::vector<unoidl::PlainStructTypeEntity::Member>::const_iterator - j(ent2->getDirectMembers().begin()); - j != ent2->getDirectMembers().end(); ++j) - { + for (auto & j: ent2->getDirectMembers()) { indent(modules, 1); - writeAnnotations(j->annotations); - writeType(j->type); - std::cout << ' ' << j->name << ";\n"; + writeAnnotations(j.annotations); + writeType(j.type); + std::cout << ' ' << j.name << ";\n"; } indent(modules); std::cout << "};\n"; @@ -681,8 +628,7 @@ void writeEntity( ent.get())); writeAnnotationsPublished(ent); std::cout << "struct " << id << '<'; - for (std::vector<OUString>::const_iterator j( - ent2->getTypeParameters().begin()); + for (auto j(ent2->getTypeParameters().begin()); j != ent2->getTypeParameters().end(); ++j) { if (j != ent2->getTypeParameters().begin()) { @@ -691,18 +637,15 @@ void writeEntity( std::cout << *j; } std::cout << "> {\n"; - for (std::vector<unoidl::PolymorphicStructTypeTemplateEntity::Member>::const_iterator - j(ent2->getMembers().begin()); - j != ent2->getMembers().end(); ++j) - { + for (auto & j: ent2->getMembers()) { indent(modules, 1); - writeAnnotations(j->annotations); - if (j->parameterized) { - std::cout << j->type; + writeAnnotations(j.annotations); + if (j.parameterized) { + std::cout << j.type; } else { - writeType(j->type); + writeType(j.type); } - std::cout << ' ' << j->name << ";\n"; + std::cout << ' ' << j.name << ";\n"; } indent(modules); std::cout << "};\n"; @@ -719,14 +662,11 @@ void writeEntity( writeName(ent2->getDirectBase()); } std::cout << " {\n"; - for (std::vector<unoidl::ExceptionTypeEntity::Member>::const_iterator - j(ent2->getDirectMembers().begin()); - j != ent2->getDirectMembers().end(); ++j) - { + for (auto & j: ent2->getDirectMembers()) { indent(modules, 1); - writeAnnotations(j->annotations); - writeType(j->type); - std::cout << ' ' << j->name << ";\n"; + writeAnnotations(j.annotations); + writeType(j.type); + std::cout << ' ' << j.name << ";\n"; } indent(modules); std::cout << "};\n"; @@ -739,74 +679,60 @@ void writeEntity( ent.get())); writeAnnotationsPublished(ent); std::cout << "interface " << id << " {\n"; - for (std::vector<unoidl::AnnotatedReference>::const_iterator j( - ent2->getDirectMandatoryBases().begin()); - j != ent2->getDirectMandatoryBases().end(); ++j) - { + for (auto & j: ent2->getDirectMandatoryBases()) { indent(modules, 1); - writeAnnotations(j->annotations); + writeAnnotations(j.annotations); std::cout << "interface "; - writeName(j->name); + writeName(j.name); std::cout << ";\n"; } - for (std::vector<unoidl::AnnotatedReference>::const_iterator j( - ent2->getDirectOptionalBases().begin()); - j != ent2->getDirectOptionalBases().end(); ++j) - { + for (auto & j: ent2->getDirectOptionalBases()) { indent(modules, 1); - writeAnnotations(j->annotations); + writeAnnotations(j.annotations); std::cout << "[optional] interface "; - writeName(j->name); + writeName(j.name); std::cout << ";\n"; } - for (std::vector<unoidl::InterfaceTypeEntity::Attribute>::const_iterator - j(ent2->getDirectAttributes().begin()); - j != ent2->getDirectAttributes().end(); ++j) - { + for (auto & j: ent2->getDirectAttributes()) { indent(modules, 1); - writeAnnotations(j->annotations); + writeAnnotations(j.annotations); std::cout << "[attribute"; - if (j->bound) { + if (j.bound) { std::cout << ", bound"; } - if (j->readOnly) { + if (j.readOnly) { std::cout << ", readonly"; } std::cout << "] "; - writeType(j->type); - std::cout << ' ' << j->name; - if (!(j->getExceptions.empty() && j->setExceptions.empty())) - { + writeType(j.type); + std::cout << ' ' << j.name; + if (!(j.getExceptions.empty() && j.setExceptions.empty())) { std::cout << " {\n"; - if (!j->getExceptions.empty()) { + if (!j.getExceptions.empty()) { indent(modules, 2); std::cout << "get"; - writeExceptionSpecification(j->getExceptions); + writeExceptionSpecification(j.getExceptions); std::cout << ";\n"; } - if (!j->setExceptions.empty()) { + if (!j.setExceptions.empty()) { indent(modules, 2); std::cout << "set"; - writeExceptionSpecification(j->setExceptions); + writeExceptionSpecification(j.setExceptions); std::cout << ";\n"; } std::cout << " }"; } std::cout << ";\n"; } - for (std::vector<unoidl::InterfaceTypeEntity::Method>::const_iterator - j(ent2->getDirectMethods().begin()); - j != ent2->getDirectMethods().end(); ++j) - { + for (auto & j: ent2->getDirectMethods()) { indent(modules, 1); - writeAnnotations(j->annotations); - writeType(j->returnType); - std::cout << ' ' << j->name << '('; - for (std::vector<unoidl::InterfaceTypeEntity::Method::Parameter>::const_iterator - k(j->parameters.begin()); - k != j->parameters.end(); ++k) + writeAnnotations(j.annotations); + writeType(j.returnType); + std::cout << ' ' << j.name << '('; + for (auto k(j.parameters.begin()); k != j.parameters.end(); + ++k) { - if (k != j->parameters.begin()) { + if (k != j.parameters.begin()) { std::cout << ", "; } switch (k->direction) { @@ -824,7 +750,7 @@ void writeEntity( std::cout << ' ' << k->name; } std::cout << ')'; - writeExceptionSpecification(j->exceptions); + writeExceptionSpecification(j.exceptions); std::cout << ";\n"; } indent(modules); @@ -847,14 +773,11 @@ void writeEntity( static_cast<unoidl::ConstantGroupEntity *>(ent.get())); writeAnnotationsPublished(ent); std::cout << "constants " << id << " {\n"; - for (std::vector<unoidl::ConstantGroupEntity::Member>::const_iterator - j(ent2->getMembers().begin()); - j != ent2->getMembers().end(); ++j) - { + for (auto & j: ent2->getMembers()) { indent(modules, 1); - writeAnnotations(j->annotations); + writeAnnotations(j.annotations); std::cout << "const "; - switch (j->value.type) { + switch (j.value.type) { case unoidl::ConstantValue::TYPE_BOOLEAN: std::cout << "boolean"; break; @@ -886,37 +809,37 @@ void writeEntity( std::cout << "double"; break; } - std::cout << ' ' << j->name << " = "; - switch (j->value.type) { + std::cout << ' ' << j.name << " = "; + switch (j.value.type) { case unoidl::ConstantValue::TYPE_BOOLEAN: - std::cout << (j->value.booleanValue ? "TRUE" : "FALSE"); + std::cout << (j.value.booleanValue ? "TRUE" : "FALSE"); break; case unoidl::ConstantValue::TYPE_BYTE: - std::cout << int(j->value.byteValue); + std::cout << int(j.value.byteValue); break; case unoidl::ConstantValue::TYPE_SHORT: - std::cout << j->value.shortValue; + std::cout << j.value.shortValue; break; case unoidl::ConstantValue::TYPE_UNSIGNED_SHORT: - std::cout << j->value.unsignedShortValue; + std::cout << j.value.unsignedShortValue; break; case unoidl::ConstantValue::TYPE_LONG: - std::cout << j->value.longValue; + std::cout << j.value.longValue; break; case unoidl::ConstantValue::TYPE_UNSIGNED_LONG: - std::cout << j->value.unsignedLongValue; + std::cout << j.value.unsignedLongValue; break; case unoidl::ConstantValue::TYPE_HYPER: - std::cout << j->value.hyperValue; + std::cout << j.value.hyperValue; break; case unoidl::ConstantValue::TYPE_UNSIGNED_HYPER: - std::cout << j->value.unsignedHyperValue; + std::cout << j.value.unsignedHyperValue; break; case unoidl::ConstantValue::TYPE_FLOAT: - std::cout << j->value.floatValue; + std::cout << j.value.floatValue; break; case unoidl::ConstantValue::TYPE_DOUBLE: - std::cout << j->value.doubleValue; + std::cout << j.value.doubleValue; break; } std::cout << ";\n"; @@ -937,18 +860,14 @@ void writeEntity( || !ent2->getConstructors().front().defaultConstructor) { std::cout << " {\n"; - for (std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor>::const_iterator - j(ent2->getConstructors().begin()); - j != ent2->getConstructors().end(); ++j) - { + for (auto & j: ent2->getConstructors()) { indent(modules, 1); - writeAnnotations(j->annotations); - std::cout << j->name << '('; - for (std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter>::const_iterator - k(j->parameters.begin()); - k != j->parameters.end(); ++k) + writeAnnotations(j.annotations); + std::cout << j.name << '('; + for (auto k(j.parameters.begin()); + k != j.parameters.end(); ++k) { - if (k != j->parameters.begin()) { + if (k != j.parameters.begin()) { std::cout << ", "; } std::cout << "[in] "; @@ -959,7 +878,7 @@ void writeEntity( std::cout << ' ' << k->name; } std::cout << ')'; - writeExceptionSpecification(j->exceptions); + writeExceptionSpecification(j.exceptions); std::cout << ";\n"; } indent(modules); @@ -975,110 +894,95 @@ void writeEntity( ent.get())); writeAnnotationsPublished(ent); std::cout << "service " << id << " {\n"; - for (std::vector<unoidl::AnnotatedReference>::const_iterator j( - ent2->getDirectMandatoryBaseServices().begin()); - j != ent2->getDirectMandatoryBaseServices().end(); ++j) - { + for (auto & j: ent2->getDirectMandatoryBaseServices()) { indent(modules, 1); - writeAnnotations(j->annotations); + writeAnnotations(j.annotations); std::cout << "service "; - writeName(j->name); + writeName(j.name); std::cout << ";\n"; } - for (std::vector<unoidl::AnnotatedReference>::const_iterator j( - ent2->getDirectOptionalBaseServices().begin()); - j != ent2->getDirectOptionalBaseServices().end(); ++j) - { + for (auto & j: ent2->getDirectOptionalBaseServices()) { indent(modules, 1); - writeAnnotations(j->annotations); + writeAnnotations(j.annotations); std::cout << "[optional] service "; - writeName(j->name); + writeName(j.name); std::cout << ";\n"; } - for (std::vector<unoidl::AnnotatedReference>::const_iterator j( - ent2->getDirectMandatoryBaseInterfaces().begin()); - j != ent2->getDirectMandatoryBaseInterfaces().end(); ++j) - { + for (auto & j: ent2->getDirectMandatoryBaseInterfaces()) { indent(modules, 1); - writeAnnotations(j->annotations); + writeAnnotations(j.annotations); std::cout << "interface "; - writeName(j->name); + writeName(j.name); std::cout << ";\n"; } - for (std::vector<unoidl::AnnotatedReference>::const_iterator j( - ent2->getDirectOptionalBaseInterfaces().begin()); - j != ent2->getDirectOptionalBaseInterfaces().end(); ++j) - { + for (auto & j: ent2->getDirectOptionalBaseInterfaces()) { indent(modules, 1); - writeAnnotations(j->annotations); + writeAnnotations(j.annotations); std::cout << "[optional] interface "; - writeName(j->name); + writeName(j.name); std::cout << ";\n"; } - for (std::vector<unoidl::AccumulationBasedServiceEntity::Property>::const_iterator - j(ent2->getDirectProperties().begin()); - j != ent2->getDirectProperties().end(); ++j) - { + for (auto & j: ent2->getDirectProperties()) { indent(modules, 1); - writeAnnotations(j->annotations); + writeAnnotations(j.annotations); std::cout << "[property"; - if ((j->attributes + if ((j.attributes & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_BOUND) != 0) { std::cout << ", bound"; } - if ((j->attributes + if ((j.attributes & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_CONSTRAINED) != 0) { std::cout << ", constrained"; } - if ((j->attributes + if ((j.attributes & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_MAYBE_AMBIGUOUS) != 0) { std::cout << ", maybeambiguous"; } - if ((j->attributes + if ((j.attributes & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_MAYBE_DEFAULT) != 0) { std::cout << ", maybedefault"; } - if ((j->attributes + if ((j.attributes & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_MAYBE_VOID) != 0) { std::cout << ", maybevoid"; } - if ((j->attributes + if ((j.attributes & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_OPTIONAL) != 0) { std::cout << ", optional"; } - if ((j->attributes + if ((j.attributes & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_READ_ONLY) != 0) { std::cout << ", readonly"; } - if ((j->attributes + if ((j.attributes & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_REMOVABLE) != 0) { std::cout << ", removable"; } - if ((j->attributes + if ((j.attributes & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_TRANSIENT) != 0) { std::cout << ", transient"; } std::cout << "] "; - writeType(j->type); - std::cout << ' ' << j->name << ";\n"; + writeType(j.type); + std::cout << ' ' << j.name << ";\n"; } indent(modules); std::cout << "};\n"; @@ -1140,10 +1044,8 @@ SAL_IMPLEMENT_MAIN() { scanMap(mgr, prov->createRootCursor(), published, "", ents); std::vector<OUString> sorted(sort(ents)); std::vector<OUString> mods; - for (std::vector<OUString>::iterator i(sorted.begin()); - i != sorted.end(); ++i) - { - writeEntity(ents, mods, *i); + for (auto & i: sorted) { + writeEntity(ents, mods, i); } closeModules(mods, mods.size()); return EXIT_SUCCESS; diff --git a/unoidl/source/unoidl-write.cxx b/unoidl/source/unoidl-write.cxx index 01d22baffd52..d95dbb0b5c95 100644 --- a/unoidl/source/unoidl-write.cxx +++ b/unoidl/source/unoidl-write.cxx @@ -271,10 +271,8 @@ void writeAnnotations( if (annotate) { write32(file, annotations.size()); // overflow from std::vector::size_type -> sal_uInt64 is unrealistic - for (std::vector< OUString >::const_iterator i(annotations.begin()); - i != annotations.end(); ++i) - { - writeIdxString(file, toUtf8(*i)); + for (auto & i: annotations) { + writeIdxString(file, toUtf8(i)); } } } @@ -449,35 +447,29 @@ void mapCursor( sal_uInt64 writeMap( osl::File & file, std::map< OUString, Item > & map, std::size_t * rootSize) { - for (std::map< OUString, Item >::iterator i(map.begin()); i != map.end(); - ++i) - { - switch (i->second.entity->getSort()) { + for (auto & i: map) { + switch (i.second.entity->getSort()) { case unoidl::Entity::SORT_MODULE: - i->second.dataOffset = writeMap(file, i->second.module, nullptr); + i.second.dataOffset = writeMap(file, i.second.module, nullptr); break; case unoidl::Entity::SORT_ENUM_TYPE: { rtl::Reference< unoidl::EnumTypeEntity > ent2( static_cast< unoidl::EnumTypeEntity * >( - i->second.entity.get())); + i.second.entity.get())); bool ann = !ent2->getAnnotations().empty(); - for (std::vector< unoidl::EnumTypeEntity::Member >:: - const_iterator j(ent2->getMembers().begin()); + for (auto j(ent2->getMembers().begin()); !ann && j != ent2->getMembers().end(); ++j) { ann = !j->annotations.empty(); } - i->second.dataOffset = getOffset(file); + i.second.dataOffset = getOffset(file); writeKind(file, ent2.get(), ann); write32(file, ent2->getMembers().size()); - for (std::vector< unoidl::EnumTypeEntity::Member >:: - const_iterator j(ent2->getMembers().begin()); - j != ent2->getMembers().end(); ++j) - { - writeIdxName(file, j->name); - write32(file, static_cast< sal_uInt32 >(j->value)); - writeAnnotations(file, ann, j->annotations); + for (auto & j: ent2->getMembers()) { + writeIdxName(file, j.name); + write32(file, static_cast< sal_uInt32 >(j.value)); + writeAnnotations(file, ann, j.annotations); } writeAnnotations(file, ann, ent2->getAnnotations()); break; @@ -486,28 +478,24 @@ sal_uInt64 writeMap( { rtl::Reference< unoidl::PlainStructTypeEntity > ent2( static_cast< unoidl::PlainStructTypeEntity * >( - i->second.entity.get())); + i.second.entity.get())); bool ann = !ent2->getAnnotations().empty(); - for (std::vector< unoidl::PlainStructTypeEntity::Member >:: - const_iterator j(ent2->getDirectMembers().begin()); + for (auto j(ent2->getDirectMembers().begin()); !ann && j != ent2->getDirectMembers().end(); ++j) { ann = !j->annotations.empty(); } - i->second.dataOffset = getOffset(file); + i.second.dataOffset = getOffset(file); writeKind( file, ent2.get(), ann, !ent2->getDirectBase().isEmpty()); if (!ent2->getDirectBase().isEmpty()) { writeIdxName(file, ent2->getDirectBase()); } write32(file, ent2->getDirectMembers().size()); - for (std::vector< unoidl::PlainStructTypeEntity::Member >:: - const_iterator j(ent2->getDirectMembers().begin()); - j != ent2->getDirectMembers().end(); ++j) - { - writeIdxName(file, j->name); - writeIdxName(file, j->type); - writeAnnotations(file, ann, j->annotations); + for (auto & j: ent2->getDirectMembers()) { + writeIdxName(file, j.name); + writeIdxName(file, j.type); + writeAnnotations(file, ann, j.annotations); } writeAnnotations(file, ann, ent2->getAnnotations()); break; @@ -518,40 +506,29 @@ sal_uInt64 writeMap( ent2( static_cast< unoidl::PolymorphicStructTypeTemplateEntity * >( - i->second.entity.get())); + i.second.entity.get())); bool ann = !ent2->getAnnotations().empty(); - for (std::vector< - unoidl::PolymorphicStructTypeTemplateEntity::Member >:: - const_iterator j( - ent2->getMembers().begin()); + for (auto j(ent2->getMembers().begin()); !ann && j != ent2->getMembers().end(); ++j) { ann = !j->annotations.empty(); } - i->second.dataOffset = getOffset(file); + i.second.dataOffset = getOffset(file); writeKind(file, ent2.get(), ann); write32(file, ent2->getTypeParameters().size()); - for (std::vector< OUString >::const_iterator j( - ent2->getTypeParameters().begin()); - j != ent2->getTypeParameters().end(); ++j) - { - writeIdxName(file, *j); + for (auto & j: ent2->getTypeParameters()) { + writeIdxName(file, j); } write32(file, ent2->getMembers().size()); - for (std::vector< - unoidl::PolymorphicStructTypeTemplateEntity::Member >:: - const_iterator j( - ent2->getMembers().begin()); - j != ent2->getMembers().end(); ++j) - { + for (auto & j: ent2->getMembers()) { sal_uInt64 f = 0; - if (j->parameterized) { + if (j.parameterized) { f |= 0x01; } write8(file, f); - writeIdxName(file, j->name); - writeIdxName(file, j->type); - writeAnnotations(file, ann, j->annotations); + writeIdxName(file, j.name); + writeIdxName(file, j.type); + writeAnnotations(file, ann, j.annotations); } writeAnnotations(file, ann, ent2->getAnnotations()); break; @@ -560,28 +537,24 @@ sal_uInt64 writeMap( { rtl::Reference< unoidl::ExceptionTypeEntity > ent2( static_cast< unoidl::ExceptionTypeEntity * >( - i->second.entity.get())); + i.second.entity.get())); bool ann = !ent2->getAnnotations().empty(); - for (std::vector< unoidl::ExceptionTypeEntity::Member >:: - const_iterator j(ent2->getDirectMembers().begin()); + for (auto j(ent2->getDirectMembers().begin()); !ann && j != ent2->getDirectMembers().end(); ++j) { ann = !j->annotations.empty(); } - i->second.dataOffset = getOffset(file); + i.second.dataOffset = getOffset(file); writeKind( file, ent2.get(), ann, !ent2->getDirectBase().isEmpty()); if (!ent2->getDirectBase().isEmpty()) { writeIdxName(file, ent2->getDirectBase()); } write32(file, ent2->getDirectMembers().size()); - for (std::vector< unoidl::ExceptionTypeEntity::Member >:: - const_iterator j(ent2->getDirectMembers().begin()); - j != ent2->getDirectMembers().end(); ++j) - { - writeIdxName(file, j->name); - writeIdxName(file, j->type); - writeAnnotations(file, ann, j->annotations); + for (auto & j: ent2->getDirectMembers()) { + writeIdxName(file, j.name); + writeIdxName(file, j.type); + writeAnnotations(file, ann, j.annotations); } writeAnnotations(file, ann, ent2->getAnnotations()); break; @@ -590,108 +563,79 @@ sal_uInt64 writeMap( { rtl::Reference< unoidl::InterfaceTypeEntity > ent2( static_cast< unoidl::InterfaceTypeEntity * >( - i->second.entity.get())); + i.second.entity.get())); bool ann = !ent2->getAnnotations().empty(); - for (std::vector< unoidl::AnnotatedReference >::const_iterator - j(ent2->getDirectMandatoryBases().begin()); + for (auto j(ent2->getDirectMandatoryBases().begin()); !ann && j != ent2->getDirectMandatoryBases().end(); ++j) { ann = !j->annotations.empty(); } - for (std::vector< unoidl::AnnotatedReference >::const_iterator - j(ent2->getDirectOptionalBases().begin()); + for (auto j(ent2->getDirectOptionalBases().begin()); !ann && j != ent2->getDirectOptionalBases().end(); ++j) { ann = !j->annotations.empty(); } - for (std::vector< unoidl::InterfaceTypeEntity::Attribute >:: - const_iterator j(ent2->getDirectAttributes().begin()); + for (auto j(ent2->getDirectAttributes().begin()); !ann && j != ent2->getDirectAttributes().end(); ++j) { ann = !j->annotations.empty(); } - for (std::vector< unoidl::InterfaceTypeEntity::Method >:: - const_iterator j(ent2->getDirectMethods().begin()); + for (auto j(ent2->getDirectMethods().begin()); !ann && j != ent2->getDirectMethods().end(); ++j) { ann = !j->annotations.empty(); } - i->second.dataOffset = getOffset(file); + i.second.dataOffset = getOffset(file); writeKind(file, ent2.get(), ann); write32(file, ent2->getDirectMandatoryBases().size()); - for (std::vector< unoidl::AnnotatedReference >::const_iterator - j(ent2->getDirectMandatoryBases().begin()); - j != ent2->getDirectMandatoryBases().end(); ++j) - { - writeIdxName(file, j->name); - writeAnnotations(file, ann, j->annotations); + for (auto & j: ent2->getDirectMandatoryBases()) { + writeIdxName(file, j.name); + writeAnnotations(file, ann, j.annotations); } write32(file, ent2->getDirectOptionalBases().size()); - for (std::vector< unoidl::AnnotatedReference >::const_iterator - j(ent2->getDirectOptionalBases().begin()); - j != ent2->getDirectOptionalBases().end(); ++j) - { - writeIdxName(file, j->name); - writeAnnotations(file, ann, j->annotations); + for (auto & j: ent2->getDirectOptionalBases()) { + writeIdxName(file, j.name); + writeAnnotations(file, ann, j.annotations); } write32(file, ent2->getDirectAttributes().size()); - for (std::vector< unoidl::InterfaceTypeEntity::Attribute >:: - const_iterator j(ent2->getDirectAttributes().begin()); - j != ent2->getDirectAttributes().end(); ++j) - { + for (auto & j: ent2->getDirectAttributes()) { sal_uInt64 f = 0; - if (j->bound) { + if (j.bound) { f |= 0x01; } - if (j->readOnly) { + if (j.readOnly) { f |= 0x02; } write8(file, f); - writeIdxName(file, j->name); - writeIdxName(file, j->type); - write32(file, j->getExceptions.size()); - for (std::vector< OUString >::const_iterator k( - j->getExceptions.begin()); - k != j->getExceptions.end(); ++k) - { - writeIdxName(file, *k); + writeIdxName(file, j.name); + writeIdxName(file, j.type); + write32(file, j.getExceptions.size()); + for (auto & k: j.getExceptions) { + writeIdxName(file, k); } - if (!j->readOnly) { - write32(file, j->setExceptions.size()); - for (std::vector< OUString >::const_iterator k( - j->setExceptions.begin()); - k != j->setExceptions.end(); ++k) - { - writeIdxName(file, *k); + if (!j.readOnly) { + write32(file, j.setExceptions.size()); + for (auto & k: j.setExceptions) { + writeIdxName(file, k); } } - writeAnnotations(file, ann, j->annotations); + writeAnnotations(file, ann, j.annotations); } write32(file, ent2->getDirectMethods().size()); - for (std::vector< unoidl::InterfaceTypeEntity::Method >:: - const_iterator j(ent2->getDirectMethods().begin()); - j != ent2->getDirectMethods().end(); ++j) - { - writeIdxName(file, j->name); - writeIdxName(file, j->returnType); - write32(file, j->parameters.size()); - for (std::vector< - unoidl::InterfaceTypeEntity::Method::Parameter >:: - const_iterator k(j->parameters.begin()); - k != j->parameters.end(); ++k) - { - write8(file, k->direction); - writeIdxName(file, k->name); - writeIdxName(file, k->type); + for (auto & j: ent2->getDirectMethods()) { + writeIdxName(file, j.name); + writeIdxName(file, j.returnType); + write32(file, j.parameters.size()); + for (auto & k: j.parameters) { + write8(file, k.direction); + writeIdxName(file, k.name); + writeIdxName(file, k.type); } - write32(file, j->exceptions.size()); - for (std::vector< OUString >::const_iterator k( - j->exceptions.begin()); - k != j->exceptions.end(); ++k) - { - writeIdxName(file, *k); + write32(file, j.exceptions.size()); + for (auto & k: j.exceptions) { + writeIdxName(file, k); } - writeAnnotations(file, ann, j->annotations); + writeAnnotations(file, ann, j.annotations); } writeAnnotations(file, ann, ent2->getAnnotations()); break; @@ -700,9 +644,9 @@ sal_uInt64 writeMap( { rtl::Reference< unoidl::TypedefEntity > ent2( static_cast< unoidl::TypedefEntity * >( - i->second.entity.get())); + i.second.entity.get())); bool ann = !ent2->getAnnotations().empty(); - i->second.dataOffset = getOffset(file); + i.second.dataOffset = getOffset(file); writeKind(file, ent2.get(), ann); writeIdxName(file, ent2->getType()); writeAnnotations(file, ann, ent2->getAnnotations()); @@ -712,102 +656,91 @@ sal_uInt64 writeMap( { rtl::Reference< unoidl::ConstantGroupEntity > ent2( static_cast< unoidl::ConstantGroupEntity * >( - i->second.entity.get())); + i.second.entity.get())); std::map< OUString, ConstItem > cmap; - for (std::vector< unoidl::ConstantGroupEntity::Member >:: - const_iterator j(ent2->getMembers().begin()); - j != ent2->getMembers().end(); ++j) - { + for (auto & j: ent2->getMembers()) { if (!cmap.insert( std::make_pair( - j->name, ConstItem(j->value, j->annotations))). + j.name, ConstItem(j.value, j.annotations))). second) { std::cout << "Duplicate constant group member name \"" - << j->name << '"' << std::endl; + << j.name << '"' << std::endl; std::exit(EXIT_FAILURE); } } - for (std::map< OUString, ConstItem >::iterator j(cmap.begin()); - j != cmap.end(); ++j) - { - j->second.dataOffset = getOffset(file); - sal_uInt64 v = j->second.constant.type; - if (!j->second.annotations.empty()) { + for (auto & j: cmap) { + j.second.dataOffset = getOffset(file); + sal_uInt64 v = j.second.constant.type; + if (!j.second.annotations.empty()) { v |= 0x80; } write8(file, v); - switch (j->second.constant.type) { + switch (j.second.constant.type) { case unoidl::ConstantValue::TYPE_BOOLEAN: - write8(file, j->second.constant.booleanValue ? 1 : 0); + write8(file, j.second.constant.booleanValue ? 1 : 0); break; case unoidl::ConstantValue::TYPE_BYTE: write8( file, static_cast< sal_uInt8 >( - j->second.constant.byteValue)); + j.second.constant.byteValue)); break; case unoidl::ConstantValue::TYPE_SHORT: write16( file, static_cast< sal_uInt16 >( - j->second.constant.shortValue)); + j.second.constant.shortValue)); break; case unoidl::ConstantValue::TYPE_UNSIGNED_SHORT: - write16(file, j->second.constant.unsignedShortValue); + write16(file, j.second.constant.unsignedShortValue); break; case unoidl::ConstantValue::TYPE_LONG: write32( file, static_cast< sal_uInt32 >( - j->second.constant.longValue)); + j.second.constant.longValue)); break; case unoidl::ConstantValue::TYPE_UNSIGNED_LONG: - write32(file, j->second.constant.unsignedLongValue); + write32(file, j.second.constant.unsignedLongValue); break; case unoidl::ConstantValue::TYPE_HYPER: write64( file, static_cast< sal_uInt64 >( - j->second.constant.hyperValue)); + j.second.constant.hyperValue)); break; case unoidl::ConstantValue::TYPE_UNSIGNED_HYPER: - write64(file, j->second.constant.unsignedHyperValue); + write64(file, j.second.constant.unsignedHyperValue); break; case unoidl::ConstantValue::TYPE_FLOAT: writeIso60599Binary32( - file, j->second.constant.floatValue); + file, j.second.constant.floatValue); break; case unoidl::ConstantValue::TYPE_DOUBLE: writeIso60599Binary64( - file, j->second.constant.doubleValue); + file, j.second.constant.doubleValue); break; default: for (;;) { std::abort(); } // this cannot happen } writeAnnotations( - file, !j->second.annotations.empty(), - j->second.annotations); + file, !j.second.annotations.empty(), + j.second.annotations); } - for (std::map< OUString, ConstItem >::iterator j( - cmap.begin()); - j != cmap.end(); ++j) - { - j->second.nameOffset = writeNulName(file, j->first); + for (auto & j: cmap) { + j.second.nameOffset = writeNulName(file, j.first); } bool ann = !ent2->getAnnotations().empty(); - i->second.dataOffset = getOffset(file); + i.second.dataOffset = getOffset(file); writeKind(file, ent2.get(), ann); write32(file, cmap.size()); // overflow from std::map::size_type -> sal_uInt64 is // unrealistic - for (std::map< OUString, ConstItem >::iterator j( - cmap.begin()); - j != cmap.end(); ++j) - { - write32(file, j->second.nameOffset); - write32(file, j->second.dataOffset); + for (auto & j: cmap) { + write32(file, j.second.nameOffset); + write32(file, j.second.dataOffset); } writeAnnotations(file, ann, ent2->getAnnotations()); break; @@ -818,61 +751,45 @@ sal_uInt64 writeMap( ent2( static_cast< unoidl::SingleInterfaceBasedServiceEntity * >( - i->second.entity.get())); + i.second.entity.get())); bool dfltCtor = ent2->getConstructors().size() == 1 && ent2->getConstructors()[0].defaultConstructor; bool ann = !ent2->getAnnotations().empty(); if (!dfltCtor) { - for (std::vector< - unoidl::SingleInterfaceBasedServiceEntity:: - Constructor >::const_iterator j( - ent2->getConstructors().begin()); + for (auto j(ent2->getConstructors().begin()); !ann && j != ent2->getConstructors().end(); ++j) { ann = !j->annotations.empty(); } } - i->second.dataOffset = getOffset(file); + i.second.dataOffset = getOffset(file); writeKind(file, ent2.get(), ann, dfltCtor); writeIdxName(file, ent2->getBase()); if (!dfltCtor) { write32(file, ent2->getConstructors().size()); - for (std::vector< - unoidl::SingleInterfaceBasedServiceEntity:: - Constructor >::const_iterator j( - ent2->getConstructors().begin()); - j != ent2->getConstructors().end(); ++j) - { - if (j->defaultConstructor) { + for (auto & j: ent2->getConstructors()) { + if (j.defaultConstructor) { std::cout << "Unexpected default constructor \"" - << j->name << '"' << std::endl; + << j.name << '"' << std::endl; std::exit(EXIT_FAILURE); } - writeIdxName(file, j->name); - write32(file, j->parameters.size()); - for (std::vector< - unoidl::SingleInterfaceBasedServiceEntity:: - Constructor::Parameter >::const_iterator k( - j->parameters.begin()); - k != j->parameters.end(); ++k) - { + writeIdxName(file, j.name); + write32(file, j.parameters.size()); + for (auto & k: j.parameters) { sal_uInt64 f = 0; - if (k->rest) { + if (k.rest) { f |= 0x04; } write8(file, f); - writeIdxName(file, k->name); - writeIdxName(file, k->type); + writeIdxName(file, k.name); + writeIdxName(file, k.type); } - write32(file, j->exceptions.size()); - for (std::vector< OUString >::const_iterator k( - j->exceptions.begin()); - k != j->exceptions.end(); ++k) - { - writeIdxName(file, *k); + write32(file, j.exceptions.size()); + for (auto & k: j.exceptions) { + writeIdxName(file, k); } - writeAnnotations(file, ann, j->annotations); + writeAnnotations(file, ann, j.annotations); } } writeAnnotations(file, ann, ent2->getAnnotations()); @@ -882,90 +799,66 @@ sal_uInt64 writeMap( { rtl::Reference< unoidl::AccumulationBasedServiceEntity > ent2( static_cast< unoidl::AccumulationBasedServiceEntity * >( - i->second.entity.get())); + i.second.entity.get())); bool ann = !ent2->getAnnotations().empty(); - for (std::vector< unoidl::AnnotatedReference >::const_iterator - j(ent2->getDirectMandatoryBaseServices().begin()); + for (auto j(ent2->getDirectMandatoryBaseServices().begin()); !ann && j != ent2->getDirectMandatoryBaseServices().end(); ++j) { ann = !j->annotations.empty(); } - for (std::vector< unoidl::AnnotatedReference >::const_iterator - j(ent2->getDirectOptionalBaseServices().begin()); + for (auto j(ent2->getDirectOptionalBaseServices().begin()); !ann && j != ent2->getDirectOptionalBaseServices().end(); ++j) { ann = !j->annotations.empty(); } - for (std::vector< unoidl::AnnotatedReference >::const_iterator - j(ent2->getDirectMandatoryBaseInterfaces().begin()); + for (auto j(ent2->getDirectMandatoryBaseInterfaces().begin()); (!ann && j != ent2->getDirectMandatoryBaseInterfaces().end()); ++j) { ann = !j->annotations.empty(); } - for (std::vector< unoidl::AnnotatedReference >::const_iterator - j(ent2->getDirectOptionalBaseInterfaces().begin()); + for (auto j(ent2->getDirectOptionalBaseInterfaces().begin()); !ann && j != ent2->getDirectOptionalBaseInterfaces().end(); ++j) { ann = !j->annotations.empty(); } - for (std::vector< - unoidl::AccumulationBasedServiceEntity::Property >:: - const_iterator j( - ent2->getDirectProperties().begin()); + for (auto j(ent2->getDirectProperties().begin()); !ann && j != ent2->getDirectProperties().end(); ++j) { ann = !j->annotations.empty(); } - i->second.dataOffset = getOffset(file); + i.second.dataOffset = getOffset(file); writeKind(file, ent2.get(), ann); write32(file, ent2->getDirectMandatoryBaseServices().size()); - for (std::vector< unoidl::AnnotatedReference >::const_iterator - j(ent2->getDirectMandatoryBaseServices().begin()); - j != ent2->getDirectMandatoryBaseServices().end(); ++j) - { - writeIdxName(file, j->name); - writeAnnotations(file, ann, j->annotations); + for (auto & j: ent2->getDirectMandatoryBaseServices()) { + writeIdxName(file, j.name); + writeAnnotations(file, ann, j.annotations); } write32(file, ent2->getDirectOptionalBaseServices().size()); - for (std::vector< unoidl::AnnotatedReference >::const_iterator - j(ent2->getDirectOptionalBaseServices().begin()); - j != ent2->getDirectOptionalBaseServices().end(); ++j) - { - writeIdxName(file, j->name); - writeAnnotations(file, ann, j->annotations); + for (auto & j: ent2->getDirectOptionalBaseServices()) { + writeIdxName(file, j.name); + writeAnnotations(file, ann, j.annotations); } write32(file, ent2->getDirectMandatoryBaseInterfaces().size()); - for (std::vector< unoidl::AnnotatedReference >::const_iterator - j(ent2->getDirectMandatoryBaseInterfaces().begin()); - j != ent2->getDirectMandatoryBaseInterfaces().end(); ++j) - { - writeIdxName(file, j->name); - writeAnnotations(file, ann, j->annotations); + for (auto & j: ent2->getDirectMandatoryBaseInterfaces()) { + writeIdxName(file, j.name); + writeAnnotations(file, ann, j.annotations); } write32(file, ent2->getDirectOptionalBaseInterfaces().size()); - for (std::vector< unoidl::AnnotatedReference >::const_iterator - j(ent2->getDirectOptionalBaseInterfaces().begin()); - j != ent2->getDirectOptionalBaseInterfaces().end(); ++j) - { - writeIdxName(file, j->name); - writeAnnotations(file, ann, j->annotations); + for (auto & j: ent2->getDirectOptionalBaseInterfaces()) { + writeIdxName(file, j.name); + writeAnnotations(file, ann, j.annotations); } write32(file, ent2->getDirectProperties().size()); - for (std::vector< - unoidl::AccumulationBasedServiceEntity::Property >:: - const_iterator j( - ent2->getDirectProperties().begin()); - j != ent2->getDirectProperties().end(); ++j) - { - write16(file, static_cast< sal_uInt16 >(j->attributes)); - writeIdxName(file, j->name); - writeIdxName(file, j->type); - writeAnnotations(file, ann, j->annotations); + for (auto & j: ent2->getDirectProperties()) { + write16(file, static_cast< sal_uInt16 >(j.attributes)); + writeIdxName(file, j.name); + writeIdxName(file, j.type); + writeAnnotations(file, ann, j.annotations); } writeAnnotations(file, ann, ent2->getAnnotations()); break; @@ -974,9 +867,9 @@ sal_uInt64 writeMap( { rtl::Reference< unoidl::InterfaceBasedSingletonEntity > ent2( static_cast< unoidl::InterfaceBasedSingletonEntity * >( - i->second.entity.get())); + i.second.entity.get())); bool ann = !ent2->getAnnotations().empty(); - i->second.dataOffset = getOffset(file); + i.second.dataOffset = getOffset(file); writeKind(file, ent2.get(), ann); writeIdxName(file, ent2->getBase()); writeAnnotations(file, ann, ent2->getAnnotations()); @@ -986,9 +879,9 @@ sal_uInt64 writeMap( { rtl::Reference< unoidl::ServiceBasedSingletonEntity > ent2( static_cast< unoidl::ServiceBasedSingletonEntity * >( - i->second.entity.get())); + i.second.entity.get())); bool ann = !ent2->getAnnotations().empty(); - i->second.dataOffset = getOffset(file); + i.second.dataOffset = getOffset(file); writeKind(file, ent2.get(), ann); writeIdxName(file, ent2->getBase()); writeAnnotations(file, ann, ent2->getAnnotations()); @@ -996,10 +889,8 @@ sal_uInt64 writeMap( } } } - for (std::map< OUString, Item >::iterator i(map.begin()); i != map.end(); - ++i) - { - i->second.nameOffset = writeNulName(file, i->first); + for (auto & i: map) { + i.second.nameOffset = writeNulName(file, i.first); } sal_uInt64 off = getOffset(file); if (rootSize == nullptr) { @@ -1010,11 +901,9 @@ sal_uInt64 writeMap( *rootSize = map.size(); // overflow from std::map::size_type -> std::size_t is unrealistic } - for (std::map< OUString, Item >::iterator i(map.begin()); i != map.end(); - ++i) - { - write32(file, i->second.nameOffset); - write32(file, i->second.dataOffset); + for (auto & i: map) { + write32(file, i.second.nameOffset); + write32(file, i.second.dataOffset); } return off; } diff --git a/unoidl/source/unoidl.cxx b/unoidl/source/unoidl.cxx index 56761e1e315b..26236a4e27d2 100644 --- a/unoidl/source/unoidl.cxx +++ b/unoidl/source/unoidl.cxx @@ -49,11 +49,8 @@ private: std::vector< OUString > AggregatingModule::getMemberNames() const { std::set< OUString > names; - for (std::vector< rtl::Reference< Provider > >::const_iterator i( - providers_.begin()); - i != providers_.end(); ++i) - { - rtl::Reference< Entity > ent((*i)->findEntity(name_)); + for (auto & i: providers_) { + rtl::Reference< Entity > ent(i->findEntity(name_)); if (ent.is() && ent->getSort() == Entity::SORT_MODULE) { std::vector< OUString > ns( static_cast< ModuleEntity * >(ent.get())->getMemberNames()); @@ -179,11 +176,8 @@ rtl::Reference< Provider > Manager::addProvider(OUString const & uri) { rtl::Reference< Entity > Manager::findEntity(rtl::OUString const & name) const { //TODO: caching? (here or in cppuhelper::TypeManager?) osl::MutexGuard g(mutex_); - for (std::vector< rtl::Reference< Provider > >::const_iterator i( - providers_.begin()); - i != providers_.end(); ++i) - { - rtl::Reference< Entity > ent((*i)->findEntity(name)); + for (auto & i: providers_) { + rtl::Reference< Entity > ent(i->findEntity(name)); if (ent.is()) { return ent; } |