userver: proto_structs::io Namespace Reference
Loading...
Searching...
No Matches
proto_structs::io Namespace Reference

Detailed Description

Namespace for conversion utlities and predefined proto-structs conversion hooks for well-known std/userver types.

Classes

class  Context
 Read/write operation context. More...
 
class  ContextWithErrors
 Read/write operation context with error information. More...
 
class  ReadContext
 Read operation context passed to user-defined ReadProtoStruct global functions. More...
 
struct  To
 An ADL helper which allows compiler to find functions to read proto structs from protobuf messages. More...
 
class  WriteContext
 Write operation context passed to user-defined WriteProtoStruct global functions. More...
 

Functions

template<typename TStructField, typename TMessageField>
requires ScalarCompatibleWith<TStructField, TMessageField>
TStructField ReadProtoField (ReadContext &ctx, To< TStructField >, int field_number, const TMessageField &message_field)
 
template<typename TStructField, typename TMessageField>
requires ScalarCompatibleWith<std::remove_cvref_t<TStructField>, TMessageField>
void WriteProtoField (WriteContext &ctx, TStructField &&struct_field, int field_number, TMessageField &message_field)
 
std::chrono::time_point< std::chrono::system_clock > ReadProtoStruct (ReadContext &ctx, To< std::chrono::time_point< std::chrono::system_clock > >, const ::google::protobuf::Timestamp &msg)
 
void WriteProtoStruct (WriteContext &, const std::chrono::time_point< std::chrono::system_clock > &obj, ::google::protobuf::Timestamp &msg)
 
std::chrono::year_month_day ReadProtoStruct (ReadContext &ctx, To< std::chrono::year_month_day >, const ::google::type::Date &msg)
 
void WriteProtoStruct (WriteContext &ctx, const std::chrono::year_month_day &obj, ::google::type::Date &msg)
 
proto_structs::Any ReadProtoStruct (ReadContext &, To< proto_structs::Any >, const ::google::protobuf::Any &msg)
 
void WriteProtoStruct (WriteContext &, const proto_structs::Any &obj, ::google::protobuf::Any &msg)
 
void WriteProtoStruct (WriteContext &, proto_structs::Any &&obj, ::google::protobuf::Any &msg)
 
template<typename TRep, typename TPeriod>
std::chrono::duration< TRep, TPeriod > ReadProtoStruct (ReadContext &ctx, To< std::chrono::duration< TRep, TPeriod > >, const ::google::protobuf::Duration &msg)
 
template<typename TRep, typename TPeriod>
void WriteProtoStruct (WriteContext &, const std::chrono::duration< TRep, TPeriod > &obj, ::google::protobuf::Duration &msg)
 
template<typename TDuration>
std::chrono::hh_mm_ss< TDuration > ReadProtoStruct (ReadContext &ctx, To< std::chrono::hh_mm_ss< TDuration > >, const ::google::type::TimeOfDay &msg)
 
template<typename TDuration>
void WriteProtoStruct (WriteContext &ctx, const std::chrono::hh_mm_ss< TDuration > &obj, ::google::type::TimeOfDay &msg)
 
template<typename TKey, typename TValue, typename TCompare, typename TAllocator, typename TProtoKey, typename TProtoValue>
std::map< TKey, TValue, TCompare, TAllocator > ReadProtoField (ReadContext &ctx, To< std::map< TKey, TValue, TCompare, TAllocator > >, int field_number, const ::google::protobuf::Map< TProtoKey, TProtoValue > &message_field)
 
template<typename TKey, typename TValue, typename TCompare, typename TAllocator, typename TProtoKey, typename TProtoValue>
void WriteProtoField (WriteContext &ctx, const std::map< TKey, TValue, TCompare, TAllocator > &struct_field, int field_number, ::google::protobuf::Map< TProtoKey, TProtoValue > &message_field)
 
