in tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/generators/cpp/JsonCppClientGenerator.java [92:151]
protected SdkFileEntry generateModelSourceFile(ServiceModel serviceModel, Map.Entry<String, Shape> shapeEntry) {
Shape shape = shapeEntry.getValue();
if (shape.isResult() && shape.hasEventStreamMembers())
return null;
// if the shape is an event and its content type is "blob" then we don't need a source file, because the whole
// class is implemented in the header file. See EventHeader.vm
if (shape.isEvent() && "blob".equals(shape.getEventPayloadType()))
return null;
if (shape.isException() && !shape.isJsonModeledException())
return null;
if (shape.isEventStream())
return null;
if (shape.isDocument())
return null;
if (shape.isEnum()) {
// event-stream input shapes do their serialization via the encoder; So skip generating code for those.
return super.generateModelSourceFile(serviceModel, shapeEntry);
}
if (shape.isStructure() && shape.isReferenced()) {
Template template;
VelocityContext context = createContext(serviceModel);
if (shape.isRequest() && (shape.hasStreamMembers() || shape.hasEventStreamMembers())) {
if (shape.hasEventStreamMembers()) {
HashMap<String, String> headersMap = new HashMap<>(10);
headersMap.put("Aws::Http::CONTENT_TYPE_HEADER", "Aws::AMZN_EVENTSTREAM_CONTENT_TYPE");
context.put("requestSpecificHeaders", headersMap);
}
template = velocityEngine.getTemplate("/com/amazonaws/util/awsclientgenerator/velocity/cpp/StreamRequestSource.vm", StandardCharsets.UTF_8.name());
}
else if (shape.isRequest()) {
template = velocityEngine.getTemplate("/com/amazonaws/util/awsclientgenerator/velocity/cpp/json/JsonRequestSource.vm", StandardCharsets.UTF_8.name());
}
else if (shape.isResult() && shape.hasStreamMembers()) {
template = velocityEngine.getTemplate("/com/amazonaws/util/awsclientgenerator/velocity/cpp/StreamResultSource.vm", StandardCharsets.UTF_8.name());
}
else if (shape.isResult()) {
template = velocityEngine.getTemplate("/com/amazonaws/util/awsclientgenerator/velocity/cpp/json/JsonResultSource.vm", StandardCharsets.UTF_8.name());
} else {
template = velocityEngine.getTemplate("/com/amazonaws/util/awsclientgenerator/velocity/cpp/json/JsonSubObjectSource.vm", StandardCharsets.UTF_8.name());
}
context.put("operation", serviceModel.getOperationForRequestShapeName(shape.getName()));
context.put("shape", shape);
context.put("typeInfo", new CppShapeInformation(shape, serviceModel));
context.put("CppViewHelper", CppViewHelper.class);
context.put("presignerTemplate", "/com/amazonaws/util/awsclientgenerator/velocity/cpp/json/JsonDumpBodyToUrl.vm");
String fileName = String.format("source/model/%s.cpp", shapeEntry.getKey());
return makeFile(template, context, fileName, true);
}
return null;
}