userver: userver/ugrpc/protobuf_visit.hpp File Reference
Loading...
Searching...
No Matches
protobuf_visit.hpp File Reference

Detailed Description

Utilities for visiting the fields of protobufs.

Definition in file protobuf_visit.hpp.

Go to the source code of this file.

#include <shared_mutex>
#include <string_view>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <google/protobuf/stubs/common.h>
#include <userver/utils/function_ref.hpp>
#include <userver/utils/impl/internal_tag.hpp>
#include <userver/utils/span.hpp>

Classes

class  ugrpc::BaseVisitor< Callback >
 Base class for FieldsVisitor and MessagesVisitor. Provides the interface and manages the descriptor graph to enable the visitors to find all selected structures. More...
 
class  ugrpc::FieldsVisitor
 Collects knowledge of the structure of the protobuf messages allowing for efficient loops over fields to apply a callback to the ones selected by the 'selector' function. More...
 
class  ugrpc::MessagesVisitor
 Collects knowledge of the structure of the protobuf messages allowing for efficient loops over nested messages to apply a callback to the ones selected by the 'selector' function. More...
 

Namespaces

namespace  ugrpc
 Asynchronous gRPC driver.
 

Typedefs

using ugrpc::MessageVisitCallback = utils::function_ref<void(google::protobuf::Message&)>
 
using ugrpc::FieldVisitCallback
 
using ugrpc::DescriptorList = std::vector<const google::protobuf::Descriptor*>
 
using ugrpc::FieldDescriptorList = std::vector<const google::protobuf::FieldDescriptor*>
 

Functions

void ugrpc::VisitFields (google::protobuf::Message &message, FieldVisitCallback callback)
 Execute a callback for all non-empty fields of the message.
 
void ugrpc::VisitMessagesRecursive (google::protobuf::Message &message, MessageVisitCallback callback)
 Execute a callback for the message and its non-empty submessages.
 
void ugrpc::VisitFieldsRecursive (google::protobuf::Message &message, FieldVisitCallback callback)
 Execute a callback for all fields of the message and its non-empty submessages.
 
FieldDescriptorList ugrpc::GetFieldDescriptors (const google::protobuf::Descriptor &descriptor)
 Get the descriptors of fields in the message.
 
DescriptorList ugrpc::GetNestedMessageDescriptors (const google::protobuf::Descriptor &descriptor)
 Get the descriptors of current and nested messages.
 
const google::protobuf::Descriptor * ugrpc::FindGeneratedMessage (std::string_view name)
 Find a generated type by name.
 
const google::protobuf::FieldDescriptor * ugrpc::FindField (const google::protobuf::Descriptor *descriptor, std::string_view field)
 Find the field of a generated type by name.