thrift.codegen.base

Code generation metadata and templates used for implementing struct serialization.

Many templates can be customized using field meta data, which is read from a manifest constant member of the given type called fieldMeta (if present), and is concatenated with the elements from the optional fieldMetaData template alias parameter.

Some code generation templates take account of the optional TVerboseCodegen version declaration, which causes warning messages to be emitted if no metadata for a field/method has been found and the default behavior is used instead. If this version is not defined, the templates just silently behave like the Thrift compiler does in this situation, i.e. automatically assign negative ids (starting at -1) for fields and assume TReq.AUTO as requirement level.

Members

Enums

TMethodType
enum TMethodType

The way how methods are called.

TReq
enum TReq

Struct field requirement levels.

Functions

readStruct
void readStruct(T s, Protocol p)

Deserializes a Thrift struct from a protocol.

thriftFieldInitCode
string thriftFieldInitCode(string thisName)
Undocumented in source. Be warned that the author may not have intended to support it.
writeStruct
void writeStruct(T s, Protocol p)

Serializes a struct to the target protocol.

Mixin templates

TStructHelpers
mixintemplate TStructHelpers(alias fieldMetaData = cast(TFieldMeta[])null)

Mixin template defining additional helper methods for using a struct with Thrift, and a member called isSetFlags if the struct contains any fields for which an »is set« flag is needed.

Structs

TExceptionMeta
struct TExceptionMeta

Compile-time metadata for a service method exception annotation.

TFieldMeta
struct TFieldMeta

Compile-time metadata for a struct field.

TMethodMeta
struct TMethodMeta

Compile-time metadata for a service method.

TParamMeta
struct TParamMeta

Compile-time metadata for a service method parameter.

TProtocolPair
struct TProtocolPair(InputProtocol, OutputProtocol)

A pair of two TPorotocols. To be used in places where a list of protocols is expected, for specifying different protocols for input and output.

Templates

BaseService
template BaseService(T)

For derived services, gets the base service interface.

TIsSetFlags
template TIsSetFlags(T, alias fieldMetaData)

Generates an eponymous struct with boolean flags for the non-required non-nullable fields of T.

isBaseService
template isBaseService(T)

true if T represents a Thrift service not derived from another service.

isDerivedService
template isDerivedService(T)

true if T represents a Thrift service derived from another service.

isService
template isService(T)

true if T represents a Thrift service.

isTProtocolOrPair
template isTProtocolOrPair(T)

true if T is a TProtocol or a TProtocolPair.

isTProtocolPair
template isTProtocolPair(T)

true if T is a TProtocolPair.

Meta