cpp

package
v0.0.0-...-7428086 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EnumUnderlyingTypeNames = []string{
	"I8",
	"U8",
	"I16",
	"U16",
	"U32",
}
View Source
var GoUnusedProtection__ int
View Source
var RefTypeNames = []string{
	"Unique",
	"Shared",
	"SharedMutable",
}
View Source
var RefTypeToName = map[RefType]string{
	RefType_Unique:        "Unique",
	RefType_Shared:        "Shared",
	RefType_SharedMutable: "SharedMutable",
}
View Source
var RefTypeToValue = map[string]RefType{
	"Unique":        RefType_Unique,
	"Shared":        RefType_Shared,
	"SharedMutable": RefType_SharedMutable,
}

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	Name           string `thrift:"name,1" db:"name" json:"name"`
	AdaptedType    string `thrift:"adaptedType,2" db:"adaptedType" json:"adaptedType"`
	UnderlyingName string `thrift:"underlyingName,3" db:"underlyingName" json:"underlyingName"`
	ExtraNamespace string `thrift:"extraNamespace,4" db:"extraNamespace" json:"extraNamespace"`
	MoveOnly       bool   `thrift:"moveOnly,5" db:"moveOnly" json:"moveOnly"`
}

An annotation that applies a C++ adapter to typedef, field, or struct.

For example:

@cpp.Adapter{name = "::ns::IdAdapter"}
typedef i64 MyI64;

Here the type `MyI64` has the C++ adapter `IdAdapter`.

struct User {
  @cpp.Adapter{name = "::ns::IdAdapter"}
  1: i64 id;
}

Here the field `id` has the C++ adapter `IdAdapter`.

Attributes:

  • Name: The name of a C++ adapter type used to convert between Thrift and native

C++ representation.

The adapter can be either a Type or Field adapter, providing either of the following APIs:

   struct ThriftTypeAdapter {
     static AdaptedType fromThrift(ThriftType thrift);
     static {const ThriftType& | ThriftType} toThrift(const AdaptedType& native);
   };

   struct ThriftFieldAdapter {
     // Context is an instantiation of apache::thrift::FieldContext
     template <class Context>
     static void construct(AdaptedType& field, Context ctx);

     template <class Context>
     static AdaptedType fromThriftField(ThriftType value, Context ctx);

     template <class Context>
     static {const ThriftType& | ThriftType} toThrift(const AdaptedType& adapted, Context ctx);
   };
- AdaptedType: It is sometimes necessary to specify AdaptedType here (in case the codegen would

have a circular depdenceny, which will cause the C++ build to fail).

  • UnderlyingName: The name and/or extra namespace to use when directly adapting a type

(as opposed a typedef).

In this case, the IDL name of the type will refer to the adapted type in C++ and the underlying thrift type will be generated in a nested namespace and/or with a different name.

If neither `underlyingName` or `extraNamespace` is provided, the underlying type will be generated in a nested 'detail' namespace with the same name.

  • ExtraNamespace
  • MoveOnly: Must set to true when adapted type is not copyable.

func NewAdapter

func NewAdapter() *Adapter

func (*Adapter) GetAdaptedType

func (p *Adapter) GetAdaptedType() string

func (*Adapter) GetExtraNamespace

func (p *Adapter) GetExtraNamespace() string

func (*Adapter) GetMoveOnly

func (p *Adapter) GetMoveOnly() bool

func (*Adapter) GetName

func (p *Adapter) GetName() string

func (*Adapter) GetUnderlyingName

func (p *Adapter) GetUnderlyingName() string

func (*Adapter) Read

func (p *Adapter) Read(iprot thrift.Protocol) error

func (*Adapter) ReadField1

func (p *Adapter) ReadField1(iprot thrift.Protocol) error

func (*Adapter) ReadField2

func (p *Adapter) ReadField2(iprot thrift.Protocol) error

func (*Adapter) ReadField3

func (p *Adapter) ReadField3(iprot thrift.Protocol) error

