diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2018-10-17 00:16:56 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-17 09:14:15 +0200 |
commit | 87bd462eff0e746835bb4e449bdea19ff3749580 (patch) | |
tree | 02a6405889bb1913ea142aab2e4c0796bc0d0fc7 /unodevtools | |
parent | ccb2a1f650bc505f8a4f1abebf8ce4f9396562a8 (diff) |
Simplify containers iterations in unodevtools, unoidl
Use range-based loop or replace with STL functions.
Change-Id: I3089a4d4a94eea849cad442b04906908908e4c27
Reviewed-on: https://gerrit.libreoffice.org/61854
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unodevtools')
-rw-r--r-- | unodevtools/source/skeletonmaker/cppcompskeleton.cxx | 78 | ||||
-rw-r--r-- | unodevtools/source/skeletonmaker/cpptypemaker.cxx | 169 | ||||
-rw-r--r-- | unodevtools/source/skeletonmaker/javacompskeleton.cxx | 65 | ||||
-rw-r--r-- | unodevtools/source/skeletonmaker/javatypemaker.cxx | 159 | ||||
-rw-r--r-- | unodevtools/source/skeletonmaker/skeletoncommon.cxx | 160 | ||||
-rw-r--r-- | unodevtools/source/skeletonmaker/skeletonmaker.cxx | 13 |
6 files changed, 246 insertions, 398 deletions
diff --git a/unodevtools/source/skeletonmaker/cppcompskeleton.cxx b/unodevtools/source/skeletonmaker/cppcompskeleton.cxx index 75da490435e7..2bf20dc2b613 100644 --- a/unodevtools/source/skeletonmaker/cppcompskeleton.cxx +++ b/unodevtools/source/skeletonmaker/cppcompskeleton.cxx @@ -57,13 +57,11 @@ static void generateIncludes(std::ostream & o, o << "#include \"cppuhelper/propertysetmixin.hxx\"\n"; } - std::set< OUString >::const_iterator iter = interfaces.begin(); - while (iter != interfaces.end()) + for (const auto& rIface : interfaces) { o << "#include \"" - << (*iter).replace('.', '/') + << rIface.replace('.', '/') << ".hpp\"\n"; - ++iter; } } @@ -153,13 +151,11 @@ static void generateCompHelperDefinition(std::ostream & o, "_getSupportedServiceNames()\n{\n css::uno::Sequence< " "::rtl::OUString > s(" << services.size() << ");\n"; - std::set< OUString >::const_iterator iter = services.begin(); short i=0; - while (iter != services.end()) + for (const auto& rService : services) { o << " s[" << i++ << "] = ::rtl::OUString(\"" - << *iter << "\");\n"; - ++iter; + << rService << "\");\n"; } o << " return s;\n}\n\n"; @@ -424,20 +420,17 @@ void generateXDispatch(std::ostream& o, "css::uno::Sequence< css::beans::PropertyValue >& aArguments ) throw" "(css::uno::RuntimeException)\n{\n"; - ProtocolCmdMap::const_iterator iter = protocolCmdMap.begin(); - while (iter != protocolCmdMap.end()) { - o << " if ( aURL.Protocol.equalsAscii(\"" << (*iter).first + for (const auto& rEntry : protocolCmdMap) { + o << " if ( aURL.Protocol.equalsAscii(\"" << rEntry.first << "\") == 0 )\n {\n"; - for (std::vector< OString >::const_iterator i = (*iter).second.begin(); - i != (*iter).second.end(); ++i) { - o << " if ( aURL.Path.equalsAscii(\"" << (*i) << "\") )\n" + for (const auto& rCmd : rEntry.second) { + o << " if ( aURL.Path.equalsAscii(\"" << rCmd << "\") )\n" " {\n // add your own code here\n" " return;\n }\n"; } o << " }\n"; - ++iter; } o << "}\n\n"; @@ -469,19 +462,16 @@ void generateXDispatchProvider(std::ostream& o, "css::frame::XDispatch > xRet;\n" " if ( !m_xFrame.is() )\n return 0;\n\n"; - ProtocolCmdMap::const_iterator iter = protocolCmdMap.begin(); - while (iter != protocolCmdMap.end()) { - o << " if ( aURL.Protocol.equalsAscii(\"" << (*iter).first + for (const auto& rEntry : protocolCmdMap) { + o << " if ( aURL.Protocol.equalsAscii(\"" << rEntry.first << "\") == 0 )\n {\n"; - for (std::vector< OString >::const_iterator i = (*iter).second.begin(); - i != (*iter).second.end(); ++i) { - o << " if ( aURL.Path.equalsAscii(\"" << (*i) << "\") == 0 )\n" + for (const auto& rCmd : rEntry.second) { + o << " if ( aURL.Path.equalsAscii(\"" << rCmd << "\") == 0 )\n" " xRet = this;\n"; } o << " }\n"; - ++iter; } o << " return xRet;\n}\n\n"; @@ -580,16 +570,15 @@ static void generateMemberInitialization(std::ostream& o, AttributeInfo const & members) { if (!members.empty()) { - for (AttributeInfo::const_iterator i(members.begin()); - i != members.end(); ++i) + for (const auto& rMember : members) { sal_Int32 rank; - if ((manager->decompose(i->type, true, nullptr, &rank, nullptr, nullptr) + if ((manager->decompose(rMember.type, true, nullptr, &rank, nullptr, nullptr) <= codemaker::UnoType::Sort::Char) && rank == 0) { - o << ",\n m_" << i->name << "("; - printType(o, options, manager, i->type, 16, true); + o << ",\n m_" << rMember.name << "("; + printType(o, options, manager, rMember.type, 16, true); o << ")"; } } @@ -601,12 +590,11 @@ static void generateMemberDeclaration(std::ostream& o, rtl::Reference< TypeManager > const & manager, AttributeInfo const & members) { - for (AttributeInfo::const_iterator i(members.begin()); - i != members.end(); ++i) + for (const auto& rMember : members) { o << " "; - printType(o, options, manager, i->type, 1); - o << " m_" << i->name << ";\n"; + printType(o, options, manager, rMember.type, 1); + o << " m_" << rMember.name << ";\n"; } } @@ -693,13 +681,11 @@ static OString generateClassDefinition(std::ostream& o, << parent << "::release(); }\n\n"; } - std::set< OUString >::const_iterator it = interfaces.begin(); codemaker::GeneratedTypeSet generated; - while (it != interfaces.end()) + for (const auto& rIface : interfaces) { - printMethods(o, options, manager, *it, generated, "", "", " ", + printMethods(o, options, manager, rIface, generated, "", "", " ", true, propertyhelper); - ++it; } o << "private:\n " << classname << "(const " << classname << " &); // not defined\n" @@ -877,17 +863,15 @@ static void generateMethodBodies(std::ostream& o, OUString const & propertyhelper) { OString name(classname.concat("::")); - std::set< OUString >::const_iterator iter = interfaces.begin(); codemaker::GeneratedTypeSet generated; - while (iter != interfaces.end()) { - if ( *iter == "com.sun.star.lang.XServiceInfo" ) { + for (const auto& rIface : interfaces) { + if ( rIface == "com.sun.star.lang.XServiceInfo" ) { generateXServiceInfoBodies(o, name, comphelpernamespace); - generated.add(u2b(*iter)); + generated.add(u2b(rIface)); } else { - printMethods(o, options, manager, *iter, generated, "_", + printMethods(o, options, manager, rIface, generated, "_", name, "", true, propertyhelper); } - ++iter; } } @@ -957,10 +941,8 @@ void generateSkeleton(ProgramOptions const & options, bool serviceobject = false; bool supportxcomponent = false; - std::vector< OString >::const_iterator iter = types.begin(); - while (iter != types.end()) { - checkType(manager, b2u(*iter), interfaces, services, properties); - ++iter; + for (const auto& rType : types) { + checkType(manager, b2u(rType), interfaces, services, properties); } if (options.componenttype == 3) { @@ -1090,10 +1072,8 @@ void generateCalcAddin(ProgramOptions const & options, bool supportxcomponent = false; - std::vector< OString >::const_iterator iter = types.begin(); - while (iter != types.end()) { - checkType(manager, b2u(*iter), interfaces, services, properties); - ++iter; + for (const auto& rType : types) { + checkType(manager, b2u(rType), interfaces, services, properties); } OUString sAddinService; diff --git a/unodevtools/source/skeletonmaker/cpptypemaker.cxx b/unodevtools/source/skeletonmaker/cpptypemaker.cxx index 05ca099998cc..5fbd2e37ce33 100644 --- a/unodevtools/source/skeletonmaker/cpptypemaker.cxx +++ b/unodevtools/source/skeletonmaker/cpptypemaker.cxx @@ -26,6 +26,8 @@ #include "skeletoncommon.hxx" #include "skeletoncpp.hxx" +#include <algorithm> + using namespace ::codemaker::cpp; namespace skeletonmaker { namespace cpp { @@ -156,18 +158,16 @@ static bool printConstructorParameters( o, options, manager, baseSort, baseEnt, ent2->getDirectBase(), std::vector< OUString >()); } - for (std::vector< unoidl::PlainStructTypeEntity::Member >:: - const_iterator i(ent2->getDirectMembers().begin()); - i != ent2->getDirectMembers().end(); ++i) + for (const auto& rMember : ent2->getDirectMembers()) { if (previous) { o << ", "; } previous = true; - printType(o, options, manager, i->type, 4); + printType(o, options, manager, rMember.type, 4); o << ' ' << codemaker::cpp::translateUnoToCppIdentifier( - u2b(i->name), "param"); + u2b(rMember.name), "param"); } break; } @@ -177,23 +177,20 @@ static bool printConstructorParameters( dynamic_cast< unoidl::PolymorphicStructTypeTemplateEntity * >( entity.get())); assert(ent2.is()); - for (std::vector< - unoidl::PolymorphicStructTypeTemplateEntity::Member >:: - const_iterator i(ent2->getMembers().begin()); - i != ent2->getMembers().end(); ++i) + for (const auto& rMember : ent2->getMembers()) { if (previous) { o << ", "; } previous = true; - if (i->parameterized) { - o << i->type; + if (rMember.parameterized) { + o << rMember.type; } else { - printType(o, options, manager, i->type, 4); + printType(o, options, manager, rMember.type, 4); } o << ' ' << codemaker::cpp::translateUnoToCppIdentifier( - u2b(i->name), "param"); + u2b(rMember.name), "param"); } break; } @@ -203,32 +200,24 @@ static bool printConstructorParameters( dynamic_cast< unoidl::PolymorphicStructTypeTemplateEntity * >( entity.get())); assert(ent2.is()); - for (std::vector< - unoidl::PolymorphicStructTypeTemplateEntity::Member >:: - const_iterator i(ent2->getMembers().begin()); - i != ent2->getMembers().end(); ++i) + for (const auto& rMember : ent2->getMembers()) { if (previous) { o << ", "; } previous = true; - if (i->parameterized) { - for (std::vector< OUString >::const_iterator j( - ent2->getTypeParameters().begin()); - j != ent2->getTypeParameters().end(); ++j) - { - if (i->type == *j) { - o << arguments[ - j - ent2->getTypeParameters().begin()]; - break; - } + if (rMember.parameterized) { + auto j = std::find(ent2->getTypeParameters().begin(), + ent2->getTypeParameters().end(), rMember.type); + if (j != ent2->getTypeParameters().end()) { + o << arguments[j - ent2->getTypeParameters().begin()]; } } else { - printType(o, options, manager, i->type, 4); + printType(o, options, manager, rMember.type, 4); } o << ' ' << codemaker::cpp::translateUnoToCppIdentifier( - u2b(i->name), "param"); + u2b(rMember.name), "param"); } break; } @@ -245,18 +234,16 @@ static bool printConstructorParameters( o, options, manager, baseSort, baseEnt, ent2->getDirectBase(), std::vector< OUString >()); } - for (std::vector< unoidl::ExceptionTypeEntity::Member >:: - const_iterator i(ent2->getDirectMembers().begin()); - i != ent2->getDirectMembers().end(); ++i) + for (const auto& rMember : ent2->getDirectMembers()) { if (previous) { o << ", "; } previous = true; - printType(o, options, manager, i->type, 4); + printType(o, options, manager, rMember.type, 4); o << ' ' << codemaker::cpp::translateUnoToCppIdentifier( - u2b(i->name), "param"); + u2b(rMember.name), "param"); } break; } @@ -319,11 +306,10 @@ static void printExceptionSpecification( { o << ((options.shortnames) ? " throw (css::uno::RuntimeException" : " throw (::com::sun::star::uno::RuntimeException"); - for (std::vector< OUString >::const_iterator i(exceptions.begin()); - i != exceptions.end(); ++i) + for (const auto& rException : exceptions) { o << ", "; - printType(o, options, manager, *i, 1); + printType(o, options, manager, rException, 1); } o << ")"; } @@ -508,12 +494,10 @@ void printMethods(std::ostream & o, dynamic_cast< unoidl::InterfaceTypeEntity * >(ent.get())); assert(ent2.is()); if (options.all || defaultvalue) { - for (std::vector< unoidl::AnnotatedReference >::const_iterator i( - ent2->getDirectMandatoryBases().begin()); - i != ent2->getDirectMandatoryBases().end(); ++i) + for (const auto& rBase : ent2->getDirectMandatoryBases()) { printMethods( - o, options, manager, i->name, generated, delegate, classname, + o, options, manager, rBase.name, generated, delegate, classname, indentation, defaultvalue, propertyhelper); } if (!(ent2->getDirectAttributes().empty() @@ -524,45 +508,43 @@ void printMethods(std::ostream & o, o << ":\n"; } } - for (std::vector< unoidl::InterfaceTypeEntity::Attribute >::const_iterator - i(ent2->getDirectAttributes().begin()); - i != ent2->getDirectAttributes().end(); ++i) + for (const auto& rAttr : ent2->getDirectAttributes()) { o << indentation; if (!body) o << "virtual "; - printType(o, options, manager, i->type, 1); + printType(o, options, manager, rAttr.type, 1); o << " SAL_CALL "; if (!classname.isEmpty()) o << classname; - o << "get" << i->name << "()"; - printExceptionSpecification(o, options, manager, i->getExceptions); + o << "get" << rAttr.name << "()"; + printExceptionSpecification(o, options, manager, rAttr.getExceptions); if (body) { if (defaultbody) { if (!propertyhelper.isEmpty()) { o << "\n{\n osl::MutexGuard g(m_aMutex);\n return m_" - << i->name << ";\n}\n\n"; + << rAttr.name << ";\n}\n\n"; } else { o << "\n{\n return "; if (options.componenttype == 1) { - o << "m_" << i->name; + o << "m_" << rAttr.name; } else { - printType(o, options, manager, i->type, 8, true); + printType(o, options, manager, rAttr.type, 8, true); } o << ";\n}\n\n"; } } else { o << "\n" << indentation << "{\n" << indentation << " return " - << delegate << "get" << i->name << "();\n" + << delegate << "get" << rAttr.name << "();\n" << indentation << "}\n\n"; } } else { o << ";\n"; } - if (!i->readOnly) { + if (!rAttr.readOnly) { o << indentation; if (!body) o << "virtual "; @@ -571,17 +553,17 @@ void printMethods(std::ostream & o, if (!classname.isEmpty()) o << classname; - o << "set" << i->name << '('; - printType(o, options, manager, i->type, 4); + o << "set" << rAttr.name << '('; + printType(o, options, manager, rAttr.type, 4); o << " the_value)"; - printExceptionSpecification(o, options, manager, i->setExceptions); + printExceptionSpecification(o, options, manager, rAttr.setExceptions); if (body) { if (defaultbody) { if (!propertyhelper.isEmpty()) { - printSetPropertyMixinBody(o, *i); + printSetPropertyMixinBody(o, rAttr); } else { if (options.componenttype == 1) { - o << "\n{\n m_" << i->name + o << "\n{\n m_" << rAttr.name << " = the_value;\n}\n\n"; } else { o << "\n{\n\n}\n\n"; @@ -589,7 +571,7 @@ void printMethods(std::ostream & o, } } else { o << "\n" << indentation << "{\n" << indentation << " " - << delegate << "set" << i->name + << delegate << "set" << rAttr.name << "(the_value);\n" << indentation << "}\n\n"; } } else { @@ -597,50 +579,48 @@ void printMethods(std::ostream & o, } } } - for (std::vector< unoidl::InterfaceTypeEntity::Method >::const_iterator i( - ent2->getDirectMethods().begin()); - i != ent2->getDirectMethods().end(); ++i) + for (const auto& rMethod : ent2->getDirectMethods()) { o << indentation; if (!body) o << "virtual "; - printType(o, options, manager, i->returnType, 1); + printType(o, options, manager, rMethod.returnType, 1); o << " SAL_CALL "; if (!classname.isEmpty()) o << classname; - o << i->name << '('; - printMethodParameters(o, options, manager, i->parameters, true); + o << rMethod.name << '('; + printMethodParameters(o, options, manager, rMethod.parameters, true); o << ')'; - printExceptionSpecification(o, options, manager, i->exceptions); + printExceptionSpecification(o, options, manager, rMethod.exceptions); if (body) { if (defaultbody) { o << "\n{\n"; - if (i->returnType != "void") { + if (rMethod.returnType != "void") { o << " // TODO: Exchange the default return implementation for \"" - << i->name << "\" !!!\n"; + << rMethod.name << "\" !!!\n"; o << " // Exchange the default return implementation.\n" " // NOTE: Default initialized polymorphic structs " "can cause problems because of\n // missing default " "initialization of primitive types of some C++ compilers or" "\n // different Any initialization in Java and C++ " "polymorphic structs.\n return "; - printType(o, options, manager, i->returnType, 8, true); + printType(o, options, manager, rMethod.returnType, 8, true); o << ";"; } else { o << " // TODO: Insert your implementation for \"" - << i->name << "\" here."; + << rMethod.name << "\" here."; } o << "\n}\n\n"; } else { o << "\n" << indentation << "{\n" << indentation << " "; - if (i->returnType != "void") + if (rMethod.returnType != "void") o << "return "; - o << delegate << i->name << '('; + o << delegate << rMethod.name << '('; printMethodParameters( - o, options, manager, i->parameters, false); + o, options, manager, rMethod.parameters, false); o << ");\n" << indentation << "}\n\n"; } } else { @@ -667,35 +647,30 @@ static void printConstructors( rtl::Reference< unoidl::SingleInterfaceBasedServiceEntity > ent2( dynamic_cast< unoidl::SingleInterfaceBasedServiceEntity * >(ent.get())); assert(ent2.is()); - for (std::vector< unoidl::SingleInterfaceBasedServiceEntity::Constructor >:: - const_iterator i(ent2->getConstructors().begin()); - i != ent2->getConstructors().end(); ++i) + for (const auto& rConstructor : ent2->getConstructors()) { o << "static "; printType(o, options, manager, ent2->getBase(), 1); o << ' '; - if (i->defaultConstructor) { + if (rConstructor.defaultConstructor) { o << "create"; } else { o << codemaker::cpp::translateUnoToCppIdentifier( - u2b(i->name), "method"); + u2b(rConstructor.name), "method"); } o << ((options.shortnames) ? "(css::uno::Reference< css" : "(::com::sun::star::uno::Reference< ::com::sun::star") << "::uno::XComponentContext > const & the_context"; - for (std::vector< - unoidl::SingleInterfaceBasedServiceEntity::Constructor:: - Parameter >::const_iterator j(i->parameters.begin()); - j != i->parameters.end(); ++j) + for (const auto& rParam : rConstructor.parameters) { o << ", "; - printType(o, options, manager, j->type, 4); + printType(o, options, manager, rParam.type, 4); o << ' ' << codemaker::cpp::translateUnoToCppIdentifier( - u2b(j->name), "param"); + u2b(rParam.name), "param"); } o << ')'; - printExceptionSpecification(o, options, manager, i->exceptions); + printExceptionSpecification(o, options, manager, rConstructor.exceptions); o << ";\n"; } } @@ -708,32 +683,26 @@ static void printServiceMembers( OString const & delegate) { assert(entity.is()); - for (std::vector< unoidl::AnnotatedReference >::const_iterator i( - entity->getDirectMandatoryBaseServices().begin()); - i != entity->getDirectMandatoryBaseServices().end(); ++i) + for (const auto& rService : entity->getDirectMandatoryBaseServices()) { - o << "\n// exported service " << i->name << "\n"; - generateDocumentation(o, options, manager, u2b(i->name), delegate); - o << "\n// end of exported service " << i->name << "\n"; + o << "\n// exported service " << rService.name << "\n"; + generateDocumentation(o, options, manager, u2b(rService.name), delegate); + o << "\n// end of exported service " << rService.name << "\n"; } - for (std::vector< unoidl::AnnotatedReference >::const_iterator i( - entity->getDirectMandatoryBaseInterfaces().begin()); - i != entity->getDirectMandatoryBaseInterfaces().end(); ++i) + for (const auto& rIface : entity->getDirectMandatoryBaseInterfaces()) { - o << "\n// supported interface " << i->name << "\n"; - generateDocumentation(o, options, manager, u2b(i->name), delegate); + o << "\n// supported interface " << rIface.name << "\n"; + generateDocumentation(o, options, manager, u2b(rIface.name), delegate); } if (delegate.isEmpty()) { o << "\n// properties of service \""<< name << "\"\n"; - for (std::vector< unoidl::AccumulationBasedServiceEntity::Property >:: - const_iterator i(entity->getDirectProperties().begin()); - i != entity->getDirectProperties().end(); ++i) + for (const auto& rProp : entity->getDirectProperties()) { o << "// private "; - printType(o, options, manager, i->type, 1); + printType(o, options, manager, rProp.type, 1); o << " " << codemaker::cpp::translateUnoToCppIdentifier( - u2b(i->name), "property") + u2b(rProp.name), "property") << ";\n"; } } diff --git a/unodevtools/source/skeletonmaker/javacompskeleton.cxx b/unodevtools/source/skeletonmaker/javacompskeleton.cxx index be3bfe7fe751..f64a341e0d9b 100644 --- a/unodevtools/source/skeletonmaker/javacompskeleton.cxx +++ b/unodevtools/source/skeletonmaker/javacompskeleton.cxx @@ -256,18 +256,17 @@ static void registerProperties(std::ostream& o, if (!properties.empty()) { bool cast = false; OStringBuffer attributeValue; - for (AttributeInfo::const_iterator i(properties.begin()); - i != properties.end(); ++i) + for (const auto& rProp : properties) { - if (i->attributes != 0) { - cast = checkAttribute(attributeValue, i->attributes); + if (rProp.attributes != 0) { + cast = checkAttribute(attributeValue, rProp.attributes); } else { cast = true; attributeValue.append('0'); } - o << indentation << "registerProperty(\"" << i->name - << "\", \"m_" << i->name << "\",\n" + o << indentation << "registerProperty(\"" << rProp.name + << "\", \"m_" << rProp.name << "\",\n" << indentation << " "; if (cast) o << "(short)"; @@ -425,20 +424,17 @@ static void generateXDispatchBodies(std::ostream& o, ProgramOptions const & opti " public void dispatch( com.sun.star.util.URL aURL,\n" " com.sun.star.beans.PropertyValue[] aArguments )\n {\n"; - ProtocolCmdMap::const_iterator iter = options.protocolCmdMap.begin(); - while (iter != options.protocolCmdMap.end()) { - o << " if ( aURL.Protocol.equals(\"" << (*iter).first + for (const auto& rEntry : options.protocolCmdMap) { + o << " if ( aURL.Protocol.equals(\"" << rEntry.first << "\") )\n {\n"; - for (std::vector< OString >::const_iterator i = (*iter).second.begin(); - i != (*iter).second.end(); ++i) { - o << " if ( aURL.Path.equals(\"" << (*i) << "\") )\n" + for (const auto& rCmd : rEntry.second) { + o << " if ( aURL.Path.equals(\"" << rCmd << "\") )\n" " {\n // add your own code here\n" " return;\n }\n"; } o << " }\n"; - ++iter; } o << " }\n\n"; @@ -462,19 +458,16 @@ static void generateXDispatchProviderBodies(std::ostream& o, ProgramOptions cons " String sTargetFrameName,\n" " int iSearchFlags )\n {\n"; - ProtocolCmdMap::const_iterator iter = options.protocolCmdMap.begin(); - while (iter != options.protocolCmdMap.end()) { - o << " if ( aURL.Protocol.equals(\"" << (*iter).first + for (const auto& rEntry : options.protocolCmdMap) { + o << " if ( aURL.Protocol.equals(\"" << rEntry.first << "\") )\n {\n"; - for (std::vector< OString >::const_iterator i = (*iter).second.begin(); - i != (*iter).second.end(); ++i) { - o << " if ( aURL.Path.equals(\"" << (*i) << "\") )\n" + for (const auto& rCmd : rEntry.second) { + o << " if ( aURL.Path.equals(\"" << rCmd << "\") )\n" " return this;\n"; } o << " }\n"; - ++iter; } o << " return null;\n }\n\n"; @@ -498,11 +491,9 @@ static void generateMethodBodies(std::ostream& o, const std::set< OUString >& interfaces, const OString& indentation, bool usepropertymixin) { - std::set< OUString >::const_iterator iter = interfaces.begin(); codemaker::GeneratedTypeSet generated; - while (iter != interfaces.end()) { - OUString type(*iter); - ++iter; + for (const auto& rIface : interfaces) { + OUString type(rIface); if (type == "com.sun.star.lang.XServiceInfo") { generateXServiceInfoBodies(o); generated.add(u2b(type)); @@ -760,26 +751,20 @@ static void generateClassDefinition(std::ostream& o, // attribute/property members if (!properties.empty()) { - AttributeInfo::const_iterator iter = - properties.begin(); o << " // properties\n"; - while (iter != properties.end()) { + for (const auto& rProp : properties) { o << " protected "; - printType(o, options, manager, iter->type, false); - o << " m_" << iter->name << ";\n"; - ++iter; + printType(o, options, manager, rProp.type, false); + o << " m_" << rProp.name << ";\n"; } } else if (!attributes.empty()) { - AttributeInfo::const_iterator iter = - attributes.begin(); o << " // attributes\n"; - while (iter != attributes.end()) { + for (const auto& rAttr : attributes) { o << " private "; - printType(o, options, manager, iter->type, false); - o << " m_" << iter->name << " = "; - printType(o, options, manager, iter->type, false, true); + printType(o, options, manager, rAttr.type, false); + o << " m_" << rAttr.name << " = "; + printType(o, options, manager, rAttr.type, false, true); o <<";\n"; - ++iter; } } @@ -827,10 +812,8 @@ void generateSkeleton(ProgramOptions const & options, bool serviceobject = false; bool supportxcomponent = false; - std::vector< OString >::const_iterator iter = types.begin(); - while (iter != types.end()) { - checkType(manager, b2u(*iter), interfaces, services, properties); - ++iter; + for (const auto& rType : types) { + checkType(manager, b2u(rType), interfaces, services, properties); } if (options.componenttype == 3) { diff --git a/unodevtools/source/skeletonmaker/javatypemaker.cxx b/unodevtools/source/skeletonmaker/javatypemaker.cxx index 3c45fc209b1f..692b502e4800 100644 --- a/unodevtools/source/skeletonmaker/javatypemaker.cxx +++ b/unodevtools/source/skeletonmaker/javatypemaker.cxx @@ -19,6 +19,7 @@ #include <sal/config.h> +#include <algorithm> #include <cstring> #include <codemaker/codemaker.hxx> @@ -145,18 +146,16 @@ static bool printConstructorParameters( o, options, manager, baseSort, baseEnt, ent2->getDirectBase(), std::vector< OUString >()); } - for (std::vector< unoidl::PlainStructTypeEntity::Member >:: - const_iterator i(ent2->getDirectMembers().begin()); - i != ent2->getDirectMembers().end(); ++i) + for (const auto& rMember : ent2->getDirectMembers()) { if (previous) { o << ", "; } previous = true; - printType(o, options, manager, i->type, false); + printType(o, options, manager, rMember.type, false); o << ' ' << codemaker::java::translateUnoToJavaIdentifier( - u2b(i->name), "param"); + u2b(rMember.name), "param"); } break; } @@ -166,23 +165,20 @@ static bool printConstructorParameters( dynamic_cast< unoidl::PolymorphicStructTypeTemplateEntity * >( entity.get())); assert(ent2.is()); - for (std::vector< - unoidl::PolymorphicStructTypeTemplateEntity::Member >:: - const_iterator i(ent2->getMembers().begin()); - i != ent2->getMembers().end(); ++i) + for (const auto& rMember : ent2->getMembers()) { if (previous) { o << ", "; } previous = true; - if (i->parameterized) { - o << i->type; + if (rMember.parameterized) { + o << rMember.type; } else { - printType(o, options, manager, i->type, false); + printType(o, options, manager, rMember.type, false); } o << ' ' << codemaker::java::translateUnoToJavaIdentifier( - u2b(i->name), "param"); + u2b(rMember.name), "param"); } break; } @@ -192,32 +188,24 @@ static bool printConstructorParameters( dynamic_cast< unoidl::PolymorphicStructTypeTemplateEntity * >( entity.get())); assert(ent2.is()); - for (std::vector< - unoidl::PolymorphicStructTypeTemplateEntity::Member >:: - const_iterator i(ent2->getMembers().begin()); - i != ent2->getMembers().end(); ++i) + for (const auto& rMember : ent2->getMembers()) { if (previous) { o << ", "; } previous = true; - if (i->parameterized) { - for (std::vector< OUString >::const_iterator j( - ent2->getTypeParameters().begin()); - j != ent2->getTypeParameters().end(); ++j) - { - if (i->type == *j) { - o << arguments[ - j - ent2->getTypeParameters().begin()]; - break; - } + if (rMember.parameterized) { + auto j = std::find(ent2->getTypeParameters().begin(), + ent2->getTypeParameters().end(), rMember.type); + if (j != ent2->getTypeParameters().end()) { + o << arguments[j - ent2->getTypeParameters().begin()]; } } else { - printType(o, options, manager, i->type, false); + printType(o, options, manager, rMember.type, false); } o << ' ' << codemaker::java::translateUnoToJavaIdentifier( - u2b(i->name), "param"); + u2b(rMember.name), "param"); } break; } @@ -234,18 +222,16 @@ static bool printConstructorParameters( o, options, manager, baseSort, baseEnt, ent2->getDirectBase(), std::vector< OUString >()); } - for (std::vector< unoidl::ExceptionTypeEntity::Member >:: - const_iterator i(ent2->getDirectMembers().begin()); - i != ent2->getDirectMembers().end(); ++i) + for (const auto& rMember : ent2->getDirectMembers()) { if (previous) { o << ", "; } previous = true; - printType(o, options, manager, i->type, false); + printType(o, options, manager, rMember.type, false); o << ' ' << codemaker::java::translateUnoToJavaIdentifier( - u2b(i->name), "param"); + u2b(rMember.name), "param"); } break; } @@ -455,12 +441,10 @@ void printMethods(std::ostream & o, dynamic_cast< unoidl::InterfaceTypeEntity * >(ent.get())); assert(ent2.is()); if ( options.all || defaultvalue ) { - for (std::vector< unoidl::AnnotatedReference >::const_iterator i( - ent2->getDirectMandatoryBases().begin()); - i != ent2->getDirectMandatoryBases().end(); ++i) + for (const auto& rBase : ent2->getDirectMandatoryBases()) { printMethods( - o, options, manager, i->name, generated, delegate, indentation, + o, options, manager, rBase.name, generated, delegate, indentation, defaultvalue, usepropertymixin); } if (!(ent2->getDirectAttributes().empty() @@ -471,29 +455,27 @@ void printMethods(std::ostream & o, o << ":\n"; } } - for (std::vector< unoidl::InterfaceTypeEntity::Attribute >::const_iterator - i(ent2->getDirectAttributes().begin()); - i != ent2->getDirectAttributes().end(); ++i) + for (const auto& rAttr : ent2->getDirectAttributes()) { o << indentation << "public "; - printType(o, options, manager, i->type, false); - o << " get" << i->name << "()"; - printExceptionSpecification(o, options, manager, i->getExceptions); + printType(o, options, manager, rAttr.type, false); + o << " get" << rAttr.name << "()"; + printExceptionSpecification(o, options, manager, rAttr.getExceptions); if ( body ) { if ( defaultbody ) { if ( usepropertymixin ) { o << "\n" << indentation << "{\n" << indentation - << " return m_" << i->name << ";\n" << indentation + << " return m_" << rAttr.name << ";\n" << indentation << "}\n\n"; } else { o << "\n" << indentation << "{\n" << indentation << " return "; - printType(o, options, manager, i->type, false, true); + printType(o, options, manager, rAttr.type, false, true); o << ";\n" << indentation << "}\n\n"; } } else { o << "\n" << indentation << "{\n" << indentation - << " return " << delegate << "get" << i->name + << " return " << delegate << "get" << rAttr.name << "();\n" << indentation << "}\n\n"; } } else { @@ -501,22 +483,22 @@ void printMethods(std::ostream & o, } // REMOVE next line - if (!i->readOnly) { - o << indentation << "public void set" << i->name << '('; - printType(o, options, manager, i->type, false); + if (!rAttr.readOnly) { + o << indentation << "public void set" << rAttr.name << '('; + printType(o, options, manager, rAttr.type, false); o << " the_value)"; - printExceptionSpecification(o, options, manager, i->setExceptions); + printExceptionSpecification(o, options, manager, rAttr.setExceptions); if ( body ) { if ( defaultbody ) { if ( usepropertymixin ) { - printSetPropertyMixinBody(o, *i, indentation); + printSetPropertyMixinBody(o, rAttr, indentation); } else { o << "\n" << indentation << "{\n\n" << indentation << "}\n\n"; } } else { o << "\n" << indentation << "{\n" << indentation - << " " << delegate << "set" << i->name + << " " << delegate << "set" << rAttr.name << "(the_value);\n" << indentation << "}\n\n"; } } else { @@ -524,21 +506,19 @@ void printMethods(std::ostream & o, } } } - for (std::vector< unoidl::InterfaceTypeEntity::Method >::const_iterator i( - ent2->getDirectMethods().begin()); - i != ent2->getDirectMethods().end(); ++i) + for (const auto& rMethod : ent2->getDirectMethods()) { o << indentation << "public "; - printType(o, options, manager, i->returnType, false); - o << ' ' << i->name << '('; - printMethodParameters(o, options, manager, i->parameters, true); + printType(o, options, manager, rMethod.returnType, false); + o << ' ' << rMethod.name << '('; + printMethodParameters(o, options, manager, rMethod.parameters, true); o << ')'; - printExceptionSpecification(o, options, manager, i->exceptions); + printExceptionSpecification(o, options, manager, rMethod.exceptions); if ( body ) { if ( defaultbody ) { o << "\n" << indentation << "{\n"; - if (i->returnType != "void") { - o << indentation << " // TODO: Exchange the default return implementation for \"" << i->name << "\" !!!\n"; + if (rMethod.returnType != "void") { + o << indentation << " // TODO: Exchange the default return implementation for \"" << rMethod.name << "\" !!!\n"; o << indentation << " // NOTE: " "Default initialized polymorphic structs can cause problems" "\n" << indentation << " // because of missing default " @@ -547,21 +527,21 @@ void printMethods(std::ostream & o, " in Java and C++\n" << indentation << " // polymorphic structs.\n" << indentation << " return "; - printType(o, options, manager, i->returnType, false, true); + printType(o, options, manager, rMethod.returnType, false, true); o << ";"; } else { o << indentation << " // TODO: Insert your implementation for \"" - << i->name << "\" here."; + << rMethod.name << "\" here."; } o << "\n" << indentation << "}\n\n"; } else { o << "\n" << indentation << "{\n" << indentation << " "; - if (i->returnType != "void") { + if (rMethod.returnType != "void") { o << "return "; } - o << delegate << i->name << '('; + o << delegate << rMethod.name << '('; printMethodParameters( - o, options, manager, i->parameters, false); + o, options, manager, rMethod.parameters, false); o << ");\n" << indentation << "}\n\n"; } } else { @@ -585,36 +565,31 @@ static void printConstructors( rtl::Reference< unoidl::SingleInterfaceBasedServiceEntity > ent2( dynamic_cast< unoidl::SingleInterfaceBasedServiceEntity * >(ent.get())); assert(ent2.is()); - for (std::vector< unoidl::SingleInterfaceBasedServiceEntity::Constructor >:: - const_iterator i(ent2->getConstructors().begin()); - i != ent2->getConstructors().end(); ++i) + for (const auto& rConstructor : ent2->getConstructors()) { o << "public static "; printType(o, options, manager, ent2->getBase(), false); o << ' '; - if (i->defaultConstructor) { + if (rConstructor.defaultConstructor) { o << "create"; } else { o << codemaker::java::translateUnoToJavaIdentifier( - u2b(i->name), "method"); + u2b(rConstructor.name), "method"); } o << "(com.sun.star.uno.XComponentContext the_context"; - for (std::vector< - unoidl::SingleInterfaceBasedServiceEntity::Constructor:: - Parameter >::const_iterator j(i->parameters.begin()); - j != i->parameters.end(); ++i) + for (const auto& rParam : rConstructor.parameters) { o << ", "; - printType(o, options, manager, j->type, false); - if (j->rest) { + printType(o, options, manager, rParam.type, false); + if (rParam.rest) { o << "..."; } o << ' ' << codemaker::java::translateUnoToJavaIdentifier( - u2b(j->name), "param"); + u2b(rParam.name), "param"); } o << ')'; - printExceptionSpecification(o, options, manager, i->exceptions); + printExceptionSpecification(o, options, manager, rConstructor.exceptions); o << ";\n"; } } @@ -627,30 +602,24 @@ static void printServiceMembers( OString const & delegate) { assert(entity.is()); - for (std::vector< unoidl::AnnotatedReference >::const_iterator i( - entity->getDirectMandatoryBaseServices().begin()); - i != entity->getDirectMandatoryBaseServices().end(); ++i) + for (const auto& rService : entity->getDirectMandatoryBaseServices()) { - o << "\n// exported service " << i->name << "\n"; - generateDocumentation(o, options, manager, u2b(i->name), delegate); + o << "\n// exported service " << rService.name << "\n"; + generateDocumentation(o, options, manager, u2b(rService.name), delegate); } - for (std::vector< unoidl::AnnotatedReference >::const_iterator i( - entity->getDirectMandatoryBaseInterfaces().begin()); - i != entity->getDirectMandatoryBaseInterfaces().end(); ++i) + for (const auto& rIface : entity->getDirectMandatoryBaseInterfaces()) { - o << "\n// supported interface " << i->name << "\n"; - generateDocumentation(o, options, manager, u2b(i->name), delegate); + o << "\n// supported interface " << rIface.name << "\n"; + generateDocumentation(o, options, manager, u2b(rIface.name), delegate); } o << "\n// properties of service \""<< name << "\"\n"; - for (std::vector< unoidl::AccumulationBasedServiceEntity::Property >:: - const_iterator i(entity->getDirectProperties().begin()); - i != entity->getDirectProperties().end(); ++i) + for (const auto& rProp : entity->getDirectProperties()) { o << "// private "; - printType(o, options, manager, i->type, false); + printType(o, options, manager, rProp.type, false); o << " " << codemaker::java::translateUnoToJavaIdentifier( - u2b(i->name), "property") + u2b(rProp.name), "property") << ";\n"; } } diff --git a/unodevtools/source/skeletonmaker/skeletoncommon.cxx b/unodevtools/source/skeletonmaker/skeletoncommon.cxx index 08df9ebf930f..330bb2470177 100644 --- a/unodevtools/source/skeletonmaker/skeletoncommon.cxx +++ b/unodevtools/source/skeletonmaker/skeletoncommon.cxx @@ -27,6 +27,7 @@ #include "skeletoncommon.hxx" +#include <algorithm> #include <cassert> #include <iostream> @@ -92,13 +93,9 @@ bool getOutputStream(ProgramOptions const & options, static bool containsAttribute(AttributeInfo& attributes, OUString const & attrname) { - for ( AttributeInfo::const_iterator i(attributes.begin()); - i != attributes.end(); ++i ) { - if ( (*i).name == attrname ) { - return true; - } - } - return false; + return std::any_of(attributes.begin(), attributes.end(), + [&attrname](const unoidl::AccumulationBasedServiceEntity::Property& rAttr) { + return rAttr.name == attrname; }); } // collect attributes including inherited attributes @@ -120,25 +117,21 @@ static void checkAttributes(rtl::Reference< TypeManager > const & manager, rtl::Reference< unoidl::InterfaceTypeEntity > ent2( dynamic_cast< unoidl::InterfaceTypeEntity * >(ent.get())); assert(ent2.is()); - for (std::vector< unoidl::AnnotatedReference >::const_iterator i( - ent2->getDirectMandatoryBases().begin()); - i != ent2->getDirectMandatoryBases().end(); ++i) + for (const auto& rBase : ent2->getDirectMandatoryBases()) { - checkAttributes(manager, i->name, attributes, propinterfaces); + checkAttributes(manager, rBase.name, attributes, propinterfaces); } - for (std::vector< unoidl::InterfaceTypeEntity::Attribute >:: - const_iterator i(ent2->getDirectAttributes().begin()); - i != ent2->getDirectAttributes().end(); ++i) + for (const auto& rAttr : ent2->getDirectAttributes()) { - if (!containsAttribute(attributes, i->name)) { + if (!containsAttribute(attributes, rAttr.name)) { attributes.emplace_back( - i->name, i->type, + rAttr.name, rAttr.type, (unoidl::AccumulationBasedServiceEntity::Property:: Attributes( - ((i->bound + ((rAttr.bound ? unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_BOUND : 0) - | (i->readOnly + | (rAttr.readOnly ? unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_READ_ONLY : 0)))), std::vector< OUString >()); @@ -152,25 +145,18 @@ static void checkAttributes(rtl::Reference< TypeManager > const & manager, dynamic_cast< unoidl::AccumulationBasedServiceEntity * >( ent.get())); assert(ent2.is()); - for (std::vector< unoidl::AnnotatedReference >::const_iterator i( - ent2->getDirectMandatoryBaseServices().begin()); - i != ent2->getDirectMandatoryBaseServices().end(); ++i) + for (const auto& rService : ent2->getDirectMandatoryBaseServices()) { - checkAttributes(manager, i->name, attributes, propinterfaces); + checkAttributes(manager, rService.name, attributes, propinterfaces); } - for (std::vector< unoidl::AnnotatedReference >::const_iterator i( - ent2->getDirectMandatoryBaseInterfaces().begin()); - i != ent2->getDirectMandatoryBaseInterfaces().end(); ++i) + for (const auto& rIface : ent2->getDirectMandatoryBaseInterfaces()) { - checkAttributes(manager, i->name, attributes, propinterfaces); + checkAttributes(manager, rIface.name, attributes, propinterfaces); } - for (std::vector< - unoidl::AccumulationBasedServiceEntity::Property >:: - const_iterator i(ent2->getDirectProperties().begin()); - i != ent2->getDirectProperties().end(); ++i) + for (const auto& rProp : ent2->getDirectProperties()) { - if (!containsAttribute(attributes, i->name)) { - attributes.push_back(*i); + if (!containsAttribute(attributes, rProp.name)) { + attributes.push_back(rProp); } } break; @@ -232,26 +218,19 @@ void checkType(rtl::Reference< TypeManager > const & manager, dynamic_cast< unoidl::AccumulationBasedServiceEntity * >( ent.get())); assert(ent2.is()); - for (std::vector< unoidl::AnnotatedReference >::const_iterator i( - ent2->getDirectMandatoryBaseServices().begin()); - i != ent2->getDirectMandatoryBaseServices().end(); ++i) + for (const auto& rService : ent2->getDirectMandatoryBaseServices()) { checkType( - manager, i->name, interfaceTypes, serviceTypes, properties); + manager, rService.name, interfaceTypes, serviceTypes, properties); } - for (std::vector< unoidl::AnnotatedReference >::const_iterator i( - ent2->getDirectMandatoryBaseInterfaces().begin()); - i != ent2->getDirectMandatoryBaseInterfaces().end(); ++i) + for (const auto& rIface : ent2->getDirectMandatoryBaseInterfaces()) { checkType( - manager, i->name, interfaceTypes, serviceTypes, properties); + manager, rIface.name, interfaceTypes, serviceTypes, properties); } - for (std::vector< - unoidl::AccumulationBasedServiceEntity::Property >:: - const_iterator i(ent2->getDirectProperties().begin()); - i != ent2->getDirectProperties().end(); ++i) + for (const auto& rProp : ent2->getDirectProperties()) { - properties.push_back(*i); + properties.push_back(rProp); } } break; @@ -295,14 +274,10 @@ static bool checkServiceProperties(rtl::Reference< TypeManager > const & manager if (!ent2->getDirectProperties().empty()) { return true; } - for (std::vector< unoidl::AnnotatedReference >::const_iterator i( - ent2->getDirectMandatoryBaseServices().begin()); - i != ent2->getDirectMandatoryBaseServices().end(); ++i) - { - if (checkServiceProperties(manager, i->name)) { - return true; - } - } + return std::any_of(ent2->getDirectMandatoryBaseServices().begin(), + ent2->getDirectMandatoryBaseServices().end(), + [&manager](const unoidl::AnnotatedReference& rService) { + return checkServiceProperties(manager, rService.name); }); } return false; } @@ -379,15 +354,8 @@ static bool checkXComponentSupport( rtl::Reference< unoidl::InterfaceTypeEntity > ent2( dynamic_cast< unoidl::InterfaceTypeEntity * >(ent.get())); assert(ent2.is()); - for (std::vector< unoidl::AnnotatedReference >::const_iterator i( - ent2->getDirectMandatoryBases().begin()); - i != ent2->getDirectMandatoryBases().end(); ++i) - { - if (checkXComponentSupport(manager, i->name)) { - return true; - } - } - return false; + return std::any_of(ent2->getDirectMandatoryBases().begin(), ent2->getDirectMandatoryBases().end(), + [&manager](const unoidl::AnnotatedReference& rBase) { return checkXComponentSupport(manager, rBase.name); }); } @@ -399,15 +367,13 @@ bool checkXComponentSupport(rtl::Reference< TypeManager > const & manager, if ( interfaces.empty() ) return false; - std::set< OUString >::const_iterator iter = interfaces.begin(); - while ( iter != interfaces.end() ) { - if ( *iter == "com.sun.star.lang.XComponent" ) { + for ( const auto& rIface : interfaces ) { + if ( rIface == "com.sun.star.lang.XComponent" ) { interfaces.erase("com.sun.star.lang.XComponent"); return true; } - if ( checkXComponentSupport(manager, *iter) ) + if ( checkXComponentSupport(manager, rIface) ) return true; - ++iter; } return false; @@ -419,23 +385,19 @@ checkAdditionalPropertyFlags( { int flags = 0; bool getterSupportsUnknown = false; - for (std::vector< OUString >::const_iterator i( - attribute.getExceptions.begin()); - i != attribute.getExceptions.end(); ++i) + for (const auto& rException : attribute.getExceptions) { - if (*i == "com.sun.star.beans.UnknownPropertyException") { + if (rException == "com.sun.star.beans.UnknownPropertyException") { getterSupportsUnknown = true; } } - for (std::vector< OUString >::const_iterator i( - attribute.setExceptions.begin()); - i != attribute.setExceptions.end(); ++i) + for (const auto& rException : attribute.setExceptions) { - if (*i == "com.sun.star.beans.PropertyVetoException") { + if (rException == "com.sun.star.beans.PropertyVetoException") { flags |= unoidl::AccumulationBasedServiceEntity::Property:: ATTRIBUTE_CONSTRAINED; } else if (getterSupportsUnknown - && *i == "com.sun.star.beans.UnknownPropertyException") + && rException == "com.sun.star.beans.UnknownPropertyException") { flags |= unoidl::AccumulationBasedServiceEntity::Property:: ATTRIBUTE_OPTIONAL; @@ -501,33 +463,29 @@ static void checkAddInTypes( assert(entity.is()); bool bLastAny = false; bool bHasXPropertySet = false; - for (std::vector< unoidl::InterfaceTypeEntity::Method >::const_iterator i( - entity->getDirectMethods().begin()); - i != entity->getDirectMethods().end(); ++i) + for (const auto& rMethod : entity->getDirectMethods()) { if ( !checkAddinType( - manager, i->returnType, bLastAny, bHasXPropertySet, true) ) + manager, rMethod.returnType, bLastAny, bHasXPropertySet, true) ) { throw CannotDumpException( "the return type of the calc add-in function '" + name - + ":" + i->name + + ":" + rMethod.name + "' is invalid. Please check your IDL definition."); } bHasXPropertySet = false; - for (std::vector< unoidl::InterfaceTypeEntity::Method::Parameter >:: - const_iterator j(i->parameters.begin()); - j != i->parameters.end(); ++j) + for (const auto& rParam : rMethod.parameters) { bLastAny = false; - if ( !checkAddinType(manager, j->type, + if ( !checkAddinType(manager, rParam.type, bLastAny, bHasXPropertySet, false) || bLastAny ) { throw CannotDumpException( - "the type of the " + j->name + "the type of the " + rParam.name + " parameter of the calc add-in function '" + name - + ":" + i->name + "' is invalid." + + ":" + rMethod.name + "' is invalid." + (bLastAny ? OUString( " The type 'sequence<any>' is allowed as last" @@ -575,12 +533,10 @@ static void generateFunctionParameterMap(std::ostream& o, // check if the specified add-in functions supports valid types checkAddInTypes(manager, name, ent2); - for (std::vector< unoidl::AnnotatedReference >::const_iterator i( - ent2->getDirectMandatoryBases().begin()); - i != ent2->getDirectMandatoryBases().end(); ++i) + for (const auto& rBase : ent2->getDirectMandatoryBases()) { generateFunctionParameterMap( - o, options, manager, i->name, generated, bFirst); + o, options, manager, rBase.name, generated, bFirst); } if ( generated.contains(u2b(name)) ) @@ -588,9 +544,7 @@ static void generateFunctionParameterMap(std::ostream& o, else generated.add(u2b(name)); - for (std::vector< unoidl::InterfaceTypeEntity::Method >::const_iterator i( - ent2->getDirectMethods().begin()); - i != ent2->getDirectMethods().end(); ++i) + for (const auto& rMethod : ent2->getDirectMethods()) { if ( bFirst ) { if (options.language == 2) { @@ -612,19 +566,17 @@ static void generateFunctionParameterMap(std::ostream& o, std::vector< unoidl::InterfaceTypeEntity::Method::Parameter >::size_type n = 0; - for (std::vector< unoidl::InterfaceTypeEntity::Method::Parameter >:: - const_iterator j(i->parameters.begin()); - j != i->parameters.end(); ++j) + for (const auto& rParam : rMethod.parameters) { if ( options.language == 2 ) { o << " fpm[" << n << "] = ::rtl::OUString(\"" - << j->name + << rParam.name << "\");\n"; } else { o << " fpm.put(" << n << ", \"" - << j->name + << rParam.name << "\");\n"; } ++n; @@ -632,10 +584,10 @@ static void generateFunctionParameterMap(std::ostream& o, if ( options.language == 2 ) { o << " m_functionMap[::rtl::OUString(\"" - << i->name << "\")] = fpm;\n\n"; + << rMethod.name << "\")] = fpm;\n\n"; } else { - o << " m_functionMap.put(\"" << i->name << "\", fpm);\n\n"; + o << " m_functionMap.put(\"" << rMethod.name << "\", fpm);\n\n"; } } } @@ -647,10 +599,8 @@ void generateFunctionParameterMap(std::ostream& o, { ::codemaker::GeneratedTypeSet generated; bool bFirst = true; - std::set< OUString >::const_iterator iter = interfaces.begin(); - while ( iter != interfaces.end() ) { - generateFunctionParameterMap(o, options, manager, *iter, generated, bFirst); - ++iter; + for ( const auto& rIface : interfaces ) { + generateFunctionParameterMap(o, options, manager, rIface, generated, bFirst); } } diff --git a/unodevtools/source/skeletonmaker/skeletonmaker.cxx b/unodevtools/source/skeletonmaker/skeletonmaker.cxx index 5ddaf8ee1d4f..14b857ddcee1 100644 --- a/unodevtools/source/skeletonmaker/skeletonmaker.cxx +++ b/unodevtools/source/skeletonmaker/skeletonmaker.cxx @@ -260,32 +260,29 @@ SAL_IMPLEMENT_MAIN() } rtl::Reference< TypeManager > manager(new TypeManager); - for (std::vector< OString >::const_iterator i(registries.begin()); - i != registries.end(); ++i) + for (const auto& rRegistry : registries) { - manager->loadProvider(convertToFileUrl(*i), true); + manager->loadProvider(convertToFileUrl(rRegistry), true); } if ( options.dump ) { - std::vector< OString >::const_iterator iter = types.begin(); - while (iter != types.end()) { + for (const auto& rType : types) { std::cout << "\n/***************************************************" "*****************************/\n"; switch (options.language ) { case 1: //Java java::generateDocumentation(std::cout, options, manager, - *iter, delegate); + rType, delegate); break; case 2: //C++ cpp::generateDocumentation(std::cout, options, manager, - *iter, delegate); + rType, delegate); break; default: OSL_ASSERT(false); break; } - ++iter; } } else { switch ( options.language ) |