1 // Protocol Buffers - Google's data interchange format 2 // Copyright 2023 Google LLC. All rights reserved. 3 // 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file or at 6 // https://developers.google.com/open-source/licenses/bsd 7 8 #ifndef PROTOBUF_COMPILER_HBP_GEN_UTILS_H_ 9 #define PROTOBUF_COMPILER_HBP_GEN_UTILS_H_ 10 11 #include <string> 12 #include <vector> 13 14 #include "google/protobuf/descriptor.pb.h" 15 #include "absl/strings/string_view.h" 16 #include "google/protobuf/compiler/code_generator.h" 17 #include "google/protobuf/descriptor.h" 18 19 namespace google::protobuf::hpb_generator { 20 21 namespace protobuf = ::proto2; 22 23 enum class MessageClassType { 24 kMessage, 25 kMessageCProxy, 26 kMessageProxy, 27 kMessageAccess, 28 }; 29 IsMapEntryMessage(const protobuf::Descriptor * descriptor)30inline bool IsMapEntryMessage(const protobuf::Descriptor* descriptor) { 31 return descriptor->options().map_entry(); 32 } 33 std::vector<const protobuf::EnumDescriptor*> SortedEnums( 34 const protobuf::FileDescriptor* file); 35 std::vector<const protobuf::Descriptor*> SortedMessages( 36 const protobuf::FileDescriptor* file); 37 std::vector<const protobuf::FieldDescriptor*> SortedExtensions( 38 const protobuf::FileDescriptor* file); 39 std::vector<const protobuf::FieldDescriptor*> FieldNumberOrder( 40 const protobuf::Descriptor* message); 41 42 std::string ToCamelCase(absl::string_view input, bool lower_first); 43 44 } // namespace protobuf 45 } // namespace google::hpb_generator 46 47 #endif // PROTOBUF_COMPILER_HBP_GEN_UTILS_H_ 48