func (*Adapter) ReadField4

func (p *Adapter) ReadField4(iprot thrift.Protocol) error

func (*Adapter) ReadField5

func (p *Adapter) ReadField5(iprot thrift.Protocol) error

func (*Adapter) SetAdaptedType

func (a *Adapter) SetAdaptedType(adaptedType string) *Adapter

func (*Adapter) SetExtraNamespace

func (a *Adapter) SetExtraNamespace(extraNamespace string) *Adapter

func (*Adapter) SetMoveOnly

func (a *Adapter) SetMoveOnly(moveOnly bool) *Adapter

func (*Adapter) SetName

func (a *Adapter) SetName(name string) *Adapter

func (*Adapter) SetUnderlyingName

func (a *Adapter) SetUnderlyingName(underlyingName string) *Adapter

func (*Adapter) String

func (p *Adapter) String() string

func (*Adapter) Write

func (p *Adapter) Write(oprot thrift.Protocol) error

type AdapterBuilder

type AdapterBuilder struct {
	// contains filtered or unexported fields
}

func NewAdapterBuilder

func NewAdapterBuilder() *AdapterBuilder

func (*AdapterBuilder) AdaptedType

func (a *AdapterBuilder) AdaptedType(adaptedType string) *AdapterBuilder

func (AdapterBuilder) Emit

func (p AdapterBuilder) Emit() *Adapter

func (*AdapterBuilder) ExtraNamespace

func (a *AdapterBuilder) ExtraNamespace(extraNamespace string) *AdapterBuilder

func (*AdapterBuilder) MoveOnly

func (a *AdapterBuilder) MoveOnly(moveOnly bool) *AdapterBuilder

func (*AdapterBuilder) Name

func (a *AdapterBuilder) Name(name string) *AdapterBuilder

func (*AdapterBuilder) UnderlyingName

func (a *AdapterBuilder) UnderlyingName(underlyingName string) *AdapterBuilder

type DisableLazyChecksum

type DisableLazyChecksum struct {
}

func NewDisableLazyChecksum

func NewDisableLazyChecksum() *DisableLazyChecksum

func (*DisableLazyChecksum) Read

func (p *DisableLazyChecksum) Read(iprot thrift.Protocol) error

func (*DisableLazyChecksum) String

func (p *DisableLazyChecksum) String() string

func (*DisableLazyChecksum) Write

func (p *DisableLazyChecksum) Write(oprot thrift.Protocol) error

type DisableLazyChecksumBuilder

type DisableLazyChecksumBuilder struct {
	// contains filtered or unexported fields
}

func NewDisableLazyChecksumBuilder

func NewDisableLazyChecksumBuilder() *DisableLazyChecksumBuilder

func (DisableLazyChecksumBuilder) Emit

type EnumType

type EnumType struct {
	Type EnumUnderlyingType `thrift:"type,1" db:"type" json:"type"`
}

Indicates an integer type for C++ to use as the underlying type of enum, for example:

@cpp.EnumType{type = cpp.EnumUnderlyingType.I8}
enum Fruit {
  Apple = 0,
  Banana = 1,
}

will be generated into the following:

enum class Fruit : ::std::int8_t {
  Apple = 0,
  Banana = 1,
};

Attributes:

  • Type

func NewEnumType

func NewEnumType() *EnumType

func (*EnumType) GetType

func (p *EnumType) GetType() EnumUnderlyingType

func (*EnumType) Read

func (p *EnumType) Read(iprot thrift.Protocol) error

func (*EnumType) ReadField1

func (p *EnumType) ReadField1(iprot thrift.Protocol) error

func (*EnumType) SetType

func (e *EnumType) SetType(type_a1 EnumUnderlyingType) *EnumType

func (*EnumType) String

func (p *EnumType) String() string

func (*EnumType) Write

func (p *EnumType) Write(oprot thrift.Protocol) error

type EnumTypeBuilder

type EnumTypeBuilder struct {
	// contains filtered or unexported fields
}

