@@ -26,7 +26,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
26
26
protected Set <String > systemIncludes = new HashSet <String >();
27
27
28
28
protected Set <String > nonFrameworkPrimitives = new HashSet <String >();
29
-
29
+
30
30
public CppQt5AbstractCodegen () {
31
31
super ();
32
32
// set modelNamePrefix as default for QHttpEngine Server
@@ -61,10 +61,10 @@ public CppQt5AbstractCodegen() {
61
61
"double" )
62
62
);
63
63
nonFrameworkPrimitives .addAll (languageSpecificPrimitives );
64
-
64
+
65
65
foundationClasses .addAll (
66
66
Arrays .asList (
67
- "QString" ,
67
+ "QString" ,
68
68
"QDate" ,
69
69
"QDateTime" ,
70
70
"QByteArray" )
@@ -78,7 +78,7 @@ public CppQt5AbstractCodegen() {
78
78
typeMapping .put ("integer" , "qint32" );
79
79
typeMapping .put ("long" , "qint64" );
80
80
typeMapping .put ("boolean" , "bool" );
81
- typeMapping .put ("number" , "double" );
81
+ typeMapping .put ("number" , "double" );
82
82
typeMapping .put ("array" , "QList" );
83
83
typeMapping .put ("map" , "QMap" );
84
84
typeMapping .put ("object" , PREFIX + "Object" );
@@ -90,8 +90,8 @@ public CppQt5AbstractCodegen() {
90
90
// modifications on multiple templates)
91
91
typeMapping .put ("UUID" , "QString" );
92
92
typeMapping .put ("URI" , "QString" );
93
- typeMapping .put ("file" , "QIODevice " );
94
- typeMapping .put ("binary" , "QIODevice " );
93
+ typeMapping .put ("file" , "QByteArray " );
94
+ typeMapping .put ("binary" , "QByteArray " );
95
95
importMapping = new HashMap <String , String >();
96
96
namespaces = new HashMap <String , String >();
97
97
@@ -101,7 +101,6 @@ public CppQt5AbstractCodegen() {
101
101
systemIncludes .add ("QDate" );
102
102
systemIncludes .add ("QDateTime" );
103
103
systemIncludes .add ("QByteArray" );
104
- systemIncludes .add ("QIODevice" );
105
104
}
106
105
@ Override
107
106
public void processOpts () {
@@ -119,7 +118,7 @@ public void processOpts() {
119
118
additionalProperties ().put ("prefix" , modelNamePrefix );
120
119
}
121
120
}
122
-
121
+
123
122
@ Override
124
123
public String toModelImport (String name ) {
125
124
if ( name .isEmpty () ) {
@@ -140,7 +139,7 @@ public String toModelImport(String name) {
140
139
141
140
return "#include \" " + folder + name + ".h\" " ;
142
141
}
143
-
142
+
144
143
/**
145
144
* Optional - type declaration. This is a String which is used by the templates to instantiate your
146
145
* types. There is typically special handling for different property types
@@ -160,9 +159,9 @@ public String getTypeDeclaration(Schema p) {
160
159
Schema inner = ModelUtils .getAdditionalProperties (p );
161
160
return getSchemaType (p ) + "<QString, " + getTypeDeclaration (inner ) + ">" ;
162
161
} else if (ModelUtils .isBinarySchema (p )) {
163
- return getSchemaType (p ) + "*" ;
162
+ return getSchemaType (p );
164
163
} else if (ModelUtils .isFileSchema (p )) {
165
- return getSchemaType (p ) + "*" ;
164
+ return getSchemaType (p );
166
165
}
167
166
if (foundationClasses .contains (openAPIType )) {
168
167
return openAPIType ;
@@ -174,7 +173,7 @@ public String getTypeDeclaration(Schema p) {
174
173
}
175
174
176
175
@ Override
177
- @ SuppressWarnings ("rawtypes" )
176
+ @ SuppressWarnings ("rawtypes" )
178
177
public String toDefaultValue (Schema p ) {
179
178
if (ModelUtils .isBooleanSchema (p )) {
180
179
return "false" ;
@@ -211,15 +210,15 @@ public String toDefaultValue(Schema p) {
211
210
public String toModelFilename (String name ) {
212
211
return toModelName (name );
213
212
}
214
-
213
+
215
214
/**
216
215
* Optional - OpenAPI type conversion. This is used to map OpenAPI types in a `Schema` into
217
216
* either language specific types via `typeMapping` or into complex models if there is not a mapping.
218
217
*
219
218
* @return a string value of the type or complex model for this property
220
219
*/
221
220
@ Override
222
- @ SuppressWarnings ("rawtypes" )
221
+ @ SuppressWarnings ("rawtypes" )
223
222
public String getSchemaType (Schema p ) {
224
223
String openAPIType = super .getSchemaType (p );
225
224
@@ -242,7 +241,7 @@ public String getSchemaType(Schema p) {
242
241
public String toVarName (String name ) {
243
242
// sanitize name
244
243
String varName = name ;
245
- varName = sanitizeName (name );
244
+ varName = sanitizeName (name );
246
245
247
246
// if it's all uppper case, convert to lower case
248
247
if (varName .matches ("^[A-Z_]*$" )) {
@@ -270,7 +269,7 @@ public String toParamName(String name) {
270
269
public String getTypeDeclaration (String str ) {
271
270
return str ;
272
271
}
273
-
272
+
274
273
@ Override
275
274
protected boolean needToImport (String type ) {
276
275
return StringUtils .isNotBlank (type ) && !defaultIncludes .contains (type )
@@ -283,7 +282,7 @@ protected boolean needToImport(String type) {
283
282
public Map <String , Object > postProcessOperationsWithModels (Map <String , Object > objs , List <Object > allModels ) {
284
283
Map <String , Object > objectMap = (Map <String , Object >) objs .get ("operations" );
285
284
List <CodegenOperation > operations = (List <CodegenOperation >) objectMap .get ("operation" );
286
-
285
+
287
286
List <Map <String , String >> imports = (List <Map <String , String >>) objs .get ("imports" );
288
287
Map <String , CodegenModel > codegenModels = new HashMap <String , CodegenModel > ();
289
288
for (Object moObj : allModels ) {
@@ -298,7 +297,7 @@ public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> o
298
297
operation .vendorExtensions .put ("returnsEnum" , true );
299
298
}
300
299
}
301
- // Check all return parameter baseType if there is a necessity to include, include it if not
300
+ // Check all return parameter baseType if there is a necessity to include, include it if not
302
301
// already done
303
302
if (operation .returnBaseType != null && needToImport (operation .returnBaseType )) {
304
303
if (!isIncluded (operation .returnBaseType , imports )) {
@@ -308,7 +307,7 @@ public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> o
308
307
List <CodegenParameter > params = new ArrayList <CodegenParameter >();
309
308
if (operation .allParams != null )params .addAll (operation .allParams );
310
309
311
- // Check all parameter baseType if there is a necessity to include, include it if not
310
+ // Check all parameter baseType if there is a necessity to include, include it if not
312
311
// already done
313
312
for (CodegenParameter param : params ) {
314
313
if (param .isPrimitiveType && needToImport (param .baseType )) {
@@ -321,7 +320,7 @@ public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> o
321
320
// We use QString to pass path params, add it to include
322
321
if (!isIncluded ("QString" , imports )) {
323
322
imports .add (createMapping ("import" , "QString" ));
324
- }
323
+ }
325
324
}
326
325
}
327
326
if (isIncluded ("QMap" , imports )) {
@@ -332,7 +331,7 @@ public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> o
332
331
}
333
332
return objs ;
334
333
}
335
-
334
+
336
335
@ Override
337
336
public Map <String , Object > postProcessModels (Map <String , Object > objs ) {
338
337
return postProcessModelsEnum (objs );
@@ -342,18 +341,18 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
342
341
public String toEnumValue (String value , String datatype ) {
343
342
return escapeText (value );
344
343
}
345
-
344
+
346
345
@ Override
347
346
public boolean isDataTypeString (String dataType ) {
348
347
return "QString" .equals (dataType );
349
348
}
350
-
349
+
351
350
private Map <String , String > createMapping (String key , String value ) {
352
351
Map <String , String > customImport = new HashMap <String , String >();
353
352
customImport .put (key , toModelImport (value ));
354
353
return customImport ;
355
354
}
356
-
355
+
357
356
private boolean isIncluded (String type , List <Map <String , String >> imports ) {
358
357
boolean included = false ;
359
358
String inclStr = toModelImport (type );
0 commit comments