Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-07 08:32:58

0001 // Protocol Buffers - Google's data interchange format
0002 // Copyright 2008 Google Inc.  All rights reserved.
0003 //
0004 // Use of this source code is governed by a BSD-style
0005 // license that can be found in the LICENSE file or at
0006 // https://developers.google.com/open-source/licenses/bsd
0007 
0008 // Author: jasonh@google.com (Jason Hsueh)
0009 //
0010 // This header is logically internal, but is made public because it is used
0011 // from protocol-compiler-generated code, which may reside in other components.
0012 // It provides reflection support for generated enums, and is included in
0013 // generated .pb.h files and should have minimal dependencies. The methods are
0014 // implemented in generated_message_reflection.cc.
0015 
0016 #ifndef GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__
0017 #define GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__
0018 
0019 #include <string>
0020 
0021 #include "absl/strings/string_view.h"
0022 #include "google/protobuf/generated_enum_util.h"
0023 #include "google/protobuf/port.h"
0024 
0025 #ifdef SWIG
0026 #error "You cannot SWIG proto headers"
0027 #endif
0028 
0029 // Must be included last.
0030 #include "google/protobuf/port_def.inc"
0031 
0032 namespace google {
0033 namespace protobuf {
0034 class EnumDescriptor;
0035 }  // namespace protobuf
0036 }  // namespace google
0037 
0038 namespace google {
0039 namespace protobuf {
0040 
0041 // Returns the EnumDescriptor for enum type E, which must be a
0042 // proto-declared enum type.  Code generated by the protocol compiler
0043 // will include specializations of this template for each enum type declared.
0044 template <typename E>
0045 const EnumDescriptor* PROTOBUF_NONNULL GetEnumDescriptor();
0046 
0047 namespace internal {
0048 
0049 // Helper for EnumType_Parse functions: try to parse the string 'name' as
0050 // an enum name of the given type, returning true and filling in value on
0051 // success, or returning false and leaving value unchanged on failure.
0052 PROTOBUF_EXPORT bool ParseNamedEnum(
0053     const EnumDescriptor* PROTOBUF_NONNULL descriptor, absl::string_view name,
0054     int* PROTOBUF_NONNULL value);
0055 
0056 template <typename EnumType>
0057 bool ParseNamedEnum(const EnumDescriptor* PROTOBUF_NONNULL descriptor,
0058                     absl::string_view name, EnumType* PROTOBUF_NONNULL value) {
0059   int tmp;
0060   if (!ParseNamedEnum(descriptor, name, &tmp)) return false;
0061   *value = static_cast<EnumType>(tmp);
0062   return true;
0063 }
0064 
0065 // Just a wrapper around printing the name of a value. The main point of this
0066 // function is not to be inlined, so that you can do this without including
0067 // descriptor.h.
0068 PROTOBUF_EXPORT const std::string& NameOfEnum(
0069     const EnumDescriptor* PROTOBUF_NONNULL descriptor, int value);
0070 
0071 }  // namespace internal
0072 }  // namespace protobuf
0073 }  // namespace google
0074 
0075 #include "google/protobuf/port_undef.inc"
0076 
0077 #endif  // GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__