func NewEnumTypeBuilder

func NewEnumTypeBuilder() *EnumTypeBuilder

func (EnumTypeBuilder) Emit

func (p EnumTypeBuilder) Emit() *EnumType

func (*EnumTypeBuilder) Type

type EnumUnderlyingType

type EnumUnderlyingType int64

Enum in C++ by default uses signed 32 bit integer. There is no need to specify underlying type for signed 32 bit integer.

const (
	EnumUnderlyingType_I8  EnumUnderlyingType = 0
	EnumUnderlyingType_U8  EnumUnderlyingType = 1
	EnumUnderlyingType_I16 EnumUnderlyingType = 2
	EnumUnderlyingType_U16 EnumUnderlyingType = 3
	EnumUnderlyingType_U32 EnumUnderlyingType = 4
)

func EnumUnderlyingTypeFromString

func EnumUnderlyingTypeFromString(s string) (EnumUnderlyingType, error)

func EnumUnderlyingTypePtr

func EnumUnderlyingTypePtr(v EnumUnderlyingType) *EnumUnderlyingType

func (EnumUnderlyingType) String

func (p EnumUnderlyingType) String() string

type FieldInterceptor

type FieldInterceptor struct {
	Name     string `thrift:"name,1" db:"name" json:"name"`
	Noinline bool   `thrift:"noinline,2" db:"noinline" json:"noinline"`
}

An annotation that intercepts field access with C++ field interceptor. Use with *caution* since this may introduce substantial performance overhead on each field access.

For example:

struct Foo {
  @cpp.FieldInterceptor{name = "MyFieldInterceptor"}
  1: i64 id;
}

The field interceptor `MyFieldInterceptor` will intercept with `interceptThriftFieldAccess` when the field `id` is accessed.

Attributes:

  • Name: The name of a field interceptor.

The field interceptor provides the following API:

struct ThriftFieldInterceptor {
  template <typename T, typename Struct, int16_t FieldId>
  static void interceptThriftFieldAccess(T&& field,
                                         apache::thrift::FieldContext<Struct, FieldId>&& ctx);
};

The field interceptor intercepts with the field value and the field context. It enforces an easily searchable function name `interceptThriftFieldAccess`.

  • Noinline: Setting to true makes compiler not inline and erase function signature for

the intercepting field accessor.

func NewFieldInterceptor

func NewFieldInterceptor() *FieldInterceptor

func (*FieldInterceptor) GetName

func (p *FieldInterceptor) GetName() string

func (*FieldInterceptor) GetNoinline

func (p *FieldInterceptor) GetNoinline() bool

func (*FieldInterceptor) Read

func (p *FieldInterceptor) Read(iprot thrift.Protocol) error

func (*FieldInterceptor) ReadField1

func (p *FieldInterceptor) ReadField1(iprot thrift.Protocol) error

func (*FieldInterceptor) ReadField2

func (p *FieldInterceptor) ReadField2(iprot thrift.Protocol) error

func (*FieldInterceptor) SetName

func (f *FieldInterceptor) SetName(name string) *FieldInterceptor

func (*FieldInterceptor) SetNoinline

func (f *FieldInterceptor) SetNoinline(noinline bool) *FieldInterceptor

func (*FieldInterceptor) String

func (p *FieldInterceptor) String() string

func (*FieldInterceptor) Write

func (p *FieldInterceptor) Write(oprot thrift.Protocol) error

type FieldInterceptorBuilder

type FieldInterceptorBuilder struct {
	// contains filtered or unexported fields
}

func NewFieldInterceptorBuilder

func NewFieldInterceptorBuilder() *FieldInterceptorBuilder

func (FieldInterceptorBuilder) Emit

func (*FieldInterceptorBuilder) Name

func (*FieldInterceptorBuilder) Noinline

func (f *FieldInterceptorBuilder) Noinline(noinline bool) *FieldInterceptorBuilder

type Lazy

