1
#pragma once
2

            
3
#include <algorithm>
4
#include <string>
5
#include <vector>
6

            
7
#include "envoy/common/platform.h"
8

            
9
#include "google/protobuf/any.pb.h"
10
#include "google/protobuf/descriptor.h"
11
#include "google/protobuf/descriptor.pb.h"
12
#include "google/protobuf/descriptor_database.h"
13
#include "google/protobuf/dynamic_message.h"
14
#include "google/protobuf/empty.pb.h"
15
#include "google/protobuf/extension_set.h"
16
#include "google/protobuf/io/coded_stream.h"
17
#include "google/protobuf/io/zero_copy_stream.h"
18
#include "google/protobuf/io/zero_copy_stream_impl.h"
19
#include "google/protobuf/map.h"
20
#include "google/protobuf/message.h"
21
#include "google/protobuf/repeated_field.h"
22
#include "google/protobuf/service.h"
23
#include "google/protobuf/struct.pb.h"
24
#include "google/protobuf/text_format.h"
25
#include "google/protobuf/util/converter/json_stream_parser.h"
26
#include "google/protobuf/util/converter/object_writer.h"
27
#include "google/protobuf/util/field_mask_util.h"
28
#include "google/protobuf/util/json_util.h"
29
#include "google/protobuf/util/message_differencer.h"
30
#include "google/protobuf/util/time_util.h"
31
#include "google/protobuf/util/type_resolver.h"
32
#include "google/protobuf/util/type_resolver_util.h"
33
#include "google/protobuf/wrappers.pb.h"
34

            
35
#if defined(ENVOY_ENABLE_FULL_PROTOS)
36

            
37
namespace google::protobuf {
38
using ReflectableMessage = ::google::protobuf::Message*;
39
} // namespace google::protobuf
40

            
41
namespace Envoy {
42
// All references to google::protobuf in Envoy need to be made via the
43
// Envoy::Protobuf namespace. This is required to allow remapping of protobuf to
44
// alternative implementations during import into other repositories. E.g. at
45
// Google we have more than one protobuf implementation.
46
namespace Protobuf = google::protobuf;
47

            
48
} // namespace Envoy
49

            
50
#else
51

            
52
// Forward declarations
53
namespace google::protobuf {
54
class FileDescriptorSet;
55
} // namespace google::protobuf
56
namespace cc_proto_descriptor_library::internal {
57
struct FileDescriptorInfo;
58
} // namespace cc_proto_descriptor_library::internal
59

            
60
namespace Envoy {
61
class MessageLiteDifferencer;
62
// All references to google::protobuf in Envoy need to be made via the
63
// Envoy::Protobuf namespace. This is required to allow remapping of protobuf to
64
// alternative implementations during import into other repositories. E.g. at
65
// Google we have more than one protobuf implementation.
66
namespace Protobuf {
67

            
68
using Closure = ::google::protobuf::Closure;
69

            
70
using ::google::protobuf::Any;                          // NOLINT(misc-unused-using-decls)
71
using ::google::protobuf::Arena;                        // NOLINT(misc-unused-using-decls)
72
using ::google::protobuf::BoolValue;                    // NOLINT(misc-unused-using-decls)
73
using ::google::protobuf::BytesValue;                   // NOLINT(misc-unused-using-decls)
74
using ::google::protobuf::Descriptor;                   // NOLINT(misc-unused-using-decls)
75
using ::google::protobuf::DescriptorPool;               // NOLINT(misc-unused-using-decls)
76
using ::google::protobuf::DescriptorPoolDatabase;       // NOLINT(misc-unused-using-decls)
77
using ::google::protobuf::Duration;                     // NOLINT(misc-unused-using-decls)
78
using ::google::protobuf::DynamicCastMessage;           // NOLINT(misc-unused-using-decls)
79
using ::google::protobuf::DynamicMessageFactory;        // NOLINT(misc-unused-using-decls)
80
using ::google::protobuf::Empty;                        // NOLINT(misc-unused-using-decls)
81
using ::google::protobuf::EnumValueDescriptor;          // NOLINT(misc-unused-using-decls)
82
using ::google::protobuf::FieldDescriptor;              // NOLINT(misc-unused-using-decls)
83
using ::google::protobuf::FieldMask;                    // NOLINT(misc-unused-using-decls)
84
using ::google::protobuf::FileDescriptor;               // NOLINT(misc-unused-using-decls)
85
using ::google::protobuf::FileDescriptorProto;          // NOLINT(misc-unused-using-decls)
86
using ::google::protobuf::FileDescriptorSet;            // NOLINT(misc-unused-using-decls)
87
using ::google::protobuf::ListValue;                    // NOLINT(misc-unused-using-decls)
88
using ::google::protobuf::Map;                          // NOLINT(misc-unused-using-decls)
89
using ::google::protobuf::MapPair;                      // NOLINT(misc-unused-using-decls)
90
using ::google::protobuf::MessageFactory;               // NOLINT(misc-unused-using-decls)
91
using ::google::protobuf::MethodDescriptor;             // NOLINT(misc-unused-using-decls)
92
using ::google::protobuf::NULL_VALUE;                   // NOLINT(misc-unused-using-decls)
93
using ::google::protobuf::OneofDescriptor;              // NOLINT(misc-unused-using-decls)
94
using ::google::protobuf::Reflection;                   // NOLINT(misc-unused-using-decls)
95
using ::google::protobuf::RepeatedField;                // NOLINT(misc-unused-using-decls)
96
using ::google::protobuf::RepeatedFieldBackInserter;    // NOLINT(misc-unused-using-decls)
97
using ::google::protobuf::RepeatedPtrField;             // NOLINT(misc-unused-using-decls)
98
using ::google::protobuf::RepeatedPtrFieldBackInserter; // NOLINT(misc-unused-using-decls)
99
using ::google::protobuf::StringValue;                  // NOLINT(misc-unused-using-decls)
100
using ::google::protobuf::Struct;                       // NOLINT(misc-unused-using-decls)
101
using ::google::protobuf::TextFormat;                   // NOLINT(misc-unused-using-decls)
102
using ::google::protobuf::Timestamp;                    // NOLINT(misc-unused-using-decls)
103
using ::google::protobuf::Type;                         // NOLINT(misc-unused-using-decls)
104
using ::google::protobuf::UInt32Value;                  // NOLINT(misc-unused-using-decls)
105
using ::google::protobuf::Value;                        // NOLINT(misc-unused-using-decls)
106

            
107
using Message = ::google::protobuf::MessageLite;
108

            
109
using ReflectableMessage = std::unique_ptr<::google::protobuf::Message>;
110
using uint32 = uint32_t;
111
using int32 = int32_t;
112

            
113
namespace internal {
114
using ::google::protobuf::internal::WireFormatLite; // NOLINT(misc-unused-using-decls)
115
} // namespace internal
116

            
117
namespace io {
118
using ::google::protobuf::io::ArrayOutputStream;   // NOLINT(misc-unused-using-decls)
119
using ::google::protobuf::io::CodedInputStream;    // NOLINT(misc-unused-using-decls)
120
using ::google::protobuf::io::CodedOutputStream;   // NOLINT(misc-unused-using-decls)
121
using ::google::protobuf::io::IstreamInputStream;  // NOLINT(misc-unused-using-decls)
122
using ::google::protobuf::io::OstreamOutputStream; // NOLINT(misc-unused-using-decls)
123
using ::google::protobuf::io::StringOutputStream;  // NOLINT(misc-unused-using-decls)
124
using ::google::protobuf::io::ZeroCopyInputStream; // NOLINT(misc-unused-using-decls)
125
} // namespace io
126

            
127
namespace util {
128
using ::google::protobuf::util::JsonStringToMessage;              // NOLINT(misc-unused-using-decls)
129
using ::google::protobuf::util::MessageToJsonString;              // NOLINT(misc-unused-using-decls)
130
using ::google::protobuf::util::NewTypeResolverForDescriptorPool; // NOLINT(misc-unused-using-decls)
131
using MessageDifferencer = MessageLiteDifferencer;
132
using ::google::protobuf::util::JsonParseOptions; // NOLINT(misc-unused-using-decls)
133
using ::google::protobuf::util::JsonPrintOptions; // NOLINT(misc-unused-using-decls)
134
using ::google::protobuf::util::TimeUtil;         // NOLINT(misc-unused-using-decls)
135
} // namespace util
136

            
137
} // namespace Protobuf
138

            
139
class MessageLiteDifferencer {
140
public:
141
  // NOLINTNEXTLINE(readability-identifier-naming)
142
  static bool Equals(const Protobuf::Message& message1, const Protobuf::Message& message2);
143

            
144
  // NOLINTNEXTLINE(readability-identifier-naming)
145
  static bool Equivalent(const Protobuf::Message& message1, const Protobuf::Message& message2);
146
};
147

            
148
using ConstMessagePtrVector = std::vector<std::unique_ptr<const Protobuf::Message>>;
149

            
150
using FileDescriptorInfo = ::cc_proto_descriptor_library::internal::FileDescriptorInfo;
151
void loadFileDescriptors(const FileDescriptorInfo& file_descriptor_info);
152

            
153
} // namespace Envoy
154

            
155
#endif
156

            
157
namespace Envoy {
158

            
159
// Allows mapping from google::protobuf::util to other util libraries.
160
namespace ProtobufUtil = ::google::protobuf::util;
161

            
162
// Alternative protobuf implementations might not have the same basic types.
163
// Below we provide wrappers to facilitate remapping of the type during import.
164
namespace ProtobufTypes {
165

            
166
using MessagePtr = std::unique_ptr<Protobuf::Message>;
167
using ConstMessagePtrVector = std::vector<std::unique_ptr<const Protobuf::Message>>;
168

            
169
using Int64 = int64_t;
170

            
171
} // namespace ProtobufTypes
172

            
173
Protobuf::ReflectableMessage createReflectableMessage(const Protobuf::Message& message);
174

            
175
} // namespace Envoy