All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.thrift_cpp.include.interface_cast.body.vm Maven / Gradle / Ivy

There is a newer version: 3.5.0
Show newest version
#parse("thrift_cpp/include/cxx_schema_include.vm")
#parse("thrift_cpp/include/cxx.helper.vm")
#set( $output_basename = "${interfaceName}_cast")
#set( $output_filename = "${output_basename}.${source_type}")
## 当前代码名字空间
#set($source_namespace = "net.gdface.utils")
$codewriter.setCurrentCxxFilename($output_filename)
#define($use_pointer)#if(!$cxxType.primitive)*#end#end
## 返回正确的thrift 类型
#define($native_type)${cxxType.stubType.type}#end
##### thrift stub类型字段有效性检查 #########################
#define($stub_issetcheck)
#if(${cxxType.enum} && !${type.isRequired($name)})if(left.__isset.$name)##
#elseif(!${cxxType.enum} && !${cxxType.primitive})if(left.__isset.$name)##
#end
#end###define($stub_issetcheck)
##### UI type类型字段有效性检查 #########################
#define($ui_issetcheck)
#if(${cxxType.enum} && !${type.isRequired($name)})if(left.__get_${name}())##
#elseif(!${cxxType.enum} && !${cxxType.primitive})if(left.__get_${name}())##
#end
#end###define($ui_issetcheck)
######################################
$header_begin
/**
 * $interfaceName 接口数据类型转换定义(C++11) 
* C++11 compiler or VS2015 or above required
* $GENERAED_BY
*/ #if( $source_type == "cpp" ) \#include "${output_basename}.h" using namespace ${cxxhelper.cxxNamespace($source_namespace,true)}; #if($schemainfo.sql2java4x) \#include "common_utilits.h" using namespace ::gdface; #end #else \#include \#include \#include \#include \#include \#include \#include \#include \#include \#include \#include "${interfaceName}_types.h" \#include "${interfaceName}_typedef.h" #end #pkg_namespace_begin($source_namespace) ////////////////define transformer for types///////////////////// #foreach($entry in $structGenseqMap.entries()) #set($package = $entry.key) #foreach($type in $entry.value) #if(!$type.enum && !$type.extThriftStruct) #set($typeClass = ${type.cxxType.uiType.type} ) #set($thriftStub = ${schemainfo.toStubCxxType($type.baseClass)}) ######## thrift stub type to UI type ########## // right value left void ${ns_method_prefix}cast(const ${thriftStub}& left,${typeClass}&right)$method_declare_suffix #if( $source_type == "cpp" ) { #foreach($name in $type.fields) #set ($cxxType = $type.getCxxField($name)) ${stub_issetcheck}right.__set_$name(cast(left.$name,(decltype(right.$name)*)nullptr)); #end##foreach name #if($type.sql2javaBean) right._new = left._new; #end##if($type.sql2javaBean) } #end##if source_type // const input left ${typeClass} ${ns_method_prefix}cast(const ${thriftStub}& left,${typeClass} *)$method_declare_suffix #if( $source_type == "cpp" ) { ${typeClass} right; cast(left,right); return right; } #end##if source_type #if(!$type.exception) ######## UI type to thrift stub type ########## void ${ns_method_prefix}cast(const ${typeClass}& left,${thriftStub} &right)$method_declare_suffix #if( $source_type == "cpp" ) { #foreach($name in $type.fields) #set ($cxxType = $type.getCxxField($name)) ${ui_issetcheck}right.__set_$name(cast(${use_pointer}left.__get_${name}(),(decltype(right.$name)*)nullptr)); #end##foreach name #if($type.sql2javaBean) right._new = left._new; #if(${type.getCxxField("modified").string}) ## for sql2java 4.x right.initialized = bytes_to_hex_string(left.initialized); right.modified = bytes_to_hex_string(left.modified); #else right.initialized = left.initialized; right.modified = left.modified; #end #end##if($type.sql2javaBean) } #end##if source_type ${thriftStub} ${ns_method_prefix}cast(const ${typeClass}& left,${thriftStub} *)$method_declare_suffix #if( $source_type == "cpp" ) { ${thriftStub} right; cast(left,right); return right; } #end##if source_type #end##if($type.exception) #end###if(!$type.enum && !$type.extThriftStruct) #end##foreach($type) #end##foreach($package) #pkg_namespace_end() #if( $source_type == "h" ) \#include "cast_utilits.h" #end $header_end




© 2015 - 2025 Weber Informatics LLC | Privacy Policy