template<typename TKey, typename TValue, typename TCompare, typename TAllocator, typename TProtoKey, typename TProtoValue>
void WriteProtoField (WriteContext &ctx, std::map< TKey, TValue, TCompare, TAllocator > &&struct_field, int field_number, ::google::protobuf::Map< TProtoKey, TProtoValue > &message_field)
 
template<typename TKey, typename TValue, typename THash, typename TKeyEqual, typename TAllocator, typename TProtoKey, typename TProtoValue>
std::unordered_map< TKey, TValue, THash, TKeyEqual, TAllocator > ReadProtoField (ReadContext &ctx, To< std::unordered_map< TKey, TValue, THash, TKeyEqual, TAllocator > >, int field_number, const ::google::protobuf::Map< TProtoKey, TProtoValue > &message_field)
 
template<typename TKey, typename TValue, typename THash, typename TKeyEqual, typename TAllocator, typename TProtoKey, typename TProtoValue>
void WriteProtoField (WriteContext &ctx, const std::unordered_map< TKey, TValue, THash, TKeyEqual, TAllocator > &struct_field, int field_number, ::google::protobuf::Map< TProtoKey, TProtoValue > &message_field)
 
template<typename TKey, typename TValue, typename THash, typename TKeyEqual, typename TAllocator, typename TProtoKey, typename TProtoValue>
void WriteProtoField (WriteContext &ctx, std::unordered_map< TKey, TValue, THash, TKeyEqual, TAllocator > &&struct_field, int field_number, ::google::protobuf::Map< TProtoKey, TProtoValue > &message_field)
 
template<typename TItem, typename TAllocator, proto_structs::traits::ProtoRepeated TRepeated>
std::vector< TItem, TAllocator > ReadProtoField (ReadContext &ctx, To< std::vector< TItem, TAllocator > >, int field_number, const TRepeated &message_field)
 
template<typename TItem, typename TAllocator, proto_structs::traits::ProtoRepeated TRepeated>
void WriteProtoField (WriteContext &ctx, const std::vector< TItem, TAllocator > &struct_field, int field_number, TRepeated &message_field)
 
template<typename TItem, typename TAllocator, proto_structs::traits::ProtoRepeated TRepeated>
void WriteProtoField (WriteContext &ctx, std::vector< TItem, TAllocator > &&struct_field, int field_number, TRepeated &message_field)
 
template<int Prec, typename TRoundPolicy>
decimal64::Decimal< Prec, TRoundPolicy > ReadProtoStruct (ReadContext &ctx, To< decimal64::Decimal< Prec, TRoundPolicy > >, const ::google::type::Decimal &msg)
 
template<int Prec, typename TRoundPolicy>
void WriteProtoStruct (WriteContext &, const decimal64::Decimal< Prec, TRoundPolicy > &obj, ::google::type::Decimal &msg)
 
template<typename TField>
UnbreakableDependencyCycle ReadProtoField (ReadContext &, To< UnbreakableDependencyCycle >, int, const TField &)
 
template<typename TField>
void WriteProtoField (WriteContext &, const UnbreakableDependencyCycle &, int, TField &)
 
template<typename TField>
void WriteProtoField (WriteContext &, UnbreakableDependencyCycle &&, int, TField &)
 
template<typename T, proto_structs::traits::ProtoMessage TMessage>
utils::Box< T > ReadProtoStruct (ReadContext &ctx, To< utils::Box< T > >, const TMessage &msg)
 
template<typename T, proto_structs::traits::ProtoMessage TMessage>
void WriteProtoStruct (WriteContext &ctx, const utils::Box< T > &obj, TMessage &msg)
 
template<typename T, proto_structs::traits::ProtoMessage TMessage>
void WriteProtoStruct (WriteContext &ctx, utils::Box< T > &&obj, TMessage &msg)
 
template<typename TStructField, typename TMessageField>
utils::Box< TStructField > ReadProtoField (ReadContext &ctx, To< utils::Box< TStructField > >, int field_number, const TMessageField &message_field)
 
template<typename TStructField, typename TMessageField>
void WriteProtoField (WriteContext &ctx, const utils::Box< TStructField > &struct_field, int field_number, TMessageField &message_field)
 