type Lazy struct {
	Ref bool `thrift:"ref,1" db:"ref" json:"ref"`
}

Attributes:

  • Ref

func NewLazy

func NewLazy() *Lazy

func (*Lazy) GetRef

func (p *Lazy) GetRef() bool

func (*Lazy) Read

func (p *Lazy) Read(iprot thrift.Protocol) error

func (*Lazy) ReadField1

func (p *Lazy) ReadField1(iprot thrift.Protocol) error

func (*Lazy) SetRef

func (l *Lazy) SetRef(ref bool) *Lazy

func (*Lazy) String

func (p *Lazy) String() string

func (*Lazy) Write

func (p *Lazy) Write(oprot thrift.Protocol) error

type LazyBuilder

type LazyBuilder struct {
	// contains filtered or unexported fields
}

func NewLazyBuilder

func NewLazyBuilder() *LazyBuilder

func (LazyBuilder) Emit

func (p LazyBuilder) Emit() *Lazy

func (*LazyBuilder) Ref

func (l *LazyBuilder) Ref(ref bool) *LazyBuilder

type MinimizePadding

type MinimizePadding struct {
}

func NewMinimizePadding

func NewMinimizePadding() *MinimizePadding

func (*MinimizePadding) Read

func (p *MinimizePadding) Read(iprot thrift.Protocol) error

func (*MinimizePadding) String

func (p *MinimizePadding) String() string

func (*MinimizePadding) Write

func (p *MinimizePadding) Write(oprot thrift.Protocol) error

type MinimizePaddingBuilder

type MinimizePaddingBuilder struct {
	// contains filtered or unexported fields
}

func NewMinimizePaddingBuilder

func NewMinimizePaddingBuilder() *MinimizePaddingBuilder

func (MinimizePaddingBuilder) Emit

type PackIsset

type PackIsset struct {
	Atomic bool `thrift:"atomic,1" db:"atomic" json:"atomic"`
}

Attributes:

  • Atomic

func NewPackIsset

func NewPackIsset() *PackIsset

func (*PackIsset) GetAtomic

func (p *PackIsset) GetAtomic() bool

func (*PackIsset) Read

func (p *PackIsset) Read(iprot thrift.Protocol) error

func (*PackIsset) ReadField1

func (p *PackIsset) ReadField1(iprot thrift.Protocol) error

func (*PackIsset) SetAtomic

func (p *PackIsset) SetAtomic(atomic bool) *PackIsset

func (*PackIsset) String

func (p *PackIsset) String() string

func (*PackIsset) Write

func (p *PackIsset) Write(oprot thrift.Protocol) error

type PackIssetBuilder

type PackIssetBuilder struct {
	// contains filtered or unexported fields
}

func NewPackIssetBuilder

func NewPackIssetBuilder() *PackIssetBuilder

func (*PackIssetBuilder) Atomic

func (p *PackIssetBuilder) Atomic(atomic bool) *PackIssetBuilder

func (PackIssetBuilder) Emit

func (p PackIssetBuilder) Emit() *PackIsset

type Ref

type Ref struct {
	Type RefType `thrift:"type,1" db:"type" json:"type"`
}

Attributes:

  • Type

func NewRef

func NewRef() *Ref

func (*Ref) GetType

func (p *Ref) GetType() RefType

func (*Ref) Read

func (p *Ref) Read(iprot thrift.Protocol) error

func (*Ref) ReadField1

func (p *Ref) ReadField1(iprot thrift.Protocol) error

func (*Ref) SetType

func (r *Ref) SetType(type_a1 RefType) *Ref

func (*Ref) String

func (p *Ref) String() string

func (*Ref) Write

func (p *Ref) Write(oprot thrift.Protocol) error

type RefBuilder

type RefBuilder struct {
	// contains filtered or unexported fields
}

func NewRefBuilder

func NewRefBuilder() *RefBuilder

func (RefBuilder) Emit

func (p RefBuilder) Emit() *Ref

func (*RefBuilder) Type

