File indexing completed on 2025-02-28 10:10:19
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef GOOGLE_PROTOBUF_JSON_INTERNAL_MESSAGE_PATH_H__
0009 #define GOOGLE_PROTOBUF_JSON_INTERNAL_MESSAGE_PATH_H__
0010
0011 #include <string>
0012 #include <vector>
0013
0014 #include "absl/cleanup/cleanup.h"
0015 #include "absl/strings/string_view.h"
0016 #include "google/protobuf/descriptor.h"
0017
0018 namespace google {
0019 namespace protobuf {
0020 namespace json_internal {
0021
0022
0023 class MessagePath {
0024 public:
0025 explicit MessagePath(absl::string_view message_root)
0026 : components_(
0027 {Component{FieldDescriptor::TYPE_MESSAGE, message_root, "", -1}}) {}
0028
0029
0030
0031
0032
0033 auto Push(absl::string_view field_name, FieldDescriptor::Type type,
0034 absl::string_view type_name = "") {
0035
0036 components_.push_back(Component{type, type_name, field_name, -1});
0037 return absl::MakeCleanup([this] { components_.pop_back(); });
0038 }
0039
0040
0041
0042
0043
0044 void NextRepeated() { ++components_.back().repeated_index; }
0045
0046
0047 void Describe(std::string& out) const;
0048
0049 private:
0050 struct Component {
0051 FieldDescriptor::Type type;
0052 absl::string_view type_name, field_name;
0053 int32_t repeated_index;
0054 };
0055 std::vector<Component> components_;
0056 };
0057 }
0058 }
0059 }
0060
0061 #endif