template<typename TStructField, typename TMessageField>
void WriteProtoField (WriteContext &ctx, utils::Box< TStructField > &&struct_field, int field_number, TMessageField &message_field)
 
template<typename TDuration>
utils::datetime::TimeOfDay< TDuration > ReadProtoStruct (ReadContext &ctx, To< utils::datetime::TimeOfDay< TDuration > >, const ::google::type::TimeOfDay &msg)
 
template<typename TDuration>
void WriteProtoStruct (WriteContext &ctx, const utils::datetime::TimeOfDay< TDuration > &obj, ::google::type::TimeOfDay &msg)
 
template<typename TTag, typename TStructField, utils::StrongTypedefOps Ops, typename TEnable, typename TMessageField>
utils::StrongTypedef< TTag, TStructField, Ops, TEnable > ReadProtoField (ReadContext &ctx, To< utils::StrongTypedef< TTag, TStructField, Ops, TEnable > >, int field_number, const TMessageField &message_field)
 
template<typename TTag, typename TStructField, utils::StrongTypedefOps Ops, typename TEnable, typename TMessageField>
void WriteProtoField (WriteContext &ctx, const utils::StrongTypedef< TTag, TStructField, Ops, TEnable > &struct_field, int field_number, TMessageField &message_field)
 
template<typename TTag, typename TStructField, utils::StrongTypedefOps Ops, typename TEnable, typename TMessageField>
void WriteProtoField (WriteContext &ctx, utils::StrongTypedef< TTag, TStructField, Ops, TEnable > &&struct_field, int field_number, TMessageField &message_field)
 

Variables

constexpr int kMaxYearInGoogleDate = 9999
 
constexpr int kMinYearInGoogleDate = 1
 

Function Documentation

◆ ReadProtoField() [1/7]

template<typename TField>
UnbreakableDependencyCycle proto_structs::io::ReadProtoField ( ReadContext & ,
To< UnbreakableDependencyCycle > ,
int ,
const TField &  )

Definition at line 16 of file unbreakable_dependency_cycle_conv.hpp.

◆ ReadProtoField() [2/7]

template<typename TKey, typename TValue, typename TCompare, typename TAllocator, typename TProtoKey, typename TProtoValue>
std::map< TKey, TValue, TCompare, TAllocator > proto_structs::io::ReadProtoField ( ReadContext & ctx,
To< std::map< TKey, TValue, TCompare, TAllocator > > ,
int field_number,
const ::google::protobuf::Map< TProtoKey, TProtoValue > & message_field )

Definition at line 21 of file map_conv.hpp.

◆ ReadProtoField() [3/7]

template<typename TKey, typename TValue, typename THash, typename TKeyEqual, typename TAllocator, typename TProtoKey, typename TProtoValue>
std::unordered_map< TKey, TValue, THash, TKeyEqual, TAllocator > proto_structs::io::ReadProtoField ( ReadContext & ctx,
To< std::unordered_map< TKey, TValue, THash, TKeyEqual, TAllocator > > ,
int field_number,
const ::google::protobuf::Map< TProtoKey, TProtoValue > & message_field )

Definition at line 22 of file unordered_map_conv.hpp.

◆ ReadProtoField() [4/7]

template<typename TItem, typename TAllocator, proto_structs::traits::ProtoRepeated TRepeated>
std::vector< TItem, TAllocator > proto_structs::io::ReadProtoField ( ReadContext & ctx,
To< std::vector< TItem, TAllocator > > ,
int field_number,
const TRepeated & message_field )

Definition at line 38 of file vector_conv.hpp.

◆ ReadProtoField() [5/7]

template<typename TStructField, typename TMessageField>
requires ScalarCompatibleWith<TStructField, TMessageField>
TStructField proto_structs::io::ReadProtoField ( ReadContext & ctx,
To< TStructField > ,
int field_number,
const TMessageField & message_field )

Definition at line 221 of file context.hpp.

