Skip to content

Commit

Permalink
Add a -keep-ununsed-types argument to kdwsdl2cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Knarf64 committed Jul 19, 2017
1 parent 066a50e commit 890eb7c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kdwsdl2cpp/src/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ void Converter::setWSDL(const WSDL &wsdl)

mTypeMap.setNSManager(&mNSManager);

cleanupUnusedTypes();
if (!Settings::self()->keepUnusedTypes()) {
cleanupUnusedTypes();
}

// set the xsd types
mTypeMap.addSchemaTypes(mWSDL.definitions().type().types(), Settings::self()->nameSpace());
Expand Down
5 changes: 5 additions & 0 deletions kdwsdl2cpp/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ static void showHelp(const char *appName)
" -optional-element-type <type>\n"
" use <type> as the getter return value for optional elements.\n"
" <type> can be either raw-pointer or boost-optional\n"
" -keep-unused-types keep the wsdl unused types to the cpp generation step\n"
"\n", appName);
}

Expand All @@ -61,6 +62,7 @@ int main(int argc, char **argv)
QString exportMacro;
QString nameSpace;
Settings::OptionalElementType optionalElementType = Settings::ENone;
bool keepUnusedTypes = false;

int arg = 1;
while (arg < argc) {
Expand Down Expand Up @@ -121,6 +123,8 @@ int main(int argc, char **argv)
} else if (optType == QLatin1String("boost-optional")) {
optionalElementType = Settings::EBoostOptional;
}
} else if (opt == QLatin1String("-keep-unused-types")) {
keepUnusedTypes = true;
} else if (!fileName) {
fileName = argv[arg];
} else {
Expand All @@ -145,6 +149,7 @@ int main(int argc, char **argv)
Settings::self()->setExportDeclaration(exportMacro);
Settings::self()->setNameSpace(nameSpace);
Settings::self()->setOptionalElementType(optionalElementType);
Settings::self()->setKeepUnusedTypes(keepUnusedTypes);
KWSDL::Compiler compiler;

// so that we have an event loop, for downloads
Expand Down
11 changes: 11 additions & 0 deletions kdwsdl2cpp/src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Settings::Settings()
mOutputFileName = QString::fromLatin1("kwsdl_generated");
mImpl = false;
mServer = false;
mKeepUnusedTypes = false;
mOptionalElementType = Settings::ENone;
}

Expand Down Expand Up @@ -129,6 +130,16 @@ Settings::OptionalElementType Settings::optionalElementType() const
return mOptionalElementType;
}

void Settings::setKeepUnusedTypes(bool b)
{
mKeepUnusedTypes = b;
}

bool Settings::keepUnusedTypes() const
{
return mKeepUnusedTypes;
}

void Settings::setNamespaceMapping(const NSMapping &namespaceMapping)
{
mNamespaceMapping = namespaceMapping;
Expand Down
4 changes: 4 additions & 0 deletions kdwsdl2cpp/src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class Settings
void setOptionalElementType(OptionalElementType optionalElementType);
OptionalElementType optionalElementType() const;

void setKeepUnusedTypes(bool b);
bool keepUnusedTypes() const;

// UNUSED
void setNamespaceMapping(const NSMapping &namespaceMapping);
NSMapping namespaceMapping() const;
Expand Down Expand Up @@ -84,6 +87,7 @@ class Settings
bool mImpl;
bool mServer;
OptionalElementType mOptionalElementType;
bool mKeepUnusedTypes;
};

#endif

0 comments on commit 890eb7c

Please sign in to comment.