[QT5CPP] General Improvements (#6315)

* - check C++ keywords
- setter for SSL configuration

* recreate example QT5CPP

* only emit error signal if error happens

* provide more error information

* regenerate example QT5CPP

* * use reserved words in abstract cpp generator
* update CppRest examples

* remove tabs
This commit is contained in:
stmeyer
2017-08-25 12:35:56 +02:00
committed by wing328
parent 1b05960a74
commit 6c8bd6b83e
62 changed files with 547 additions and 351 deletions

View File

@@ -5,8 +5,94 @@ import io.swagger.codegen.CodegenProperty;
import io.swagger.codegen.DefaultCodegen;
import io.swagger.models.properties.Property;
import java.util.Arrays;
abstract public class AbstractCppCodegen extends DefaultCodegen implements CodegenConfig {
public AbstractCppCodegen() {
super();
/*
* Reserved words. Override this with reserved words specific to your language
*/
setReservedWordsLowerCase(
Arrays.asList(
"auto",
"break",
"case",
"char",
"const",
"continue",
"default",
"do",
"double",
"else",
"enum",
"extern",
"float",
"for",
"goto",
"if",
"int",
"long",
"register",
"return",
"short",
"signed",
"sizeof",
"static",
"struct",
"switch",
"typedef",
"union",
"unsigned",
"void",
"volatile",
"while",
"asm",
"bool",
"catch",
"class",
"const_cast",
"delete",
"dynamic_cast",
"explicit",
"false",
"friend",
"inline",
"mutable",
"namespace",
"new",
"operator",
"private",
"public",
"protected",
"reinterpret_cast",
"static_cast",
"template",
"this",
"throw",
"true",
"try",
"typeid",
"typename",
"using",
"virtual",
"wchar_t",
"and",
"and_eq",
"bitand",
"bitor",
"compl",
"not",
"not_eq",
"or",
"or_eq",
"xor",
"xor_eq")
);
}
@Override
public String toVarName(String name) {
if (typeMapping.keySet().contains(name) || typeMapping.values().contains(name)

View File

@@ -23,7 +23,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
public class Qt5CPPGenerator extends AbstractCppCodegen implements CodegenConfig {
public static final String CPP_NAMESPACE = "cppNamespace";
public static final String CPP_NAMESPACE_DESC = "C++ namespace (convention: name::space::for::api).";
@@ -42,6 +42,11 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
// set the output folder here
outputFolder = "generated-code/qt5cpp";
// set modelNamePrefix as default for QT5CPP
if (modelNamePrefix == "") {
modelNamePrefix = PREFIX;
}
/*
* Models. You can write model files using the modelTemplateFiles map.
* if you want to create one template for file, you can do so here.
@@ -78,15 +83,6 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
// CLI options
addOption(CPP_NAMESPACE, CPP_NAMESPACE_DESC, this.cppNamespace);
/*
* Reserved words. Override this with reserved words specific to your language
*/
setReservedWordsLowerCase(
Arrays.asList(
"sample1", // replace with static values
"sample2")
);
/*
* Additional Properties. These values can be passed to the templates and
* are available in models, apis, and supporting files