userver: proto_structs::io::ReadContext Class Reference
Loading...
Searching...
No Matches
proto_structs::io::ReadContext Class Referencefinal

#include </data/code/userver/libraries/proto-structs/include/userver/proto-structs/io/context.hpp>

Detailed Description

Read operation context passed to user-defined ReadProtoStruct global functions.

Definition at line 31 of file context.hpp.

+ Inheritance diagram for proto_structs::io::ReadContext:

Public Types

using Error
 

Public Member Functions

template<typename T, typename U>
ReadField (int field_number, const U &message_field)
 Converts protobuf message field message_field with number field_number to a proto struct field with type T
 
template<proto_structs::traits::ProtoStruct TStruct, proto_structs::traits::ProtoMessage TMessage>
TStruct ReadField (int field_number, const TMessage &message_field)
 Converts protobuf message field message_field with number field_number to a proto struct field with type T
 
template<typename T, typename U>
void ReadField (T &struct_field, int field_number, const U &message_field)
 Converts protobuf message field message_field with number field_number to the proto struct field struct_field.
 
bool HasErrors () const noexcept
 Returns true if context contains at least one error.
 
void AddError (int field_number, std::string_view reason)
 Adds conversion error.
 
void AddError (const ::google::protobuf::FieldDescriptor &field_desc, std::string_view reason)
 Adds conversion error Parameter field_desc contains protobuf message field descriptor for which conversion has failed.
 
void AddError (std::string_view reason)
 Adds conversion error Method is intended for cases when it is hard to associate error with concrete field of the protobuf message.
 

Protected Member Functions

 Context (const ::google::protobuf::Descriptor &message_desc) noexcept
 
 Context (const ::google::protobuf::Descriptor &message_desc) noexcept
 
std::string GetCurrentPath (int current_field_number) const
 
std::string GetCurrentPath (const ::google::protobuf::FieldDescriptor &current_field_desc) const
 
std::string GetCurrentPath () const
 
std::string GetCurrentPath (int current_field_number) const
 
std::string GetCurrentPath (const ::google::protobuf::FieldDescriptor &current_field_desc) const
 
std::string GetCurrentPath () const
 
void PopFromPath ()
 
void PopFromPath ()
 
void PushToPath (int field_number)
 
void PushToPath (int field_number)
 

Member Typedef Documentation

◆ Error

Definition at line 50 of file context_base.hpp.

Member Function Documentation

◆ AddError() [1/3]

void proto_structs::io::ContextWithErrors< ReadError >::AddError ( const ::google::protobuf::FieldDescriptor & field_desc,
std::string_view reason )
inherited

Adds conversion error Parameter field_desc contains protobuf message field descriptor for which conversion has failed.

Definition at line 67 of file context_base.cpp.

◆ AddError() [2/3]

void proto_structs::io::ContextWithErrors< ReadError >::AddError ( int field_number,
std::string_view reason )
inherited

Adds conversion error.

Exceptions
Errorexception Parameter field_number contains protobuf message field number for which conversion has failed.

Definition at line 63 of file context_base.cpp.

◆ AddError() [3/3]

void proto_structs::io::ContextWithErrors< ReadError >::AddError ( std::string_view reason)
inherited

Adds conversion error Method is intended for cases when it is hard to associate error with concrete field of the protobuf message.

Definition at line 71 of file context_base.cpp.

◆ Context()

proto_structs::io::Context::Context ( const ::google::protobuf::Descriptor & message_desc)
inlineexplicitprotectednoexceptinherited

Definition at line 74 of file context_base.hpp.

◆ GetCurrentPath() [1/3]

std::string proto_structs::io::Context::GetCurrentPath ( ) const
protectedinherited

Definition at line 75 of file context_base.cpp.

◆ GetCurrentPath() [2/3]

std::string proto_structs::io::Context::GetCurrentPath ( const ::google::protobuf::FieldDescriptor & current_field_desc) const
protectedinherited

Definition at line 75 of file context_base.cpp.

◆ GetCurrentPath() [3/3]

std::string proto_structs::io::Context::GetCurrentPath ( int current_field_number) const
protectedinherited

Definition at line 75 of file context_base.cpp.

◆ HasErrors()

bool proto_structs::io::ContextWithErrors< ReadError >::HasErrors ( ) const
inlinenoexceptinherited

Returns true if context contains at least one error.

Definition at line 53 of file context_base.hpp.

◆ PopFromPath()

void proto_structs::io::Context::PopFromPath ( )
inlineprotectedinherited

Definition at line 76 of file context_base.hpp.

◆ PushToPath()

void proto_structs::io::Context::PushToPath ( int field_number)
inlineprotectedinherited

Definition at line 77 of file context_base.hpp.

◆ ReadField() [1/3]

TStruct proto_structs::io::ReadContext::ReadField ( int field_number,
const TMessage & message_field )
inline

Converts protobuf message field message_field with number field_number to a proto struct field with type T

Template Parameters
Tproto struct field type
Uprotobuf message type

Definition at line 65 of file context.hpp.

◆ ReadField() [2/3]

template<typename T, typename U>
T proto_structs::io::ReadContext::ReadField ( int field_number,
const U & message_field )
inline

Converts protobuf message field message_field with number field_number to a proto struct field with type T

Template Parameters
Tproto struct field type
Uprotobuf message type

Definition at line 46 of file context.hpp.

◆ ReadField() [3/3]

template<typename T, typename U>
void proto_structs::io::ReadContext::ReadField ( T & struct_field,
int field_number,
const U & message_field )
inline

Converts protobuf message field message_field with number field_number to the proto struct field struct_field.

Template Parameters
Tproto struct field type
Uprotobuf message type

Definition at line 97 of file context.hpp.


The documentation for this class was generated from the following file: