blob: 7ba55c3cc814e541f199d17bff2219c0c1ee8dc2 [file] [log] [blame]
Adam Cozzette501ecec2023-09-26 14:36:20 -07001// Protocol Buffers - Google's data interchange format
2// Copyright 2023 Google LLC. All rights reserved.
Adam Cozzette501ecec2023-09-26 14:36:20 -07003//
Hong Shinc482a8a2023-11-09 09:30:34 -08004// 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
Adam Cozzette501ecec2023-09-26 14:36:20 -07007
Hong Shin096b1392024-07-03 10:04:09 -07008#ifndef PROTOBUF_COMPILER_HBP_GEN_NAMES_H_
9#define PROTOBUF_COMPILER_HBP_GEN_NAMES_H_
Adam Cozzette501ecec2023-09-26 14:36:20 -070010
11#include <string>
12
13#include "google/protobuf/descriptor.pb.h"
Hong Shin082cf002024-10-15 12:29:42 -070014#include "google/protobuf/compiler/hpb/context.h"
Adam Cozzette501ecec2023-09-26 14:36:20 -070015
Hong Shin7a2b37f2024-07-09 15:42:34 -070016namespace google::protobuf::hpb_generator {
Adam Cozzette501ecec2023-09-26 14:36:20 -070017
Hong Shin096b1392024-07-03 10:04:09 -070018namespace protobuf = ::proto2;
Adam Cozzette501ecec2023-09-26 14:36:20 -070019
Hong Shin7a2b37f2024-07-09 15:42:34 -070020inline constexpr absl::string_view kNoPackageNamePrefix = "hpb_";
Adam Cozzette501ecec2023-09-26 14:36:20 -070021
22std::string ClassName(const protobuf::Descriptor* descriptor);
23std::string QualifiedClassName(const protobuf::Descriptor* descriptor);
24std::string QualifiedInternalClassName(const protobuf::Descriptor* descriptor);
25
26std::string CppSourceFilename(const google::protobuf::FileDescriptor* file);
27std::string ForwardingHeaderFilename(const google::protobuf::FileDescriptor* file);
28std::string UpbCFilename(const google::protobuf::FileDescriptor* file);
29std::string CppHeaderFilename(const google::protobuf::FileDescriptor* file);
30
Hong Shin082cf002024-10-15 12:29:42 -070031void WriteStartNamespace(const protobuf::FileDescriptor* file, Context& ctx);
32void WriteEndNamespace(const protobuf::FileDescriptor* file, Context& ctx);
Adam Cozzette501ecec2023-09-26 14:36:20 -070033
34std::string CppConstType(const protobuf::FieldDescriptor* field);
35std::string CppTypeParameterName(const protobuf::FieldDescriptor* field);
36
37std::string MessageBaseType(const protobuf::FieldDescriptor* field,
38 bool is_const);
Hong Shin4535f862024-09-03 10:46:25 -070039// Generate hpb::Ptr<const Model> to be used in accessors as public
Adam Cozzette501ecec2023-09-26 14:36:20 -070040// signatures.
41std::string MessagePtrConstType(const protobuf::FieldDescriptor* field,
42 bool is_const);
43std::string MessageCProxyType(const protobuf::FieldDescriptor* field,
44 bool is_const);
45std::string MessageProxyType(const protobuf::FieldDescriptor* field,
46 bool is_const);
47
Hong Shin7a2b37f2024-07-09 15:42:34 -070048} // namespace protobuf
49} // namespace google::hpb_generator
Adam Cozzette501ecec2023-09-26 14:36:20 -070050
Hong Shin096b1392024-07-03 10:04:09 -070051#endif // PROTOBUF_COMPILER_HBP_GEN_NAMES_H_