◆ ReadProtoField() [6/7]

template<typename TStructField, typename TMessageField>
utils::Box< TStructField > proto_structs::io::ReadProtoField ( ReadContext & ctx,
To< utils::Box< TStructField > > ,
int field_number,
const TMessageField & message_field )

Definition at line 31 of file box_conv.hpp.

◆ ReadProtoField() [7/7]

template<typename TTag, typename TStructField, utils::StrongTypedefOps Ops, typename TEnable, typename TMessageField>
utils::StrongTypedef< TTag, TStructField, Ops, TEnable > proto_structs::io::ReadProtoField ( ReadContext & ctx,
To< utils::StrongTypedef< TTag, TStructField, Ops, TEnable > > ,
int field_number,
const TMessageField & message_field )

Definition at line 13 of file strong_typedef_conv.hpp.

◆ ReadProtoStruct() [1/8]

proto_structs::Any proto_structs::io::ReadProtoStruct ( ReadContext & ,
To< proto_structs::Any > ,
const ::google::protobuf::Any & msg )

Definition at line 9 of file any.cpp.

◆ ReadProtoStruct() [2/8]

template<int Prec, typename TRoundPolicy>
decimal64::Decimal< Prec, TRoundPolicy > proto_structs::io::ReadProtoStruct ( ReadContext & ctx,
To< decimal64::Decimal< Prec, TRoundPolicy > > ,
const ::google::type::Decimal & msg )

Definition at line 18 of file decimal_conv.hpp.

◆ ReadProtoStruct() [3/8]

template<typename TRep, typename TPeriod>
std::chrono::duration< TRep, TPeriod > proto_structs::io::ReadProtoStruct ( ReadContext & ctx,
To< std::chrono::duration< TRep, TPeriod > > ,
const ::google::protobuf::Duration & msg )

Definition at line 20 of file duration_conv.hpp.

◆ ReadProtoStruct() [4/8]

template<typename TDuration>
std::chrono::hh_mm_ss< TDuration > proto_structs::io::ReadProtoStruct ( ReadContext & ctx,
To< std::chrono::hh_mm_ss< TDuration > > ,
const ::google::type::TimeOfDay & msg )

Definition at line 21 of file hh_mm_ss_conv.hpp.

◆ ReadProtoStruct() [5/8]

std::chrono::time_point< std::chrono::system_clock > proto_structs::io::ReadProtoStruct ( ReadContext & ctx,
To< std::chrono::time_point< std::chrono::system_clock > > ,
const ::google::protobuf::Timestamp & msg )

Definition at line 11 of file time_point.cpp.

◆ ReadProtoStruct() [6/8]

std::chrono::year_month_day proto_structs::io::ReadProtoStruct ( ReadContext & ctx,
To< std::chrono::year_month_day > ,
const ::google::type::Date & msg )

Definition at line 16 of file year_month_day.cpp.

◆ ReadProtoStruct() [7/8]

template<typename T, proto_structs::traits::ProtoMessage TMessage>
utils::Box< T > proto_structs::io::ReadProtoStruct ( ReadContext & ctx,
To< utils::Box< T > > ,
const TMessage & msg )

Definition at line 15 of file box_conv.hpp.

◆ ReadProtoStruct() [8/8]

template<typename TDuration>
utils::datetime::TimeOfDay< TDuration > proto_structs::io::ReadProtoStruct ( ReadContext & ctx,
To< utils::datetime::TimeOfDay< TDuration > > ,
const ::google::type::TimeOfDay & msg )

Definition at line 16 of file time_of_day_conv.hpp.

◆ WriteProtoField() [1/13]

template<typename TField>
void proto_structs::io::WriteProtoField ( WriteContext & ,
const UnbreakableDependencyCycle & ,
int ,
TField &  )

Definition at line 26 of file unbreakable_dependency_cycle_conv.hpp.

◆ WriteProtoField() [2/13]

template<typename TField>
void proto_structs::io::WriteProtoField ( WriteContext & ,
UnbreakableDependencyCycle && ,
int ,
TField &  )

Definition at line 34 of file unbreakable_dependency_cycle_conv.hpp.

◆ WriteProtoField() [3/13]

template<typename TKey, typename TValue, typename TCompare, typename TAllocator, typename TProtoKey, typename TProtoValue>
void proto_structs::io::WriteProtoField ( WriteContext & ctx,
const std::map< TKey, TValue, TCompare, TAllocator > & struct_field,
int field_number,
::google::protobuf::Map< TProtoKey, TProtoValue > & message_field )

Definition at line 37 of file map_conv.hpp.

◆ WriteProtoField() [4/13]

template<typename TKey, typename TValue, typename THash, typename TKeyEqual, typename TAllocator, typename TProtoKey, typename TProtoValue>
void proto_structs::io::WriteProtoField ( WriteContext & ctx,
const std::unordered_map< TKey, TValue, THash, TKeyEqual, TAllocator > & struct_field,
int field_number,
::google::protobuf::Map< TProtoKey, TProtoValue > & message_field )

Definition at line 41 of file unordered_map_conv.hpp.

◆ WriteProtoField() [5/13]

template<typename TItem, typename TAllocator, proto_structs::traits::ProtoRepeated TRepeated>
void proto_structs::io::WriteProtoField ( WriteContext & ctx,
const std::vector< TItem, TAllocator > & struct_field,
int field_number,
TRepeated & message_field )

Definition at line 50 of file vector_conv.hpp.

◆ WriteProtoField() [6/13]

template<typename TStructField, typename TMessageField>
void proto_structs::io::WriteProtoField ( WriteContext & ctx,
const utils::Box< TStructField > & struct_field,
int field_number,
TMessageField & message_field )

Definition at line 36 of file box_conv.hpp.

◆ WriteProtoField() [7/13]

template<typename TTag, typename TStructField, utils::StrongTypedefOps Ops, typename TEnable, typename TMessageField>
void proto_structs::io::WriteProtoField ( WriteContext & ctx,
const utils::StrongTypedef< TTag, TStructField, Ops, TEnable > & struct_field,
int field_number,
TMessageField & message_field )

Definition at line 24 of file strong_typedef_conv.hpp.

◆ WriteProtoField() [8/13]

template<typename TKey, typename TValue, typename TCompare, typename TAllocator, typename TProtoKey, typename TProtoValue>
void proto_structs::io::WriteProtoField ( WriteContext & ctx,
std::map< TKey, TValue, TCompare, TAllocator > && struct_field,
int field_number,
::google::protobuf::Map< TProtoKey, TProtoValue > & message_field )

Definition at line 53 of file map_conv.hpp.

◆ WriteProtoField() [9/13]

template<typename TKey, typename TValue, typename THash, typename TKeyEqual, typename TAllocator, typename TProtoKey, typename TProtoValue>
void proto_structs::io::WriteProtoField ( WriteContext & ctx,
std::unordered_map< TKey, TValue, THash, TKeyEqual, TAllocator > && struct_field,
int field_number,
::google::protobuf::Map< TProtoKey, TProtoValue > & message_field )

Definition at line 58 of file unordered_map_conv.hpp.

◆ WriteProtoField() [10/13]

template<typename TItem, typename TAllocator, proto_structs::traits::ProtoRepeated TRepeated>
void proto_structs::io::WriteProtoField ( WriteContext & ctx,
std::vector< TItem, TAllocator > && struct_field,
int field_number,
TRepeated & message_field )

Definition at line 60 of file vector_conv.hpp.

◆ WriteProtoField() [11/13]

template<typename TStructField, typename TMessageField>
requires ScalarCompatibleWith<std::remove_cvref_t<TStructField>, TMessageField>
void proto_structs::io::WriteProtoField ( WriteContext & ctx,
TStructField && struct_field,
int field_number,
TMessageField & message_field )

Definition at line 237 of file context.hpp.

◆ WriteProtoField() [12/13]