func (r *RefBuilder) Type(type_a1 RefType) *RefBuilder

type RefType

type RefType int64
const (
	RefType_Unique        RefType = 0
	RefType_Shared        RefType = 1
	RefType_SharedMutable RefType = 2
)

func RefTypeFromString

func RefTypeFromString(s string) (RefType, error)

func RefTypePtr

func RefTypePtr(v RefType) *RefType

func (RefType) String

func (p RefType) String() string

type ScopedEnumAsUnionType

type ScopedEnumAsUnionType struct {
}

func NewScopedEnumAsUnionType

func NewScopedEnumAsUnionType() *ScopedEnumAsUnionType

func (*ScopedEnumAsUnionType) Read

func (p *ScopedEnumAsUnionType) Read(iprot thrift.Protocol) error

func (*ScopedEnumAsUnionType) String

func (p *ScopedEnumAsUnionType) String() string

func (*ScopedEnumAsUnionType) Write

func (p *ScopedEnumAsUnionType) Write(oprot thrift.Protocol) error

type ScopedEnumAsUnionTypeBuilder

type ScopedEnumAsUnionTypeBuilder struct {
	// contains filtered or unexported fields
}

func NewScopedEnumAsUnionTypeBuilder

func NewScopedEnumAsUnionTypeBuilder() *ScopedEnumAsUnionTypeBuilder

func (ScopedEnumAsUnionTypeBuilder) Emit

type StrongType

type StrongType struct {
}

Indicates a typedef should be 'strong', and require an explicit cast to the underlying type.

Currently only works for integer typedefs, for example:

@cpp.StrongType
typedef i32 MyId;

Will cause an enum class to be used instead of a typedef in the genearte code, for example:

enum class MyId : ::std::int32_t {};

func NewStrongType

func NewStrongType() *StrongType

func (*StrongType) Read

func (p *StrongType) Read(iprot thrift.Protocol) error

func (*StrongType) String

func (p *StrongType) String() string

func (*StrongType) Write

func (p *StrongType) Write(oprot thrift.Protocol) error

type StrongTypeBuilder

type StrongTypeBuilder struct {
	// contains filtered or unexported fields
}

func NewStrongTypeBuilder

func NewStrongTypeBuilder() *StrongTypeBuilder

func (StrongTypeBuilder) Emit

func (p StrongTypeBuilder) Emit() *StrongType

type TriviallyRelocatable

type TriviallyRelocatable struct {
}

func NewTriviallyRelocatable

func NewTriviallyRelocatable() *TriviallyRelocatable

func (*TriviallyRelocatable) Read

func (p *TriviallyRelocatable) Read(iprot thrift.Protocol) error

func (*TriviallyRelocatable) String

func (p *TriviallyRelocatable) String() string

func (*TriviallyRelocatable) Write

func (p *TriviallyRelocatable) Write(oprot thrift.Protocol) error

type TriviallyRelocatableBuilder

type TriviallyRelocatableBuilder struct {
	// contains filtered or unexported fields
}

func NewTriviallyRelocatableBuilder

func NewTriviallyRelocatableBuilder() *TriviallyRelocatableBuilder

func (TriviallyRelocatableBuilder) Emit

type UseOpEncode

type UseOpEncode struct {
}

func NewUseOpEncode

func NewUseOpEncode() *UseOpEncode

func (*UseOpEncode) Read

func (p *UseOpEncode) Read(iprot thrift.Protocol) error

func (*UseOpEncode) String

func (p *UseOpEncode) String() string

func (*UseOpEncode) Write

func (p *UseOpEncode) Write(oprot thrift.Protocol) error

type UseOpEncodeBuilder

type UseOpEncodeBuilder struct {
	// contains filtered or unexported fields
}

func NewUseOpEncodeBuilder

func NewUseOpEncodeBuilder() *UseOpEncodeBuilder

func (UseOpEncodeBuilder) Emit

func (p UseOpEncodeBuilder) Emit() *UseOpEncode

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL