upb_utils.h
Go to the documentation of this file.
1 //
2 // Copyright 2018 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef GRPC_CORE_EXT_XDS_UPB_UTILS_H
18 #define GRPC_CORE_EXT_XDS_UPB_UTILS_H
19 
21 
22 #include <string>
23 
24 #include "absl/strings/string_view.h"
25 #include "upb/def.h"
26 #include "upb/upb.h"
27 
31 
32 namespace grpc_core {
33 
34 class XdsClient;
35 
36 // TODO(roth): Rethink this. All fields except symtab and arena should come
37 // from XdsClient, injected into XdsResourceType::Decode() somehow without
38 // passing through XdsApi code, maybe via the AdsResponseParser.
40  XdsClient* client; // Used only for logging. Unsafe for dereferencing.
45  bool use_v3;
48 };
49 
50 // Works for both std::string and absl::string_view.
51 template <typename T>
53  return upb_StringView_FromDataAndSize(str.data(), str.size());
54 }
55 
57  return absl::string_view(str.data, str.size);
58 }
59 
61  return std::string(str.data, str.size);
62 }
63 
64 } // namespace grpc_core
65 
66 #endif // GRPC_CORE_EXT_XDS_UPB_UTILS_H
trace.h
xds_interop_client.str
str
Definition: xds_interop_client.py:487
grpc_core::XdsEncodingContext::server
const XdsBootstrap::XdsServer & server
Definition: upb_utils.h:41
certificate_provider_store.h
grpc_core::XdsEncodingContext
Definition: upb_utils.h:39
grpc_core
Definition: call_metric_recorder.h:31
grpc_core::XdsClient
Definition: xds_client.h:60
absl::string_view
Definition: abseil-cpp/absl/strings/string_view.h:167
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc_core::StdStringToUpbString
upb_StringView StdStringToUpbString(const T &str)
Definition: upb_utils.h:52
grpc_core::XdsEncodingContext::client
XdsClient * client
Definition: upb_utils.h:40
T
#define T(upbtypeconst, upbtype, ctype, default_value)
grpc_core::CertificateProviderStore::PluginDefinitionMap
std::map< std::string, PluginDefinition > PluginDefinitionMap
Definition: certificate_provider_store.h:55
grpc_core::UpbStringToStdString
std::string UpbStringToStdString(const upb_StringView &str)
Definition: upb_utils.h:60
upb.h
xds_bootstrap.h
grpc_core::XdsEncodingContext::arena
upb_Arena * arena
Definition: upb_utils.h:44
grpc_core::TraceFlag
Definition: debug/trace.h:63
grpc_core::XdsEncodingContext::certificate_provider_definition_map
const CertificateProviderStore::PluginDefinitionMap * certificate_provider_definition_map
Definition: upb_utils.h:47
grpc_core::XdsEncodingContext::use_v3
bool use_v3
Definition: upb_utils.h:45
grpc_core::XdsBootstrap::XdsServer
Definition: xds_bootstrap.h:52
upb_StringView
Definition: upb/upb/upb.h:72
def.h
grpc_core::XdsEncodingContext::symtab
upb_DefPool * symtab
Definition: upb_utils.h:43
string_view
absl::string_view string_view
Definition: attr.cc:22
upb_StringView_FromDataAndSize
UPB_INLINE upb_StringView upb_StringView_FromDataAndSize(const char *data, size_t size)
Definition: upb/upb/upb.h:77
upb_DefPool
Definition: upb/upb/def.c:217
grpc_core::UpbStringToAbsl
absl::string_view UpbStringToAbsl(const upb_StringView &str)
Definition: upb_utils.h:56
upb_Arena
Definition: upb_internal.h:36
grpc_core::XdsEncodingContext::tracer
TraceFlag * tracer
Definition: upb_utils.h:42
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:47