template<typename TStructField, typename TMessageField>
void proto_structs::io::WriteProtoField ( WriteContext & ctx,
utils::Box< TStructField > && struct_field,
int field_number,
TMessageField & message_field )

Definition at line 46 of file box_conv.hpp.

◆ WriteProtoField() [13/13]

template<typename TTag, typename TStructField, utils::StrongTypedefOps Ops, typename TEnable, typename TMessageField>
void proto_structs::io::WriteProtoField ( WriteContext & ctx,
utils::StrongTypedef< TTag, TStructField, Ops, TEnable > && struct_field,
int field_number,
TMessageField & message_field )

Definition at line 34 of file strong_typedef_conv.hpp.

◆ WriteProtoStruct() [1/10]

template<int Prec, typename TRoundPolicy>
void proto_structs::io::WriteProtoStruct ( WriteContext & ,
const decimal64::Decimal< Prec, TRoundPolicy > & obj,
::google::type::Decimal & msg )

Definition at line 37 of file decimal_conv.hpp.

◆ WriteProtoStruct() [2/10]

void proto_structs::io::WriteProtoStruct ( WriteContext & ,
const proto_structs::Any & obj,
::google::protobuf::Any & msg )

Definition at line 13 of file any.cpp.

◆ WriteProtoStruct() [3/10]

template<typename TRep, typename TPeriod>
void proto_structs::io::WriteProtoStruct ( WriteContext & ,
const std::chrono::duration< TRep, TPeriod > & obj,
::google::protobuf::Duration & msg )

Definition at line 47 of file duration_conv.hpp.

◆ WriteProtoStruct() [4/10]

void proto_structs::io::WriteProtoStruct ( WriteContext & ,
const std::chrono::time_point< std::chrono::system_clock > & obj,
::google::protobuf::Timestamp & msg )

Definition at line 41 of file time_point.cpp.

◆ WriteProtoStruct() [5/10]

void proto_structs::io::WriteProtoStruct ( WriteContext & ,
proto_structs::Any && obj,
::google::protobuf::Any & msg )

Definition at line 17 of file any.cpp.

◆ WriteProtoStruct() [6/10]

template<typename TDuration>
void proto_structs::io::WriteProtoStruct ( WriteContext & ctx,
const std::chrono::hh_mm_ss< TDuration > & obj,
::google::type::TimeOfDay & msg )

Definition at line 49 of file hh_mm_ss_conv.hpp.

◆ WriteProtoStruct() [7/10]

void proto_structs::io::WriteProtoStruct ( WriteContext & ctx,
const std::chrono::year_month_day & obj,
::google::type::Date & msg )

Definition at line 43 of file year_month_day.cpp.

◆ WriteProtoStruct() [8/10]

template<typename T, proto_structs::traits::ProtoMessage TMessage>
void proto_structs::io::WriteProtoStruct ( WriteContext & ctx,
const utils::Box< T > & obj,
TMessage & msg )

Definition at line 20 of file box_conv.hpp.

◆ WriteProtoStruct() [9/10]

template<typename TDuration>
void proto_structs::io::WriteProtoStruct ( WriteContext & ctx,
const utils::datetime::TimeOfDay< TDuration > & obj,
::google::type::TimeOfDay & msg )

Definition at line 22 of file time_of_day_conv.hpp.

◆ WriteProtoStruct() [10/10]

template<typename T, proto_structs::traits::ProtoMessage TMessage>
void proto_structs::io::WriteProtoStruct ( WriteContext & ctx,
utils::Box< T > && obj,
TMessage & msg )

Definition at line 25 of file box_conv.hpp.

Variable Documentation

◆ kMaxYearInGoogleDate

int proto_structs::io::kMaxYearInGoogleDate = 9999
constexpr

Definition at line 12 of file year_month_day.cpp.

◆ kMinYearInGoogleDate

int proto_structs::io::kMinYearInGoogleDate = 1
constexpr

Definition at line 13 of file year_month_day.cpp.