Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/any.pb.h +384 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/arena_impl.h +686 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/arenaz_sampler.h +207 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/compiler/zip_writer.h +69 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/descriptor.h +0 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/descriptor.pb.h +0 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/endian.h +198 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/extension_set.h +1561 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/generated_message_bases.h +87 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/generated_message_tctable_impl.h +553 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/implicit_weak_message.h +213 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/io/coded_stream.h +1799 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/io/gzip_stream.h +205 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/io/io_win32.h +141 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/io/package_info.h +53 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/io/printer.h +387 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/io/strtod.h +55 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/io/tokenizer.h +442 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/io/zero_copy_stream.h +260 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/io/zero_copy_stream_impl.h +336 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/io/zero_copy_stream_impl_lite.h +413 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/map_lite_test_util.h +80 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/map_test_util.h +46 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/map_test_util.inc +271 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/map_test_util_impl.h +476 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/message_unittest.inc +1131 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/metadata_lite.h +316 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/parse_context.h +1025 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/port_def.inc +928 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/reflection_ops.h +92 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/source_context.pb.h +282 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/struct.pb.h +1177 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/testing/file.h +107 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/testing/googletest.h +104 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/delimited_message_util.h +109 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/field_comparator.h +288 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/field_mask_util.h +263 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/constants.h +101 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/datapiece.h +219 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/default_value_objectwriter.h +332 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/error_listener.h +109 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/expecting_objectwriter.h +250 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/field_mask_utility.h +74 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/json_escaping.h +98 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/json_objectwriter.h +278 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/json_stream_parser.h +350 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/location_tracker.h +70 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/mock_error_listener.h +68 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/object_location_tracker.h +64 -0
- videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/object_source.h +85 -0
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/any.pb.h
ADDED
|
@@ -0,0 +1,384 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
| 2 |
+
// source: google/protobuf/any.proto
|
| 3 |
+
|
| 4 |
+
#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fany_2eproto
|
| 5 |
+
#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fany_2eproto
|
| 6 |
+
|
| 7 |
+
#include <limits>
|
| 8 |
+
#include <string>
|
| 9 |
+
|
| 10 |
+
#include <google/protobuf/port_def.inc>
|
| 11 |
+
#if PROTOBUF_VERSION < 3021000
|
| 12 |
+
#error This file was generated by a newer version of protoc which is
|
| 13 |
+
#error incompatible with your Protocol Buffer headers. Please update
|
| 14 |
+
#error your headers.
|
| 15 |
+
#endif
|
| 16 |
+
#if 3021009 < PROTOBUF_MIN_PROTOC_VERSION
|
| 17 |
+
#error This file was generated by an older version of protoc which is
|
| 18 |
+
#error incompatible with your Protocol Buffer headers. Please
|
| 19 |
+
#error regenerate this file with a newer version of protoc.
|
| 20 |
+
#endif
|
| 21 |
+
|
| 22 |
+
#include <google/protobuf/port_undef.inc>
|
| 23 |
+
#include <google/protobuf/io/coded_stream.h>
|
| 24 |
+
#include <google/protobuf/arena.h>
|
| 25 |
+
#include <google/protobuf/arenastring.h>
|
| 26 |
+
#include <google/protobuf/generated_message_util.h>
|
| 27 |
+
#include <google/protobuf/metadata_lite.h>
|
| 28 |
+
#include <google/protobuf/generated_message_reflection.h>
|
| 29 |
+
#include <google/protobuf/message.h>
|
| 30 |
+
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
|
| 31 |
+
#include <google/protobuf/extension_set.h> // IWYU pragma: export
|
| 32 |
+
#include <google/protobuf/unknown_field_set.h>
|
| 33 |
+
// @@protoc_insertion_point(includes)
|
| 34 |
+
#include <google/protobuf/port_def.inc>
|
| 35 |
+
#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fany_2eproto PROTOBUF_EXPORT
|
| 36 |
+
PROTOBUF_NAMESPACE_OPEN
|
| 37 |
+
namespace internal {
|
| 38 |
+
class AnyMetadata;
|
| 39 |
+
} // namespace internal
|
| 40 |
+
PROTOBUF_NAMESPACE_CLOSE
|
| 41 |
+
|
| 42 |
+
// Internal implementation detail -- do not use these members.
|
| 43 |
+
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fany_2eproto {
|
| 44 |
+
static const uint32_t offsets[];
|
| 45 |
+
};
|
| 46 |
+
PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fany_2eproto;
|
| 47 |
+
PROTOBUF_NAMESPACE_OPEN
|
| 48 |
+
class Any;
|
| 49 |
+
struct AnyDefaultTypeInternal;
|
| 50 |
+
PROTOBUF_EXPORT extern AnyDefaultTypeInternal _Any_default_instance_;
|
| 51 |
+
PROTOBUF_NAMESPACE_CLOSE
|
| 52 |
+
PROTOBUF_NAMESPACE_OPEN
|
| 53 |
+
template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Any* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Any>(Arena*);
|
| 54 |
+
PROTOBUF_NAMESPACE_CLOSE
|
| 55 |
+
PROTOBUF_NAMESPACE_OPEN
|
| 56 |
+
|
| 57 |
+
// ===================================================================
|
| 58 |
+
|
| 59 |
+
class PROTOBUF_EXPORT Any final :
|
| 60 |
+
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Any) */ {
|
| 61 |
+
public:
|
| 62 |
+
inline Any() : Any(nullptr) {}
|
| 63 |
+
~Any() override;
|
| 64 |
+
explicit PROTOBUF_CONSTEXPR Any(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
|
| 65 |
+
|
| 66 |
+
Any(const Any& from);
|
| 67 |
+
Any(Any&& from) noexcept
|
| 68 |
+
: Any() {
|
| 69 |
+
*this = ::std::move(from);
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
inline Any& operator=(const Any& from) {
|
| 73 |
+
CopyFrom(from);
|
| 74 |
+
return *this;
|
| 75 |
+
}
|
| 76 |
+
inline Any& operator=(Any&& from) noexcept {
|
| 77 |
+
if (this == &from) return *this;
|
| 78 |
+
if (GetOwningArena() == from.GetOwningArena()
|
| 79 |
+
#ifdef PROTOBUF_FORCE_COPY_IN_MOVE
|
| 80 |
+
&& GetOwningArena() != nullptr
|
| 81 |
+
#endif // !PROTOBUF_FORCE_COPY_IN_MOVE
|
| 82 |
+
) {
|
| 83 |
+
InternalSwap(&from);
|
| 84 |
+
} else {
|
| 85 |
+
CopyFrom(from);
|
| 86 |
+
}
|
| 87 |
+
return *this;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
|
| 91 |
+
return GetDescriptor();
|
| 92 |
+
}
|
| 93 |
+
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
|
| 94 |
+
return default_instance().GetMetadata().descriptor;
|
| 95 |
+
}
|
| 96 |
+
static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
|
| 97 |
+
return default_instance().GetMetadata().reflection;
|
| 98 |
+
}
|
| 99 |
+
static const Any& default_instance() {
|
| 100 |
+
return *internal_default_instance();
|
| 101 |
+
}
|
| 102 |
+
static inline const Any* internal_default_instance() {
|
| 103 |
+
return reinterpret_cast<const Any*>(
|
| 104 |
+
&_Any_default_instance_);
|
| 105 |
+
}
|
| 106 |
+
static constexpr int kIndexInFileMessages =
|
| 107 |
+
0;
|
| 108 |
+
|
| 109 |
+
// implements Any -----------------------------------------------
|
| 110 |
+
|
| 111 |
+
bool PackFrom(const ::PROTOBUF_NAMESPACE_ID::Message& message) {
|
| 112 |
+
GOOGLE_DCHECK_NE(&message, this);
|
| 113 |
+
return _impl_._any_metadata_.PackFrom(GetArena(), message);
|
| 114 |
+
}
|
| 115 |
+
bool PackFrom(const ::PROTOBUF_NAMESPACE_ID::Message& message,
|
| 116 |
+
::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url_prefix) {
|
| 117 |
+
GOOGLE_DCHECK_NE(&message, this);
|
| 118 |
+
return _impl_._any_metadata_.PackFrom(GetArena(), message, type_url_prefix);
|
| 119 |
+
}
|
| 120 |
+
bool UnpackTo(::PROTOBUF_NAMESPACE_ID::Message* message) const {
|
| 121 |
+
return _impl_._any_metadata_.UnpackTo(message);
|
| 122 |
+
}
|
| 123 |
+
static bool GetAnyFieldDescriptors(
|
| 124 |
+
const ::PROTOBUF_NAMESPACE_ID::Message& message,
|
| 125 |
+
const ::PROTOBUF_NAMESPACE_ID::FieldDescriptor** type_url_field,
|
| 126 |
+
const ::PROTOBUF_NAMESPACE_ID::FieldDescriptor** value_field);
|
| 127 |
+
template <typename T, class = typename std::enable_if<!std::is_convertible<T, const ::PROTOBUF_NAMESPACE_ID::Message&>::value>::type>
|
| 128 |
+
bool PackFrom(const T& message) {
|
| 129 |
+
return _impl_._any_metadata_.PackFrom<T>(GetArena(), message);
|
| 130 |
+
}
|
| 131 |
+
template <typename T, class = typename std::enable_if<!std::is_convertible<T, const ::PROTOBUF_NAMESPACE_ID::Message&>::value>::type>
|
| 132 |
+
bool PackFrom(const T& message,
|
| 133 |
+
::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url_prefix) {
|
| 134 |
+
return _impl_._any_metadata_.PackFrom<T>(GetArena(), message, type_url_prefix);}
|
| 135 |
+
template <typename T, class = typename std::enable_if<!std::is_convertible<T, const ::PROTOBUF_NAMESPACE_ID::Message&>::value>::type>
|
| 136 |
+
bool UnpackTo(T* message) const {
|
| 137 |
+
return _impl_._any_metadata_.UnpackTo<T>(message);
|
| 138 |
+
}
|
| 139 |
+
template<typename T> bool Is() const {
|
| 140 |
+
return _impl_._any_metadata_.Is<T>();
|
| 141 |
+
}
|
| 142 |
+
static bool ParseAnyTypeUrl(::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url,
|
| 143 |
+
std::string* full_type_name);
|
| 144 |
+
friend void swap(Any& a, Any& b) {
|
| 145 |
+
a.Swap(&b);
|
| 146 |
+
}
|
| 147 |
+
inline void Swap(Any* other) {
|
| 148 |
+
if (other == this) return;
|
| 149 |
+
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
|
| 150 |
+
if (GetOwningArena() != nullptr &&
|
| 151 |
+
GetOwningArena() == other->GetOwningArena()) {
|
| 152 |
+
#else // PROTOBUF_FORCE_COPY_IN_SWAP
|
| 153 |
+
if (GetOwningArena() == other->GetOwningArena()) {
|
| 154 |
+
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
|
| 155 |
+
InternalSwap(other);
|
| 156 |
+
} else {
|
| 157 |
+
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
void UnsafeArenaSwap(Any* other) {
|
| 161 |
+
if (other == this) return;
|
| 162 |
+
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
|
| 163 |
+
InternalSwap(other);
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
// implements Message ----------------------------------------------
|
| 167 |
+
|
| 168 |
+
Any* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final {
|
| 169 |
+
return CreateMaybeMessage<Any>(arena);
|
| 170 |
+
}
|
| 171 |
+
using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom;
|
| 172 |
+
void CopyFrom(const Any& from);
|
| 173 |
+
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
|
| 174 |
+
void MergeFrom( const Any& from) {
|
| 175 |
+
Any::MergeImpl(*this, from);
|
| 176 |
+
}
|
| 177 |
+
private:
|
| 178 |
+
static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg);
|
| 179 |
+
public:
|
| 180 |
+
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
|
| 181 |
+
bool IsInitialized() const final;
|
| 182 |
+
|
| 183 |
+
size_t ByteSizeLong() const final;
|
| 184 |
+
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
|
| 185 |
+
uint8_t* _InternalSerialize(
|
| 186 |
+
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
|
| 187 |
+
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
|
| 188 |
+
|
| 189 |
+
private:
|
| 190 |
+
void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
|
| 191 |
+
void SharedDtor();
|
| 192 |
+
void SetCachedSize(int size) const final;
|
| 193 |
+
void InternalSwap(Any* other);
|
| 194 |
+
|
| 195 |
+
private:
|
| 196 |
+
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
|
| 197 |
+
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
|
| 198 |
+
return "google.protobuf.Any";
|
| 199 |
+
}
|
| 200 |
+
protected:
|
| 201 |
+
explicit Any(::PROTOBUF_NAMESPACE_ID::Arena* arena,
|
| 202 |
+
bool is_message_owned = false);
|
| 203 |
+
public:
|
| 204 |
+
|
| 205 |
+
static const ClassData _class_data_;
|
| 206 |
+
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final;
|
| 207 |
+
|
| 208 |
+
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
|
| 209 |
+
|
| 210 |
+
// nested types ----------------------------------------------------
|
| 211 |
+
|
| 212 |
+
// accessors -------------------------------------------------------
|
| 213 |
+
|
| 214 |
+
enum : int {
|
| 215 |
+
kTypeUrlFieldNumber = 1,
|
| 216 |
+
kValueFieldNumber = 2,
|
| 217 |
+
};
|
| 218 |
+
// string type_url = 1;
|
| 219 |
+
void clear_type_url();
|
| 220 |
+
const std::string& type_url() const;
|
| 221 |
+
template <typename ArgT0 = const std::string&, typename... ArgT>
|
| 222 |
+
void set_type_url(ArgT0&& arg0, ArgT... args);
|
| 223 |
+
std::string* mutable_type_url();
|
| 224 |
+
PROTOBUF_NODISCARD std::string* release_type_url();
|
| 225 |
+
void set_allocated_type_url(std::string* type_url);
|
| 226 |
+
private:
|
| 227 |
+
const std::string& _internal_type_url() const;
|
| 228 |
+
inline PROTOBUF_ALWAYS_INLINE void _internal_set_type_url(const std::string& value);
|
| 229 |
+
std::string* _internal_mutable_type_url();
|
| 230 |
+
public:
|
| 231 |
+
|
| 232 |
+
// bytes value = 2;
|
| 233 |
+
void clear_value();
|
| 234 |
+
const std::string& value() const;
|
| 235 |
+
template <typename ArgT0 = const std::string&, typename... ArgT>
|
| 236 |
+
void set_value(ArgT0&& arg0, ArgT... args);
|
| 237 |
+
std::string* mutable_value();
|
| 238 |
+
PROTOBUF_NODISCARD std::string* release_value();
|
| 239 |
+
void set_allocated_value(std::string* value);
|
| 240 |
+
private:
|
| 241 |
+
const std::string& _internal_value() const;
|
| 242 |
+
inline PROTOBUF_ALWAYS_INLINE void _internal_set_value(const std::string& value);
|
| 243 |
+
std::string* _internal_mutable_value();
|
| 244 |
+
public:
|
| 245 |
+
|
| 246 |
+
// @@protoc_insertion_point(class_scope:google.protobuf.Any)
|
| 247 |
+
private:
|
| 248 |
+
class _Internal;
|
| 249 |
+
|
| 250 |
+
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
|
| 251 |
+
typedef void InternalArenaConstructable_;
|
| 252 |
+
typedef void DestructorSkippable_;
|
| 253 |
+
struct Impl_ {
|
| 254 |
+
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr type_url_;
|
| 255 |
+
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr value_;
|
| 256 |
+
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
|
| 257 |
+
::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata _any_metadata_;
|
| 258 |
+
};
|
| 259 |
+
union { Impl_ _impl_; };
|
| 260 |
+
friend struct ::TableStruct_google_2fprotobuf_2fany_2eproto;
|
| 261 |
+
};
|
| 262 |
+
// ===================================================================
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
// ===================================================================
|
| 266 |
+
|
| 267 |
+
#ifdef __GNUC__
|
| 268 |
+
#pragma GCC diagnostic push
|
| 269 |
+
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
| 270 |
+
#endif // __GNUC__
|
| 271 |
+
// Any
|
| 272 |
+
|
| 273 |
+
// string type_url = 1;
|
| 274 |
+
inline void Any::clear_type_url() {
|
| 275 |
+
_impl_.type_url_.ClearToEmpty();
|
| 276 |
+
}
|
| 277 |
+
inline const std::string& Any::type_url() const {
|
| 278 |
+
// @@protoc_insertion_point(field_get:google.protobuf.Any.type_url)
|
| 279 |
+
return _internal_type_url();
|
| 280 |
+
}
|
| 281 |
+
template <typename ArgT0, typename... ArgT>
|
| 282 |
+
inline PROTOBUF_ALWAYS_INLINE
|
| 283 |
+
void Any::set_type_url(ArgT0&& arg0, ArgT... args) {
|
| 284 |
+
|
| 285 |
+
_impl_.type_url_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
|
| 286 |
+
// @@protoc_insertion_point(field_set:google.protobuf.Any.type_url)
|
| 287 |
+
}
|
| 288 |
+
inline std::string* Any::mutable_type_url() {
|
| 289 |
+
std::string* _s = _internal_mutable_type_url();
|
| 290 |
+
// @@protoc_insertion_point(field_mutable:google.protobuf.Any.type_url)
|
| 291 |
+
return _s;
|
| 292 |
+
}
|
| 293 |
+
inline const std::string& Any::_internal_type_url() const {
|
| 294 |
+
return _impl_.type_url_.Get();
|
| 295 |
+
}
|
| 296 |
+
inline void Any::_internal_set_type_url(const std::string& value) {
|
| 297 |
+
|
| 298 |
+
_impl_.type_url_.Set(value, GetArenaForAllocation());
|
| 299 |
+
}
|
| 300 |
+
inline std::string* Any::_internal_mutable_type_url() {
|
| 301 |
+
|
| 302 |
+
return _impl_.type_url_.Mutable(GetArenaForAllocation());
|
| 303 |
+
}
|
| 304 |
+
inline std::string* Any::release_type_url() {
|
| 305 |
+
// @@protoc_insertion_point(field_release:google.protobuf.Any.type_url)
|
| 306 |
+
return _impl_.type_url_.Release();
|
| 307 |
+
}
|
| 308 |
+
inline void Any::set_allocated_type_url(std::string* type_url) {
|
| 309 |
+
if (type_url != nullptr) {
|
| 310 |
+
|
| 311 |
+
} else {
|
| 312 |
+
|
| 313 |
+
}
|
| 314 |
+
_impl_.type_url_.SetAllocated(type_url, GetArenaForAllocation());
|
| 315 |
+
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
| 316 |
+
if (_impl_.type_url_.IsDefault()) {
|
| 317 |
+
_impl_.type_url_.Set("", GetArenaForAllocation());
|
| 318 |
+
}
|
| 319 |
+
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
| 320 |
+
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url)
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
// bytes value = 2;
|
| 324 |
+
inline void Any::clear_value() {
|
| 325 |
+
_impl_.value_.ClearToEmpty();
|
| 326 |
+
}
|
| 327 |
+
inline const std::string& Any::value() const {
|
| 328 |
+
// @@protoc_insertion_point(field_get:google.protobuf.Any.value)
|
| 329 |
+
return _internal_value();
|
| 330 |
+
}
|
| 331 |
+
template <typename ArgT0, typename... ArgT>
|
| 332 |
+
inline PROTOBUF_ALWAYS_INLINE
|
| 333 |
+
void Any::set_value(ArgT0&& arg0, ArgT... args) {
|
| 334 |
+
|
| 335 |
+
_impl_.value_.SetBytes(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
|
| 336 |
+
// @@protoc_insertion_point(field_set:google.protobuf.Any.value)
|
| 337 |
+
}
|
| 338 |
+
inline std::string* Any::mutable_value() {
|
| 339 |
+
std::string* _s = _internal_mutable_value();
|
| 340 |
+
// @@protoc_insertion_point(field_mutable:google.protobuf.Any.value)
|
| 341 |
+
return _s;
|
| 342 |
+
}
|
| 343 |
+
inline const std::string& Any::_internal_value() const {
|
| 344 |
+
return _impl_.value_.Get();
|
| 345 |
+
}
|
| 346 |
+
inline void Any::_internal_set_value(const std::string& value) {
|
| 347 |
+
|
| 348 |
+
_impl_.value_.Set(value, GetArenaForAllocation());
|
| 349 |
+
}
|
| 350 |
+
inline std::string* Any::_internal_mutable_value() {
|
| 351 |
+
|
| 352 |
+
return _impl_.value_.Mutable(GetArenaForAllocation());
|
| 353 |
+
}
|
| 354 |
+
inline std::string* Any::release_value() {
|
| 355 |
+
// @@protoc_insertion_point(field_release:google.protobuf.Any.value)
|
| 356 |
+
return _impl_.value_.Release();
|
| 357 |
+
}
|
| 358 |
+
inline void Any::set_allocated_value(std::string* value) {
|
| 359 |
+
if (value != nullptr) {
|
| 360 |
+
|
| 361 |
+
} else {
|
| 362 |
+
|
| 363 |
+
}
|
| 364 |
+
_impl_.value_.SetAllocated(value, GetArenaForAllocation());
|
| 365 |
+
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
| 366 |
+
if (_impl_.value_.IsDefault()) {
|
| 367 |
+
_impl_.value_.Set("", GetArenaForAllocation());
|
| 368 |
+
}
|
| 369 |
+
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
| 370 |
+
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value)
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
#ifdef __GNUC__
|
| 374 |
+
#pragma GCC diagnostic pop
|
| 375 |
+
#endif // __GNUC__
|
| 376 |
+
|
| 377 |
+
// @@protoc_insertion_point(namespace_scope)
|
| 378 |
+
|
| 379 |
+
PROTOBUF_NAMESPACE_CLOSE
|
| 380 |
+
|
| 381 |
+
// @@protoc_insertion_point(global_scope)
|
| 382 |
+
|
| 383 |
+
#include <google/protobuf/port_undef.inc>
|
| 384 |
+
#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fany_2eproto
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/arena_impl.h
ADDED
|
@@ -0,0 +1,686 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// This file defines an Arena allocator for better allocation performance.
|
| 32 |
+
|
| 33 |
+
#ifndef GOOGLE_PROTOBUF_ARENA_IMPL_H__
|
| 34 |
+
#define GOOGLE_PROTOBUF_ARENA_IMPL_H__
|
| 35 |
+
|
| 36 |
+
#include <atomic>
|
| 37 |
+
#include <limits>
|
| 38 |
+
#include <typeinfo>
|
| 39 |
+
|
| 40 |
+
#include <google/protobuf/stubs/common.h>
|
| 41 |
+
#include <google/protobuf/stubs/logging.h>
|
| 42 |
+
#include <google/protobuf/stubs/port.h>
|
| 43 |
+
|
| 44 |
+
#ifdef ADDRESS_SANITIZER
|
| 45 |
+
#include <sanitizer/asan_interface.h>
|
| 46 |
+
#endif // ADDRESS_SANITIZER
|
| 47 |
+
|
| 48 |
+
#include <google/protobuf/arenaz_sampler.h>
|
| 49 |
+
|
| 50 |
+
// Must be included last.
|
| 51 |
+
#include <google/protobuf/port_def.inc>
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
namespace google {
|
| 55 |
+
namespace protobuf {
|
| 56 |
+
namespace internal {
|
| 57 |
+
|
| 58 |
+
// To prevent sharing cache lines between threads
|
| 59 |
+
#ifdef __cpp_aligned_new
|
| 60 |
+
enum { kCacheAlignment = 64 };
|
| 61 |
+
#else
|
| 62 |
+
enum { kCacheAlignment = alignof(max_align_t) }; // do the best we can
|
| 63 |
+
#endif
|
| 64 |
+
|
| 65 |
+
inline constexpr size_t AlignUpTo8(size_t n) {
|
| 66 |
+
// Align n to next multiple of 8 (from Hacker's Delight, Chapter 3.)
|
| 67 |
+
return (n + 7) & static_cast<size_t>(-8);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
using LifecycleIdAtomic = uint64_t;
|
| 71 |
+
|
| 72 |
+
// MetricsCollector collects stats for a particular arena.
|
| 73 |
+
class PROTOBUF_EXPORT ArenaMetricsCollector {
|
| 74 |
+
public:
|
| 75 |
+
ArenaMetricsCollector(bool record_allocs) : record_allocs_(record_allocs) {}
|
| 76 |
+
|
| 77 |
+
// Invoked when the arena is about to be destroyed. This method will
|
| 78 |
+
// typically finalize any metric collection and delete the collector.
|
| 79 |
+
// space_allocated is the space used by the arena.
|
| 80 |
+
virtual void OnDestroy(uint64_t space_allocated) = 0;
|
| 81 |
+
|
| 82 |
+
// OnReset() is called when the associated arena is reset.
|
| 83 |
+
// space_allocated is the space used by the arena just before the reset.
|
| 84 |
+
virtual void OnReset(uint64_t space_allocated) = 0;
|
| 85 |
+
|
| 86 |
+
// OnAlloc is called when an allocation happens.
|
| 87 |
+
// type_info is promised to be static - its lifetime extends to
|
| 88 |
+
// match program's lifetime (It is given by typeid operator).
|
| 89 |
+
// Note: typeid(void) will be passed as allocated_type every time we
|
| 90 |
+
// intentionally want to avoid monitoring an allocation. (i.e. internal
|
| 91 |
+
// allocations for managing the arena)
|
| 92 |
+
virtual void OnAlloc(const std::type_info* allocated_type,
|
| 93 |
+
uint64_t alloc_size) = 0;
|
| 94 |
+
|
| 95 |
+
// Does OnAlloc() need to be called? If false, metric collection overhead
|
| 96 |
+
// will be reduced since we will not do extra work per allocation.
|
| 97 |
+
bool RecordAllocs() { return record_allocs_; }
|
| 98 |
+
|
| 99 |
+
protected:
|
| 100 |
+
// This class is destructed by the call to OnDestroy().
|
| 101 |
+
~ArenaMetricsCollector() = default;
|
| 102 |
+
const bool record_allocs_;
|
| 103 |
+
};
|
| 104 |
+
|
| 105 |
+
struct AllocationPolicy {
|
| 106 |
+
static constexpr size_t kDefaultStartBlockSize = 256;
|
| 107 |
+
static constexpr size_t kDefaultMaxBlockSize = 8192;
|
| 108 |
+
|
| 109 |
+
size_t start_block_size = kDefaultStartBlockSize;
|
| 110 |
+
size_t max_block_size = kDefaultMaxBlockSize;
|
| 111 |
+
void* (*block_alloc)(size_t) = nullptr;
|
| 112 |
+
void (*block_dealloc)(void*, size_t) = nullptr;
|
| 113 |
+
ArenaMetricsCollector* metrics_collector = nullptr;
|
| 114 |
+
|
| 115 |
+
bool IsDefault() const {
|
| 116 |
+
return start_block_size == kDefaultMaxBlockSize &&
|
| 117 |
+
max_block_size == kDefaultMaxBlockSize && block_alloc == nullptr &&
|
| 118 |
+
block_dealloc == nullptr && metrics_collector == nullptr;
|
| 119 |
+
}
|
| 120 |
+
};
|
| 121 |
+
|
| 122 |
+
// Tagged pointer to an AllocationPolicy.
|
| 123 |
+
class TaggedAllocationPolicyPtr {
|
| 124 |
+
public:
|
| 125 |
+
constexpr TaggedAllocationPolicyPtr() : policy_(0) {}
|
| 126 |
+
|
| 127 |
+
explicit TaggedAllocationPolicyPtr(AllocationPolicy* policy)
|
| 128 |
+
: policy_(reinterpret_cast<uintptr_t>(policy)) {}
|
| 129 |
+
|
| 130 |
+
void set_policy(AllocationPolicy* policy) {
|
| 131 |
+
auto bits = policy_ & kTagsMask;
|
| 132 |
+
policy_ = reinterpret_cast<uintptr_t>(policy) | bits;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
AllocationPolicy* get() {
|
| 136 |
+
return reinterpret_cast<AllocationPolicy*>(policy_ & kPtrMask);
|
| 137 |
+
}
|
| 138 |
+
const AllocationPolicy* get() const {
|
| 139 |
+
return reinterpret_cast<const AllocationPolicy*>(policy_ & kPtrMask);
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
AllocationPolicy& operator*() { return *get(); }
|
| 143 |
+
const AllocationPolicy& operator*() const { return *get(); }
|
| 144 |
+
|
| 145 |
+
AllocationPolicy* operator->() { return get(); }
|
| 146 |
+
const AllocationPolicy* operator->() const { return get(); }
|
| 147 |
+
|
| 148 |
+
bool is_user_owned_initial_block() const {
|
| 149 |
+
return static_cast<bool>(get_mask<kUserOwnedInitialBlock>());
|
| 150 |
+
}
|
| 151 |
+
void set_is_user_owned_initial_block(bool v) {
|
| 152 |
+
set_mask<kUserOwnedInitialBlock>(v);
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
bool should_record_allocs() const {
|
| 156 |
+
return static_cast<bool>(get_mask<kRecordAllocs>());
|
| 157 |
+
}
|
| 158 |
+
void set_should_record_allocs(bool v) { set_mask<kRecordAllocs>(v); }
|
| 159 |
+
|
| 160 |
+
uintptr_t get_raw() const { return policy_; }
|
| 161 |
+
|
| 162 |
+
inline void RecordAlloc(const std::type_info* allocated_type,
|
| 163 |
+
size_t n) const {
|
| 164 |
+
get()->metrics_collector->OnAlloc(allocated_type, n);
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
private:
|
| 168 |
+
enum : uintptr_t {
|
| 169 |
+
kUserOwnedInitialBlock = 1,
|
| 170 |
+
kRecordAllocs = 2,
|
| 171 |
+
};
|
| 172 |
+
|
| 173 |
+
static constexpr uintptr_t kTagsMask = 7;
|
| 174 |
+
static constexpr uintptr_t kPtrMask = ~kTagsMask;
|
| 175 |
+
|
| 176 |
+
template <uintptr_t kMask>
|
| 177 |
+
uintptr_t get_mask() const {
|
| 178 |
+
return policy_ & kMask;
|
| 179 |
+
}
|
| 180 |
+
template <uintptr_t kMask>
|
| 181 |
+
void set_mask(bool v) {
|
| 182 |
+
if (v) {
|
| 183 |
+
policy_ |= kMask;
|
| 184 |
+
} else {
|
| 185 |
+
policy_ &= ~kMask;
|
| 186 |
+
}
|
| 187 |
+
}
|
| 188 |
+
uintptr_t policy_;
|
| 189 |
+
};
|
| 190 |
+
|
| 191 |
+
enum class AllocationClient { kDefault, kArray };
|
| 192 |
+
|
| 193 |
+
// A simple arena allocator. Calls to allocate functions must be properly
|
| 194 |
+
// serialized by the caller, hence this class cannot be used as a general
|
| 195 |
+
// purpose allocator in a multi-threaded program. It serves as a building block
|
| 196 |
+
// for ThreadSafeArena, which provides a thread-safe arena allocator.
|
| 197 |
+
//
|
| 198 |
+
// This class manages
|
| 199 |
+
// 1) Arena bump allocation + owning memory blocks.
|
| 200 |
+
// 2) Maintaining a cleanup list.
|
| 201 |
+
// It delagetes the actual memory allocation back to ThreadSafeArena, which
|
| 202 |
+
// contains the information on block growth policy and backing memory allocation
|
| 203 |
+
// used.
|
| 204 |
+
class PROTOBUF_EXPORT SerialArena {
|
| 205 |
+
public:
|
| 206 |
+
struct Memory {
|
| 207 |
+
void* ptr;
|
| 208 |
+
size_t size;
|
| 209 |
+
};
|
| 210 |
+
|
| 211 |
+
// Node contains the ptr of the object to be cleaned up and the associated
|
| 212 |
+
// cleanup function ptr.
|
| 213 |
+
struct CleanupNode {
|
| 214 |
+
void* elem; // Pointer to the object to be cleaned up.
|
| 215 |
+
void (*cleanup)(void*); // Function pointer to the destructor or deleter.
|
| 216 |
+
};
|
| 217 |
+
|
| 218 |
+
void CleanupList();
|
| 219 |
+
uint64_t SpaceAllocated() const {
|
| 220 |
+
return space_allocated_.load(std::memory_order_relaxed);
|
| 221 |
+
}
|
| 222 |
+
uint64_t SpaceUsed() const;
|
| 223 |
+
|
| 224 |
+
bool HasSpace(size_t n) const {
|
| 225 |
+
return n <= static_cast<size_t>(limit_ - ptr_);
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
// See comments on `cached_blocks_` member for details.
|
| 229 |
+
PROTOBUF_ALWAYS_INLINE void* TryAllocateFromCachedBlock(size_t size) {
|
| 230 |
+
if (PROTOBUF_PREDICT_FALSE(size < 16)) return nullptr;
|
| 231 |
+
// We round up to the next larger block in case the memory doesn't match
|
| 232 |
+
// the pattern we are looking for.
|
| 233 |
+
const size_t index = Bits::Log2FloorNonZero64(size - 1) - 3;
|
| 234 |
+
|
| 235 |
+
if (index >= cached_block_length_) return nullptr;
|
| 236 |
+
auto& cached_head = cached_blocks_[index];
|
| 237 |
+
if (cached_head == nullptr) return nullptr;
|
| 238 |
+
|
| 239 |
+
void* ret = cached_head;
|
| 240 |
+
#ifdef ADDRESS_SANITIZER
|
| 241 |
+
ASAN_UNPOISON_MEMORY_REGION(ret, size);
|
| 242 |
+
#endif // ADDRESS_SANITIZER
|
| 243 |
+
cached_head = cached_head->next;
|
| 244 |
+
return ret;
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
// In kArray mode we look through cached blocks.
|
| 248 |
+
// We do not do this by default because most non-array allocations will not
|
| 249 |
+
// have the right size and will fail to find an appropriate cached block.
|
| 250 |
+
//
|
| 251 |
+
// TODO(sbenza): Evaluate if we should use cached blocks for message types of
|
| 252 |
+
// the right size. We can statically know if the allocation size can benefit
|
| 253 |
+
// from it.
|
| 254 |
+
template <AllocationClient alloc_client = AllocationClient::kDefault>
|
| 255 |
+
void* AllocateAligned(size_t n, const AllocationPolicy* policy) {
|
| 256 |
+
GOOGLE_DCHECK_EQ(internal::AlignUpTo8(n), n); // Must be already aligned.
|
| 257 |
+
GOOGLE_DCHECK_GE(limit_, ptr_);
|
| 258 |
+
|
| 259 |
+
if (alloc_client == AllocationClient::kArray) {
|
| 260 |
+
if (void* res = TryAllocateFromCachedBlock(n)) {
|
| 261 |
+
return res;
|
| 262 |
+
}
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
if (PROTOBUF_PREDICT_FALSE(!HasSpace(n))) {
|
| 266 |
+
return AllocateAlignedFallback(n, policy);
|
| 267 |
+
}
|
| 268 |
+
return AllocateFromExisting(n);
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
private:
|
| 272 |
+
void* AllocateFromExisting(size_t n) {
|
| 273 |
+
void* ret = ptr_;
|
| 274 |
+
ptr_ += n;
|
| 275 |
+
#ifdef ADDRESS_SANITIZER
|
| 276 |
+
ASAN_UNPOISON_MEMORY_REGION(ret, n);
|
| 277 |
+
#endif // ADDRESS_SANITIZER
|
| 278 |
+
return ret;
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
// See comments on `cached_blocks_` member for details.
|
| 282 |
+
void ReturnArrayMemory(void* p, size_t size) {
|
| 283 |
+
// We only need to check for 32-bit platforms.
|
| 284 |
+
// In 64-bit platforms the minimum allocation size from Repeated*Field will
|
| 285 |
+
// be 16 guaranteed.
|
| 286 |
+
if (sizeof(void*) < 8) {
|
| 287 |
+
if (PROTOBUF_PREDICT_FALSE(size < 16)) return;
|
| 288 |
+
} else {
|
| 289 |
+
GOOGLE_DCHECK(size >= 16);
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
// We round down to the next smaller block in case the memory doesn't match
|
| 293 |
+
// the pattern we are looking for. eg, someone might have called Reserve()
|
| 294 |
+
// on the repeated field.
|
| 295 |
+
const size_t index = Bits::Log2FloorNonZero64(size) - 4;
|
| 296 |
+
|
| 297 |
+
if (PROTOBUF_PREDICT_FALSE(index >= cached_block_length_)) {
|
| 298 |
+
// We can't put this object on the freelist so make this object the
|
| 299 |
+
// freelist. It is guaranteed it is larger than the one we have, and
|
| 300 |
+
// large enough to hold another allocation of `size`.
|
| 301 |
+
CachedBlock** new_list = static_cast<CachedBlock**>(p);
|
| 302 |
+
size_t new_size = size / sizeof(CachedBlock*);
|
| 303 |
+
|
| 304 |
+
std::copy(cached_blocks_, cached_blocks_ + cached_block_length_,
|
| 305 |
+
new_list);
|
| 306 |
+
std::fill(new_list + cached_block_length_, new_list + new_size, nullptr);
|
| 307 |
+
cached_blocks_ = new_list;
|
| 308 |
+
// Make the size fit in uint8_t. This is the power of two, so we don't
|
| 309 |
+
// need anything larger.
|
| 310 |
+
cached_block_length_ =
|
| 311 |
+
static_cast<uint8_t>(std::min(size_t{64}, new_size));
|
| 312 |
+
|
| 313 |
+
return;
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
auto& cached_head = cached_blocks_[index];
|
| 317 |
+
auto* new_node = static_cast<CachedBlock*>(p);
|
| 318 |
+
new_node->next = cached_head;
|
| 319 |
+
cached_head = new_node;
|
| 320 |
+
#ifdef ADDRESS_SANITIZER
|
| 321 |
+
ASAN_POISON_MEMORY_REGION(p, size);
|
| 322 |
+
#endif // ADDRESS_SANITIZER
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
public:
|
| 326 |
+
// Allocate space if the current region provides enough space.
|
| 327 |
+
bool MaybeAllocateAligned(size_t n, void** out) {
|
| 328 |
+
GOOGLE_DCHECK_EQ(internal::AlignUpTo8(n), n); // Must be already aligned.
|
| 329 |
+
GOOGLE_DCHECK_GE(limit_, ptr_);
|
| 330 |
+
if (PROTOBUF_PREDICT_FALSE(!HasSpace(n))) return false;
|
| 331 |
+
*out = AllocateFromExisting(n);
|
| 332 |
+
return true;
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
std::pair<void*, CleanupNode*> AllocateAlignedWithCleanup(
|
| 336 |
+
size_t n, const AllocationPolicy* policy) {
|
| 337 |
+
GOOGLE_DCHECK_EQ(internal::AlignUpTo8(n), n); // Must be already aligned.
|
| 338 |
+
if (PROTOBUF_PREDICT_FALSE(!HasSpace(n + kCleanupSize))) {
|
| 339 |
+
return AllocateAlignedWithCleanupFallback(n, policy);
|
| 340 |
+
}
|
| 341 |
+
return AllocateFromExistingWithCleanupFallback(n);
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
private:
|
| 345 |
+
std::pair<void*, CleanupNode*> AllocateFromExistingWithCleanupFallback(
|
| 346 |
+
size_t n) {
|
| 347 |
+
void* ret = ptr_;
|
| 348 |
+
ptr_ += n;
|
| 349 |
+
limit_ -= kCleanupSize;
|
| 350 |
+
#ifdef ADDRESS_SANITIZER
|
| 351 |
+
ASAN_UNPOISON_MEMORY_REGION(ret, n);
|
| 352 |
+
ASAN_UNPOISON_MEMORY_REGION(limit_, kCleanupSize);
|
| 353 |
+
#endif // ADDRESS_SANITIZER
|
| 354 |
+
return CreatePair(ret, reinterpret_cast<CleanupNode*>(limit_));
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
public:
|
| 358 |
+
void AddCleanup(void* elem, void (*cleanup)(void*),
|
| 359 |
+
const AllocationPolicy* policy) {
|
| 360 |
+
auto res = AllocateAlignedWithCleanup(0, policy);
|
| 361 |
+
res.second->elem = elem;
|
| 362 |
+
res.second->cleanup = cleanup;
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
void* owner() const { return owner_; }
|
| 366 |
+
SerialArena* next() const { return next_; }
|
| 367 |
+
void set_next(SerialArena* next) { next_ = next; }
|
| 368 |
+
|
| 369 |
+
private:
|
| 370 |
+
friend class ThreadSafeArena;
|
| 371 |
+
friend class ArenaBenchmark;
|
| 372 |
+
|
| 373 |
+
// Creates a new SerialArena inside mem using the remaining memory as for
|
| 374 |
+
// future allocations.
|
| 375 |
+
static SerialArena* New(SerialArena::Memory mem, void* owner,
|
| 376 |
+
ThreadSafeArenaStats* stats);
|
| 377 |
+
// Free SerialArena returning the memory passed in to New
|
| 378 |
+
template <typename Deallocator>
|
| 379 |
+
Memory Free(Deallocator deallocator);
|
| 380 |
+
|
| 381 |
+
// Blocks are variable length malloc-ed objects. The following structure
|
| 382 |
+
// describes the common header for all blocks.
|
| 383 |
+
struct Block {
|
| 384 |
+
Block(Block* next, size_t size) : next(next), size(size), start(nullptr) {}
|
| 385 |
+
|
| 386 |
+
char* Pointer(size_t n) {
|
| 387 |
+
GOOGLE_DCHECK(n <= size);
|
| 388 |
+
return reinterpret_cast<char*>(this) + n;
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
Block* const next;
|
| 392 |
+
const size_t size;
|
| 393 |
+
CleanupNode* start;
|
| 394 |
+
// data follows
|
| 395 |
+
};
|
| 396 |
+
|
| 397 |
+
void* owner_; // &ThreadCache of this thread;
|
| 398 |
+
Block* head_; // Head of linked list of blocks.
|
| 399 |
+
SerialArena* next_; // Next SerialArena in this linked list.
|
| 400 |
+
size_t space_used_ = 0; // Necessary for metrics.
|
| 401 |
+
std::atomic<size_t> space_allocated_;
|
| 402 |
+
|
| 403 |
+
// Next pointer to allocate from. Always 8-byte aligned. Points inside
|
| 404 |
+
// head_ (and head_->pos will always be non-canonical). We keep these
|
| 405 |
+
// here to reduce indirection.
|
| 406 |
+
char* ptr_;
|
| 407 |
+
// Limiting address up to which memory can be allocated from the head block.
|
| 408 |
+
char* limit_;
|
| 409 |
+
// For holding sampling information. The pointer is owned by the
|
| 410 |
+
// ThreadSafeArena that holds this serial arena.
|
| 411 |
+
ThreadSafeArenaStats* arena_stats_;
|
| 412 |
+
|
| 413 |
+
// Repeated*Field and Arena play together to reduce memory consumption by
|
| 414 |
+
// reusing blocks. Currently, natural growth of the repeated field types makes
|
| 415 |
+
// them allocate blocks of size `8 + 2^N, N>=3`.
|
| 416 |
+
// When the repeated field grows returns the previous block and we put it in
|
| 417 |
+
// this free list.
|
| 418 |
+
// `cached_blocks_[i]` points to the free list for blocks of size `8+2^(i+3)`.
|
| 419 |
+
// The array of freelists is grown when needed in `ReturnArrayMemory()`.
|
| 420 |
+
struct CachedBlock {
|
| 421 |
+
// Simple linked list.
|
| 422 |
+
CachedBlock* next;
|
| 423 |
+
};
|
| 424 |
+
uint8_t cached_block_length_ = 0;
|
| 425 |
+
CachedBlock** cached_blocks_ = nullptr;
|
| 426 |
+
|
| 427 |
+
// Constructor is private as only New() should be used.
|
| 428 |
+
inline SerialArena(Block* b, void* owner, ThreadSafeArenaStats* stats);
|
| 429 |
+
void* AllocateAlignedFallback(size_t n, const AllocationPolicy* policy);
|
| 430 |
+
std::pair<void*, CleanupNode*> AllocateAlignedWithCleanupFallback(
|
| 431 |
+
size_t n, const AllocationPolicy* policy);
|
| 432 |
+
void AllocateNewBlock(size_t n, const AllocationPolicy* policy);
|
| 433 |
+
|
| 434 |
+
std::pair<void*, CleanupNode*> CreatePair(void* ptr, CleanupNode* node) {
|
| 435 |
+
return {ptr, node};
|
| 436 |
+
}
|
| 437 |
+
|
| 438 |
+
public:
|
| 439 |
+
static constexpr size_t kBlockHeaderSize = AlignUpTo8(sizeof(Block));
|
| 440 |
+
static constexpr size_t kCleanupSize = AlignUpTo8(sizeof(CleanupNode));
|
| 441 |
+
};
|
| 442 |
+
|
| 443 |
+
// Tag type used to invoke the constructor of message-owned arena.
|
| 444 |
+
// Only message-owned arenas use this constructor for creation.
|
| 445 |
+
// Such constructors are internal implementation details of the library.
|
| 446 |
+
struct MessageOwned {
|
| 447 |
+
explicit MessageOwned() = default;
|
| 448 |
+
};
|
| 449 |
+
|
| 450 |
+
// This class provides the core Arena memory allocation library. Different
|
| 451 |
+
// implementations only need to implement the public interface below.
|
| 452 |
+
// Arena is not a template type as that would only be useful if all protos
|
| 453 |
+
// in turn would be templates, which will/cannot happen. However separating
|
| 454 |
+
// the memory allocation part from the cruft of the API users expect we can
|
| 455 |
+
// use #ifdef the select the best implementation based on hardware / OS.
|
| 456 |
+
class PROTOBUF_EXPORT ThreadSafeArena {
|
| 457 |
+
public:
|
| 458 |
+
ThreadSafeArena() { Init(); }
|
| 459 |
+
|
| 460 |
+
// Constructor solely used by message-owned arena.
|
| 461 |
+
ThreadSafeArena(internal::MessageOwned) : tag_and_id_(kMessageOwnedArena) {
|
| 462 |
+
Init();
|
| 463 |
+
}
|
| 464 |
+
|
| 465 |
+
ThreadSafeArena(char* mem, size_t size) { InitializeFrom(mem, size); }
|
| 466 |
+
|
| 467 |
+
explicit ThreadSafeArena(void* mem, size_t size,
|
| 468 |
+
const AllocationPolicy& policy) {
|
| 469 |
+
InitializeWithPolicy(mem, size, policy);
|
| 470 |
+
}
|
| 471 |
+
|
| 472 |
+
// Destructor deletes all owned heap allocated objects, and destructs objects
|
| 473 |
+
// that have non-trivial destructors, except for proto2 message objects whose
|
| 474 |
+
// destructors can be skipped. Also, frees all blocks except the initial block
|
| 475 |
+
// if it was passed in.
|
| 476 |
+
~ThreadSafeArena();
|
| 477 |
+
|
| 478 |
+
uint64_t Reset();
|
| 479 |
+
|
| 480 |
+
uint64_t SpaceAllocated() const;
|
| 481 |
+
uint64_t SpaceUsed() const;
|
| 482 |
+
|
| 483 |
+
template <AllocationClient alloc_client = AllocationClient::kDefault>
|
| 484 |
+
void* AllocateAligned(size_t n, const std::type_info* type) {
|
| 485 |
+
SerialArena* arena;
|
| 486 |
+
if (PROTOBUF_PREDICT_TRUE(!alloc_policy_.should_record_allocs() &&
|
| 487 |
+
GetSerialArenaFast(&arena))) {
|
| 488 |
+
return arena->AllocateAligned<alloc_client>(n, AllocPolicy());
|
| 489 |
+
} else {
|
| 490 |
+
return AllocateAlignedFallback(n, type);
|
| 491 |
+
}
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
void ReturnArrayMemory(void* p, size_t size) {
|
| 495 |
+
SerialArena* arena;
|
| 496 |
+
if (PROTOBUF_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
|
| 497 |
+
arena->ReturnArrayMemory(p, size);
|
| 498 |
+
}
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
// This function allocates n bytes if the common happy case is true and
|
| 502 |
+
// returns true. Otherwise does nothing and returns false. This strange
|
| 503 |
+
// semantics is necessary to allow callers to program functions that only
|
| 504 |
+
// have fallback function calls in tail position. This substantially improves
|
| 505 |
+
// code for the happy path.
|
| 506 |
+
PROTOBUF_NDEBUG_INLINE bool MaybeAllocateAligned(size_t n, void** out) {
|
| 507 |
+
SerialArena* arena;
|
| 508 |
+
if (PROTOBUF_PREDICT_TRUE(!alloc_policy_.should_record_allocs() &&
|
| 509 |
+
GetSerialArenaFromThreadCache(&arena))) {
|
| 510 |
+
return arena->MaybeAllocateAligned(n, out);
|
| 511 |
+
}
|
| 512 |
+
return false;
|
| 513 |
+
}
|
| 514 |
+
|
| 515 |
+
std::pair<void*, SerialArena::CleanupNode*> AllocateAlignedWithCleanup(
|
| 516 |
+
size_t n, const std::type_info* type);
|
| 517 |
+
|
| 518 |
+
// Add object pointer and cleanup function pointer to the list.
|
| 519 |
+
void AddCleanup(void* elem, void (*cleanup)(void*));
|
| 520 |
+
|
| 521 |
+
// Checks whether this arena is message-owned.
|
| 522 |
+
PROTOBUF_ALWAYS_INLINE bool IsMessageOwned() const {
|
| 523 |
+
return tag_and_id_ & kMessageOwnedArena;
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
private:
|
| 527 |
+
// Unique for each arena. Changes on Reset().
|
| 528 |
+
uint64_t tag_and_id_ = 0;
|
| 529 |
+
// The LSB of tag_and_id_ indicates if the arena is message-owned.
|
| 530 |
+
enum : uint64_t { kMessageOwnedArena = 1 };
|
| 531 |
+
|
| 532 |
+
TaggedAllocationPolicyPtr alloc_policy_; // Tagged pointer to AllocPolicy.
|
| 533 |
+
|
| 534 |
+
static_assert(std::is_trivially_destructible<SerialArena>{},
|
| 535 |
+
"SerialArena needs to be trivially destructible.");
|
| 536 |
+
// Pointer to a linked list of SerialArena.
|
| 537 |
+
std::atomic<SerialArena*> threads_;
|
| 538 |
+
std::atomic<SerialArena*> hint_; // Fast thread-local block access
|
| 539 |
+
|
| 540 |
+
const AllocationPolicy* AllocPolicy() const { return alloc_policy_.get(); }
|
| 541 |
+
void InitializeFrom(void* mem, size_t size);
|
| 542 |
+
void InitializeWithPolicy(void* mem, size_t size, AllocationPolicy policy);
|
| 543 |
+
void* AllocateAlignedFallback(size_t n, const std::type_info* type);
|
| 544 |
+
std::pair<void*, SerialArena::CleanupNode*>
|
| 545 |
+
AllocateAlignedWithCleanupFallback(size_t n, const std::type_info* type);
|
| 546 |
+
|
| 547 |
+
void Init();
|
| 548 |
+
void SetInitialBlock(void* mem, size_t size);
|
| 549 |
+
|
| 550 |
+
// Delete or Destruct all objects owned by the arena.
|
| 551 |
+
void CleanupList();
|
| 552 |
+
|
| 553 |
+
inline uint64_t LifeCycleId() const {
|
| 554 |
+
return tag_and_id_ & ~kMessageOwnedArena;
|
| 555 |
+
}
|
| 556 |
+
|
| 557 |
+
inline void CacheSerialArena(SerialArena* serial) {
|
| 558 |
+
thread_cache().last_serial_arena = serial;
|
| 559 |
+
thread_cache().last_lifecycle_id_seen = tag_and_id_;
|
| 560 |
+
// TODO(haberman): evaluate whether we would gain efficiency by getting rid
|
| 561 |
+
// of hint_. It's the only write we do to ThreadSafeArena in the allocation
|
| 562 |
+
// path, which will dirty the cache line.
|
| 563 |
+
|
| 564 |
+
hint_.store(serial, std::memory_order_release);
|
| 565 |
+
}
|
| 566 |
+
|
| 567 |
+
PROTOBUF_NDEBUG_INLINE bool GetSerialArenaFast(SerialArena** arena) {
|
| 568 |
+
if (GetSerialArenaFromThreadCache(arena)) return true;
|
| 569 |
+
|
| 570 |
+
// Check whether we own the last accessed SerialArena on this arena. This
|
| 571 |
+
// fast path optimizes the case where a single thread uses multiple arenas.
|
| 572 |
+
ThreadCache* tc = &thread_cache();
|
| 573 |
+
SerialArena* serial = hint_.load(std::memory_order_acquire);
|
| 574 |
+
if (PROTOBUF_PREDICT_TRUE(serial != nullptr && serial->owner() == tc)) {
|
| 575 |
+
*arena = serial;
|
| 576 |
+
return true;
|
| 577 |
+
}
|
| 578 |
+
return false;
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
PROTOBUF_NDEBUG_INLINE bool GetSerialArenaFromThreadCache(
|
| 582 |
+
SerialArena** arena) {
|
| 583 |
+
// If this thread already owns a block in this arena then try to use that.
|
| 584 |
+
// This fast path optimizes the case where multiple threads allocate from
|
| 585 |
+
// the same arena.
|
| 586 |
+
ThreadCache* tc = &thread_cache();
|
| 587 |
+
if (PROTOBUF_PREDICT_TRUE(tc->last_lifecycle_id_seen == tag_and_id_)) {
|
| 588 |
+
*arena = tc->last_serial_arena;
|
| 589 |
+
return true;
|
| 590 |
+
}
|
| 591 |
+
return false;
|
| 592 |
+
}
|
| 593 |
+
SerialArena* GetSerialArenaFallback(void* me);
|
| 594 |
+
|
| 595 |
+
template <typename Functor>
|
| 596 |
+
void PerSerialArena(Functor fn) {
|
| 597 |
+
// By omitting an Acquire barrier we ensure that any user code that doesn't
|
| 598 |
+
// properly synchronize Reset() or the destructor will throw a TSAN warning.
|
| 599 |
+
SerialArena* serial = threads_.load(std::memory_order_relaxed);
|
| 600 |
+
|
| 601 |
+
for (; serial; serial = serial->next()) fn(serial);
|
| 602 |
+
}
|
| 603 |
+
|
| 604 |
+
// Releases all memory except the first block which it returns. The first
|
| 605 |
+
// block might be owned by the user and thus need some extra checks before
|
| 606 |
+
// deleting.
|
| 607 |
+
SerialArena::Memory Free(size_t* space_allocated);
|
| 608 |
+
|
| 609 |
+
#ifdef _MSC_VER
|
| 610 |
+
#pragma warning(disable : 4324)
|
| 611 |
+
#endif
|
| 612 |
+
struct alignas(kCacheAlignment) ThreadCache {
|
| 613 |
+
#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
|
| 614 |
+
// If we are using the ThreadLocalStorage class to store the ThreadCache,
|
| 615 |
+
// then the ThreadCache's default constructor has to be responsible for
|
| 616 |
+
// initializing it.
|
| 617 |
+
ThreadCache()
|
| 618 |
+
: next_lifecycle_id(0),
|
| 619 |
+
last_lifecycle_id_seen(-1),
|
| 620 |
+
last_serial_arena(nullptr) {}
|
| 621 |
+
#endif
|
| 622 |
+
|
| 623 |
+
// Number of per-thread lifecycle IDs to reserve. Must be power of two.
|
| 624 |
+
// To reduce contention on a global atomic, each thread reserves a batch of
|
| 625 |
+
// IDs. The following number is calculated based on a stress test with
|
| 626 |
+
// ~6500 threads all frequently allocating a new arena.
|
| 627 |
+
static constexpr size_t kPerThreadIds = 256;
|
| 628 |
+
// Next lifecycle ID available to this thread. We need to reserve a new
|
| 629 |
+
// batch, if `next_lifecycle_id & (kPerThreadIds - 1) == 0`.
|
| 630 |
+
uint64_t next_lifecycle_id;
|
| 631 |
+
// The ThreadCache is considered valid as long as this matches the
|
| 632 |
+
// lifecycle_id of the arena being used.
|
| 633 |
+
uint64_t last_lifecycle_id_seen;
|
| 634 |
+
SerialArena* last_serial_arena;
|
| 635 |
+
};
|
| 636 |
+
|
| 637 |
+
// Lifecycle_id can be highly contended variable in a situation of lots of
|
| 638 |
+
// arena creation. Make sure that other global variables are not sharing the
|
| 639 |
+
// cacheline.
|
| 640 |
+
#ifdef _MSC_VER
|
| 641 |
+
#pragma warning(disable : 4324)
|
| 642 |
+
#endif
|
| 643 |
+
struct alignas(kCacheAlignment) CacheAlignedLifecycleIdGenerator {
|
| 644 |
+
std::atomic<LifecycleIdAtomic> id;
|
| 645 |
+
};
|
| 646 |
+
static CacheAlignedLifecycleIdGenerator lifecycle_id_generator_;
|
| 647 |
+
#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
|
| 648 |
+
// iOS does not support __thread keyword so we use a custom thread local
|
| 649 |
+
// storage class we implemented.
|
| 650 |
+
static ThreadCache& thread_cache();
|
| 651 |
+
#elif defined(PROTOBUF_USE_DLLS)
|
| 652 |
+
// Thread local variables cannot be exposed through DLL interface but we can
|
| 653 |
+
// wrap them in static functions.
|
| 654 |
+
static ThreadCache& thread_cache();
|
| 655 |
+
#else
|
| 656 |
+
static PROTOBUF_THREAD_LOCAL ThreadCache thread_cache_;
|
| 657 |
+
static ThreadCache& thread_cache() { return thread_cache_; }
|
| 658 |
+
#endif
|
| 659 |
+
|
| 660 |
+
ThreadSafeArenaStatsHandle arena_stats_;
|
| 661 |
+
|
| 662 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ThreadSafeArena);
|
| 663 |
+
// All protos have pointers back to the arena hence Arena must have
|
| 664 |
+
// pointer stability.
|
| 665 |
+
ThreadSafeArena(ThreadSafeArena&&) = delete;
|
| 666 |
+
ThreadSafeArena& operator=(ThreadSafeArena&&) = delete;
|
| 667 |
+
|
| 668 |
+
public:
|
| 669 |
+
// kBlockHeaderSize is sizeof(Block), aligned up to the nearest multiple of 8
|
| 670 |
+
// to protect the invariant that pos is always at a multiple of 8.
|
| 671 |
+
static constexpr size_t kBlockHeaderSize = SerialArena::kBlockHeaderSize;
|
| 672 |
+
static constexpr size_t kSerialArenaSize =
|
| 673 |
+
(sizeof(SerialArena) + 7) & static_cast<size_t>(-8);
|
| 674 |
+
static_assert(kBlockHeaderSize % 8 == 0,
|
| 675 |
+
"kBlockHeaderSize must be a multiple of 8.");
|
| 676 |
+
static_assert(kSerialArenaSize % 8 == 0,
|
| 677 |
+
"kSerialArenaSize must be a multiple of 8.");
|
| 678 |
+
};
|
| 679 |
+
|
| 680 |
+
} // namespace internal
|
| 681 |
+
} // namespace protobuf
|
| 682 |
+
} // namespace google
|
| 683 |
+
|
| 684 |
+
#include <google/protobuf/port_undef.inc>
|
| 685 |
+
|
| 686 |
+
#endif // GOOGLE_PROTOBUF_ARENA_IMPL_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/arenaz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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_SRC_GOOGLE_PROTOBUF_ARENAZ_SAMPLER_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_SRC_GOOGLE_PROTOBUF_ARENAZ_SAMPLER_H__
|
| 33 |
+
|
| 34 |
+
#include <atomic>
|
| 35 |
+
#include <cstddef>
|
| 36 |
+
#include <cstdint>
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
// Must be included last.
|
| 40 |
+
#include <google/protobuf/port_def.inc>
|
| 41 |
+
|
| 42 |
+
namespace google {
|
| 43 |
+
namespace protobuf {
|
| 44 |
+
namespace internal {
|
| 45 |
+
|
| 46 |
+
#if defined(PROTOBUF_ARENAZ_SAMPLE)
|
| 47 |
+
struct ThreadSafeArenaStats;
|
| 48 |
+
void RecordResetSlow(ThreadSafeArenaStats* info);
|
| 49 |
+
void RecordAllocateSlow(ThreadSafeArenaStats* info, size_t requested,
|
| 50 |
+
size_t allocated, size_t wasted);
|
| 51 |
+
// Stores information about a sampled thread safe arena. All mutations to this
|
| 52 |
+
// *must* be made through `Record*` functions below. All reads from this *must*
|
| 53 |
+
// only occur in the callback to `ThreadSafeArenazSampler::Iterate`.
|
| 54 |
+
struct ThreadSafeArenaStats
|
| 55 |
+
: public absl::profiling_internal::Sample<ThreadSafeArenaStats> {
|
| 56 |
+
// Constructs the object but does not fill in any fields.
|
| 57 |
+
ThreadSafeArenaStats();
|
| 58 |
+
~ThreadSafeArenaStats();
|
| 59 |
+
|
| 60 |
+
// Puts the object into a clean state, fills in the logically `const` members,
|
| 61 |
+
// blocking for any readers that are currently sampling the object.
|
| 62 |
+
void PrepareForSampling() ABSL_EXCLUSIVE_LOCKS_REQUIRED(init_mu);
|
| 63 |
+
|
| 64 |
+
// These fields are mutated by the various Record* APIs and need to be
|
| 65 |
+
// thread-safe.
|
| 66 |
+
std::atomic<int> num_allocations;
|
| 67 |
+
std::atomic<int> num_resets;
|
| 68 |
+
std::atomic<size_t> bytes_requested;
|
| 69 |
+
std::atomic<size_t> bytes_allocated;
|
| 70 |
+
std::atomic<size_t> bytes_wasted;
|
| 71 |
+
// Records the largest size an arena ever had. Maintained across resets.
|
| 72 |
+
std::atomic<size_t> max_bytes_allocated;
|
| 73 |
+
// Bit i when set to 1 indicates that a thread with tid % 63 = i accessed the
|
| 74 |
+
// underlying arena. The field is maintained across resets.
|
| 75 |
+
std::atomic<uint64_t> thread_ids;
|
| 76 |
+
|
| 77 |
+
// All of the fields below are set by `PrepareForSampling`, they must not
|
| 78 |
+
// be mutated in `Record*` functions. They are logically `const` in that
|
| 79 |
+
// sense. These are guarded by init_mu, but that is not externalized to
|
| 80 |
+
// clients, who can only read them during
|
| 81 |
+
// `ThreadSafeArenazSampler::Iterate` which will hold the lock.
|
| 82 |
+
static constexpr int kMaxStackDepth = 64;
|
| 83 |
+
int32_t depth;
|
| 84 |
+
void* stack[kMaxStackDepth];
|
| 85 |
+
static void RecordAllocateStats(ThreadSafeArenaStats* info, size_t requested,
|
| 86 |
+
size_t allocated, size_t wasted) {
|
| 87 |
+
if (PROTOBUF_PREDICT_TRUE(info == nullptr)) return;
|
| 88 |
+
RecordAllocateSlow(info, requested, allocated, wasted);
|
| 89 |
+
}
|
| 90 |
+
};
|
| 91 |
+
|
| 92 |
+
ThreadSafeArenaStats* SampleSlow(int64_t* next_sample);
|
| 93 |
+
void UnsampleSlow(ThreadSafeArenaStats* info);
|
| 94 |
+
|
| 95 |
+
class ThreadSafeArenaStatsHandle {
|
| 96 |
+
public:
|
| 97 |
+
explicit ThreadSafeArenaStatsHandle() = default;
|
| 98 |
+
explicit ThreadSafeArenaStatsHandle(ThreadSafeArenaStats* info)
|
| 99 |
+
: info_(info) {}
|
| 100 |
+
|
| 101 |
+
~ThreadSafeArenaStatsHandle() {
|
| 102 |
+
if (PROTOBUF_PREDICT_TRUE(info_ == nullptr)) return;
|
| 103 |
+
UnsampleSlow(info_);
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
ThreadSafeArenaStatsHandle(ThreadSafeArenaStatsHandle&& other) noexcept
|
| 107 |
+
: info_(absl::exchange(other.info_, nullptr)) {}
|
| 108 |
+
|
| 109 |
+
ThreadSafeArenaStatsHandle& operator=(
|
| 110 |
+
ThreadSafeArenaStatsHandle&& other) noexcept {
|
| 111 |
+
if (PROTOBUF_PREDICT_FALSE(info_ != nullptr)) {
|
| 112 |
+
UnsampleSlow(info_);
|
| 113 |
+
}
|
| 114 |
+
info_ = absl::exchange(other.info_, nullptr);
|
| 115 |
+
return *this;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
void RecordReset() {
|
| 119 |
+
if (PROTOBUF_PREDICT_TRUE(info_ == nullptr)) return;
|
| 120 |
+
RecordResetSlow(info_);
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
ThreadSafeArenaStats* MutableStats() { return info_; }
|
| 124 |
+
|
| 125 |
+
friend void swap(ThreadSafeArenaStatsHandle& lhs,
|
| 126 |
+
ThreadSafeArenaStatsHandle& rhs) {
|
| 127 |
+
std::swap(lhs.info_, rhs.info_);
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
friend class ThreadSafeArenaStatsHandlePeer;
|
| 131 |
+
|
| 132 |
+
private:
|
| 133 |
+
ThreadSafeArenaStats* info_ = nullptr;
|
| 134 |
+
};
|
| 135 |
+
|
| 136 |
+
using ThreadSafeArenazSampler =
|
| 137 |
+
::absl::profiling_internal::SampleRecorder<ThreadSafeArenaStats>;
|
| 138 |
+
|
| 139 |
+
extern PROTOBUF_THREAD_LOCAL int64_t global_next_sample;
|
| 140 |
+
|
| 141 |
+
// Returns an RAII sampling handle that manages registration and unregistation
|
| 142 |
+
// with the global sampler.
|
| 143 |
+
inline ThreadSafeArenaStatsHandle Sample() {
|
| 144 |
+
if (PROTOBUF_PREDICT_TRUE(--global_next_sample > 0)) {
|
| 145 |
+
return ThreadSafeArenaStatsHandle(nullptr);
|
| 146 |
+
}
|
| 147 |
+
return ThreadSafeArenaStatsHandle(SampleSlow(&global_next_sample));
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
#else
|
| 151 |
+
struct ThreadSafeArenaStats {
|
| 152 |
+
static void RecordAllocateStats(ThreadSafeArenaStats*, size_t /*requested*/,
|
| 153 |
+
size_t /*allocated*/, size_t /*wasted*/) {}
|
| 154 |
+
};
|
| 155 |
+
|
| 156 |
+
ThreadSafeArenaStats* SampleSlow(int64_t* next_sample);
|
| 157 |
+
void UnsampleSlow(ThreadSafeArenaStats* info);
|
| 158 |
+
|
| 159 |
+
class ThreadSafeArenaStatsHandle {
|
| 160 |
+
public:
|
| 161 |
+
explicit ThreadSafeArenaStatsHandle() = default;
|
| 162 |
+
explicit ThreadSafeArenaStatsHandle(ThreadSafeArenaStats*) {}
|
| 163 |
+
|
| 164 |
+
void RecordReset() {}
|
| 165 |
+
|
| 166 |
+
ThreadSafeArenaStats* MutableStats() { return nullptr; }
|
| 167 |
+
|
| 168 |
+
friend void swap(ThreadSafeArenaStatsHandle&, ThreadSafeArenaStatsHandle&) {}
|
| 169 |
+
|
| 170 |
+
private:
|
| 171 |
+
friend class ThreadSafeArenaStatsHandlePeer;
|
| 172 |
+
};
|
| 173 |
+
|
| 174 |
+
class ThreadSafeArenazSampler {
|
| 175 |
+
public:
|
| 176 |
+
void Unregister(ThreadSafeArenaStats*) {}
|
| 177 |
+
void SetMaxSamples(int32_t) {}
|
| 178 |
+
};
|
| 179 |
+
|
| 180 |
+
// Returns an RAII sampling handle that manages registration and unregistation
|
| 181 |
+
// with the global sampler.
|
| 182 |
+
inline ThreadSafeArenaStatsHandle Sample() {
|
| 183 |
+
return ThreadSafeArenaStatsHandle(nullptr);
|
| 184 |
+
}
|
| 185 |
+
#endif // defined(PROTOBUF_ARENAZ_SAMPLE)
|
| 186 |
+
|
| 187 |
+
// Returns a global Sampler.
|
| 188 |
+
ThreadSafeArenazSampler& GlobalThreadSafeArenazSampler();
|
| 189 |
+
|
| 190 |
+
// Enables or disables sampling for thread safe arenas.
|
| 191 |
+
void SetThreadSafeArenazEnabled(bool enabled);
|
| 192 |
+
|
| 193 |
+
// Sets the rate at which thread safe arena will be sampled.
|
| 194 |
+
void SetThreadSafeArenazSampleParameter(int32_t rate);
|
| 195 |
+
|
| 196 |
+
// Sets a soft max for the number of samples that will be kept.
|
| 197 |
+
void SetThreadSafeArenazMaxSamples(int32_t max);
|
| 198 |
+
|
| 199 |
+
// Sets the current value for when arenas should be next sampled.
|
| 200 |
+
void SetThreadSafeArenazGlobalNextSample(int64_t next_sample);
|
| 201 |
+
|
| 202 |
+
} // namespace internal
|
| 203 |
+
} // namespace protobuf
|
| 204 |
+
} // namespace google
|
| 205 |
+
|
| 206 |
+
#include <google/protobuf/port_undef.inc>
|
| 207 |
+
#endif // GOOGLE_PROTOBUF_SRC_PROTOBUF_ARENAZ_SAMPLER_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/compiler/zip_writer.h
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// Author: kenton@google.com (Kenton Varda)
|
| 32 |
+
#ifndef GOOGLE_PROTOBUF_COMPILER_ZIP_WRITER_H__
|
| 33 |
+
#define GOOGLE_PROTOBUF_COMPILER_ZIP_WRITER_H__
|
| 34 |
+
|
| 35 |
+
#include <cstdint>
|
| 36 |
+
#include <vector>
|
| 37 |
+
|
| 38 |
+
#include <google/protobuf/stubs/common.h>
|
| 39 |
+
#include <google/protobuf/io/zero_copy_stream.h>
|
| 40 |
+
|
| 41 |
+
namespace google {
|
| 42 |
+
namespace protobuf {
|
| 43 |
+
namespace compiler {
|
| 44 |
+
|
| 45 |
+
class ZipWriter {
|
| 46 |
+
public:
|
| 47 |
+
ZipWriter(io::ZeroCopyOutputStream* raw_output);
|
| 48 |
+
~ZipWriter();
|
| 49 |
+
|
| 50 |
+
bool Write(const std::string& filename, const std::string& contents);
|
| 51 |
+
bool WriteDirectory();
|
| 52 |
+
|
| 53 |
+
private:
|
| 54 |
+
struct FileInfo {
|
| 55 |
+
std::string name;
|
| 56 |
+
uint32_t offset;
|
| 57 |
+
uint32_t size;
|
| 58 |
+
uint32_t crc32;
|
| 59 |
+
};
|
| 60 |
+
|
| 61 |
+
io::ZeroCopyOutputStream* raw_output_;
|
| 62 |
+
std::vector<FileInfo> files_;
|
| 63 |
+
};
|
| 64 |
+
|
| 65 |
+
} // namespace compiler
|
| 66 |
+
} // namespace protobuf
|
| 67 |
+
} // namespace google
|
| 68 |
+
|
| 69 |
+
#endif // GOOGLE_PROTOBUF_COMPILER_ZIP_WRITER_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/descriptor.h
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/descriptor.pb.h
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/endian.h
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_ENDIAN_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_ENDIAN_H__
|
| 33 |
+
|
| 34 |
+
#if defined(_MSC_VER)
|
| 35 |
+
#include <stdlib.h>
|
| 36 |
+
#endif
|
| 37 |
+
|
| 38 |
+
#include <cstdint>
|
| 39 |
+
|
| 40 |
+
// Must be included last.
|
| 41 |
+
#include <google/protobuf/port_def.inc>
|
| 42 |
+
|
| 43 |
+
namespace google {
|
| 44 |
+
namespace protobuf {
|
| 45 |
+
namespace internal {
|
| 46 |
+
|
| 47 |
+
inline uint64_t BSwap64(uint64_t host_int) {
|
| 48 |
+
#if defined(PROTOBUF_BUILTIN_BSWAP64)
|
| 49 |
+
return PROTOBUF_BUILTIN_BSWAP64(host_int);
|
| 50 |
+
#elif defined(_MSC_VER)
|
| 51 |
+
return _byteswap_uint64(host_int);
|
| 52 |
+
#else
|
| 53 |
+
return (((host_int & uint64_t{0xFF}) << 56) |
|
| 54 |
+
((host_int & uint64_t{0xFF00}) << 40) |
|
| 55 |
+
((host_int & uint64_t{0xFF0000}) << 24) |
|
| 56 |
+
((host_int & uint64_t{0xFF000000}) << 8) |
|
| 57 |
+
((host_int & uint64_t{0xFF00000000}) >> 8) |
|
| 58 |
+
((host_int & uint64_t{0xFF0000000000}) >> 24) |
|
| 59 |
+
((host_int & uint64_t{0xFF000000000000}) >> 40) |
|
| 60 |
+
((host_int & uint64_t{0xFF00000000000000}) >> 56));
|
| 61 |
+
#endif
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
inline uint32_t BSwap32(uint32_t host_int) {
|
| 65 |
+
#if defined(PROTOBUF_BUILTIN_BSWAP32)
|
| 66 |
+
return PROTOBUF_BUILTIN_BSWAP32(host_int);
|
| 67 |
+
#elif defined(_MSC_VER)
|
| 68 |
+
return _byteswap_ulong(host_int);
|
| 69 |
+
#else
|
| 70 |
+
return (((host_int & uint32_t{0xFF}) << 24) |
|
| 71 |
+
((host_int & uint32_t{0xFF00}) << 8) |
|
| 72 |
+
((host_int & uint32_t{0xFF0000}) >> 8) |
|
| 73 |
+
((host_int & uint32_t{0xFF000000}) >> 24));
|
| 74 |
+
#endif
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
inline uint16_t BSwap16(uint16_t host_int) {
|
| 78 |
+
#if defined(PROTOBUF_BUILTIN_BSWAP16)
|
| 79 |
+
return PROTOBUF_BUILTIN_BSWAP16(host_int);
|
| 80 |
+
#elif defined(_MSC_VER)
|
| 81 |
+
return _byteswap_ushort(host_int);
|
| 82 |
+
#else
|
| 83 |
+
return (((host_int & uint16_t{0xFF}) << 8) |
|
| 84 |
+
((host_int & uint16_t{0xFF00}) >> 8));
|
| 85 |
+
#endif
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
namespace little_endian {
|
| 89 |
+
|
| 90 |
+
inline uint16_t FromHost(uint16_t value) {
|
| 91 |
+
#if defined(PROTOBUF_BIG_ENDIAN)
|
| 92 |
+
return BSwap16(value);
|
| 93 |
+
#else
|
| 94 |
+
return value;
|
| 95 |
+
#endif
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
inline uint32_t FromHost(uint32_t value) {
|
| 99 |
+
#if defined(PROTOBUF_BIG_ENDIAN)
|
| 100 |
+
return BSwap32(value);
|
| 101 |
+
#else
|
| 102 |
+
return value;
|
| 103 |
+
#endif
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
inline uint64_t FromHost(uint64_t value) {
|
| 107 |
+
#if defined(PROTOBUF_BIG_ENDIAN)
|
| 108 |
+
return BSwap64(value);
|
| 109 |
+
#else
|
| 110 |
+
return value;
|
| 111 |
+
#endif
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
inline uint16_t ToHost(uint16_t value) {
|
| 115 |
+
#if defined(PROTOBUF_BIG_ENDIAN)
|
| 116 |
+
return BSwap16(value);
|
| 117 |
+
#else
|
| 118 |
+
return value;
|
| 119 |
+
#endif
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
inline uint32_t ToHost(uint32_t value) {
|
| 123 |
+
#if defined(PROTOBUF_BIG_ENDIAN)
|
| 124 |
+
return BSwap32(value);
|
| 125 |
+
#else
|
| 126 |
+
return value;
|
| 127 |
+
#endif
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
inline uint64_t ToHost(uint64_t value) {
|
| 131 |
+
#if defined(PROTOBUF_BIG_ENDIAN)
|
| 132 |
+
return BSwap64(value);
|
| 133 |
+
#else
|
| 134 |
+
return value;
|
| 135 |
+
#endif
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
} // namespace little_endian
|
| 139 |
+
|
| 140 |
+
namespace big_endian {
|
| 141 |
+
|
| 142 |
+
inline uint16_t FromHost(uint16_t value) {
|
| 143 |
+
#if defined(PROTOBUF_BIG_ENDIAN)
|
| 144 |
+
return value;
|
| 145 |
+
#else
|
| 146 |
+
return BSwap16(value);
|
| 147 |
+
#endif
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
inline uint32_t FromHost(uint32_t value) {
|
| 151 |
+
#if defined(PROTOBUF_BIG_ENDIAN)
|
| 152 |
+
return value;
|
| 153 |
+
#else
|
| 154 |
+
return BSwap32(value);
|
| 155 |
+
#endif
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
inline uint64_t FromHost(uint64_t value) {
|
| 159 |
+
#if defined(PROTOBUF_BIG_ENDIAN)
|
| 160 |
+
return value;
|
| 161 |
+
#else
|
| 162 |
+
return BSwap64(value);
|
| 163 |
+
#endif
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
inline uint16_t ToHost(uint16_t value) {
|
| 167 |
+
#if defined(PROTOBUF_BIG_ENDIAN)
|
| 168 |
+
return value;
|
| 169 |
+
#else
|
| 170 |
+
return BSwap16(value);
|
| 171 |
+
#endif
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
inline uint32_t ToHost(uint32_t value) {
|
| 175 |
+
#if defined(PROTOBUF_BIG_ENDIAN)
|
| 176 |
+
return value;
|
| 177 |
+
#else
|
| 178 |
+
return BSwap32(value);
|
| 179 |
+
#endif
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
inline uint64_t ToHost(uint64_t value) {
|
| 183 |
+
#if defined(PROTOBUF_BIG_ENDIAN)
|
| 184 |
+
return value;
|
| 185 |
+
#else
|
| 186 |
+
return BSwap64(value);
|
| 187 |
+
#endif
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
} // namespace big_endian
|
| 191 |
+
|
| 192 |
+
} // namespace internal
|
| 193 |
+
} // namespace protobuf
|
| 194 |
+
} // namespace google
|
| 195 |
+
|
| 196 |
+
#include <google/protobuf/port_undef.inc>
|
| 197 |
+
|
| 198 |
+
#endif // GOOGLE_PROTOBUF_ENDIAN_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/extension_set.h
ADDED
|
@@ -0,0 +1,1561 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// Author: kenton@google.com (Kenton Varda)
|
| 32 |
+
// Based on original Protocol Buffers design by
|
| 33 |
+
// Sanjay Ghemawat, Jeff Dean, and others.
|
| 34 |
+
//
|
| 35 |
+
// This header is logically internal, but is made public because it is used
|
| 36 |
+
// from protocol-compiler-generated code, which may reside in other components.
|
| 37 |
+
|
| 38 |
+
#ifndef GOOGLE_PROTOBUF_EXTENSION_SET_H__
|
| 39 |
+
#define GOOGLE_PROTOBUF_EXTENSION_SET_H__
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
#include <algorithm>
|
| 43 |
+
#include <cassert>
|
| 44 |
+
#include <map>
|
| 45 |
+
#include <string>
|
| 46 |
+
#include <utility>
|
| 47 |
+
#include <vector>
|
| 48 |
+
|
| 49 |
+
#include <google/protobuf/stubs/common.h>
|
| 50 |
+
#include <google/protobuf/stubs/logging.h>
|
| 51 |
+
#include <google/protobuf/io/coded_stream.h>
|
| 52 |
+
#include <google/protobuf/port.h>
|
| 53 |
+
#include <google/protobuf/parse_context.h>
|
| 54 |
+
#include <google/protobuf/repeated_field.h>
|
| 55 |
+
#include <google/protobuf/wire_format_lite.h>
|
| 56 |
+
|
| 57 |
+
// clang-format off
|
| 58 |
+
#include <google/protobuf/port_def.inc> // Must be last
|
| 59 |
+
// clang-format on
|
| 60 |
+
|
| 61 |
+
#ifdef SWIG
|
| 62 |
+
#error "You cannot SWIG proto headers"
|
| 63 |
+
#endif
|
| 64 |
+
|
| 65 |
+
namespace google {
|
| 66 |
+
namespace protobuf {
|
| 67 |
+
class Arena;
|
| 68 |
+
class Descriptor; // descriptor.h
|
| 69 |
+
class FieldDescriptor; // descriptor.h
|
| 70 |
+
class DescriptorPool; // descriptor.h
|
| 71 |
+
class MessageLite; // message_lite.h
|
| 72 |
+
class Message; // message.h
|
| 73 |
+
class MessageFactory; // message.h
|
| 74 |
+
class Reflection; // message.h
|
| 75 |
+
class UnknownFieldSet; // unknown_field_set.h
|
| 76 |
+
namespace internal {
|
| 77 |
+
class FieldSkipper; // wire_format_lite.h
|
| 78 |
+
enum class LazyVerifyOption;
|
| 79 |
+
} // namespace internal
|
| 80 |
+
} // namespace protobuf
|
| 81 |
+
} // namespace google
|
| 82 |
+
|
| 83 |
+
namespace google {
|
| 84 |
+
namespace protobuf {
|
| 85 |
+
namespace internal {
|
| 86 |
+
|
| 87 |
+
class InternalMetadata;
|
| 88 |
+
|
| 89 |
+
// Used to store values of type WireFormatLite::FieldType without having to
|
| 90 |
+
// #include wire_format_lite.h. Also, ensures that we use only one byte to
|
| 91 |
+
// store these values, which is important to keep the layout of
|
| 92 |
+
// ExtensionSet::Extension small.
|
| 93 |
+
typedef uint8_t FieldType;
|
| 94 |
+
|
| 95 |
+
// A function which, given an integer value, returns true if the number
|
| 96 |
+
// matches one of the defined values for the corresponding enum type. This
|
| 97 |
+
// is used with RegisterEnumExtension, below.
|
| 98 |
+
typedef bool EnumValidityFunc(int number);
|
| 99 |
+
|
| 100 |
+
// Version of the above which takes an argument. This is needed to deal with
|
| 101 |
+
// extensions that are not compiled in.
|
| 102 |
+
typedef bool EnumValidityFuncWithArg(const void* arg, int number);
|
| 103 |
+
|
| 104 |
+
// Information about a registered extension.
|
| 105 |
+
struct ExtensionInfo {
|
| 106 |
+
constexpr ExtensionInfo() : enum_validity_check() {}
|
| 107 |
+
constexpr ExtensionInfo(const MessageLite* extendee, int param_number,
|
| 108 |
+
FieldType type_param, bool isrepeated, bool ispacked,
|
| 109 |
+
LazyEagerVerifyFnType verify_func)
|
| 110 |
+
: message(extendee),
|
| 111 |
+
number(param_number),
|
| 112 |
+
type(type_param),
|
| 113 |
+
is_repeated(isrepeated),
|
| 114 |
+
is_packed(ispacked),
|
| 115 |
+
enum_validity_check(),
|
| 116 |
+
lazy_eager_verify_func(verify_func) {}
|
| 117 |
+
|
| 118 |
+
const MessageLite* message = nullptr;
|
| 119 |
+
int number = 0;
|
| 120 |
+
|
| 121 |
+
FieldType type = 0;
|
| 122 |
+
bool is_repeated = false;
|
| 123 |
+
bool is_packed = false;
|
| 124 |
+
|
| 125 |
+
struct EnumValidityCheck {
|
| 126 |
+
EnumValidityFuncWithArg* func;
|
| 127 |
+
const void* arg;
|
| 128 |
+
};
|
| 129 |
+
|
| 130 |
+
struct MessageInfo {
|
| 131 |
+
const MessageLite* prototype;
|
| 132 |
+
};
|
| 133 |
+
|
| 134 |
+
union {
|
| 135 |
+
EnumValidityCheck enum_validity_check;
|
| 136 |
+
MessageInfo message_info;
|
| 137 |
+
};
|
| 138 |
+
|
| 139 |
+
// The descriptor for this extension, if one exists and is known. May be
|
| 140 |
+
// nullptr. Must not be nullptr if the descriptor for the extension does not
|
| 141 |
+
// live in the same pool as the descriptor for the containing type.
|
| 142 |
+
const FieldDescriptor* descriptor = nullptr;
|
| 143 |
+
|
| 144 |
+
// If this field is potentially lazy this function can be used as a cheap
|
| 145 |
+
// verification of the raw bytes.
|
| 146 |
+
// If nullptr then no verification is performed.
|
| 147 |
+
LazyEagerVerifyFnType lazy_eager_verify_func = nullptr;
|
| 148 |
+
};
|
| 149 |
+
|
| 150 |
+
// An ExtensionFinder is an object which looks up extension definitions. It
|
| 151 |
+
// must implement this method:
|
| 152 |
+
//
|
| 153 |
+
// bool Find(int number, ExtensionInfo* output);
|
| 154 |
+
|
| 155 |
+
// GeneratedExtensionFinder is an ExtensionFinder which finds extensions
|
| 156 |
+
// defined in .proto files which have been compiled into the binary.
|
| 157 |
+
class PROTOBUF_EXPORT GeneratedExtensionFinder {
|
| 158 |
+
public:
|
| 159 |
+
explicit GeneratedExtensionFinder(const MessageLite* extendee)
|
| 160 |
+
: extendee_(extendee) {}
|
| 161 |
+
|
| 162 |
+
// Returns true and fills in *output if found, otherwise returns false.
|
| 163 |
+
bool Find(int number, ExtensionInfo* output);
|
| 164 |
+
|
| 165 |
+
private:
|
| 166 |
+
const MessageLite* extendee_;
|
| 167 |
+
};
|
| 168 |
+
|
| 169 |
+
// Note: extension_set_heavy.cc defines DescriptorPoolExtensionFinder for
|
| 170 |
+
// finding extensions from a DescriptorPool.
|
| 171 |
+
|
| 172 |
+
// This is an internal helper class intended for use within the protocol buffer
|
| 173 |
+
// library and generated classes. Clients should not use it directly. Instead,
|
| 174 |
+
// use the generated accessors such as GetExtension() of the class being
|
| 175 |
+
// extended.
|
| 176 |
+
//
|
| 177 |
+
// This class manages extensions for a protocol message object. The
|
| 178 |
+
// message's HasExtension(), GetExtension(), MutableExtension(), and
|
| 179 |
+
// ClearExtension() methods are just thin wrappers around the embedded
|
| 180 |
+
// ExtensionSet. When parsing, if a tag number is encountered which is
|
| 181 |
+
// inside one of the message type's extension ranges, the tag is passed
|
| 182 |
+
// off to the ExtensionSet for parsing. Etc.
|
| 183 |
+
class PROTOBUF_EXPORT ExtensionSet {
|
| 184 |
+
public:
|
| 185 |
+
constexpr ExtensionSet();
|
| 186 |
+
explicit ExtensionSet(Arena* arena);
|
| 187 |
+
ExtensionSet(ArenaInitialized, Arena* arena) : ExtensionSet(arena) {}
|
| 188 |
+
~ExtensionSet();
|
| 189 |
+
|
| 190 |
+
// These are called at startup by protocol-compiler-generated code to
|
| 191 |
+
// register known extensions. The registrations are used by ParseField()
|
| 192 |
+
// to look up extensions for parsed field numbers. Note that dynamic parsing
|
| 193 |
+
// does not use ParseField(); only protocol-compiler-generated parsing
|
| 194 |
+
// methods do.
|
| 195 |
+
static void RegisterExtension(const MessageLite* extendee, int number,
|
| 196 |
+
FieldType type, bool is_repeated,
|
| 197 |
+
bool is_packed,
|
| 198 |
+
LazyEagerVerifyFnType verify_func);
|
| 199 |
+
static void RegisterEnumExtension(const MessageLite* extendee, int number,
|
| 200 |
+
FieldType type, bool is_repeated,
|
| 201 |
+
bool is_packed, EnumValidityFunc* is_valid);
|
| 202 |
+
static void RegisterMessageExtension(const MessageLite* extendee, int number,
|
| 203 |
+
FieldType type, bool is_repeated,
|
| 204 |
+
bool is_packed,
|
| 205 |
+
const MessageLite* prototype,
|
| 206 |
+
LazyEagerVerifyFnType verify_func);
|
| 207 |
+
|
| 208 |
+
// =================================================================
|
| 209 |
+
|
| 210 |
+
// Add all fields which are currently present to the given vector. This
|
| 211 |
+
// is useful to implement Reflection::ListFields().
|
| 212 |
+
void AppendToList(const Descriptor* extendee, const DescriptorPool* pool,
|
| 213 |
+
std::vector<const FieldDescriptor*>* output) const;
|
| 214 |
+
|
| 215 |
+
// =================================================================
|
| 216 |
+
// Accessors
|
| 217 |
+
//
|
| 218 |
+
// Generated message classes include type-safe templated wrappers around
|
| 219 |
+
// these methods. Generally you should use those rather than call these
|
| 220 |
+
// directly, unless you are doing low-level memory management.
|
| 221 |
+
//
|
| 222 |
+
// When calling any of these accessors, the extension number requested
|
| 223 |
+
// MUST exist in the DescriptorPool provided to the constructor. Otherwise,
|
| 224 |
+
// the method will fail an assert. Normally, though, you would not call
|
| 225 |
+
// these directly; you would either call the generated accessors of your
|
| 226 |
+
// message class (e.g. GetExtension()) or you would call the accessors
|
| 227 |
+
// of the reflection interface. In both cases, it is impossible to
|
| 228 |
+
// trigger this assert failure: the generated accessors only accept
|
| 229 |
+
// linked-in extension types as parameters, while the Reflection interface
|
| 230 |
+
// requires you to provide the FieldDescriptor describing the extension.
|
| 231 |
+
//
|
| 232 |
+
// When calling any of these accessors, a protocol-compiler-generated
|
| 233 |
+
// implementation of the extension corresponding to the number MUST
|
| 234 |
+
// be linked in, and the FieldDescriptor used to refer to it MUST be
|
| 235 |
+
// the one generated by that linked-in code. Otherwise, the method will
|
| 236 |
+
// die on an assert failure. The message objects returned by the message
|
| 237 |
+
// accessors are guaranteed to be of the correct linked-in type.
|
| 238 |
+
//
|
| 239 |
+
// These methods pretty much match Reflection except that:
|
| 240 |
+
// - They're not virtual.
|
| 241 |
+
// - They identify fields by number rather than FieldDescriptors.
|
| 242 |
+
// - They identify enum values using integers rather than descriptors.
|
| 243 |
+
// - Strings provide Mutable() in addition to Set() accessors.
|
| 244 |
+
|
| 245 |
+
bool Has(int number) const;
|
| 246 |
+
int ExtensionSize(int number) const; // Size of a repeated extension.
|
| 247 |
+
int NumExtensions() const; // The number of extensions
|
| 248 |
+
FieldType ExtensionType(int number) const;
|
| 249 |
+
void ClearExtension(int number);
|
| 250 |
+
|
| 251 |
+
// singular fields -------------------------------------------------
|
| 252 |
+
|
| 253 |
+
int32_t GetInt32(int number, int32_t default_value) const;
|
| 254 |
+
int64_t GetInt64(int number, int64_t default_value) const;
|
| 255 |
+
uint32_t GetUInt32(int number, uint32_t default_value) const;
|
| 256 |
+
uint64_t GetUInt64(int number, uint64_t default_value) const;
|
| 257 |
+
float GetFloat(int number, float default_value) const;
|
| 258 |
+
double GetDouble(int number, double default_value) const;
|
| 259 |
+
bool GetBool(int number, bool default_value) const;
|
| 260 |
+
int GetEnum(int number, int default_value) const;
|
| 261 |
+
const std::string& GetString(int number,
|
| 262 |
+
const std::string& default_value) const;
|
| 263 |
+
const MessageLite& GetMessage(int number,
|
| 264 |
+
const MessageLite& default_value) const;
|
| 265 |
+
const MessageLite& GetMessage(int number, const Descriptor* message_type,
|
| 266 |
+
MessageFactory* factory) const;
|
| 267 |
+
|
| 268 |
+
// |descriptor| may be nullptr so long as it is known that the descriptor for
|
| 269 |
+
// the extension lives in the same pool as the descriptor for the containing
|
| 270 |
+
// type.
|
| 271 |
+
#define desc const FieldDescriptor* descriptor // avoid line wrapping
|
| 272 |
+
void SetInt32(int number, FieldType type, int32_t value, desc);
|
| 273 |
+
void SetInt64(int number, FieldType type, int64_t value, desc);
|
| 274 |
+
void SetUInt32(int number, FieldType type, uint32_t value, desc);
|
| 275 |
+
void SetUInt64(int number, FieldType type, uint64_t value, desc);
|
| 276 |
+
void SetFloat(int number, FieldType type, float value, desc);
|
| 277 |
+
void SetDouble(int number, FieldType type, double value, desc);
|
| 278 |
+
void SetBool(int number, FieldType type, bool value, desc);
|
| 279 |
+
void SetEnum(int number, FieldType type, int value, desc);
|
| 280 |
+
void SetString(int number, FieldType type, std::string value, desc);
|
| 281 |
+
std::string* MutableString(int number, FieldType type, desc);
|
| 282 |
+
MessageLite* MutableMessage(int number, FieldType type,
|
| 283 |
+
const MessageLite& prototype, desc);
|
| 284 |
+
MessageLite* MutableMessage(const FieldDescriptor* descriptor,
|
| 285 |
+
MessageFactory* factory);
|
| 286 |
+
// Adds the given message to the ExtensionSet, taking ownership of the
|
| 287 |
+
// message object. Existing message with the same number will be deleted.
|
| 288 |
+
// If "message" is nullptr, this is equivalent to "ClearExtension(number)".
|
| 289 |
+
void SetAllocatedMessage(int number, FieldType type,
|
| 290 |
+
const FieldDescriptor* descriptor,
|
| 291 |
+
MessageLite* message);
|
| 292 |
+
void UnsafeArenaSetAllocatedMessage(int number, FieldType type,
|
| 293 |
+
const FieldDescriptor* descriptor,
|
| 294 |
+
MessageLite* message);
|
| 295 |
+
PROTOBUF_NODISCARD MessageLite* ReleaseMessage(int number,
|
| 296 |
+
const MessageLite& prototype);
|
| 297 |
+
MessageLite* UnsafeArenaReleaseMessage(int number,
|
| 298 |
+
const MessageLite& prototype);
|
| 299 |
+
|
| 300 |
+
PROTOBUF_NODISCARD MessageLite* ReleaseMessage(
|
| 301 |
+
const FieldDescriptor* descriptor, MessageFactory* factory);
|
| 302 |
+
MessageLite* UnsafeArenaReleaseMessage(const FieldDescriptor* descriptor,
|
| 303 |
+
MessageFactory* factory);
|
| 304 |
+
#undef desc
|
| 305 |
+
Arena* GetArena() const { return arena_; }
|
| 306 |
+
|
| 307 |
+
// repeated fields -------------------------------------------------
|
| 308 |
+
|
| 309 |
+
// Fetches a RepeatedField extension by number; returns |default_value|
|
| 310 |
+
// if no such extension exists. User should not touch this directly; it is
|
| 311 |
+
// used by the GetRepeatedExtension() method.
|
| 312 |
+
const void* GetRawRepeatedField(int number, const void* default_value) const;
|
| 313 |
+
// Fetches a mutable version of a RepeatedField extension by number,
|
| 314 |
+
// instantiating one if none exists. Similar to above, user should not use
|
| 315 |
+
// this directly; it underlies MutableRepeatedExtension().
|
| 316 |
+
void* MutableRawRepeatedField(int number, FieldType field_type, bool packed,
|
| 317 |
+
const FieldDescriptor* desc);
|
| 318 |
+
|
| 319 |
+
// This is an overload of MutableRawRepeatedField to maintain compatibility
|
| 320 |
+
// with old code using a previous API. This version of
|
| 321 |
+
// MutableRawRepeatedField() will GOOGLE_CHECK-fail on a missing extension.
|
| 322 |
+
// (E.g.: borg/clients/internal/proto1/proto2_reflection.cc.)
|
| 323 |
+
void* MutableRawRepeatedField(int number);
|
| 324 |
+
|
| 325 |
+
int32_t GetRepeatedInt32(int number, int index) const;
|
| 326 |
+
int64_t GetRepeatedInt64(int number, int index) const;
|
| 327 |
+
uint32_t GetRepeatedUInt32(int number, int index) const;
|
| 328 |
+
uint64_t GetRepeatedUInt64(int number, int index) const;
|
| 329 |
+
float GetRepeatedFloat(int number, int index) const;
|
| 330 |
+
double GetRepeatedDouble(int number, int index) const;
|
| 331 |
+
bool GetRepeatedBool(int number, int index) const;
|
| 332 |
+
int GetRepeatedEnum(int number, int index) const;
|
| 333 |
+
const std::string& GetRepeatedString(int number, int index) const;
|
| 334 |
+
const MessageLite& GetRepeatedMessage(int number, int index) const;
|
| 335 |
+
|
| 336 |
+
void SetRepeatedInt32(int number, int index, int32_t value);
|
| 337 |
+
void SetRepeatedInt64(int number, int index, int64_t value);
|
| 338 |
+
void SetRepeatedUInt32(int number, int index, uint32_t value);
|
| 339 |
+
void SetRepeatedUInt64(int number, int index, uint64_t value);
|
| 340 |
+
void SetRepeatedFloat(int number, int index, float value);
|
| 341 |
+
void SetRepeatedDouble(int number, int index, double value);
|
| 342 |
+
void SetRepeatedBool(int number, int index, bool value);
|
| 343 |
+
void SetRepeatedEnum(int number, int index, int value);
|
| 344 |
+
void SetRepeatedString(int number, int index, std::string value);
|
| 345 |
+
std::string* MutableRepeatedString(int number, int index);
|
| 346 |
+
MessageLite* MutableRepeatedMessage(int number, int index);
|
| 347 |
+
|
| 348 |
+
#define desc const FieldDescriptor* descriptor // avoid line wrapping
|
| 349 |
+
void AddInt32(int number, FieldType type, bool packed, int32_t value, desc);
|
| 350 |
+
void AddInt64(int number, FieldType type, bool packed, int64_t value, desc);
|
| 351 |
+
void AddUInt32(int number, FieldType type, bool packed, uint32_t value, desc);
|
| 352 |
+
void AddUInt64(int number, FieldType type, bool packed, uint64_t value, desc);
|
| 353 |
+
void AddFloat(int number, FieldType type, bool packed, float value, desc);
|
| 354 |
+
void AddDouble(int number, FieldType type, bool packed, double value, desc);
|
| 355 |
+
void AddBool(int number, FieldType type, bool packed, bool value, desc);
|
| 356 |
+
void AddEnum(int number, FieldType type, bool packed, int value, desc);
|
| 357 |
+
void AddString(int number, FieldType type, std::string value, desc);
|
| 358 |
+
std::string* AddString(int number, FieldType type, desc);
|
| 359 |
+
MessageLite* AddMessage(int number, FieldType type,
|
| 360 |
+
const MessageLite& prototype, desc);
|
| 361 |
+
MessageLite* AddMessage(const FieldDescriptor* descriptor,
|
| 362 |
+
MessageFactory* factory);
|
| 363 |
+
void AddAllocatedMessage(const FieldDescriptor* descriptor,
|
| 364 |
+
MessageLite* new_entry);
|
| 365 |
+
void UnsafeArenaAddAllocatedMessage(const FieldDescriptor* descriptor,
|
| 366 |
+
MessageLite* new_entry);
|
| 367 |
+
#undef desc
|
| 368 |
+
|
| 369 |
+
void RemoveLast(int number);
|
| 370 |
+
PROTOBUF_NODISCARD MessageLite* ReleaseLast(int number);
|
| 371 |
+
MessageLite* UnsafeArenaReleaseLast(int number);
|
| 372 |
+
void SwapElements(int number, int index1, int index2);
|
| 373 |
+
|
| 374 |
+
// =================================================================
|
| 375 |
+
// convenience methods for implementing methods of Message
|
| 376 |
+
//
|
| 377 |
+
// These could all be implemented in terms of the other methods of this
|
| 378 |
+
// class, but providing them here helps keep the generated code size down.
|
| 379 |
+
|
| 380 |
+
void Clear();
|
| 381 |
+
void MergeFrom(const MessageLite* extendee, const ExtensionSet& other);
|
| 382 |
+
void Swap(const MessageLite* extendee, ExtensionSet* other);
|
| 383 |
+
void InternalSwap(ExtensionSet* other);
|
| 384 |
+
void SwapExtension(const MessageLite* extendee, ExtensionSet* other,
|
| 385 |
+
int number);
|
| 386 |
+
void UnsafeShallowSwapExtension(ExtensionSet* other, int number);
|
| 387 |
+
bool IsInitialized() const;
|
| 388 |
+
|
| 389 |
+
// Lite parser
|
| 390 |
+
const char* ParseField(uint64_t tag, const char* ptr,
|
| 391 |
+
const MessageLite* extendee,
|
| 392 |
+
internal::InternalMetadata* metadata,
|
| 393 |
+
internal::ParseContext* ctx);
|
| 394 |
+
// Full parser
|
| 395 |
+
const char* ParseField(uint64_t tag, const char* ptr, const Message* extendee,
|
| 396 |
+
internal::InternalMetadata* metadata,
|
| 397 |
+
internal::ParseContext* ctx);
|
| 398 |
+
template <typename Msg>
|
| 399 |
+
const char* ParseMessageSet(const char* ptr, const Msg* extendee,
|
| 400 |
+
InternalMetadata* metadata,
|
| 401 |
+
internal::ParseContext* ctx) {
|
| 402 |
+
struct MessageSetItem {
|
| 403 |
+
const char* _InternalParse(const char* ptr, ParseContext* ctx) {
|
| 404 |
+
return me->ParseMessageSetItem(ptr, extendee, metadata, ctx);
|
| 405 |
+
}
|
| 406 |
+
ExtensionSet* me;
|
| 407 |
+
const Msg* extendee;
|
| 408 |
+
InternalMetadata* metadata;
|
| 409 |
+
} item{this, extendee, metadata};
|
| 410 |
+
while (!ctx->Done(&ptr)) {
|
| 411 |
+
uint32_t tag;
|
| 412 |
+
ptr = ReadTag(ptr, &tag);
|
| 413 |
+
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
| 414 |
+
if (tag == WireFormatLite::kMessageSetItemStartTag) {
|
| 415 |
+
ptr = ctx->ParseGroup(&item, ptr, tag);
|
| 416 |
+
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
| 417 |
+
} else {
|
| 418 |
+
if (tag == 0 || (tag & 7) == 4) {
|
| 419 |
+
ctx->SetLastTag(tag);
|
| 420 |
+
return ptr;
|
| 421 |
+
}
|
| 422 |
+
ptr = ParseField(tag, ptr, extendee, metadata, ctx);
|
| 423 |
+
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
| 424 |
+
}
|
| 425 |
+
}
|
| 426 |
+
return ptr;
|
| 427 |
+
}
|
| 428 |
+
|
| 429 |
+
// Write all extension fields with field numbers in the range
|
| 430 |
+
// [start_field_number, end_field_number)
|
| 431 |
+
// to the output stream, using the cached sizes computed when ByteSize() was
|
| 432 |
+
// last called. Note that the range bounds are inclusive-exclusive.
|
| 433 |
+
void SerializeWithCachedSizes(const MessageLite* extendee,
|
| 434 |
+
int start_field_number, int end_field_number,
|
| 435 |
+
io::CodedOutputStream* output) const {
|
| 436 |
+
output->SetCur(_InternalSerialize(extendee, start_field_number,
|
| 437 |
+
end_field_number, output->Cur(),
|
| 438 |
+
output->EpsCopy()));
|
| 439 |
+
}
|
| 440 |
+
|
| 441 |
+
// Same as SerializeWithCachedSizes, but without any bounds checking.
|
| 442 |
+
// The caller must ensure that target has sufficient capacity for the
|
| 443 |
+
// serialized extensions.
|
| 444 |
+
//
|
| 445 |
+
// Returns a pointer past the last written byte.
|
| 446 |
+
|
| 447 |
+
uint8_t* _InternalSerialize(const MessageLite* extendee,
|
| 448 |
+
int start_field_number, int end_field_number,
|
| 449 |
+
uint8_t* target,
|
| 450 |
+
io::EpsCopyOutputStream* stream) const {
|
| 451 |
+
if (flat_size_ == 0) {
|
| 452 |
+
assert(!is_large());
|
| 453 |
+
return target;
|
| 454 |
+
}
|
| 455 |
+
return _InternalSerializeImpl(extendee, start_field_number,
|
| 456 |
+
end_field_number, target, stream);
|
| 457 |
+
}
|
| 458 |
+
|
| 459 |
+
// Like above but serializes in MessageSet format.
|
| 460 |
+
void SerializeMessageSetWithCachedSizes(const MessageLite* extendee,
|
| 461 |
+
io::CodedOutputStream* output) const {
|
| 462 |
+
output->SetCur(InternalSerializeMessageSetWithCachedSizesToArray(
|
| 463 |
+
extendee, output->Cur(), output->EpsCopy()));
|
| 464 |
+
}
|
| 465 |
+
uint8_t* InternalSerializeMessageSetWithCachedSizesToArray(
|
| 466 |
+
const MessageLite* extendee, uint8_t* target,
|
| 467 |
+
io::EpsCopyOutputStream* stream) const;
|
| 468 |
+
|
| 469 |
+
// For backward-compatibility, versions of two of the above methods that
|
| 470 |
+
// serialize deterministically iff SetDefaultSerializationDeterministic()
|
| 471 |
+
// has been called.
|
| 472 |
+
uint8_t* SerializeWithCachedSizesToArray(int start_field_number,
|
| 473 |
+
int end_field_number,
|
| 474 |
+
uint8_t* target) const;
|
| 475 |
+
uint8_t* SerializeMessageSetWithCachedSizesToArray(
|
| 476 |
+
const MessageLite* extendee, uint8_t* target) const;
|
| 477 |
+
|
| 478 |
+
// Returns the total serialized size of all the extensions.
|
| 479 |
+
size_t ByteSize() const;
|
| 480 |
+
|
| 481 |
+
// Like ByteSize() but uses MessageSet format.
|
| 482 |
+
size_t MessageSetByteSize() const;
|
| 483 |
+
|
| 484 |
+
// Returns (an estimate of) the total number of bytes used for storing the
|
| 485 |
+
// extensions in memory, excluding sizeof(*this). If the ExtensionSet is
|
| 486 |
+
// for a lite message (and thus possibly contains lite messages), the results
|
| 487 |
+
// are undefined (might work, might crash, might corrupt data, might not even
|
| 488 |
+
// be linked in). It's up to the protocol compiler to avoid calling this on
|
| 489 |
+
// such ExtensionSets (easy enough since lite messages don't implement
|
| 490 |
+
// SpaceUsed()).
|
| 491 |
+
size_t SpaceUsedExcludingSelfLong() const;
|
| 492 |
+
|
| 493 |
+
// This method just calls SpaceUsedExcludingSelfLong() but it can not be
|
| 494 |
+
// inlined because the definition of SpaceUsedExcludingSelfLong() is not
|
| 495 |
+
// included in lite runtime and when an inline method refers to it MSVC
|
| 496 |
+
// will complain about unresolved symbols when building the lite runtime
|
| 497 |
+
// as .dll.
|
| 498 |
+
int SpaceUsedExcludingSelf() const;
|
| 499 |
+
|
| 500 |
+
private:
|
| 501 |
+
template <typename Type>
|
| 502 |
+
friend class PrimitiveTypeTraits;
|
| 503 |
+
|
| 504 |
+
template <typename Type>
|
| 505 |
+
friend class RepeatedPrimitiveTypeTraits;
|
| 506 |
+
|
| 507 |
+
template <typename Type, bool IsValid(int)>
|
| 508 |
+
friend class EnumTypeTraits;
|
| 509 |
+
|
| 510 |
+
template <typename Type, bool IsValid(int)>
|
| 511 |
+
friend class RepeatedEnumTypeTraits;
|
| 512 |
+
|
| 513 |
+
friend class google::protobuf::Reflection;
|
| 514 |
+
|
| 515 |
+
const int32_t& GetRefInt32(int number, const int32_t& default_value) const;
|
| 516 |
+
const int64_t& GetRefInt64(int number, const int64_t& default_value) const;
|
| 517 |
+
const uint32_t& GetRefUInt32(int number, const uint32_t& default_value) const;
|
| 518 |
+
const uint64_t& GetRefUInt64(int number, const uint64_t& default_value) const;
|
| 519 |
+
const float& GetRefFloat(int number, const float& default_value) const;
|
| 520 |
+
const double& GetRefDouble(int number, const double& default_value) const;
|
| 521 |
+
const bool& GetRefBool(int number, const bool& default_value) const;
|
| 522 |
+
const int& GetRefEnum(int number, const int& default_value) const;
|
| 523 |
+
const int32_t& GetRefRepeatedInt32(int number, int index) const;
|
| 524 |
+
const int64_t& GetRefRepeatedInt64(int number, int index) const;
|
| 525 |
+
const uint32_t& GetRefRepeatedUInt32(int number, int index) const;
|
| 526 |
+
const uint64_t& GetRefRepeatedUInt64(int number, int index) const;
|
| 527 |
+
const float& GetRefRepeatedFloat(int number, int index) const;
|
| 528 |
+
const double& GetRefRepeatedDouble(int number, int index) const;
|
| 529 |
+
const bool& GetRefRepeatedBool(int number, int index) const;
|
| 530 |
+
const int& GetRefRepeatedEnum(int number, int index) const;
|
| 531 |
+
|
| 532 |
+
// Implementation of _InternalSerialize for non-empty map_.
|
| 533 |
+
uint8_t* _InternalSerializeImpl(const MessageLite* extendee,
|
| 534 |
+
int start_field_number, int end_field_number,
|
| 535 |
+
uint8_t* target,
|
| 536 |
+
io::EpsCopyOutputStream* stream) const;
|
| 537 |
+
// Interface of a lazily parsed singular message extension.
|
| 538 |
+
class PROTOBUF_EXPORT LazyMessageExtension {
|
| 539 |
+
public:
|
| 540 |
+
LazyMessageExtension() {}
|
| 541 |
+
virtual ~LazyMessageExtension() {}
|
| 542 |
+
|
| 543 |
+
virtual LazyMessageExtension* New(Arena* arena) const = 0;
|
| 544 |
+
virtual const MessageLite& GetMessage(const MessageLite& prototype,
|
| 545 |
+
Arena* arena) const = 0;
|
| 546 |
+
virtual MessageLite* MutableMessage(const MessageLite& prototype,
|
| 547 |
+
Arena* arena) = 0;
|
| 548 |
+
virtual void SetAllocatedMessage(MessageLite* message, Arena* arena) = 0;
|
| 549 |
+
virtual void UnsafeArenaSetAllocatedMessage(MessageLite* message,
|
| 550 |
+
Arena* arena) = 0;
|
| 551 |
+
PROTOBUF_NODISCARD virtual MessageLite* ReleaseMessage(
|
| 552 |
+
const MessageLite& prototype, Arena* arena) = 0;
|
| 553 |
+
virtual MessageLite* UnsafeArenaReleaseMessage(const MessageLite& prototype,
|
| 554 |
+
Arena* arena) = 0;
|
| 555 |
+
|
| 556 |
+
virtual bool IsInitialized() const = 0;
|
| 557 |
+
|
| 558 |
+
PROTOBUF_DEPRECATED_MSG("Please use ByteSizeLong() instead")
|
| 559 |
+
virtual int ByteSize() const { return internal::ToIntSize(ByteSizeLong()); }
|
| 560 |
+
virtual size_t ByteSizeLong() const = 0;
|
| 561 |
+
virtual size_t SpaceUsedLong() const = 0;
|
| 562 |
+
|
| 563 |
+
virtual void MergeFrom(const MessageLite* prototype,
|
| 564 |
+
const LazyMessageExtension& other, Arena* arena) = 0;
|
| 565 |
+
virtual void MergeFromMessage(const MessageLite& msg, Arena* arena) = 0;
|
| 566 |
+
virtual void Clear() = 0;
|
| 567 |
+
|
| 568 |
+
virtual const char* _InternalParse(const Message& prototype, Arena* arena,
|
| 569 |
+
LazyVerifyOption option, const char* ptr,
|
| 570 |
+
ParseContext* ctx) = 0;
|
| 571 |
+
virtual uint8_t* WriteMessageToArray(
|
| 572 |
+
const MessageLite* prototype, int number, uint8_t* target,
|
| 573 |
+
io::EpsCopyOutputStream* stream) const = 0;
|
| 574 |
+
|
| 575 |
+
private:
|
| 576 |
+
virtual void UnusedKeyMethod(); // Dummy key method to avoid weak vtable.
|
| 577 |
+
|
| 578 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LazyMessageExtension);
|
| 579 |
+
};
|
| 580 |
+
// Give access to function defined below to see LazyMessageExtension.
|
| 581 |
+
friend LazyMessageExtension* MaybeCreateLazyExtension(Arena* arena);
|
| 582 |
+
struct Extension {
|
| 583 |
+
// The order of these fields packs Extension into 24 bytes when using 8
|
| 584 |
+
// byte alignment. Consider this when adding or removing fields here.
|
| 585 |
+
union {
|
| 586 |
+
int32_t int32_t_value;
|
| 587 |
+
int64_t int64_t_value;
|
| 588 |
+
uint32_t uint32_t_value;
|
| 589 |
+
uint64_t uint64_t_value;
|
| 590 |
+
float float_value;
|
| 591 |
+
double double_value;
|
| 592 |
+
bool bool_value;
|
| 593 |
+
int enum_value;
|
| 594 |
+
std::string* string_value;
|
| 595 |
+
MessageLite* message_value;
|
| 596 |
+
LazyMessageExtension* lazymessage_value;
|
| 597 |
+
|
| 598 |
+
RepeatedField<int32_t>* repeated_int32_t_value;
|
| 599 |
+
RepeatedField<int64_t>* repeated_int64_t_value;
|
| 600 |
+
RepeatedField<uint32_t>* repeated_uint32_t_value;
|
| 601 |
+
RepeatedField<uint64_t>* repeated_uint64_t_value;
|
| 602 |
+
RepeatedField<float>* repeated_float_value;
|
| 603 |
+
RepeatedField<double>* repeated_double_value;
|
| 604 |
+
RepeatedField<bool>* repeated_bool_value;
|
| 605 |
+
RepeatedField<int>* repeated_enum_value;
|
| 606 |
+
RepeatedPtrField<std::string>* repeated_string_value;
|
| 607 |
+
RepeatedPtrField<MessageLite>* repeated_message_value;
|
| 608 |
+
};
|
| 609 |
+
|
| 610 |
+
FieldType type;
|
| 611 |
+
bool is_repeated;
|
| 612 |
+
|
| 613 |
+
// For singular types, indicates if the extension is "cleared". This
|
| 614 |
+
// happens when an extension is set and then later cleared by the caller.
|
| 615 |
+
// We want to keep the Extension object around for reuse, so instead of
|
| 616 |
+
// removing it from the map, we just set is_cleared = true. This has no
|
| 617 |
+
// meaning for repeated types; for those, the size of the RepeatedField
|
| 618 |
+
// simply becomes zero when cleared.
|
| 619 |
+
bool is_cleared : 4;
|
| 620 |
+
|
| 621 |
+
// For singular message types, indicates whether lazy parsing is enabled
|
| 622 |
+
// for this extension. This field is only valid when type == TYPE_MESSAGE
|
| 623 |
+
// and !is_repeated because we only support lazy parsing for singular
|
| 624 |
+
// message types currently. If is_lazy = true, the extension is stored in
|
| 625 |
+
// lazymessage_value. Otherwise, the extension will be message_value.
|
| 626 |
+
bool is_lazy : 4;
|
| 627 |
+
|
| 628 |
+
// For repeated types, this indicates if the [packed=true] option is set.
|
| 629 |
+
bool is_packed;
|
| 630 |
+
|
| 631 |
+
// For packed fields, the size of the packed data is recorded here when
|
| 632 |
+
// ByteSize() is called then used during serialization.
|
| 633 |
+
// TODO(kenton): Use atomic<int> when C++ supports it.
|
| 634 |
+
mutable int cached_size;
|
| 635 |
+
|
| 636 |
+
// The descriptor for this extension, if one exists and is known. May be
|
| 637 |
+
// nullptr. Must not be nullptr if the descriptor for the extension does
|
| 638 |
+
// not live in the same pool as the descriptor for the containing type.
|
| 639 |
+
const FieldDescriptor* descriptor;
|
| 640 |
+
|
| 641 |
+
// Some helper methods for operations on a single Extension.
|
| 642 |
+
uint8_t* InternalSerializeFieldWithCachedSizesToArray(
|
| 643 |
+
const MessageLite* extendee, const ExtensionSet* extension_set,
|
| 644 |
+
int number, uint8_t* target, io::EpsCopyOutputStream* stream) const;
|
| 645 |
+
uint8_t* InternalSerializeMessageSetItemWithCachedSizesToArray(
|
| 646 |
+
const MessageLite* extendee, const ExtensionSet* extension_set,
|
| 647 |
+
int number, uint8_t* target, io::EpsCopyOutputStream* stream) const;
|
| 648 |
+
size_t ByteSize(int number) const;
|
| 649 |
+
size_t MessageSetItemByteSize(int number) const;
|
| 650 |
+
void Clear();
|
| 651 |
+
int GetSize() const;
|
| 652 |
+
void Free();
|
| 653 |
+
size_t SpaceUsedExcludingSelfLong() const;
|
| 654 |
+
bool IsInitialized() const;
|
| 655 |
+
};
|
| 656 |
+
|
| 657 |
+
// The Extension struct is small enough to be passed by value, so we use it
|
| 658 |
+
// directly as the value type in mappings rather than use pointers. We use
|
| 659 |
+
// sorted maps rather than hash-maps because we expect most ExtensionSets will
|
| 660 |
+
// only contain a small number of extension. Also, we want AppendToList and
|
| 661 |
+
// deterministic serialization to order fields by field number.
|
| 662 |
+
|
| 663 |
+
struct KeyValue {
|
| 664 |
+
int first;
|
| 665 |
+
Extension second;
|
| 666 |
+
|
| 667 |
+
struct FirstComparator {
|
| 668 |
+
bool operator()(const KeyValue& lhs, const KeyValue& rhs) const {
|
| 669 |
+
return lhs.first < rhs.first;
|
| 670 |
+
}
|
| 671 |
+
bool operator()(const KeyValue& lhs, int key) const {
|
| 672 |
+
return lhs.first < key;
|
| 673 |
+
}
|
| 674 |
+
bool operator()(int key, const KeyValue& rhs) const {
|
| 675 |
+
return key < rhs.first;
|
| 676 |
+
}
|
| 677 |
+
};
|
| 678 |
+
};
|
| 679 |
+
|
| 680 |
+
typedef std::map<int, Extension> LargeMap;
|
| 681 |
+
|
| 682 |
+
// Wrapper API that switches between flat-map and LargeMap.
|
| 683 |
+
|
| 684 |
+
// Finds a key (if present) in the ExtensionSet.
|
| 685 |
+
const Extension* FindOrNull(int key) const;
|
| 686 |
+
Extension* FindOrNull(int key);
|
| 687 |
+
|
| 688 |
+
// Helper-functions that only inspect the LargeMap.
|
| 689 |
+
const Extension* FindOrNullInLargeMap(int key) const;
|
| 690 |
+
Extension* FindOrNullInLargeMap(int key);
|
| 691 |
+
|
| 692 |
+
// Inserts a new (key, Extension) into the ExtensionSet (and returns true), or
|
| 693 |
+
// finds the already-existing Extension for that key (returns false).
|
| 694 |
+
// The Extension* will point to the new-or-found Extension.
|
| 695 |
+
std::pair<Extension*, bool> Insert(int key);
|
| 696 |
+
|
| 697 |
+
// Grows the flat_capacity_.
|
| 698 |
+
// If flat_capacity_ > kMaximumFlatCapacity, converts to LargeMap.
|
| 699 |
+
void GrowCapacity(size_t minimum_new_capacity);
|
| 700 |
+
static constexpr uint16_t kMaximumFlatCapacity = 256;
|
| 701 |
+
bool is_large() const { return static_cast<int16_t>(flat_size_) < 0; }
|
| 702 |
+
|
| 703 |
+
// Removes a key from the ExtensionSet.
|
| 704 |
+
void Erase(int key);
|
| 705 |
+
|
| 706 |
+
size_t Size() const {
|
| 707 |
+
return PROTOBUF_PREDICT_FALSE(is_large()) ? map_.large->size() : flat_size_;
|
| 708 |
+
}
|
| 709 |
+
|
| 710 |
+
// Similar to std::for_each.
|
| 711 |
+
// Each Iterator is decomposed into ->first and ->second fields, so
|
| 712 |
+
// that the KeyValueFunctor can be agnostic vis-a-vis KeyValue-vs-std::pair.
|
| 713 |
+
template <typename Iterator, typename KeyValueFunctor>
|
| 714 |
+
static KeyValueFunctor ForEach(Iterator begin, Iterator end,
|
| 715 |
+
KeyValueFunctor func) {
|
| 716 |
+
for (Iterator it = begin; it != end; ++it) func(it->first, it->second);
|
| 717 |
+
return std::move(func);
|
| 718 |
+
}
|
| 719 |
+
|
| 720 |
+
// Applies a functor to the <int, Extension&> pairs in sorted order.
|
| 721 |
+
template <typename KeyValueFunctor>
|
| 722 |
+
KeyValueFunctor ForEach(KeyValueFunctor func) {
|
| 723 |
+
if (PROTOBUF_PREDICT_FALSE(is_large())) {
|
| 724 |
+
return ForEach(map_.large->begin(), map_.large->end(), std::move(func));
|
| 725 |
+
}
|
| 726 |
+
return ForEach(flat_begin(), flat_end(), std::move(func));
|
| 727 |
+
}
|
| 728 |
+
|
| 729 |
+
// Applies a functor to the <int, const Extension&> pairs in sorted order.
|
| 730 |
+
template <typename KeyValueFunctor>
|
| 731 |
+
KeyValueFunctor ForEach(KeyValueFunctor func) const {
|
| 732 |
+
if (PROTOBUF_PREDICT_FALSE(is_large())) {
|
| 733 |
+
return ForEach(map_.large->begin(), map_.large->end(), std::move(func));
|
| 734 |
+
}
|
| 735 |
+
return ForEach(flat_begin(), flat_end(), std::move(func));
|
| 736 |
+
}
|
| 737 |
+
|
| 738 |
+
// Merges existing Extension from other_extension
|
| 739 |
+
void InternalExtensionMergeFrom(const MessageLite* extendee, int number,
|
| 740 |
+
const Extension& other_extension,
|
| 741 |
+
Arena* other_arena);
|
| 742 |
+
|
| 743 |
+
inline static bool is_packable(WireFormatLite::WireType type) {
|
| 744 |
+
switch (type) {
|
| 745 |
+
case WireFormatLite::WIRETYPE_VARINT:
|
| 746 |
+
case WireFormatLite::WIRETYPE_FIXED64:
|
| 747 |
+
case WireFormatLite::WIRETYPE_FIXED32:
|
| 748 |
+
return true;
|
| 749 |
+
case WireFormatLite::WIRETYPE_LENGTH_DELIMITED:
|
| 750 |
+
case WireFormatLite::WIRETYPE_START_GROUP:
|
| 751 |
+
case WireFormatLite::WIRETYPE_END_GROUP:
|
| 752 |
+
return false;
|
| 753 |
+
|
| 754 |
+
// Do not add a default statement. Let the compiler complain when
|
| 755 |
+
// someone
|
| 756 |
+
// adds a new wire type.
|
| 757 |
+
}
|
| 758 |
+
PROTOBUF_ASSUME(false); // switch handles all possible enum values
|
| 759 |
+
return false;
|
| 760 |
+
}
|
| 761 |
+
|
| 762 |
+
// Returns true and fills field_number and extension if extension is found.
|
| 763 |
+
// Note to support packed repeated field compatibility, it also fills whether
|
| 764 |
+
// the tag on wire is packed, which can be different from
|
| 765 |
+
// extension->is_packed (whether packed=true is specified).
|
| 766 |
+
template <typename ExtensionFinder>
|
| 767 |
+
bool FindExtensionInfoFromTag(uint32_t tag, ExtensionFinder* extension_finder,
|
| 768 |
+
int* field_number, ExtensionInfo* extension,
|
| 769 |
+
bool* was_packed_on_wire) {
|
| 770 |
+
*field_number = WireFormatLite::GetTagFieldNumber(tag);
|
| 771 |
+
WireFormatLite::WireType wire_type = WireFormatLite::GetTagWireType(tag);
|
| 772 |
+
return FindExtensionInfoFromFieldNumber(wire_type, *field_number,
|
| 773 |
+
extension_finder, extension,
|
| 774 |
+
was_packed_on_wire);
|
| 775 |
+
}
|
| 776 |
+
|
| 777 |
+
// Returns true and fills extension if extension is found.
|
| 778 |
+
// Note to support packed repeated field compatibility, it also fills whether
|
| 779 |
+
// the tag on wire is packed, which can be different from
|
| 780 |
+
// extension->is_packed (whether packed=true is specified).
|
| 781 |
+
template <typename ExtensionFinder>
|
| 782 |
+
bool FindExtensionInfoFromFieldNumber(int wire_type, int field_number,
|
| 783 |
+
ExtensionFinder* extension_finder,
|
| 784 |
+
ExtensionInfo* extension,
|
| 785 |
+
bool* was_packed_on_wire) const {
|
| 786 |
+
if (!extension_finder->Find(field_number, extension)) {
|
| 787 |
+
return false;
|
| 788 |
+
}
|
| 789 |
+
|
| 790 |
+
GOOGLE_DCHECK(extension->type > 0 &&
|
| 791 |
+
extension->type <= WireFormatLite::MAX_FIELD_TYPE);
|
| 792 |
+
auto real_type = static_cast<WireFormatLite::FieldType>(extension->type);
|
| 793 |
+
|
| 794 |
+
WireFormatLite::WireType expected_wire_type =
|
| 795 |
+
WireFormatLite::WireTypeForFieldType(real_type);
|
| 796 |
+
|
| 797 |
+
// Check if this is a packed field.
|
| 798 |
+
*was_packed_on_wire = false;
|
| 799 |
+
if (extension->is_repeated &&
|
| 800 |
+
wire_type == WireFormatLite::WIRETYPE_LENGTH_DELIMITED &&
|
| 801 |
+
is_packable(expected_wire_type)) {
|
| 802 |
+
*was_packed_on_wire = true;
|
| 803 |
+
return true;
|
| 804 |
+
}
|
| 805 |
+
// Otherwise the wire type must match.
|
| 806 |
+
return expected_wire_type == wire_type;
|
| 807 |
+
}
|
| 808 |
+
|
| 809 |
+
// Find the prototype for a LazyMessage from the extension registry. Returns
|
| 810 |
+
// null if the extension is not found.
|
| 811 |
+
const MessageLite* GetPrototypeForLazyMessage(const MessageLite* extendee,
|
| 812 |
+
int number) const;
|
| 813 |
+
|
| 814 |
+
// Returns true if extension is present and lazy.
|
| 815 |
+
bool HasLazy(int number) const;
|
| 816 |
+
|
| 817 |
+
// Gets the extension with the given number, creating it if it does not
|
| 818 |
+
// already exist. Returns true if the extension did not already exist.
|
| 819 |
+
bool MaybeNewExtension(int number, const FieldDescriptor* descriptor,
|
| 820 |
+
Extension** result);
|
| 821 |
+
|
| 822 |
+
// Gets the repeated extension for the given descriptor, creating it if
|
| 823 |
+
// it does not exist.
|
| 824 |
+
Extension* MaybeNewRepeatedExtension(const FieldDescriptor* descriptor);
|
| 825 |
+
|
| 826 |
+
bool FindExtension(int wire_type, uint32_t field, const MessageLite* extendee,
|
| 827 |
+
const internal::ParseContext* /*ctx*/,
|
| 828 |
+
ExtensionInfo* extension, bool* was_packed_on_wire) {
|
| 829 |
+
GeneratedExtensionFinder finder(extendee);
|
| 830 |
+
return FindExtensionInfoFromFieldNumber(wire_type, field, &finder,
|
| 831 |
+
extension, was_packed_on_wire);
|
| 832 |
+
}
|
| 833 |
+
inline bool FindExtension(int wire_type, uint32_t field,
|
| 834 |
+
const Message* extendee,
|
| 835 |
+
const internal::ParseContext* ctx,
|
| 836 |
+
ExtensionInfo* extension, bool* was_packed_on_wire);
|
| 837 |
+
// Used for MessageSet only
|
| 838 |
+
const char* ParseFieldMaybeLazily(uint64_t tag, const char* ptr,
|
| 839 |
+
const MessageLite* extendee,
|
| 840 |
+
internal::InternalMetadata* metadata,
|
| 841 |
+
internal::ParseContext* ctx) {
|
| 842 |
+
// Lite MessageSet doesn't implement lazy.
|
| 843 |
+
return ParseField(tag, ptr, extendee, metadata, ctx);
|
| 844 |
+
}
|
| 845 |
+
const char* ParseFieldMaybeLazily(uint64_t tag, const char* ptr,
|
| 846 |
+
const Message* extendee,
|
| 847 |
+
internal::InternalMetadata* metadata,
|
| 848 |
+
internal::ParseContext* ctx);
|
| 849 |
+
const char* ParseMessageSetItem(const char* ptr, const MessageLite* extendee,
|
| 850 |
+
internal::InternalMetadata* metadata,
|
| 851 |
+
internal::ParseContext* ctx);
|
| 852 |
+
const char* ParseMessageSetItem(const char* ptr, const Message* extendee,
|
| 853 |
+
internal::InternalMetadata* metadata,
|
| 854 |
+
internal::ParseContext* ctx);
|
| 855 |
+
|
| 856 |
+
// Implemented in extension_set_inl.h to keep code out of the header file.
|
| 857 |
+
template <typename T>
|
| 858 |
+
const char* ParseFieldWithExtensionInfo(int number, bool was_packed_on_wire,
|
| 859 |
+
const ExtensionInfo& info,
|
| 860 |
+
internal::InternalMetadata* metadata,
|
| 861 |
+
const char* ptr,
|
| 862 |
+
internal::ParseContext* ctx);
|
| 863 |
+
template <typename Msg, typename T>
|
| 864 |
+
const char* ParseMessageSetItemTmpl(const char* ptr, const Msg* extendee,
|
| 865 |
+
internal::InternalMetadata* metadata,
|
| 866 |
+
internal::ParseContext* ctx);
|
| 867 |
+
|
| 868 |
+
// Hack: RepeatedPtrFieldBase declares ExtensionSet as a friend. This
|
| 869 |
+
// friendship should automatically extend to ExtensionSet::Extension, but
|
| 870 |
+
// unfortunately some older compilers (e.g. GCC 3.4.4) do not implement this
|
| 871 |
+
// correctly. So, we must provide helpers for calling methods of that
|
| 872 |
+
// class.
|
| 873 |
+
|
| 874 |
+
// Defined in extension_set_heavy.cc.
|
| 875 |
+
static inline size_t RepeatedMessage_SpaceUsedExcludingSelfLong(
|
| 876 |
+
RepeatedPtrFieldBase* field);
|
| 877 |
+
|
| 878 |
+
KeyValue* flat_begin() {
|
| 879 |
+
assert(!is_large());
|
| 880 |
+
return map_.flat;
|
| 881 |
+
}
|
| 882 |
+
const KeyValue* flat_begin() const {
|
| 883 |
+
assert(!is_large());
|
| 884 |
+
return map_.flat;
|
| 885 |
+
}
|
| 886 |
+
KeyValue* flat_end() {
|
| 887 |
+
assert(!is_large());
|
| 888 |
+
return map_.flat + flat_size_;
|
| 889 |
+
}
|
| 890 |
+
const KeyValue* flat_end() const {
|
| 891 |
+
assert(!is_large());
|
| 892 |
+
return map_.flat + flat_size_;
|
| 893 |
+
}
|
| 894 |
+
|
| 895 |
+
Arena* arena_;
|
| 896 |
+
|
| 897 |
+
// Manual memory-management:
|
| 898 |
+
// map_.flat is an allocated array of flat_capacity_ elements.
|
| 899 |
+
// [map_.flat, map_.flat + flat_size_) is the currently-in-use prefix.
|
| 900 |
+
uint16_t flat_capacity_;
|
| 901 |
+
uint16_t flat_size_; // negative int16_t(flat_size_) indicates is_large()
|
| 902 |
+
union AllocatedData {
|
| 903 |
+
KeyValue* flat;
|
| 904 |
+
|
| 905 |
+
// If flat_capacity_ > kMaximumFlatCapacity, switch to LargeMap,
|
| 906 |
+
// which guarantees O(n lg n) CPU but larger constant factors.
|
| 907 |
+
LargeMap* large;
|
| 908 |
+
} map_;
|
| 909 |
+
|
| 910 |
+
static void DeleteFlatMap(const KeyValue* flat, uint16_t flat_capacity);
|
| 911 |
+
|
| 912 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionSet);
|
| 913 |
+
};
|
| 914 |
+
|
| 915 |
+
constexpr ExtensionSet::ExtensionSet()
|
| 916 |
+
: arena_(nullptr), flat_capacity_(0), flat_size_(0), map_{nullptr} {}
|
| 917 |
+
|
| 918 |
+
// These are just for convenience...
|
| 919 |
+
inline void ExtensionSet::SetString(int number, FieldType type,
|
| 920 |
+
std::string value,
|
| 921 |
+
const FieldDescriptor* descriptor) {
|
| 922 |
+
MutableString(number, type, descriptor)->assign(std::move(value));
|
| 923 |
+
}
|
| 924 |
+
inline void ExtensionSet::SetRepeatedString(int number, int index,
|
| 925 |
+
std::string value) {
|
| 926 |
+
MutableRepeatedString(number, index)->assign(std::move(value));
|
| 927 |
+
}
|
| 928 |
+
inline void ExtensionSet::AddString(int number, FieldType type,
|
| 929 |
+
std::string value,
|
| 930 |
+
const FieldDescriptor* descriptor) {
|
| 931 |
+
AddString(number, type, descriptor)->assign(std::move(value));
|
| 932 |
+
}
|
| 933 |
+
// ===================================================================
|
| 934 |
+
// Glue for generated extension accessors
|
| 935 |
+
|
| 936 |
+
// -------------------------------------------------------------------
|
| 937 |
+
// Template magic
|
| 938 |
+
|
| 939 |
+
// First we have a set of classes representing "type traits" for different
|
| 940 |
+
// field types. A type traits class knows how to implement basic accessors
|
| 941 |
+
// for extensions of a particular type given an ExtensionSet. The signature
|
| 942 |
+
// for a type traits class looks like this:
|
| 943 |
+
//
|
| 944 |
+
// class TypeTraits {
|
| 945 |
+
// public:
|
| 946 |
+
// typedef ? ConstType;
|
| 947 |
+
// typedef ? MutableType;
|
| 948 |
+
// // TypeTraits for singular fields and repeated fields will define the
|
| 949 |
+
// // symbol "Singular" or "Repeated" respectively. These two symbols will
|
| 950 |
+
// // be used in extension accessors to distinguish between singular
|
| 951 |
+
// // extensions and repeated extensions. If the TypeTraits for the passed
|
| 952 |
+
// // in extension doesn't have the expected symbol defined, it means the
|
| 953 |
+
// // user is passing a repeated extension to a singular accessor, or the
|
| 954 |
+
// // opposite. In that case the C++ compiler will generate an error
|
| 955 |
+
// // message "no matching member function" to inform the user.
|
| 956 |
+
// typedef ? Singular
|
| 957 |
+
// typedef ? Repeated
|
| 958 |
+
//
|
| 959 |
+
// static inline ConstType Get(int number, const ExtensionSet& set);
|
| 960 |
+
// static inline void Set(int number, ConstType value, ExtensionSet* set);
|
| 961 |
+
// static inline MutableType Mutable(int number, ExtensionSet* set);
|
| 962 |
+
//
|
| 963 |
+
// // Variants for repeated fields.
|
| 964 |
+
// static inline ConstType Get(int number, const ExtensionSet& set,
|
| 965 |
+
// int index);
|
| 966 |
+
// static inline void Set(int number, int index,
|
| 967 |
+
// ConstType value, ExtensionSet* set);
|
| 968 |
+
// static inline MutableType Mutable(int number, int index,
|
| 969 |
+
// ExtensionSet* set);
|
| 970 |
+
// static inline void Add(int number, ConstType value, ExtensionSet* set);
|
| 971 |
+
// static inline MutableType Add(int number, ExtensionSet* set);
|
| 972 |
+
// This is used by the ExtensionIdentifier constructor to register
|
| 973 |
+
// the extension at dynamic initialization.
|
| 974 |
+
// template <typename ExtendeeT>
|
| 975 |
+
// static void Register(int number, FieldType type, bool is_packed);
|
| 976 |
+
// };
|
| 977 |
+
//
|
| 978 |
+
// Not all of these methods make sense for all field types. For example, the
|
| 979 |
+
// "Mutable" methods only make sense for strings and messages, and the
|
| 980 |
+
// repeated methods only make sense for repeated types. So, each type
|
| 981 |
+
// traits class implements only the set of methods from this signature that it
|
| 982 |
+
// actually supports. This will cause a compiler error if the user tries to
|
| 983 |
+
// access an extension using a method that doesn't make sense for its type.
|
| 984 |
+
// For example, if "foo" is an extension of type "optional int32", then if you
|
| 985 |
+
// try to write code like:
|
| 986 |
+
// my_message.MutableExtension(foo)
|
| 987 |
+
// you will get a compile error because PrimitiveTypeTraits<int32_t> does not
|
| 988 |
+
// have a "Mutable()" method.
|
| 989 |
+
|
| 990 |
+
// -------------------------------------------------------------------
|
| 991 |
+
// PrimitiveTypeTraits
|
| 992 |
+
|
| 993 |
+
// Since the ExtensionSet has different methods for each primitive type,
|
| 994 |
+
// we must explicitly define the methods of the type traits class for each
|
| 995 |
+
// known type.
|
| 996 |
+
template <typename Type>
|
| 997 |
+
class PrimitiveTypeTraits {
|
| 998 |
+
public:
|
| 999 |
+
typedef Type ConstType;
|
| 1000 |
+
typedef Type MutableType;
|
| 1001 |
+
typedef PrimitiveTypeTraits<Type> Singular;
|
| 1002 |
+
|
| 1003 |
+
static inline ConstType Get(int number, const ExtensionSet& set,
|
| 1004 |
+
ConstType default_value);
|
| 1005 |
+
|
| 1006 |
+
static inline const ConstType* GetPtr(int number, const ExtensionSet& set,
|
| 1007 |
+
const ConstType& default_value);
|
| 1008 |
+
static inline void Set(int number, FieldType field_type, ConstType value,
|
| 1009 |
+
ExtensionSet* set);
|
| 1010 |
+
template <typename ExtendeeT>
|
| 1011 |
+
static void Register(int number, FieldType type, bool is_packed,
|
| 1012 |
+
LazyEagerVerifyFnType verify_func) {
|
| 1013 |
+
ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number,
|
| 1014 |
+
type, false, is_packed, verify_func);
|
| 1015 |
+
}
|
| 1016 |
+
};
|
| 1017 |
+
|
| 1018 |
+
template <typename Type>
|
| 1019 |
+
class RepeatedPrimitiveTypeTraits {
|
| 1020 |
+
public:
|
| 1021 |
+
typedef Type ConstType;
|
| 1022 |
+
typedef Type MutableType;
|
| 1023 |
+
typedef RepeatedPrimitiveTypeTraits<Type> Repeated;
|
| 1024 |
+
|
| 1025 |
+
typedef RepeatedField<Type> RepeatedFieldType;
|
| 1026 |
+
|
| 1027 |
+
static inline Type Get(int number, const ExtensionSet& set, int index);
|
| 1028 |
+
static inline const Type* GetPtr(int number, const ExtensionSet& set,
|
| 1029 |
+
int index);
|
| 1030 |
+
static inline const RepeatedField<ConstType>* GetRepeatedPtr(
|
| 1031 |
+
int number, const ExtensionSet& set);
|
| 1032 |
+
static inline void Set(int number, int index, Type value, ExtensionSet* set);
|
| 1033 |
+
static inline void Add(int number, FieldType field_type, bool is_packed,
|
| 1034 |
+
Type value, ExtensionSet* set);
|
| 1035 |
+
|
| 1036 |
+
static inline const RepeatedField<ConstType>& GetRepeated(
|
| 1037 |
+
int number, const ExtensionSet& set);
|
| 1038 |
+
static inline RepeatedField<Type>* MutableRepeated(int number,
|
| 1039 |
+
FieldType field_type,
|
| 1040 |
+
bool is_packed,
|
| 1041 |
+
ExtensionSet* set);
|
| 1042 |
+
|
| 1043 |
+
static const RepeatedFieldType* GetDefaultRepeatedField();
|
| 1044 |
+
template <typename ExtendeeT>
|
| 1045 |
+
static void Register(int number, FieldType type, bool is_packed,
|
| 1046 |
+
LazyEagerVerifyFnType verify_func) {
|
| 1047 |
+
ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number,
|
| 1048 |
+
type, true, is_packed, verify_func);
|
| 1049 |
+
}
|
| 1050 |
+
};
|
| 1051 |
+
|
| 1052 |
+
class PROTOBUF_EXPORT RepeatedPrimitiveDefaults {
|
| 1053 |
+
private:
|
| 1054 |
+
template <typename Type>
|
| 1055 |
+
friend class RepeatedPrimitiveTypeTraits;
|
| 1056 |
+
static const RepeatedPrimitiveDefaults* default_instance();
|
| 1057 |
+
RepeatedField<int32_t> default_repeated_field_int32_t_;
|
| 1058 |
+
RepeatedField<int64_t> default_repeated_field_int64_t_;
|
| 1059 |
+
RepeatedField<uint32_t> default_repeated_field_uint32_t_;
|
| 1060 |
+
RepeatedField<uint64_t> default_repeated_field_uint64_t_;
|
| 1061 |
+
RepeatedField<double> default_repeated_field_double_;
|
| 1062 |
+
RepeatedField<float> default_repeated_field_float_;
|
| 1063 |
+
RepeatedField<bool> default_repeated_field_bool_;
|
| 1064 |
+
};
|
| 1065 |
+
|
| 1066 |
+
#define PROTOBUF_DEFINE_PRIMITIVE_TYPE(TYPE, METHOD) \
|
| 1067 |
+
template <> \
|
| 1068 |
+
inline TYPE PrimitiveTypeTraits<TYPE>::Get( \
|
| 1069 |
+
int number, const ExtensionSet& set, TYPE default_value) { \
|
| 1070 |
+
return set.Get##METHOD(number, default_value); \
|
| 1071 |
+
} \
|
| 1072 |
+
template <> \
|
| 1073 |
+
inline const TYPE* PrimitiveTypeTraits<TYPE>::GetPtr( \
|
| 1074 |
+
int number, const ExtensionSet& set, const TYPE& default_value) { \
|
| 1075 |
+
return &set.GetRef##METHOD(number, default_value); \
|
| 1076 |
+
} \
|
| 1077 |
+
template <> \
|
| 1078 |
+
inline void PrimitiveTypeTraits<TYPE>::Set(int number, FieldType field_type, \
|
| 1079 |
+
TYPE value, ExtensionSet* set) { \
|
| 1080 |
+
set->Set##METHOD(number, field_type, value, nullptr); \
|
| 1081 |
+
} \
|
| 1082 |
+
\
|
| 1083 |
+
template <> \
|
| 1084 |
+
inline TYPE RepeatedPrimitiveTypeTraits<TYPE>::Get( \
|
| 1085 |
+
int number, const ExtensionSet& set, int index) { \
|
| 1086 |
+
return set.GetRepeated##METHOD(number, index); \
|
| 1087 |
+
} \
|
| 1088 |
+
template <> \
|
| 1089 |
+
inline const TYPE* RepeatedPrimitiveTypeTraits<TYPE>::GetPtr( \
|
| 1090 |
+
int number, const ExtensionSet& set, int index) { \
|
| 1091 |
+
return &set.GetRefRepeated##METHOD(number, index); \
|
| 1092 |
+
} \
|
| 1093 |
+
template <> \
|
| 1094 |
+
inline void RepeatedPrimitiveTypeTraits<TYPE>::Set( \
|
| 1095 |
+
int number, int index, TYPE value, ExtensionSet* set) { \
|
| 1096 |
+
set->SetRepeated##METHOD(number, index, value); \
|
| 1097 |
+
} \
|
| 1098 |
+
template <> \
|
| 1099 |
+
inline void RepeatedPrimitiveTypeTraits<TYPE>::Add( \
|
| 1100 |
+
int number, FieldType field_type, bool is_packed, TYPE value, \
|
| 1101 |
+
ExtensionSet* set) { \
|
| 1102 |
+
set->Add##METHOD(number, field_type, is_packed, value, nullptr); \
|
| 1103 |
+
} \
|
| 1104 |
+
template <> \
|
| 1105 |
+
inline const RepeatedField<TYPE>* \
|
| 1106 |
+
RepeatedPrimitiveTypeTraits<TYPE>::GetDefaultRepeatedField() { \
|
| 1107 |
+
return &RepeatedPrimitiveDefaults::default_instance() \
|
| 1108 |
+
->default_repeated_field_##TYPE##_; \
|
| 1109 |
+
} \
|
| 1110 |
+
template <> \
|
| 1111 |
+
inline const RepeatedField<TYPE>& \
|
| 1112 |
+
RepeatedPrimitiveTypeTraits<TYPE>::GetRepeated(int number, \
|
| 1113 |
+
const ExtensionSet& set) { \
|
| 1114 |
+
return *reinterpret_cast<const RepeatedField<TYPE>*>( \
|
| 1115 |
+
set.GetRawRepeatedField(number, GetDefaultRepeatedField())); \
|
| 1116 |
+
} \
|
| 1117 |
+
template <> \
|
| 1118 |
+
inline const RepeatedField<TYPE>* \
|
| 1119 |
+
RepeatedPrimitiveTypeTraits<TYPE>::GetRepeatedPtr(int number, \
|
| 1120 |
+
const ExtensionSet& set) { \
|
| 1121 |
+
return &GetRepeated(number, set); \
|
| 1122 |
+
} \
|
| 1123 |
+
template <> \
|
| 1124 |
+
inline RepeatedField<TYPE>* \
|
| 1125 |
+
RepeatedPrimitiveTypeTraits<TYPE>::MutableRepeated( \
|
| 1126 |
+
int number, FieldType field_type, bool is_packed, ExtensionSet* set) { \
|
| 1127 |
+
return reinterpret_cast<RepeatedField<TYPE>*>( \
|
| 1128 |
+
set->MutableRawRepeatedField(number, field_type, is_packed, nullptr)); \
|
| 1129 |
+
}
|
| 1130 |
+
|
| 1131 |
+
PROTOBUF_DEFINE_PRIMITIVE_TYPE(int32_t, Int32)
|
| 1132 |
+
PROTOBUF_DEFINE_PRIMITIVE_TYPE(int64_t, Int64)
|
| 1133 |
+
PROTOBUF_DEFINE_PRIMITIVE_TYPE(uint32_t, UInt32)
|
| 1134 |
+
PROTOBUF_DEFINE_PRIMITIVE_TYPE(uint64_t, UInt64)
|
| 1135 |
+
PROTOBUF_DEFINE_PRIMITIVE_TYPE(float, Float)
|
| 1136 |
+
PROTOBUF_DEFINE_PRIMITIVE_TYPE(double, Double)
|
| 1137 |
+
PROTOBUF_DEFINE_PRIMITIVE_TYPE(bool, Bool)
|
| 1138 |
+
|
| 1139 |
+
#undef PROTOBUF_DEFINE_PRIMITIVE_TYPE
|
| 1140 |
+
|
| 1141 |
+
// -------------------------------------------------------------------
|
| 1142 |
+
// StringTypeTraits
|
| 1143 |
+
|
| 1144 |
+
// Strings support both Set() and Mutable().
|
| 1145 |
+
class PROTOBUF_EXPORT StringTypeTraits {
|
| 1146 |
+
public:
|
| 1147 |
+
typedef const std::string& ConstType;
|
| 1148 |
+
typedef std::string* MutableType;
|
| 1149 |
+
typedef StringTypeTraits Singular;
|
| 1150 |
+
|
| 1151 |
+
static inline const std::string& Get(int number, const ExtensionSet& set,
|
| 1152 |
+
ConstType default_value) {
|
| 1153 |
+
return set.GetString(number, default_value);
|
| 1154 |
+
}
|
| 1155 |
+
static inline const std::string* GetPtr(int number, const ExtensionSet& set,
|
| 1156 |
+
ConstType default_value) {
|
| 1157 |
+
return &Get(number, set, default_value);
|
| 1158 |
+
}
|
| 1159 |
+
static inline void Set(int number, FieldType field_type,
|
| 1160 |
+
const std::string& value, ExtensionSet* set) {
|
| 1161 |
+
set->SetString(number, field_type, value, nullptr);
|
| 1162 |
+
}
|
| 1163 |
+
static inline std::string* Mutable(int number, FieldType field_type,
|
| 1164 |
+
ExtensionSet* set) {
|
| 1165 |
+
return set->MutableString(number, field_type, nullptr);
|
| 1166 |
+
}
|
| 1167 |
+
template <typename ExtendeeT>
|
| 1168 |
+
static void Register(int number, FieldType type, bool is_packed,
|
| 1169 |
+
LazyEagerVerifyFnType verify_func) {
|
| 1170 |
+
ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number,
|
| 1171 |
+
type, false, is_packed, verify_func);
|
| 1172 |
+
}
|
| 1173 |
+
};
|
| 1174 |
+
|
| 1175 |
+
class PROTOBUF_EXPORT RepeatedStringTypeTraits {
|
| 1176 |
+
public:
|
| 1177 |
+
typedef const std::string& ConstType;
|
| 1178 |
+
typedef std::string* MutableType;
|
| 1179 |
+
typedef RepeatedStringTypeTraits Repeated;
|
| 1180 |
+
|
| 1181 |
+
typedef RepeatedPtrField<std::string> RepeatedFieldType;
|
| 1182 |
+
|
| 1183 |
+
static inline const std::string& Get(int number, const ExtensionSet& set,
|
| 1184 |
+
int index) {
|
| 1185 |
+
return set.GetRepeatedString(number, index);
|
| 1186 |
+
}
|
| 1187 |
+
static inline const std::string* GetPtr(int number, const ExtensionSet& set,
|
| 1188 |
+
int index) {
|
| 1189 |
+
return &Get(number, set, index);
|
| 1190 |
+
}
|
| 1191 |
+
static inline const RepeatedPtrField<std::string>* GetRepeatedPtr(
|
| 1192 |
+
int number, const ExtensionSet& set) {
|
| 1193 |
+
return &GetRepeated(number, set);
|
| 1194 |
+
}
|
| 1195 |
+
static inline void Set(int number, int index, const std::string& value,
|
| 1196 |
+
ExtensionSet* set) {
|
| 1197 |
+
set->SetRepeatedString(number, index, value);
|
| 1198 |
+
}
|
| 1199 |
+
static inline std::string* Mutable(int number, int index, ExtensionSet* set) {
|
| 1200 |
+
return set->MutableRepeatedString(number, index);
|
| 1201 |
+
}
|
| 1202 |
+
static inline void Add(int number, FieldType field_type, bool /*is_packed*/,
|
| 1203 |
+
const std::string& value, ExtensionSet* set) {
|
| 1204 |
+
set->AddString(number, field_type, value, nullptr);
|
| 1205 |
+
}
|
| 1206 |
+
static inline std::string* Add(int number, FieldType field_type,
|
| 1207 |
+
ExtensionSet* set) {
|
| 1208 |
+
return set->AddString(number, field_type, nullptr);
|
| 1209 |
+
}
|
| 1210 |
+
static inline const RepeatedPtrField<std::string>& GetRepeated(
|
| 1211 |
+
int number, const ExtensionSet& set) {
|
| 1212 |
+
return *reinterpret_cast<const RepeatedPtrField<std::string>*>(
|
| 1213 |
+
set.GetRawRepeatedField(number, GetDefaultRepeatedField()));
|
| 1214 |
+
}
|
| 1215 |
+
|
| 1216 |
+
static inline RepeatedPtrField<std::string>* MutableRepeated(
|
| 1217 |
+
int number, FieldType field_type, bool is_packed, ExtensionSet* set) {
|
| 1218 |
+
return reinterpret_cast<RepeatedPtrField<std::string>*>(
|
| 1219 |
+
set->MutableRawRepeatedField(number, field_type, is_packed, nullptr));
|
| 1220 |
+
}
|
| 1221 |
+
|
| 1222 |
+
static const RepeatedFieldType* GetDefaultRepeatedField();
|
| 1223 |
+
|
| 1224 |
+
template <typename ExtendeeT>
|
| 1225 |
+
static void Register(int number, FieldType type, bool is_packed,
|
| 1226 |
+
LazyEagerVerifyFnType fn) {
|
| 1227 |
+
ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number,
|
| 1228 |
+
type, true, is_packed, fn);
|
| 1229 |
+
}
|
| 1230 |
+
|
| 1231 |
+
private:
|
| 1232 |
+
static void InitializeDefaultRepeatedFields();
|
| 1233 |
+
static void DestroyDefaultRepeatedFields();
|
| 1234 |
+
};
|
| 1235 |
+
|
| 1236 |
+
// -------------------------------------------------------------------
|
| 1237 |
+
// EnumTypeTraits
|
| 1238 |
+
|
| 1239 |
+
// ExtensionSet represents enums using integers internally, so we have to
|
| 1240 |
+
// static_cast around.
|
| 1241 |
+
template <typename Type, bool IsValid(int)>
|
| 1242 |
+
class EnumTypeTraits {
|
| 1243 |
+
public:
|
| 1244 |
+
typedef Type ConstType;
|
| 1245 |
+
typedef Type MutableType;
|
| 1246 |
+
typedef EnumTypeTraits<Type, IsValid> Singular;
|
| 1247 |
+
|
| 1248 |
+
static inline ConstType Get(int number, const ExtensionSet& set,
|
| 1249 |
+
ConstType default_value) {
|
| 1250 |
+
return static_cast<Type>(set.GetEnum(number, default_value));
|
| 1251 |
+
}
|
| 1252 |
+
static inline const ConstType* GetPtr(int number, const ExtensionSet& set,
|
| 1253 |
+
const ConstType& default_value) {
|
| 1254 |
+
return reinterpret_cast<const Type*>(
|
| 1255 |
+
&set.GetRefEnum(number, default_value));
|
| 1256 |
+
}
|
| 1257 |
+
static inline void Set(int number, FieldType field_type, ConstType value,
|
| 1258 |
+
ExtensionSet* set) {
|
| 1259 |
+
GOOGLE_DCHECK(IsValid(value));
|
| 1260 |
+
set->SetEnum(number, field_type, value, nullptr);
|
| 1261 |
+
}
|
| 1262 |
+
template <typename ExtendeeT>
|
| 1263 |
+
static void Register(int number, FieldType type, bool is_packed,
|
| 1264 |
+
LazyEagerVerifyFnType fn) {
|
| 1265 |
+
ExtensionSet::RegisterEnumExtension(&ExtendeeT::default_instance(), number,
|
| 1266 |
+
type, false, is_packed, IsValid);
|
| 1267 |
+
}
|
| 1268 |
+
};
|
| 1269 |
+
|
| 1270 |
+
template <typename Type, bool IsValid(int)>
|
| 1271 |
+
class RepeatedEnumTypeTraits {
|
| 1272 |
+
public:
|
| 1273 |
+
typedef Type ConstType;
|
| 1274 |
+
typedef Type MutableType;
|
| 1275 |
+
typedef RepeatedEnumTypeTraits<Type, IsValid> Repeated;
|
| 1276 |
+
|
| 1277 |
+
typedef RepeatedField<Type> RepeatedFieldType;
|
| 1278 |
+
|
| 1279 |
+
static inline ConstType Get(int number, const ExtensionSet& set, int index) {
|
| 1280 |
+
return static_cast<Type>(set.GetRepeatedEnum(number, index));
|
| 1281 |
+
}
|
| 1282 |
+
static inline const ConstType* GetPtr(int number, const ExtensionSet& set,
|
| 1283 |
+
int index) {
|
| 1284 |
+
return reinterpret_cast<const Type*>(
|
| 1285 |
+
&set.GetRefRepeatedEnum(number, index));
|
| 1286 |
+
}
|
| 1287 |
+
static inline void Set(int number, int index, ConstType value,
|
| 1288 |
+
ExtensionSet* set) {
|
| 1289 |
+
GOOGLE_DCHECK(IsValid(value));
|
| 1290 |
+
set->SetRepeatedEnum(number, index, value);
|
| 1291 |
+
}
|
| 1292 |
+
static inline void Add(int number, FieldType field_type, bool is_packed,
|
| 1293 |
+
ConstType value, ExtensionSet* set) {
|
| 1294 |
+
GOOGLE_DCHECK(IsValid(value));
|
| 1295 |
+
set->AddEnum(number, field_type, is_packed, value, nullptr);
|
| 1296 |
+
}
|
| 1297 |
+
static inline const RepeatedField<Type>& GetRepeated(
|
| 1298 |
+
int number, const ExtensionSet& set) {
|
| 1299 |
+
// Hack: the `Extension` struct stores a RepeatedField<int> for enums.
|
| 1300 |
+
// RepeatedField<int> cannot implicitly convert to RepeatedField<EnumType>
|
| 1301 |
+
// so we need to do some casting magic. See message.h for similar
|
| 1302 |
+
// contortions for non-extension fields.
|
| 1303 |
+
return *reinterpret_cast<const RepeatedField<Type>*>(
|
| 1304 |
+
set.GetRawRepeatedField(number, GetDefaultRepeatedField()));
|
| 1305 |
+
}
|
| 1306 |
+
static inline const RepeatedField<Type>* GetRepeatedPtr(
|
| 1307 |
+
int number, const ExtensionSet& set) {
|
| 1308 |
+
return &GetRepeated(number, set);
|
| 1309 |
+
}
|
| 1310 |
+
static inline RepeatedField<Type>* MutableRepeated(int number,
|
| 1311 |
+
FieldType field_type,
|
| 1312 |
+
bool is_packed,
|
| 1313 |
+
ExtensionSet* set) {
|
| 1314 |
+
return reinterpret_cast<RepeatedField<Type>*>(
|
| 1315 |
+
set->MutableRawRepeatedField(number, field_type, is_packed, nullptr));
|
| 1316 |
+
}
|
| 1317 |
+
|
| 1318 |
+
static const RepeatedFieldType* GetDefaultRepeatedField() {
|
| 1319 |
+
// Hack: as noted above, repeated enum fields are internally stored as a
|
| 1320 |
+
// RepeatedField<int>. We need to be able to instantiate global static
|
| 1321 |
+
// objects to return as default (empty) repeated fields on non-existent
|
| 1322 |
+
// extensions. We would not be able to know a-priori all of the enum types
|
| 1323 |
+
// (values of |Type|) to instantiate all of these, so we just re-use
|
| 1324 |
+
// int32_t's default repeated field object.
|
| 1325 |
+
return reinterpret_cast<const RepeatedField<Type>*>(
|
| 1326 |
+
RepeatedPrimitiveTypeTraits<int32_t>::GetDefaultRepeatedField());
|
| 1327 |
+
}
|
| 1328 |
+
template <typename ExtendeeT>
|
| 1329 |
+
static void Register(int number, FieldType type, bool is_packed,
|
| 1330 |
+
LazyEagerVerifyFnType fn) {
|
| 1331 |
+
ExtensionSet::RegisterEnumExtension(&ExtendeeT::default_instance(), number,
|
| 1332 |
+
type, true, is_packed, IsValid);
|
| 1333 |
+
}
|
| 1334 |
+
};
|
| 1335 |
+
|
| 1336 |
+
// -------------------------------------------------------------------
|
| 1337 |
+
// MessageTypeTraits
|
| 1338 |
+
|
| 1339 |
+
// ExtensionSet guarantees that when manipulating extensions with message
|
| 1340 |
+
// types, the implementation used will be the compiled-in class representing
|
| 1341 |
+
// that type. So, we can static_cast down to the exact type we expect.
|
| 1342 |
+
template <typename Type>
|
| 1343 |
+
class MessageTypeTraits {
|
| 1344 |
+
public:
|
| 1345 |
+
typedef const Type& ConstType;
|
| 1346 |
+
typedef Type* MutableType;
|
| 1347 |
+
typedef MessageTypeTraits<Type> Singular;
|
| 1348 |
+
|
| 1349 |
+
static inline ConstType Get(int number, const ExtensionSet& set,
|
| 1350 |
+
ConstType default_value) {
|
| 1351 |
+
return static_cast<const Type&>(set.GetMessage(number, default_value));
|
| 1352 |
+
}
|
| 1353 |
+
static inline std::nullptr_t GetPtr(int /* number */,
|
| 1354 |
+
const ExtensionSet& /* set */,
|
| 1355 |
+
ConstType /* default_value */) {
|
| 1356 |
+
// Cannot be implemented because of forward declared messages?
|
| 1357 |
+
return nullptr;
|
| 1358 |
+
}
|
| 1359 |
+
static inline MutableType Mutable(int number, FieldType field_type,
|
| 1360 |
+
ExtensionSet* set) {
|
| 1361 |
+
return static_cast<Type*>(set->MutableMessage(
|
| 1362 |
+
number, field_type, Type::default_instance(), nullptr));
|
| 1363 |
+
}
|
| 1364 |
+
static inline void SetAllocated(int number, FieldType field_type,
|
| 1365 |
+
MutableType message, ExtensionSet* set) {
|
| 1366 |
+
set->SetAllocatedMessage(number, field_type, nullptr, message);
|
| 1367 |
+
}
|
| 1368 |
+
static inline void UnsafeArenaSetAllocated(int number, FieldType field_type,
|
| 1369 |
+
MutableType message,
|
| 1370 |
+
ExtensionSet* set) {
|
| 1371 |
+
set->UnsafeArenaSetAllocatedMessage(number, field_type, nullptr, message);
|
| 1372 |
+
}
|
| 1373 |
+
PROTOBUF_NODISCARD static inline MutableType Release(
|
| 1374 |
+
int number, FieldType /* field_type */, ExtensionSet* set) {
|
| 1375 |
+
return static_cast<Type*>(
|
| 1376 |
+
set->ReleaseMessage(number, Type::default_instance()));
|
| 1377 |
+
}
|
| 1378 |
+
static inline MutableType UnsafeArenaRelease(int number,
|
| 1379 |
+
FieldType /* field_type */,
|
| 1380 |
+
ExtensionSet* set) {
|
| 1381 |
+
return static_cast<Type*>(
|
| 1382 |
+
set->UnsafeArenaReleaseMessage(number, Type::default_instance()));
|
| 1383 |
+
}
|
| 1384 |
+
template <typename ExtendeeT>
|
| 1385 |
+
static void Register(int number, FieldType type, bool is_packed,
|
| 1386 |
+
LazyEagerVerifyFnType fn) {
|
| 1387 |
+
ExtensionSet::RegisterMessageExtension(&ExtendeeT::default_instance(),
|
| 1388 |
+
number, type, false, is_packed,
|
| 1389 |
+
&Type::default_instance(), fn);
|
| 1390 |
+
}
|
| 1391 |
+
};
|
| 1392 |
+
|
| 1393 |
+
// Used by WireFormatVerify to extract the verify function from the registry.
|
| 1394 |
+
LazyEagerVerifyFnType FindExtensionLazyEagerVerifyFn(
|
| 1395 |
+
const MessageLite* extendee, int number);
|
| 1396 |
+
|
| 1397 |
+
// forward declaration.
|
| 1398 |
+
class RepeatedMessageGenericTypeTraits;
|
| 1399 |
+
|
| 1400 |
+
template <typename Type>
|
| 1401 |
+
class RepeatedMessageTypeTraits {
|
| 1402 |
+
public:
|
| 1403 |
+
typedef const Type& ConstType;
|
| 1404 |
+
typedef Type* MutableType;
|
| 1405 |
+
typedef RepeatedMessageTypeTraits<Type> Repeated;
|
| 1406 |
+
|
| 1407 |
+
typedef RepeatedPtrField<Type> RepeatedFieldType;
|
| 1408 |
+
|
| 1409 |
+
static inline ConstType Get(int number, const ExtensionSet& set, int index) {
|
| 1410 |
+
return static_cast<const Type&>(set.GetRepeatedMessage(number, index));
|
| 1411 |
+
}
|
| 1412 |
+
static inline std::nullptr_t GetPtr(int /* number */,
|
| 1413 |
+
const ExtensionSet& /* set */,
|
| 1414 |
+
int /* index */) {
|
| 1415 |
+
// Cannot be implemented because of forward declared messages?
|
| 1416 |
+
return nullptr;
|
| 1417 |
+
}
|
| 1418 |
+
static inline std::nullptr_t GetRepeatedPtr(int /* number */,
|
| 1419 |
+
const ExtensionSet& /* set */) {
|
| 1420 |
+
// Cannot be implemented because of forward declared messages?
|
| 1421 |
+
return nullptr;
|
| 1422 |
+
}
|
| 1423 |
+
static inline MutableType Mutable(int number, int index, ExtensionSet* set) {
|
| 1424 |
+
return static_cast<Type*>(set->MutableRepeatedMessage(number, index));
|
| 1425 |
+
}
|
| 1426 |
+
static inline MutableType Add(int number, FieldType field_type,
|
| 1427 |
+
ExtensionSet* set) {
|
| 1428 |
+
return static_cast<Type*>(
|
| 1429 |
+
set->AddMessage(number, field_type, Type::default_instance(), nullptr));
|
| 1430 |
+
}
|
| 1431 |
+
static inline const RepeatedPtrField<Type>& GetRepeated(
|
| 1432 |
+
int number, const ExtensionSet& set) {
|
| 1433 |
+
// See notes above in RepeatedEnumTypeTraits::GetRepeated(): same
|
| 1434 |
+
// casting hack applies here, because a RepeatedPtrField<MessageLite>
|
| 1435 |
+
// cannot naturally become a RepeatedPtrType<Type> even though Type is
|
| 1436 |
+
// presumably a message. google::protobuf::Message goes through similar contortions
|
| 1437 |
+
// with a reinterpret_cast<>.
|
| 1438 |
+
return *reinterpret_cast<const RepeatedPtrField<Type>*>(
|
| 1439 |
+
set.GetRawRepeatedField(number, GetDefaultRepeatedField()));
|
| 1440 |
+
}
|
| 1441 |
+
static inline RepeatedPtrField<Type>* MutableRepeated(int number,
|
| 1442 |
+
FieldType field_type,
|
| 1443 |
+
bool is_packed,
|
| 1444 |
+
ExtensionSet* set) {
|
| 1445 |
+
return reinterpret_cast<RepeatedPtrField<Type>*>(
|
| 1446 |
+
set->MutableRawRepeatedField(number, field_type, is_packed, nullptr));
|
| 1447 |
+
}
|
| 1448 |
+
|
| 1449 |
+
static const RepeatedFieldType* GetDefaultRepeatedField();
|
| 1450 |
+
template <typename ExtendeeT>
|
| 1451 |
+
static void Register(int number, FieldType type, bool is_packed,
|
| 1452 |
+
LazyEagerVerifyFnType fn) {
|
| 1453 |
+
ExtensionSet::RegisterMessageExtension(&ExtendeeT::default_instance(),
|
| 1454 |
+
number, type, true, is_packed,
|
| 1455 |
+
&Type::default_instance(), fn);
|
| 1456 |
+
}
|
| 1457 |
+
};
|
| 1458 |
+
|
| 1459 |
+
template <typename Type>
|
| 1460 |
+
inline const typename RepeatedMessageTypeTraits<Type>::RepeatedFieldType*
|
| 1461 |
+
RepeatedMessageTypeTraits<Type>::GetDefaultRepeatedField() {
|
| 1462 |
+
static auto instance = OnShutdownDelete(new RepeatedFieldType);
|
| 1463 |
+
return instance;
|
| 1464 |
+
}
|
| 1465 |
+
|
| 1466 |
+
// -------------------------------------------------------------------
|
| 1467 |
+
// ExtensionIdentifier
|
| 1468 |
+
|
| 1469 |
+
// This is the type of actual extension objects. E.g. if you have:
|
| 1470 |
+
// extend Foo {
|
| 1471 |
+
// optional int32 bar = 1234;
|
| 1472 |
+
// }
|
| 1473 |
+
// then "bar" will be defined in C++ as:
|
| 1474 |
+
// ExtensionIdentifier<Foo, PrimitiveTypeTraits<int32_t>, 5, false> bar(1234);
|
| 1475 |
+
//
|
| 1476 |
+
// Note that we could, in theory, supply the field number as a template
|
| 1477 |
+
// parameter, and thus make an instance of ExtensionIdentifier have no
|
| 1478 |
+
// actual contents. However, if we did that, then using an extension
|
| 1479 |
+
// identifier would not necessarily cause the compiler to output any sort
|
| 1480 |
+
// of reference to any symbol defined in the extension's .pb.o file. Some
|
| 1481 |
+
// linkers will actually drop object files that are not explicitly referenced,
|
| 1482 |
+
// but that would be bad because it would cause this extension to not be
|
| 1483 |
+
// registered at static initialization, and therefore using it would crash.
|
| 1484 |
+
|
| 1485 |
+
template <typename ExtendeeType, typename TypeTraitsType, FieldType field_type,
|
| 1486 |
+
bool is_packed>
|
| 1487 |
+
class ExtensionIdentifier {
|
| 1488 |
+
public:
|
| 1489 |
+
typedef TypeTraitsType TypeTraits;
|
| 1490 |
+
typedef ExtendeeType Extendee;
|
| 1491 |
+
|
| 1492 |
+
ExtensionIdentifier(int number, typename TypeTraits::ConstType default_value,
|
| 1493 |
+
LazyEagerVerifyFnType verify_func = nullptr)
|
| 1494 |
+
: number_(number), default_value_(default_value) {
|
| 1495 |
+
Register(number, verify_func);
|
| 1496 |
+
}
|
| 1497 |
+
inline int number() const { return number_; }
|
| 1498 |
+
typename TypeTraits::ConstType default_value() const {
|
| 1499 |
+
return default_value_;
|
| 1500 |
+
}
|
| 1501 |
+
|
| 1502 |
+
static void Register(int number, LazyEagerVerifyFnType verify_func) {
|
| 1503 |
+
TypeTraits::template Register<ExtendeeType>(number, field_type, is_packed,
|
| 1504 |
+
verify_func);
|
| 1505 |
+
}
|
| 1506 |
+
|
| 1507 |
+
typename TypeTraits::ConstType const& default_value_ref() const {
|
| 1508 |
+
return default_value_;
|
| 1509 |
+
}
|
| 1510 |
+
|
| 1511 |
+
private:
|
| 1512 |
+
const int number_;
|
| 1513 |
+
typename TypeTraits::ConstType default_value_;
|
| 1514 |
+
};
|
| 1515 |
+
|
| 1516 |
+
// -------------------------------------------------------------------
|
| 1517 |
+
// Generated accessors
|
| 1518 |
+
|
| 1519 |
+
|
| 1520 |
+
// Used to retrieve a lazy extension, may return nullptr in some environments.
|
| 1521 |
+
extern PROTOBUF_ATTRIBUTE_WEAK ExtensionSet::LazyMessageExtension*
|
| 1522 |
+
MaybeCreateLazyExtension(Arena* arena);
|
| 1523 |
+
|
| 1524 |
+
} // namespace internal
|
| 1525 |
+
|
| 1526 |
+
// Call this function to ensure that this extensions's reflection is linked into
|
| 1527 |
+
// the binary:
|
| 1528 |
+
//
|
| 1529 |
+
// google::protobuf::LinkExtensionReflection(Foo::my_extension);
|
| 1530 |
+
//
|
| 1531 |
+
// This will ensure that the following lookup will succeed:
|
| 1532 |
+
//
|
| 1533 |
+
// DescriptorPool::generated_pool()->FindExtensionByName("Foo.my_extension");
|
| 1534 |
+
//
|
| 1535 |
+
// This is often relevant for parsing extensions in text mode.
|
| 1536 |
+
//
|
| 1537 |
+
// As a side-effect, it will also guarantee that anything else from the same
|
| 1538 |
+
// .proto file will also be available for lookup in the generated pool.
|
| 1539 |
+
//
|
| 1540 |
+
// This function does not actually register the extension, so it does not need
|
| 1541 |
+
// to be called before the lookup. However it does need to occur in a function
|
| 1542 |
+
// that cannot be stripped from the binary (ie. it must be reachable from main).
|
| 1543 |
+
//
|
| 1544 |
+
// Best practice is to call this function as close as possible to where the
|
| 1545 |
+
// reflection is actually needed. This function is very cheap to call, so you
|
| 1546 |
+
// should not need to worry about its runtime overhead except in tight loops (on
|
| 1547 |
+
// x86-64 it compiles into two "mov" instructions).
|
| 1548 |
+
template <typename ExtendeeType, typename TypeTraitsType,
|
| 1549 |
+
internal::FieldType field_type, bool is_packed>
|
| 1550 |
+
void LinkExtensionReflection(
|
| 1551 |
+
const google::protobuf::internal::ExtensionIdentifier<
|
| 1552 |
+
ExtendeeType, TypeTraitsType, field_type, is_packed>& extension) {
|
| 1553 |
+
internal::StrongReference(extension);
|
| 1554 |
+
}
|
| 1555 |
+
|
| 1556 |
+
} // namespace protobuf
|
| 1557 |
+
} // namespace google
|
| 1558 |
+
|
| 1559 |
+
#include <google/protobuf/port_undef.inc>
|
| 1560 |
+
|
| 1561 |
+
#endif // GOOGLE_PROTOBUF_EXTENSION_SET_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/generated_message_bases.h
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// This file contains helpers for generated code.
|
| 32 |
+
//
|
| 33 |
+
// Nothing in this file should be directly referenced by users of protobufs.
|
| 34 |
+
|
| 35 |
+
#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_BASES_H__
|
| 36 |
+
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_BASES_H__
|
| 37 |
+
|
| 38 |
+
#include <google/protobuf/io/zero_copy_stream_impl.h>
|
| 39 |
+
#include <google/protobuf/arena.h>
|
| 40 |
+
#include <google/protobuf/generated_message_util.h>
|
| 41 |
+
#include <google/protobuf/message.h>
|
| 42 |
+
#include <google/protobuf/parse_context.h>
|
| 43 |
+
|
| 44 |
+
// Must come last:
|
| 45 |
+
#include <google/protobuf/port_def.inc>
|
| 46 |
+
|
| 47 |
+
namespace google {
|
| 48 |
+
namespace protobuf {
|
| 49 |
+
namespace internal {
|
| 50 |
+
|
| 51 |
+
// To save code size, protos without any fields are derived from ZeroFieldsBase
|
| 52 |
+
// rather than Message.
|
| 53 |
+
class PROTOBUF_EXPORT ZeroFieldsBase : public Message {
|
| 54 |
+
public:
|
| 55 |
+
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
|
| 56 |
+
bool IsInitialized() const final { return true; }
|
| 57 |
+
size_t ByteSizeLong() const final;
|
| 58 |
+
int GetCachedSize() const final { return _cached_size_.Get(); }
|
| 59 |
+
const char* _InternalParse(const char* ptr,
|
| 60 |
+
internal::ParseContext* ctx) final;
|
| 61 |
+
::uint8_t* _InternalSerialize(::uint8_t* target,
|
| 62 |
+
io::EpsCopyOutputStream* stream) const final;
|
| 63 |
+
|
| 64 |
+
protected:
|
| 65 |
+
constexpr ZeroFieldsBase() {}
|
| 66 |
+
explicit ZeroFieldsBase(Arena* arena, bool is_message_owned)
|
| 67 |
+
: Message(arena, is_message_owned) {}
|
| 68 |
+
ZeroFieldsBase(const ZeroFieldsBase&) = delete;
|
| 69 |
+
ZeroFieldsBase& operator=(const ZeroFieldsBase&) = delete;
|
| 70 |
+
~ZeroFieldsBase() override;
|
| 71 |
+
|
| 72 |
+
void SetCachedSize(int size) const final { _cached_size_.Set(size); }
|
| 73 |
+
|
| 74 |
+
static void MergeImpl(Message& to, const Message& from);
|
| 75 |
+
static void CopyImpl(Message& to, const Message& from);
|
| 76 |
+
void InternalSwap(ZeroFieldsBase* other);
|
| 77 |
+
|
| 78 |
+
mutable internal::CachedSize _cached_size_;
|
| 79 |
+
};
|
| 80 |
+
|
| 81 |
+
} // namespace internal
|
| 82 |
+
} // namespace protobuf
|
| 83 |
+
} // namespace google
|
| 84 |
+
|
| 85 |
+
#include <google/protobuf/port_undef.inc>
|
| 86 |
+
|
| 87 |
+
#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_BASES_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/generated_message_tctable_impl.h
ADDED
|
@@ -0,0 +1,553 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_TCTABLE_IMPL_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_TCTABLE_IMPL_H__
|
| 33 |
+
|
| 34 |
+
#include <cstdint>
|
| 35 |
+
#include <type_traits>
|
| 36 |
+
|
| 37 |
+
#include <google/protobuf/port.h>
|
| 38 |
+
#include <google/protobuf/extension_set.h>
|
| 39 |
+
#include <google/protobuf/generated_message_tctable_decl.h>
|
| 40 |
+
#include <google/protobuf/message_lite.h>
|
| 41 |
+
#include <google/protobuf/metadata_lite.h>
|
| 42 |
+
#include <google/protobuf/parse_context.h>
|
| 43 |
+
#include <google/protobuf/wire_format_lite.h>
|
| 44 |
+
|
| 45 |
+
// Must come last:
|
| 46 |
+
#include <google/protobuf/port_def.inc>
|
| 47 |
+
|
| 48 |
+
namespace google {
|
| 49 |
+
namespace protobuf {
|
| 50 |
+
|
| 51 |
+
class Message;
|
| 52 |
+
class UnknownFieldSet;
|
| 53 |
+
|
| 54 |
+
namespace internal {
|
| 55 |
+
|
| 56 |
+
// Field layout enums.
|
| 57 |
+
//
|
| 58 |
+
// Structural information about fields is packed into a 16-bit value. The enum
|
| 59 |
+
// types below represent bitwise fields, along with their respective widths,
|
| 60 |
+
// shifts, and masks.
|
| 61 |
+
//
|
| 62 |
+
// Bit:
|
| 63 |
+
// +-----------------------+-----------------------+
|
| 64 |
+
// |15 .. 8|7 .. 0|
|
| 65 |
+
// +-----------------------+-----------------------+
|
| 66 |
+
// : . : . : . : . : . : . : 3|========| [3] FieldType
|
| 67 |
+
// : : : : : : 5|=====| : : [2] FieldCardinality
|
| 68 |
+
// : . : . : . : . 8|========| : . : . : [3] FieldRep
|
| 69 |
+
// : : : 10|=====| : : : : [2] TransformValidation
|
| 70 |
+
// : . : .12|=====| . : . : . : . : . : [2] FormatDiscriminator
|
| 71 |
+
// +-----------------------+-----------------------+
|
| 72 |
+
// |15 .. 8|7 .. 0|
|
| 73 |
+
// +-----------------------+-----------------------+
|
| 74 |
+
//
|
| 75 |
+
namespace field_layout {
|
| 76 |
+
// clang-format off
|
| 77 |
+
|
| 78 |
+
// Field kind (3 bits):
|
| 79 |
+
// These values broadly represent a wire type and an in-memory storage class.
|
| 80 |
+
enum FieldKind : uint16_t {
|
| 81 |
+
kFkShift = 0,
|
| 82 |
+
kFkBits = 3,
|
| 83 |
+
kFkMask = ((1 << kFkBits) - 1) << kFkShift,
|
| 84 |
+
|
| 85 |
+
kFkNone = 0,
|
| 86 |
+
kFkVarint, // WT=0 rep=8,32,64 bits
|
| 87 |
+
kFkPackedVarint, // WT=2 rep=8,32,64 bits
|
| 88 |
+
kFkFixed, // WT=1,5 rep=32,64 bits
|
| 89 |
+
kFkPackedFixed, // WT=2 rep=32,64 bits
|
| 90 |
+
kFkString, // WT=2 rep=various
|
| 91 |
+
kFkMessage, // WT=2,3,4 rep=MessageLite*
|
| 92 |
+
// Maps are a special case of Message, but use different parsing logic.
|
| 93 |
+
kFkMap, // WT=2 rep=Map(Lite)<various, various>
|
| 94 |
+
};
|
| 95 |
+
|
| 96 |
+
static_assert(kFkMap < (1 << kFkBits), "too many types");
|
| 97 |
+
|
| 98 |
+
// Cardinality (2 bits):
|
| 99 |
+
// These values determine how many values a field can have and its presence.
|
| 100 |
+
// Packed fields are represented in FieldType.
|
| 101 |
+
enum Cardinality : uint16_t {
|
| 102 |
+
kFcShift = kFkShift + kFkBits,
|
| 103 |
+
kFcBits = 2,
|
| 104 |
+
kFcMask = ((1 << kFcBits) - 1) << kFcShift,
|
| 105 |
+
|
| 106 |
+
kFcSingular = 0,
|
| 107 |
+
kFcOptional = 1 << kFcShift,
|
| 108 |
+
kFcRepeated = 2 << kFcShift,
|
| 109 |
+
kFcOneof = 3 << kFcShift,
|
| 110 |
+
};
|
| 111 |
+
|
| 112 |
+
// Field representation (3 bits):
|
| 113 |
+
// These values are the specific refinements of storage classes in FieldType.
|
| 114 |
+
enum FieldRep : uint16_t {
|
| 115 |
+
kRepShift = kFcShift + kFcBits,
|
| 116 |
+
kRepBits = 3,
|
| 117 |
+
kRepMask = ((1 << kRepBits) - 1) << kRepShift,
|
| 118 |
+
|
| 119 |
+
// Numeric types (used for optional and repeated fields):
|
| 120 |
+
kRep8Bits = 0,
|
| 121 |
+
kRep32Bits = 2 << kRepShift,
|
| 122 |
+
kRep64Bits = 3 << kRepShift,
|
| 123 |
+
// String types:
|
| 124 |
+
kRepAString = 0, // ArenaStringPtr
|
| 125 |
+
kRepIString = 1 << kRepShift, // InlinedString
|
| 126 |
+
kRepCord = 2 << kRepShift, // absl::Cord
|
| 127 |
+
kRepSPiece = 3 << kRepShift, // StringPieceField
|
| 128 |
+
kRepSString = 4 << kRepShift, // std::string*
|
| 129 |
+
// Message types (WT=2 unless otherwise noted):
|
| 130 |
+
kRepMessage = 0, // MessageLite*
|
| 131 |
+
kRepGroup = 1 << kRepShift, // MessageLite* (WT=3,4)
|
| 132 |
+
kRepLazy = 2 << kRepShift, // LazyField*
|
| 133 |
+
kRepIWeak = 3 << kRepShift, // ImplicitWeak
|
| 134 |
+
};
|
| 135 |
+
|
| 136 |
+
// Transform/validation (2 bits):
|
| 137 |
+
// These values determine transforms or validation to/from wire format.
|
| 138 |
+
enum TransformValidation : uint16_t {
|
| 139 |
+
kTvShift = kRepShift + kRepBits,
|
| 140 |
+
kTvBits = 2,
|
| 141 |
+
kTvMask = ((1 << kTvBits) - 1) << kTvShift,
|
| 142 |
+
|
| 143 |
+
// Varint fields:
|
| 144 |
+
kTvZigZag = 1 << kTvShift,
|
| 145 |
+
kTvEnum = 2 << kTvShift, // validate using generated _IsValid()
|
| 146 |
+
kTvRange = 3 << kTvShift, // validate using FieldAux::enum_range
|
| 147 |
+
// String fields:
|
| 148 |
+
kTvUtf8Debug = 1 << kTvShift, // proto2
|
| 149 |
+
kTvUtf8 = 2 << kTvShift, // proto3
|
| 150 |
+
};
|
| 151 |
+
|
| 152 |
+
static_assert((kTvEnum & kTvRange) != 0,
|
| 153 |
+
"enum validation types must share a bit");
|
| 154 |
+
static_assert((kTvEnum & kTvRange & kTvZigZag) == 0,
|
| 155 |
+
"zigzag encoding is not enum validation");
|
| 156 |
+
|
| 157 |
+
// Format discriminators (2 bits):
|
| 158 |
+
enum FormatDiscriminator : uint16_t {
|
| 159 |
+
kFmtShift = kTvShift + kTvBits,
|
| 160 |
+
kFmtBits = 2,
|
| 161 |
+
kFmtMask = ((1 << kFmtBits) - 1) << kFmtShift,
|
| 162 |
+
|
| 163 |
+
// Numeric:
|
| 164 |
+
kFmtUnsigned = 1 << kFmtShift, // fixed, varint
|
| 165 |
+
kFmtSigned = 2 << kFmtShift, // fixed, varint
|
| 166 |
+
kFmtFloating = 3 << kFmtShift, // fixed
|
| 167 |
+
kFmtEnum = 3 << kFmtShift, // varint
|
| 168 |
+
// Strings:
|
| 169 |
+
kFmtUtf8 = 1 << kFmtShift, // string (proto3, enforce_utf8=true)
|
| 170 |
+
kFmtUtf8Escape = 2 << kFmtShift, // string (proto2, enforce_utf8=false)
|
| 171 |
+
// Bytes:
|
| 172 |
+
kFmtArray = 1 << kFmtShift, // bytes
|
| 173 |
+
// Messages:
|
| 174 |
+
kFmtShow = 1 << kFmtShift, // message, map
|
| 175 |
+
};
|
| 176 |
+
|
| 177 |
+
// Update this assertion (and comments above) when adding or removing bits:
|
| 178 |
+
static_assert(kFmtShift + kFmtBits == 12, "number of bits changed");
|
| 179 |
+
|
| 180 |
+
// This assertion should not change unless the storage width changes:
|
| 181 |
+
static_assert(kFmtShift + kFmtBits <= 16, "too many bits");
|
| 182 |
+
|
| 183 |
+
// Convenience aliases (16 bits, with format):
|
| 184 |
+
enum FieldType : uint16_t {
|
| 185 |
+
// Numeric types:
|
| 186 |
+
kBool = kFkVarint | kRep8Bits,
|
| 187 |
+
|
| 188 |
+
kFixed32 = kFkFixed | kRep32Bits | kFmtUnsigned,
|
| 189 |
+
kUInt32 = kFkVarint | kRep32Bits | kFmtUnsigned,
|
| 190 |
+
kSFixed32 = kFkFixed | kRep32Bits | kFmtSigned,
|
| 191 |
+
kInt32 = kFkVarint | kRep32Bits | kFmtSigned,
|
| 192 |
+
kSInt32 = kFkVarint | kRep32Bits | kFmtSigned | kTvZigZag,
|
| 193 |
+
kFloat = kFkFixed | kRep32Bits | kFmtFloating,
|
| 194 |
+
kEnum = kFkVarint | kRep32Bits | kFmtEnum | kTvEnum,
|
| 195 |
+
kEnumRange = kFkVarint | kRep32Bits | kFmtEnum | kTvRange,
|
| 196 |
+
kOpenEnum = kFkVarint | kRep32Bits | kFmtEnum,
|
| 197 |
+
|
| 198 |
+
kFixed64 = kFkFixed | kRep64Bits | kFmtUnsigned,
|
| 199 |
+
kUInt64 = kFkVarint | kRep64Bits | kFmtUnsigned,
|
| 200 |
+
kSFixed64 = kFkFixed | kRep64Bits | kFmtSigned,
|
| 201 |
+
kInt64 = kFkVarint | kRep64Bits | kFmtSigned,
|
| 202 |
+
kSInt64 = kFkVarint | kRep64Bits | kFmtSigned | kTvZigZag,
|
| 203 |
+
kDouble = kFkFixed | kRep64Bits | kFmtFloating,
|
| 204 |
+
|
| 205 |
+
kPackedBool = kFkPackedVarint | kRep8Bits,
|
| 206 |
+
|
| 207 |
+
kPackedFixed32 = kFkPackedFixed | kRep32Bits | kFmtUnsigned,
|
| 208 |
+
kPackedUInt32 = kFkPackedVarint | kRep32Bits | kFmtUnsigned,
|
| 209 |
+
kPackedSFixed32 = kFkPackedFixed | kRep32Bits | kFmtSigned,
|
| 210 |
+
kPackedInt32 = kFkPackedVarint | kRep32Bits | kFmtSigned,
|
| 211 |
+
kPackedSInt32 = kFkPackedVarint | kRep32Bits | kFmtSigned | kTvZigZag,
|
| 212 |
+
kPackedFloat = kFkPackedFixed | kRep32Bits | kFmtFloating,
|
| 213 |
+
kPackedEnum = kFkPackedVarint | kRep32Bits | kFmtEnum | kTvEnum,
|
| 214 |
+
kPackedEnumRange = kFkPackedVarint | kRep32Bits | kFmtEnum | kTvRange,
|
| 215 |
+
kPackedOpenEnum = kFkPackedVarint | kRep32Bits | kFmtEnum,
|
| 216 |
+
|
| 217 |
+
kPackedFixed64 = kFkPackedFixed | kRep64Bits | kFmtUnsigned,
|
| 218 |
+
kPackedUInt64 = kFkPackedVarint | kRep64Bits | kFmtUnsigned,
|
| 219 |
+
kPackedSFixed64 = kFkPackedFixed | kRep64Bits | kFmtSigned,
|
| 220 |
+
kPackedInt64 = kFkPackedVarint | kRep64Bits | kFmtSigned,
|
| 221 |
+
kPackedSInt64 = kFkPackedVarint | kRep64Bits | kFmtSigned | kTvZigZag,
|
| 222 |
+
kPackedDouble = kFkPackedFixed | kRep64Bits | kFmtFloating,
|
| 223 |
+
|
| 224 |
+
// String types:
|
| 225 |
+
kBytes = kFkString | kFmtArray,
|
| 226 |
+
kRawString = kFkString | kFmtUtf8 | kTvUtf8Debug,
|
| 227 |
+
kUtf8String = kFkString | kFmtUtf8 | kTvUtf8,
|
| 228 |
+
|
| 229 |
+
// Message types:
|
| 230 |
+
kMessage = kFkMessage,
|
| 231 |
+
|
| 232 |
+
// Map types:
|
| 233 |
+
kMap = kFkMap,
|
| 234 |
+
};
|
| 235 |
+
|
| 236 |
+
// clang-format on
|
| 237 |
+
} // namespace field_layout
|
| 238 |
+
|
| 239 |
+
// PROTOBUF_TC_PARAM_DECL are the parameters for tailcall functions, it is
|
| 240 |
+
// defined in port_def.inc.
|
| 241 |
+
//
|
| 242 |
+
// Note that this is performance sensitive: changing the parameters will change
|
| 243 |
+
// the registers used by the ABI calling convention, which subsequently affects
|
| 244 |
+
// register selection logic inside the function.
|
| 245 |
+
|
| 246 |
+
// PROTOBUF_TC_PARAM_PASS passes values to match PROTOBUF_TC_PARAM_DECL.
|
| 247 |
+
#define PROTOBUF_TC_PARAM_PASS msg, ptr, ctx, table, hasbits, data
|
| 248 |
+
|
| 249 |
+
#ifndef NDEBUG
|
| 250 |
+
template <size_t align>
|
| 251 |
+
#ifndef _MSC_VER
|
| 252 |
+
[[noreturn]]
|
| 253 |
+
#endif
|
| 254 |
+
void AlignFail(uintptr_t address) {
|
| 255 |
+
GOOGLE_LOG(FATAL) << "Unaligned (" << align << ") access at " << address;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
extern template void AlignFail<4>(uintptr_t);
|
| 259 |
+
extern template void AlignFail<8>(uintptr_t);
|
| 260 |
+
#endif
|
| 261 |
+
|
| 262 |
+
// TcParser implements most of the parsing logic for tailcall tables.
|
| 263 |
+
class PROTOBUF_EXPORT TcParser final {
|
| 264 |
+
public:
|
| 265 |
+
static const char* GenericFallback(PROTOBUF_TC_PARAM_DECL);
|
| 266 |
+
static const char* GenericFallbackLite(PROTOBUF_TC_PARAM_DECL);
|
| 267 |
+
|
| 268 |
+
static const char* ParseLoop(MessageLite* msg, const char* ptr,
|
| 269 |
+
ParseContext* ctx,
|
| 270 |
+
const TcParseTableBase* table);
|
| 271 |
+
|
| 272 |
+
// Functions referenced by generated fast tables (numeric types):
|
| 273 |
+
// F: fixed V: varint Z: zigzag
|
| 274 |
+
// 8/32/64: storage type width (bits)
|
| 275 |
+
// S: singular R: repeated P: packed
|
| 276 |
+
// 1/2: tag length (bytes)
|
| 277 |
+
|
| 278 |
+
// Fixed:
|
| 279 |
+
static const char* FastF32S1(PROTOBUF_TC_PARAM_DECL);
|
| 280 |
+
static const char* FastF32S2(PROTOBUF_TC_PARAM_DECL);
|
| 281 |
+
static const char* FastF32R1(PROTOBUF_TC_PARAM_DECL);
|
| 282 |
+
static const char* FastF32R2(PROTOBUF_TC_PARAM_DECL);
|
| 283 |
+
static const char* FastF32P1(PROTOBUF_TC_PARAM_DECL);
|
| 284 |
+
static const char* FastF32P2(PROTOBUF_TC_PARAM_DECL);
|
| 285 |
+
static const char* FastF64S1(PROTOBUF_TC_PARAM_DECL);
|
| 286 |
+
static const char* FastF64S2(PROTOBUF_TC_PARAM_DECL);
|
| 287 |
+
static const char* FastF64R1(PROTOBUF_TC_PARAM_DECL);
|
| 288 |
+
static const char* FastF64R2(PROTOBUF_TC_PARAM_DECL);
|
| 289 |
+
static const char* FastF64P1(PROTOBUF_TC_PARAM_DECL);
|
| 290 |
+
static const char* FastF64P2(PROTOBUF_TC_PARAM_DECL);
|
| 291 |
+
|
| 292 |
+
// Varint:
|
| 293 |
+
static const char* FastV8S1(PROTOBUF_TC_PARAM_DECL);
|
| 294 |
+
static const char* FastV8S2(PROTOBUF_TC_PARAM_DECL);
|
| 295 |
+
static const char* FastV8R1(PROTOBUF_TC_PARAM_DECL);
|
| 296 |
+
static const char* FastV8R2(PROTOBUF_TC_PARAM_DECL);
|
| 297 |
+
static const char* FastV8P1(PROTOBUF_TC_PARAM_DECL);
|
| 298 |
+
static const char* FastV8P2(PROTOBUF_TC_PARAM_DECL);
|
| 299 |
+
static const char* FastV32S1(PROTOBUF_TC_PARAM_DECL);
|
| 300 |
+
static const char* FastV32S2(PROTOBUF_TC_PARAM_DECL);
|
| 301 |
+
static const char* FastV32R1(PROTOBUF_TC_PARAM_DECL);
|
| 302 |
+
static const char* FastV32R2(PROTOBUF_TC_PARAM_DECL);
|
| 303 |
+
static const char* FastV32P1(PROTOBUF_TC_PARAM_DECL);
|
| 304 |
+
static const char* FastV32P2(PROTOBUF_TC_PARAM_DECL);
|
| 305 |
+
static const char* FastV64S1(PROTOBUF_TC_PARAM_DECL);
|
| 306 |
+
static const char* FastV64S2(PROTOBUF_TC_PARAM_DECL);
|
| 307 |
+
static const char* FastV64R1(PROTOBUF_TC_PARAM_DECL);
|
| 308 |
+
static const char* FastV64R2(PROTOBUF_TC_PARAM_DECL);
|
| 309 |
+
static const char* FastV64P1(PROTOBUF_TC_PARAM_DECL);
|
| 310 |
+
static const char* FastV64P2(PROTOBUF_TC_PARAM_DECL);
|
| 311 |
+
|
| 312 |
+
// Varint (with zigzag):
|
| 313 |
+
static const char* FastZ32S1(PROTOBUF_TC_PARAM_DECL);
|
| 314 |
+
static const char* FastZ32S2(PROTOBUF_TC_PARAM_DECL);
|
| 315 |
+
static const char* FastZ32R1(PROTOBUF_TC_PARAM_DECL);
|
| 316 |
+
static const char* FastZ32R2(PROTOBUF_TC_PARAM_DECL);
|
| 317 |
+
static const char* FastZ32P1(PROTOBUF_TC_PARAM_DECL);
|
| 318 |
+
static const char* FastZ32P2(PROTOBUF_TC_PARAM_DECL);
|
| 319 |
+
static const char* FastZ64S1(PROTOBUF_TC_PARAM_DECL);
|
| 320 |
+
static const char* FastZ64S2(PROTOBUF_TC_PARAM_DECL);
|
| 321 |
+
static const char* FastZ64R1(PROTOBUF_TC_PARAM_DECL);
|
| 322 |
+
static const char* FastZ64R2(PROTOBUF_TC_PARAM_DECL);
|
| 323 |
+
static const char* FastZ64P1(PROTOBUF_TC_PARAM_DECL);
|
| 324 |
+
static const char* FastZ64P2(PROTOBUF_TC_PARAM_DECL);
|
| 325 |
+
|
| 326 |
+
// Functions referenced by generated fast tables (closed enum):
|
| 327 |
+
// E: closed enum (N.B.: open enums use V32, above)
|
| 328 |
+
// r: enum range v: enum validator (_IsValid function)
|
| 329 |
+
// S: singular R: repeated
|
| 330 |
+
// 1/2: tag length (bytes)
|
| 331 |
+
static const char* FastErS1(PROTOBUF_TC_PARAM_DECL);
|
| 332 |
+
static const char* FastErS2(PROTOBUF_TC_PARAM_DECL);
|
| 333 |
+
static const char* FastErR1(PROTOBUF_TC_PARAM_DECL);
|
| 334 |
+
static const char* FastErR2(PROTOBUF_TC_PARAM_DECL);
|
| 335 |
+
static const char* FastEvS1(PROTOBUF_TC_PARAM_DECL);
|
| 336 |
+
static const char* FastEvS2(PROTOBUF_TC_PARAM_DECL);
|
| 337 |
+
static const char* FastEvR1(PROTOBUF_TC_PARAM_DECL);
|
| 338 |
+
static const char* FastEvR2(PROTOBUF_TC_PARAM_DECL);
|
| 339 |
+
|
| 340 |
+
// Functions referenced by generated fast tables (string types):
|
| 341 |
+
// B: bytes S: string U: UTF-8 string
|
| 342 |
+
// (empty): ArenaStringPtr i: InlinedString
|
| 343 |
+
// S: singular R: repeated
|
| 344 |
+
// 1/2: tag length (bytes)
|
| 345 |
+
static const char* FastBS1(PROTOBUF_TC_PARAM_DECL);
|
| 346 |
+
static const char* FastBS2(PROTOBUF_TC_PARAM_DECL);
|
| 347 |
+
static const char* FastBR1(PROTOBUF_TC_PARAM_DECL);
|
| 348 |
+
static const char* FastBR2(PROTOBUF_TC_PARAM_DECL);
|
| 349 |
+
static const char* FastSS1(PROTOBUF_TC_PARAM_DECL);
|
| 350 |
+
static const char* FastSS2(PROTOBUF_TC_PARAM_DECL);
|
| 351 |
+
static const char* FastSR1(PROTOBUF_TC_PARAM_DECL);
|
| 352 |
+
static const char* FastSR2(PROTOBUF_TC_PARAM_DECL);
|
| 353 |
+
static const char* FastUS1(PROTOBUF_TC_PARAM_DECL);
|
| 354 |
+
static const char* FastUS2(PROTOBUF_TC_PARAM_DECL);
|
| 355 |
+
static const char* FastUR1(PROTOBUF_TC_PARAM_DECL);
|
| 356 |
+
static const char* FastUR2(PROTOBUF_TC_PARAM_DECL);
|
| 357 |
+
|
| 358 |
+
static const char* FastBiS1(PROTOBUF_TC_PARAM_DECL);
|
| 359 |
+
static const char* FastBiS2(PROTOBUF_TC_PARAM_DECL);
|
| 360 |
+
static const char* FastSiS1(PROTOBUF_TC_PARAM_DECL);
|
| 361 |
+
static const char* FastSiS2(PROTOBUF_TC_PARAM_DECL);
|
| 362 |
+
static const char* FastUiS1(PROTOBUF_TC_PARAM_DECL);
|
| 363 |
+
static const char* FastUiS2(PROTOBUF_TC_PARAM_DECL);
|
| 364 |
+
|
| 365 |
+
// Functions referenced by generated fast tables (message types):
|
| 366 |
+
// M: message G: group
|
| 367 |
+
// S: singular R: repeated
|
| 368 |
+
// 1/2: tag length (bytes)
|
| 369 |
+
static const char* FastMS1(PROTOBUF_TC_PARAM_DECL);
|
| 370 |
+
static const char* FastMS2(PROTOBUF_TC_PARAM_DECL);
|
| 371 |
+
static const char* FastMR1(PROTOBUF_TC_PARAM_DECL);
|
| 372 |
+
static const char* FastMR2(PROTOBUF_TC_PARAM_DECL);
|
| 373 |
+
static const char* FastGS1(PROTOBUF_TC_PARAM_DECL);
|
| 374 |
+
static const char* FastGS2(PROTOBUF_TC_PARAM_DECL);
|
| 375 |
+
static const char* FastGR1(PROTOBUF_TC_PARAM_DECL);
|
| 376 |
+
static const char* FastGR2(PROTOBUF_TC_PARAM_DECL);
|
| 377 |
+
|
| 378 |
+
template <typename T>
|
| 379 |
+
static inline T& RefAt(void* x, size_t offset) {
|
| 380 |
+
T* target = reinterpret_cast<T*>(static_cast<char*>(x) + offset);
|
| 381 |
+
#ifndef NDEBUG
|
| 382 |
+
if (PROTOBUF_PREDICT_FALSE(
|
| 383 |
+
reinterpret_cast<uintptr_t>(target) % alignof(T) != 0)) {
|
| 384 |
+
AlignFail<alignof(T)>(reinterpret_cast<uintptr_t>(target));
|
| 385 |
+
}
|
| 386 |
+
#endif
|
| 387 |
+
return *target;
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
template <typename T>
|
| 391 |
+
static inline const T& RefAt(const void* x, size_t offset) {
|
| 392 |
+
const T* target =
|
| 393 |
+
reinterpret_cast<const T*>(static_cast<const char*>(x) + offset);
|
| 394 |
+
#ifndef NDEBUG
|
| 395 |
+
if (PROTOBUF_PREDICT_FALSE(
|
| 396 |
+
reinterpret_cast<uintptr_t>(target) % alignof(T) != 0)) {
|
| 397 |
+
AlignFail<alignof(T)>(reinterpret_cast<uintptr_t>(target));
|
| 398 |
+
}
|
| 399 |
+
#endif
|
| 400 |
+
return *target;
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
template <typename T>
|
| 404 |
+
static inline T ReadAt(const void* x, size_t offset) {
|
| 405 |
+
T out;
|
| 406 |
+
memcpy(&out, static_cast<const char*>(x) + offset, sizeof(T));
|
| 407 |
+
return out;
|
| 408 |
+
}
|
| 409 |
+
|
| 410 |
+
// Mini parsing:
|
| 411 |
+
//
|
| 412 |
+
// This function parses a field from incoming data based on metadata stored in
|
| 413 |
+
// the message definition. If the field is not defined in the message, it is
|
| 414 |
+
// stored in either the ExtensionSet (if applicable) or the UnknownFieldSet.
|
| 415 |
+
//
|
| 416 |
+
// NOTE: Currently, this function only calls the table-level fallback
|
| 417 |
+
// function, so it should only be called as the fallback from fast table
|
| 418 |
+
// parsing.
|
| 419 |
+
static const char* MiniParse(PROTOBUF_TC_PARAM_DECL);
|
| 420 |
+
|
| 421 |
+
private:
|
| 422 |
+
friend class GeneratedTcTableLiteTest;
|
| 423 |
+
|
| 424 |
+
template <typename TagType, bool group_coding>
|
| 425 |
+
static inline const char* SingularParseMessageAuxImpl(PROTOBUF_TC_PARAM_DECL);
|
| 426 |
+
template <typename TagType, bool group_coding>
|
| 427 |
+
static inline const char* RepeatedParseMessageAuxImpl(PROTOBUF_TC_PARAM_DECL);
|
| 428 |
+
|
| 429 |
+
static inline PROTOBUF_ALWAYS_INLINE void SyncHasbits(
|
| 430 |
+
MessageLite* msg, uint64_t hasbits, const TcParseTableBase* table) {
|
| 431 |
+
const uint32_t has_bits_offset = table->has_bits_offset;
|
| 432 |
+
if (has_bits_offset) {
|
| 433 |
+
// Only the first 32 has-bits are updated. Nothing above those is stored,
|
| 434 |
+
// but e.g. messages without has-bits update the upper bits.
|
| 435 |
+
RefAt<uint32_t>(msg, has_bits_offset) = static_cast<uint32_t>(hasbits);
|
| 436 |
+
}
|
| 437 |
+
}
|
| 438 |
+
|
| 439 |
+
static const char* TagDispatch(PROTOBUF_TC_PARAM_DECL);
|
| 440 |
+
static const char* ToTagDispatch(PROTOBUF_TC_PARAM_DECL);
|
| 441 |
+
static const char* ToParseLoop(PROTOBUF_TC_PARAM_DECL);
|
| 442 |
+
static const char* Error(PROTOBUF_TC_PARAM_DECL);
|
| 443 |
+
|
| 444 |
+
static const char* FastUnknownEnumFallback(PROTOBUF_TC_PARAM_DECL);
|
| 445 |
+
|
| 446 |
+
class ScopedArenaSwap;
|
| 447 |
+
|
| 448 |
+
template <class MessageBaseT, class UnknownFieldsT>
|
| 449 |
+
static const char* GenericFallbackImpl(PROTOBUF_TC_PARAM_DECL) {
|
| 450 |
+
#define CHK_(x) \
|
| 451 |
+
if (PROTOBUF_PREDICT_FALSE(!(x))) return nullptr /* NOLINT */
|
| 452 |
+
|
| 453 |
+
SyncHasbits(msg, hasbits, table);
|
| 454 |
+
CHK_(ptr);
|
| 455 |
+
uint32_t tag = data.tag();
|
| 456 |
+
if ((tag & 7) == WireFormatLite::WIRETYPE_END_GROUP || tag == 0) {
|
| 457 |
+
ctx->SetLastTag(tag);
|
| 458 |
+
return ptr;
|
| 459 |
+
}
|
| 460 |
+
uint32_t num = tag >> 3;
|
| 461 |
+
if (table->extension_range_low <= num &&
|
| 462 |
+
num <= table->extension_range_high) {
|
| 463 |
+
return RefAt<ExtensionSet>(msg, table->extension_offset)
|
| 464 |
+
.ParseField(tag, ptr,
|
| 465 |
+
static_cast<const MessageBaseT*>(table->default_instance),
|
| 466 |
+
&msg->_internal_metadata_, ctx);
|
| 467 |
+
}
|
| 468 |
+
return UnknownFieldParse(
|
| 469 |
+
tag, msg->_internal_metadata_.mutable_unknown_fields<UnknownFieldsT>(),
|
| 470 |
+
ptr, ctx);
|
| 471 |
+
#undef CHK_
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
// Note: `inline` is needed on template function declarations below to avoid
|
| 475 |
+
// -Wattributes diagnostic in GCC.
|
| 476 |
+
|
| 477 |
+
// Implementations for fast fixed field parsing functions:
|
| 478 |
+
template <typename LayoutType, typename TagType>
|
| 479 |
+
static inline const char* SingularFixed(PROTOBUF_TC_PARAM_DECL);
|
| 480 |
+
template <typename LayoutType, typename TagType>
|
| 481 |
+
static inline const char* RepeatedFixed(PROTOBUF_TC_PARAM_DECL);
|
| 482 |
+
template <typename LayoutType, typename TagType>
|
| 483 |
+
static inline const char* PackedFixed(PROTOBUF_TC_PARAM_DECL);
|
| 484 |
+
|
| 485 |
+
// Implementations for fast varint field parsing functions:
|
| 486 |
+
template <typename FieldType, typename TagType, bool zigzag = false>
|
| 487 |
+
static inline const char* SingularVarint(PROTOBUF_TC_PARAM_DECL);
|
| 488 |
+
template <typename FieldType, typename TagType, bool zigzag = false>
|
| 489 |
+
static inline const char* RepeatedVarint(PROTOBUF_TC_PARAM_DECL);
|
| 490 |
+
template <typename FieldType, typename TagType, bool zigzag = false>
|
| 491 |
+
static inline const char* PackedVarint(PROTOBUF_TC_PARAM_DECL);
|
| 492 |
+
|
| 493 |
+
// Helper for ints > 127:
|
| 494 |
+
template <typename FieldType, typename TagType, bool zigzag = false>
|
| 495 |
+
static const char* SingularVarBigint(PROTOBUF_TC_PARAM_DECL);
|
| 496 |
+
|
| 497 |
+
// Implementations for fast enum field parsing functions:
|
| 498 |
+
template <typename TagType, uint16_t xform_val>
|
| 499 |
+
static inline const char* SingularEnum(PROTOBUF_TC_PARAM_DECL);
|
| 500 |
+
template <typename TagType, uint16_t xform_val>
|
| 501 |
+
static inline const char* RepeatedEnum(PROTOBUF_TC_PARAM_DECL);
|
| 502 |
+
|
| 503 |
+
// Implementations for fast string field parsing functions:
|
| 504 |
+
enum Utf8Type { kNoUtf8 = 0, kUtf8 = 1, kUtf8ValidateOnly = 2 };
|
| 505 |
+
template <typename TagType, Utf8Type utf8>
|
| 506 |
+
static inline const char* SingularString(PROTOBUF_TC_PARAM_DECL);
|
| 507 |
+
template <typename TagType, Utf8Type utf8>
|
| 508 |
+
static inline const char* RepeatedString(PROTOBUF_TC_PARAM_DECL);
|
| 509 |
+
|
| 510 |
+
// Mini field lookup:
|
| 511 |
+
static const TcParseTableBase::FieldEntry* FindFieldEntry(
|
| 512 |
+
const TcParseTableBase* table, uint32_t field_num);
|
| 513 |
+
static StringPiece MessageName(const TcParseTableBase* table);
|
| 514 |
+
static StringPiece FieldName(const TcParseTableBase* table,
|
| 515 |
+
const TcParseTableBase::FieldEntry*);
|
| 516 |
+
static bool ChangeOneof(const TcParseTableBase* table,
|
| 517 |
+
const TcParseTableBase::FieldEntry& entry,
|
| 518 |
+
uint32_t field_num, ParseContext* ctx,
|
| 519 |
+
MessageLite* msg);
|
| 520 |
+
|
| 521 |
+
// UTF-8 validation:
|
| 522 |
+
static void ReportFastUtf8Error(uint32_t decoded_tag,
|
| 523 |
+
const TcParseTableBase* table);
|
| 524 |
+
static bool MpVerifyUtf8(StringPiece wire_bytes,
|
| 525 |
+
const TcParseTableBase* table,
|
| 526 |
+
const TcParseTableBase::FieldEntry& entry,
|
| 527 |
+
uint16_t xform_val);
|
| 528 |
+
|
| 529 |
+
// For FindFieldEntry tests:
|
| 530 |
+
friend class FindFieldEntryTest;
|
| 531 |
+
static constexpr const uint32_t kMtSmallScanSize = 4;
|
| 532 |
+
|
| 533 |
+
// Mini parsing:
|
| 534 |
+
static const char* MpVarint(PROTOBUF_TC_PARAM_DECL);
|
| 535 |
+
static const char* MpRepeatedVarint(PROTOBUF_TC_PARAM_DECL);
|
| 536 |
+
static const char* MpPackedVarint(PROTOBUF_TC_PARAM_DECL);
|
| 537 |
+
static const char* MpFixed(PROTOBUF_TC_PARAM_DECL);
|
| 538 |
+
static const char* MpRepeatedFixed(PROTOBUF_TC_PARAM_DECL);
|
| 539 |
+
static const char* MpPackedFixed(PROTOBUF_TC_PARAM_DECL);
|
| 540 |
+
static const char* MpString(PROTOBUF_TC_PARAM_DECL);
|
| 541 |
+
static const char* MpRepeatedString(PROTOBUF_TC_PARAM_DECL);
|
| 542 |
+
static const char* MpMessage(PROTOBUF_TC_PARAM_DECL);
|
| 543 |
+
static const char* MpRepeatedMessage(PROTOBUF_TC_PARAM_DECL);
|
| 544 |
+
static const char* MpMap(PROTOBUF_TC_PARAM_DECL);
|
| 545 |
+
};
|
| 546 |
+
|
| 547 |
+
} // namespace internal
|
| 548 |
+
} // namespace protobuf
|
| 549 |
+
} // namespace google
|
| 550 |
+
|
| 551 |
+
#include <google/protobuf/port_undef.inc>
|
| 552 |
+
|
| 553 |
+
#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_TCTABLE_IMPL_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/implicit_weak_message.h
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_IMPLICIT_WEAK_MESSAGE_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_IMPLICIT_WEAK_MESSAGE_H__
|
| 33 |
+
|
| 34 |
+
#include <string>
|
| 35 |
+
|
| 36 |
+
#include <google/protobuf/io/coded_stream.h>
|
| 37 |
+
#include <google/protobuf/arena.h>
|
| 38 |
+
#include <google/protobuf/message_lite.h>
|
| 39 |
+
#include <google/protobuf/repeated_field.h>
|
| 40 |
+
|
| 41 |
+
#ifdef SWIG
|
| 42 |
+
#error "You cannot SWIG proto headers"
|
| 43 |
+
#endif
|
| 44 |
+
|
| 45 |
+
// Must be included last.
|
| 46 |
+
#include <google/protobuf/port_def.inc>
|
| 47 |
+
|
| 48 |
+
// This file is logically internal-only and should only be used by protobuf
|
| 49 |
+
// generated code.
|
| 50 |
+
|
| 51 |
+
namespace google {
|
| 52 |
+
namespace protobuf {
|
| 53 |
+
namespace internal {
|
| 54 |
+
|
| 55 |
+
// An implementation of MessageLite that treats all data as unknown. This type
|
| 56 |
+
// acts as a placeholder for an implicit weak field in the case where the true
|
| 57 |
+
// message type does not get linked into the binary.
|
| 58 |
+
class PROTOBUF_EXPORT ImplicitWeakMessage : public MessageLite {
|
| 59 |
+
public:
|
| 60 |
+
ImplicitWeakMessage() : data_(new std::string) {}
|
| 61 |
+
explicit constexpr ImplicitWeakMessage(ConstantInitialized)
|
| 62 |
+
: data_(nullptr) {}
|
| 63 |
+
explicit ImplicitWeakMessage(Arena* arena)
|
| 64 |
+
: MessageLite(arena), data_(new std::string) {}
|
| 65 |
+
|
| 66 |
+
~ImplicitWeakMessage() override {
|
| 67 |
+
// data_ will be null in the default instance, but we can safely call delete
|
| 68 |
+
// here because the default instance will never be destroyed.
|
| 69 |
+
delete data_;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
static const ImplicitWeakMessage* default_instance();
|
| 73 |
+
|
| 74 |
+
std::string GetTypeName() const override { return ""; }
|
| 75 |
+
|
| 76 |
+
MessageLite* New(Arena* arena) const override {
|
| 77 |
+
return Arena::CreateMessage<ImplicitWeakMessage>(arena);
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
void Clear() override { data_->clear(); }
|
| 81 |
+
|
| 82 |
+
bool IsInitialized() const override { return true; }
|
| 83 |
+
|
| 84 |
+
void CheckTypeAndMergeFrom(const MessageLite& other) override {
|
| 85 |
+
const std::string* other_data =
|
| 86 |
+
static_cast<const ImplicitWeakMessage&>(other).data_;
|
| 87 |
+
if (other_data != nullptr) {
|
| 88 |
+
data_->append(*other_data);
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
const char* _InternalParse(const char* ptr, ParseContext* ctx) final;
|
| 93 |
+
|
| 94 |
+
size_t ByteSizeLong() const override {
|
| 95 |
+
return data_ == nullptr ? 0 : data_->size();
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
uint8_t* _InternalSerialize(uint8_t* target,
|
| 99 |
+
io::EpsCopyOutputStream* stream) const final {
|
| 100 |
+
if (data_ == nullptr) {
|
| 101 |
+
return target;
|
| 102 |
+
}
|
| 103 |
+
return stream->WriteRaw(data_->data(), static_cast<int>(data_->size()),
|
| 104 |
+
target);
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
int GetCachedSize() const override {
|
| 108 |
+
return data_ == nullptr ? 0 : static_cast<int>(data_->size());
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
typedef void InternalArenaConstructable_;
|
| 112 |
+
|
| 113 |
+
private:
|
| 114 |
+
// This std::string is allocated on the heap, but we use a raw pointer so that
|
| 115 |
+
// the default instance can be constant-initialized. In the const methods, we
|
| 116 |
+
// have to handle the possibility of data_ being null.
|
| 117 |
+
std::string* data_;
|
| 118 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImplicitWeakMessage);
|
| 119 |
+
};
|
| 120 |
+
|
| 121 |
+
struct ImplicitWeakMessageDefaultType;
|
| 122 |
+
extern ImplicitWeakMessageDefaultType implicit_weak_message_default_instance;
|
| 123 |
+
|
| 124 |
+
// A type handler for use with implicit weak repeated message fields.
|
| 125 |
+
template <typename ImplicitWeakType>
|
| 126 |
+
class ImplicitWeakTypeHandler {
|
| 127 |
+
public:
|
| 128 |
+
typedef MessageLite Type;
|
| 129 |
+
static constexpr bool Moveable = false;
|
| 130 |
+
|
| 131 |
+
static inline MessageLite* NewFromPrototype(const MessageLite* prototype,
|
| 132 |
+
Arena* arena = nullptr) {
|
| 133 |
+
return prototype->New(arena);
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
static inline void Delete(MessageLite* value, Arena* arena) {
|
| 137 |
+
if (arena == nullptr) {
|
| 138 |
+
delete value;
|
| 139 |
+
}
|
| 140 |
+
}
|
| 141 |
+
static inline Arena* GetArena(MessageLite* value) {
|
| 142 |
+
return value->GetArena();
|
| 143 |
+
}
|
| 144 |
+
static inline void Clear(MessageLite* value) { value->Clear(); }
|
| 145 |
+
static void Merge(const MessageLite& from, MessageLite* to) {
|
| 146 |
+
to->CheckTypeAndMergeFrom(from);
|
| 147 |
+
}
|
| 148 |
+
};
|
| 149 |
+
|
| 150 |
+
} // namespace internal
|
| 151 |
+
|
| 152 |
+
template <typename T>
|
| 153 |
+
struct WeakRepeatedPtrField {
|
| 154 |
+
using TypeHandler = internal::ImplicitWeakTypeHandler<T>;
|
| 155 |
+
constexpr WeakRepeatedPtrField() : weak() {}
|
| 156 |
+
explicit WeakRepeatedPtrField(Arena* arena) : weak(arena) {}
|
| 157 |
+
~WeakRepeatedPtrField() { weak.template Destroy<TypeHandler>(); }
|
| 158 |
+
|
| 159 |
+
typedef internal::RepeatedPtrIterator<MessageLite> iterator;
|
| 160 |
+
typedef internal::RepeatedPtrIterator<const MessageLite> const_iterator;
|
| 161 |
+
typedef internal::RepeatedPtrOverPtrsIterator<MessageLite*, void*>
|
| 162 |
+
pointer_iterator;
|
| 163 |
+
typedef internal::RepeatedPtrOverPtrsIterator<const MessageLite* const,
|
| 164 |
+
const void* const>
|
| 165 |
+
const_pointer_iterator;
|
| 166 |
+
|
| 167 |
+
iterator begin() { return iterator(base().raw_data()); }
|
| 168 |
+
const_iterator begin() const { return iterator(base().raw_data()); }
|
| 169 |
+
const_iterator cbegin() const { return begin(); }
|
| 170 |
+
iterator end() { return begin() + base().size(); }
|
| 171 |
+
const_iterator end() const { return begin() + base().size(); }
|
| 172 |
+
const_iterator cend() const { return end(); }
|
| 173 |
+
pointer_iterator pointer_begin() {
|
| 174 |
+
return pointer_iterator(base().raw_mutable_data());
|
| 175 |
+
}
|
| 176 |
+
const_pointer_iterator pointer_begin() const {
|
| 177 |
+
return const_pointer_iterator(base().raw_mutable_data());
|
| 178 |
+
}
|
| 179 |
+
pointer_iterator pointer_end() {
|
| 180 |
+
return pointer_iterator(base().raw_mutable_data() + base().size());
|
| 181 |
+
}
|
| 182 |
+
const_pointer_iterator pointer_end() const {
|
| 183 |
+
return const_pointer_iterator(base().raw_mutable_data() + base().size());
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
MessageLite* AddWeak(const MessageLite* prototype) {
|
| 187 |
+
return base().AddWeak(prototype);
|
| 188 |
+
}
|
| 189 |
+
T* Add() { return weak.Add(); }
|
| 190 |
+
void Clear() { base().template Clear<TypeHandler>(); }
|
| 191 |
+
void MergeFrom(const WeakRepeatedPtrField& other) {
|
| 192 |
+
base().template MergeFrom<TypeHandler>(other.base());
|
| 193 |
+
}
|
| 194 |
+
void InternalSwap(WeakRepeatedPtrField* other) {
|
| 195 |
+
base().InternalSwap(&other->base());
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
const internal::RepeatedPtrFieldBase& base() const { return weak; }
|
| 199 |
+
internal::RepeatedPtrFieldBase& base() { return weak; }
|
| 200 |
+
// Union disables running the destructor. Which would create a strong link.
|
| 201 |
+
// Instead we explicitly destroy the underlying base through the virtual
|
| 202 |
+
// destructor.
|
| 203 |
+
union {
|
| 204 |
+
RepeatedPtrField<T> weak;
|
| 205 |
+
};
|
| 206 |
+
};
|
| 207 |
+
|
| 208 |
+
} // namespace protobuf
|
| 209 |
+
} // namespace google
|
| 210 |
+
|
| 211 |
+
#include <google/protobuf/port_undef.inc>
|
| 212 |
+
|
| 213 |
+
#endif // GOOGLE_PROTOBUF_IMPLICIT_WEAK_MESSAGE_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/io/coded_stream.h
ADDED
|
@@ -0,0 +1,1799 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// Author: kenton@google.com (Kenton Varda)
|
| 32 |
+
// Based on original Protocol Buffers design by
|
| 33 |
+
// Sanjay Ghemawat, Jeff Dean, and others.
|
| 34 |
+
//
|
| 35 |
+
// This file contains the CodedInputStream and CodedOutputStream classes,
|
| 36 |
+
// which wrap a ZeroCopyInputStream or ZeroCopyOutputStream, respectively,
|
| 37 |
+
// and allow you to read or write individual pieces of data in various
|
| 38 |
+
// formats. In particular, these implement the varint encoding for
|
| 39 |
+
// integers, a simple variable-length encoding in which smaller numbers
|
| 40 |
+
// take fewer bytes.
|
| 41 |
+
//
|
| 42 |
+
// Typically these classes will only be used internally by the protocol
|
| 43 |
+
// buffer library in order to encode and decode protocol buffers. Clients
|
| 44 |
+
// of the library only need to know about this class if they wish to write
|
| 45 |
+
// custom message parsing or serialization procedures.
|
| 46 |
+
//
|
| 47 |
+
// CodedOutputStream example:
|
| 48 |
+
// // Write some data to "myfile". First we write a 4-byte "magic number"
|
| 49 |
+
// // to identify the file type, then write a length-delimited string. The
|
| 50 |
+
// // string is composed of a varint giving the length followed by the raw
|
| 51 |
+
// // bytes.
|
| 52 |
+
// int fd = open("myfile", O_CREAT | O_WRONLY);
|
| 53 |
+
// ZeroCopyOutputStream* raw_output = new FileOutputStream(fd);
|
| 54 |
+
// CodedOutputStream* coded_output = new CodedOutputStream(raw_output);
|
| 55 |
+
//
|
| 56 |
+
// int magic_number = 1234;
|
| 57 |
+
// char text[] = "Hello world!";
|
| 58 |
+
// coded_output->WriteLittleEndian32(magic_number);
|
| 59 |
+
// coded_output->WriteVarint32(strlen(text));
|
| 60 |
+
// coded_output->WriteRaw(text, strlen(text));
|
| 61 |
+
//
|
| 62 |
+
// delete coded_output;
|
| 63 |
+
// delete raw_output;
|
| 64 |
+
// close(fd);
|
| 65 |
+
//
|
| 66 |
+
// CodedInputStream example:
|
| 67 |
+
// // Read a file created by the above code.
|
| 68 |
+
// int fd = open("myfile", O_RDONLY);
|
| 69 |
+
// ZeroCopyInputStream* raw_input = new FileInputStream(fd);
|
| 70 |
+
// CodedInputStream* coded_input = new CodedInputStream(raw_input);
|
| 71 |
+
//
|
| 72 |
+
// coded_input->ReadLittleEndian32(&magic_number);
|
| 73 |
+
// if (magic_number != 1234) {
|
| 74 |
+
// cerr << "File not in expected format." << endl;
|
| 75 |
+
// return;
|
| 76 |
+
// }
|
| 77 |
+
//
|
| 78 |
+
// uint32_t size;
|
| 79 |
+
// coded_input->ReadVarint32(&size);
|
| 80 |
+
//
|
| 81 |
+
// char* text = new char[size + 1];
|
| 82 |
+
// coded_input->ReadRaw(buffer, size);
|
| 83 |
+
// text[size] = '\0';
|
| 84 |
+
//
|
| 85 |
+
// delete coded_input;
|
| 86 |
+
// delete raw_input;
|
| 87 |
+
// close(fd);
|
| 88 |
+
//
|
| 89 |
+
// cout << "Text is: " << text << endl;
|
| 90 |
+
// delete [] text;
|
| 91 |
+
//
|
| 92 |
+
// For those who are interested, varint encoding is defined as follows:
|
| 93 |
+
//
|
| 94 |
+
// The encoding operates on unsigned integers of up to 64 bits in length.
|
| 95 |
+
// Each byte of the encoded value has the format:
|
| 96 |
+
// * bits 0-6: Seven bits of the number being encoded.
|
| 97 |
+
// * bit 7: Zero if this is the last byte in the encoding (in which
|
| 98 |
+
// case all remaining bits of the number are zero) or 1 if
|
| 99 |
+
// more bytes follow.
|
| 100 |
+
// The first byte contains the least-significant 7 bits of the number, the
|
| 101 |
+
// second byte (if present) contains the next-least-significant 7 bits,
|
| 102 |
+
// and so on. So, the binary number 1011000101011 would be encoded in two
|
| 103 |
+
// bytes as "10101011 00101100".
|
| 104 |
+
//
|
| 105 |
+
// In theory, varint could be used to encode integers of any length.
|
| 106 |
+
// However, for practicality we set a limit at 64 bits. The maximum encoded
|
| 107 |
+
// length of a number is thus 10 bytes.
|
| 108 |
+
|
| 109 |
+
#ifndef GOOGLE_PROTOBUF_IO_CODED_STREAM_H__
|
| 110 |
+
#define GOOGLE_PROTOBUF_IO_CODED_STREAM_H__
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
#include <assert.h>
|
| 114 |
+
|
| 115 |
+
#include <atomic>
|
| 116 |
+
#include <climits>
|
| 117 |
+
#include <cstddef>
|
| 118 |
+
#include <cstring>
|
| 119 |
+
#include <limits>
|
| 120 |
+
#include <string>
|
| 121 |
+
#include <type_traits>
|
| 122 |
+
#include <utility>
|
| 123 |
+
|
| 124 |
+
#if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)
|
| 125 |
+
// If MSVC has "/RTCc" set, it will complain about truncating casts at
|
| 126 |
+
// runtime. This file contains some intentional truncating casts.
|
| 127 |
+
#pragma runtime_checks("c", off)
|
| 128 |
+
#endif
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
#include <google/protobuf/stubs/common.h>
|
| 132 |
+
#include <google/protobuf/stubs/logging.h>
|
| 133 |
+
#include <google/protobuf/stubs/strutil.h>
|
| 134 |
+
#include <google/protobuf/port.h>
|
| 135 |
+
#include <google/protobuf/stubs/port.h>
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
// Must be included last.
|
| 139 |
+
#include <google/protobuf/port_def.inc>
|
| 140 |
+
|
| 141 |
+
namespace google {
|
| 142 |
+
namespace protobuf {
|
| 143 |
+
|
| 144 |
+
class DescriptorPool;
|
| 145 |
+
class MessageFactory;
|
| 146 |
+
class ZeroCopyCodedInputStream;
|
| 147 |
+
|
| 148 |
+
namespace internal {
|
| 149 |
+
void MapTestForceDeterministic();
|
| 150 |
+
class EpsCopyByteStream;
|
| 151 |
+
} // namespace internal
|
| 152 |
+
|
| 153 |
+
namespace io {
|
| 154 |
+
|
| 155 |
+
// Defined in this file.
|
| 156 |
+
class CodedInputStream;
|
| 157 |
+
class CodedOutputStream;
|
| 158 |
+
|
| 159 |
+
// Defined in other files.
|
| 160 |
+
class ZeroCopyInputStream; // zero_copy_stream.h
|
| 161 |
+
class ZeroCopyOutputStream; // zero_copy_stream.h
|
| 162 |
+
|
| 163 |
+
// Class which reads and decodes binary data which is composed of varint-
|
| 164 |
+
// encoded integers and fixed-width pieces. Wraps a ZeroCopyInputStream.
|
| 165 |
+
// Most users will not need to deal with CodedInputStream.
|
| 166 |
+
//
|
| 167 |
+
// Most methods of CodedInputStream that return a bool return false if an
|
| 168 |
+
// underlying I/O error occurs or if the data is malformed. Once such a
|
| 169 |
+
// failure occurs, the CodedInputStream is broken and is no longer useful.
|
| 170 |
+
// After a failure, callers also should assume writes to "out" args may have
|
| 171 |
+
// occurred, though nothing useful can be determined from those writes.
|
| 172 |
+
class PROTOBUF_EXPORT CodedInputStream {
|
| 173 |
+
public:
|
| 174 |
+
// Create a CodedInputStream that reads from the given ZeroCopyInputStream.
|
| 175 |
+
explicit CodedInputStream(ZeroCopyInputStream* input);
|
| 176 |
+
|
| 177 |
+
// Create a CodedInputStream that reads from the given flat array. This is
|
| 178 |
+
// faster than using an ArrayInputStream. PushLimit(size) is implied by
|
| 179 |
+
// this constructor.
|
| 180 |
+
explicit CodedInputStream(const uint8_t* buffer, int size);
|
| 181 |
+
|
| 182 |
+
// Destroy the CodedInputStream and position the underlying
|
| 183 |
+
// ZeroCopyInputStream at the first unread byte. If an error occurred while
|
| 184 |
+
// reading (causing a method to return false), then the exact position of
|
| 185 |
+
// the input stream may be anywhere between the last value that was read
|
| 186 |
+
// successfully and the stream's byte limit.
|
| 187 |
+
~CodedInputStream();
|
| 188 |
+
|
| 189 |
+
// Return true if this CodedInputStream reads from a flat array instead of
|
| 190 |
+
// a ZeroCopyInputStream.
|
| 191 |
+
inline bool IsFlat() const;
|
| 192 |
+
|
| 193 |
+
// Skips a number of bytes. Returns false if an underlying read error
|
| 194 |
+
// occurs.
|
| 195 |
+
inline bool Skip(int count);
|
| 196 |
+
|
| 197 |
+
// Sets *data to point directly at the unread part of the CodedInputStream's
|
| 198 |
+
// underlying buffer, and *size to the size of that buffer, but does not
|
| 199 |
+
// advance the stream's current position. This will always either produce
|
| 200 |
+
// a non-empty buffer or return false. If the caller consumes any of
|
| 201 |
+
// this data, it should then call Skip() to skip over the consumed bytes.
|
| 202 |
+
// This may be useful for implementing external fast parsing routines for
|
| 203 |
+
// types of data not covered by the CodedInputStream interface.
|
| 204 |
+
bool GetDirectBufferPointer(const void** data, int* size);
|
| 205 |
+
|
| 206 |
+
// Like GetDirectBufferPointer, but this method is inlined, and does not
|
| 207 |
+
// attempt to Refresh() if the buffer is currently empty.
|
| 208 |
+
PROTOBUF_ALWAYS_INLINE
|
| 209 |
+
void GetDirectBufferPointerInline(const void** data, int* size);
|
| 210 |
+
|
| 211 |
+
// Read raw bytes, copying them into the given buffer.
|
| 212 |
+
bool ReadRaw(void* buffer, int size);
|
| 213 |
+
|
| 214 |
+
// Like ReadRaw, but reads into a string.
|
| 215 |
+
bool ReadString(std::string* buffer, int size);
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
// Read a 32-bit little-endian integer.
|
| 219 |
+
bool ReadLittleEndian32(uint32_t* value);
|
| 220 |
+
// Read a 64-bit little-endian integer.
|
| 221 |
+
bool ReadLittleEndian64(uint64_t* value);
|
| 222 |
+
|
| 223 |
+
// These methods read from an externally provided buffer. The caller is
|
| 224 |
+
// responsible for ensuring that the buffer has sufficient space.
|
| 225 |
+
// Read a 32-bit little-endian integer.
|
| 226 |
+
static const uint8_t* ReadLittleEndian32FromArray(const uint8_t* buffer,
|
| 227 |
+
uint32_t* value);
|
| 228 |
+
// Read a 64-bit little-endian integer.
|
| 229 |
+
static const uint8_t* ReadLittleEndian64FromArray(const uint8_t* buffer,
|
| 230 |
+
uint64_t* value);
|
| 231 |
+
|
| 232 |
+
// Read an unsigned integer with Varint encoding, truncating to 32 bits.
|
| 233 |
+
// Reading a 32-bit value is equivalent to reading a 64-bit one and casting
|
| 234 |
+
// it to uint32_t, but may be more efficient.
|
| 235 |
+
bool ReadVarint32(uint32_t* value);
|
| 236 |
+
// Read an unsigned integer with Varint encoding.
|
| 237 |
+
bool ReadVarint64(uint64_t* value);
|
| 238 |
+
|
| 239 |
+
// Reads a varint off the wire into an "int". This should be used for reading
|
| 240 |
+
// sizes off the wire (sizes of strings, submessages, bytes fields, etc).
|
| 241 |
+
//
|
| 242 |
+
// The value from the wire is interpreted as unsigned. If its value exceeds
|
| 243 |
+
// the representable value of an integer on this platform, instead of
|
| 244 |
+
// truncating we return false. Truncating (as performed by ReadVarint32()
|
| 245 |
+
// above) is an acceptable approach for fields representing an integer, but
|
| 246 |
+
// when we are parsing a size from the wire, truncating the value would result
|
| 247 |
+
// in us misparsing the payload.
|
| 248 |
+
bool ReadVarintSizeAsInt(int* value);
|
| 249 |
+
|
| 250 |
+
// Read a tag. This calls ReadVarint32() and returns the result, or returns
|
| 251 |
+
// zero (which is not a valid tag) if ReadVarint32() fails. Also, ReadTag
|
| 252 |
+
// (but not ReadTagNoLastTag) updates the last tag value, which can be checked
|
| 253 |
+
// with LastTagWas().
|
| 254 |
+
//
|
| 255 |
+
// Always inline because this is only called in one place per parse loop
|
| 256 |
+
// but it is called for every iteration of said loop, so it should be fast.
|
| 257 |
+
// GCC doesn't want to inline this by default.
|
| 258 |
+
PROTOBUF_ALWAYS_INLINE uint32_t ReadTag() {
|
| 259 |
+
return last_tag_ = ReadTagNoLastTag();
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
PROTOBUF_ALWAYS_INLINE uint32_t ReadTagNoLastTag();
|
| 263 |
+
|
| 264 |
+
// This usually a faster alternative to ReadTag() when cutoff is a manifest
|
| 265 |
+
// constant. It does particularly well for cutoff >= 127. The first part
|
| 266 |
+
// of the return value is the tag that was read, though it can also be 0 in
|
| 267 |
+
// the cases where ReadTag() would return 0. If the second part is true
|
| 268 |
+
// then the tag is known to be in [0, cutoff]. If not, the tag either is
|
| 269 |
+
// above cutoff or is 0. (There's intentional wiggle room when tag is 0,
|
| 270 |
+
// because that can arise in several ways, and for best performance we want
|
| 271 |
+
// to avoid an extra "is tag == 0?" check here.)
|
| 272 |
+
PROTOBUF_ALWAYS_INLINE
|
| 273 |
+
std::pair<uint32_t, bool> ReadTagWithCutoff(uint32_t cutoff) {
|
| 274 |
+
std::pair<uint32_t, bool> result = ReadTagWithCutoffNoLastTag(cutoff);
|
| 275 |
+
last_tag_ = result.first;
|
| 276 |
+
return result;
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
PROTOBUF_ALWAYS_INLINE
|
| 280 |
+
std::pair<uint32_t, bool> ReadTagWithCutoffNoLastTag(uint32_t cutoff);
|
| 281 |
+
|
| 282 |
+
// Usually returns true if calling ReadVarint32() now would produce the given
|
| 283 |
+
// value. Will always return false if ReadVarint32() would not return the
|
| 284 |
+
// given value. If ExpectTag() returns true, it also advances past
|
| 285 |
+
// the varint. For best performance, use a compile-time constant as the
|
| 286 |
+
// parameter.
|
| 287 |
+
// Always inline because this collapses to a small number of instructions
|
| 288 |
+
// when given a constant parameter, but GCC doesn't want to inline by default.
|
| 289 |
+
PROTOBUF_ALWAYS_INLINE bool ExpectTag(uint32_t expected);
|
| 290 |
+
|
| 291 |
+
// Like above, except this reads from the specified buffer. The caller is
|
| 292 |
+
// responsible for ensuring that the buffer is large enough to read a varint
|
| 293 |
+
// of the expected size. For best performance, use a compile-time constant as
|
| 294 |
+
// the expected tag parameter.
|
| 295 |
+
//
|
| 296 |
+
// Returns a pointer beyond the expected tag if it was found, or NULL if it
|
| 297 |
+
// was not.
|
| 298 |
+
PROTOBUF_ALWAYS_INLINE
|
| 299 |
+
static const uint8_t* ExpectTagFromArray(const uint8_t* buffer,
|
| 300 |
+
uint32_t expected);
|
| 301 |
+
|
| 302 |
+
// Usually returns true if no more bytes can be read. Always returns false
|
| 303 |
+
// if more bytes can be read. If ExpectAtEnd() returns true, a subsequent
|
| 304 |
+
// call to LastTagWas() will act as if ReadTag() had been called and returned
|
| 305 |
+
// zero, and ConsumedEntireMessage() will return true.
|
| 306 |
+
bool ExpectAtEnd();
|
| 307 |
+
|
| 308 |
+
// If the last call to ReadTag() or ReadTagWithCutoff() returned the given
|
| 309 |
+
// value, returns true. Otherwise, returns false.
|
| 310 |
+
// ReadTagNoLastTag/ReadTagWithCutoffNoLastTag do not preserve the last
|
| 311 |
+
// returned value.
|
| 312 |
+
//
|
| 313 |
+
// This is needed because parsers for some types of embedded messages
|
| 314 |
+
// (with field type TYPE_GROUP) don't actually know that they've reached the
|
| 315 |
+
// end of a message until they see an ENDGROUP tag, which was actually part
|
| 316 |
+
// of the enclosing message. The enclosing message would like to check that
|
| 317 |
+
// tag to make sure it had the right number, so it calls LastTagWas() on
|
| 318 |
+
// return from the embedded parser to check.
|
| 319 |
+
bool LastTagWas(uint32_t expected);
|
| 320 |
+
void SetLastTag(uint32_t tag) { last_tag_ = tag; }
|
| 321 |
+
|
| 322 |
+
// When parsing message (but NOT a group), this method must be called
|
| 323 |
+
// immediately after MergeFromCodedStream() returns (if it returns true)
|
| 324 |
+
// to further verify that the message ended in a legitimate way. For
|
| 325 |
+
// example, this verifies that parsing did not end on an end-group tag.
|
| 326 |
+
// It also checks for some cases where, due to optimizations,
|
| 327 |
+
// MergeFromCodedStream() can incorrectly return true.
|
| 328 |
+
bool ConsumedEntireMessage();
|
| 329 |
+
void SetConsumed() { legitimate_message_end_ = true; }
|
| 330 |
+
|
| 331 |
+
// Limits ----------------------------------------------------------
|
| 332 |
+
// Limits are used when parsing length-delimited embedded messages.
|
| 333 |
+
// After the message's length is read, PushLimit() is used to prevent
|
| 334 |
+
// the CodedInputStream from reading beyond that length. Once the
|
| 335 |
+
// embedded message has been parsed, PopLimit() is called to undo the
|
| 336 |
+
// limit.
|
| 337 |
+
|
| 338 |
+
// Opaque type used with PushLimit() and PopLimit(). Do not modify
|
| 339 |
+
// values of this type yourself. The only reason that this isn't a
|
| 340 |
+
// struct with private internals is for efficiency.
|
| 341 |
+
typedef int Limit;
|
| 342 |
+
|
| 343 |
+
// Places a limit on the number of bytes that the stream may read,
|
| 344 |
+
// starting from the current position. Once the stream hits this limit,
|
| 345 |
+
// it will act like the end of the input has been reached until PopLimit()
|
| 346 |
+
// is called.
|
| 347 |
+
//
|
| 348 |
+
// As the names imply, the stream conceptually has a stack of limits. The
|
| 349 |
+
// shortest limit on the stack is always enforced, even if it is not the
|
| 350 |
+
// top limit.
|
| 351 |
+
//
|
| 352 |
+
// The value returned by PushLimit() is opaque to the caller, and must
|
| 353 |
+
// be passed unchanged to the corresponding call to PopLimit().
|
| 354 |
+
Limit PushLimit(int byte_limit);
|
| 355 |
+
|
| 356 |
+
// Pops the last limit pushed by PushLimit(). The input must be the value
|
| 357 |
+
// returned by that call to PushLimit().
|
| 358 |
+
void PopLimit(Limit limit);
|
| 359 |
+
|
| 360 |
+
// Returns the number of bytes left until the nearest limit on the
|
| 361 |
+
// stack is hit, or -1 if no limits are in place.
|
| 362 |
+
int BytesUntilLimit() const;
|
| 363 |
+
|
| 364 |
+
// Returns current position relative to the beginning of the input stream.
|
| 365 |
+
int CurrentPosition() const;
|
| 366 |
+
|
| 367 |
+
// Total Bytes Limit -----------------------------------------------
|
| 368 |
+
// To prevent malicious users from sending excessively large messages
|
| 369 |
+
// and causing memory exhaustion, CodedInputStream imposes a hard limit on
|
| 370 |
+
// the total number of bytes it will read.
|
| 371 |
+
|
| 372 |
+
// Sets the maximum number of bytes that this CodedInputStream will read
|
| 373 |
+
// before refusing to continue. To prevent servers from allocating enormous
|
| 374 |
+
// amounts of memory to hold parsed messages, the maximum message length
|
| 375 |
+
// should be limited to the shortest length that will not harm usability.
|
| 376 |
+
// The default limit is INT_MAX (~2GB) and apps should set shorter limits
|
| 377 |
+
// if possible. An error will always be printed to stderr if the limit is
|
| 378 |
+
// reached.
|
| 379 |
+
//
|
| 380 |
+
// Note: setting a limit less than the current read position is interpreted
|
| 381 |
+
// as a limit on the current position.
|
| 382 |
+
//
|
| 383 |
+
// This is unrelated to PushLimit()/PopLimit().
|
| 384 |
+
void SetTotalBytesLimit(int total_bytes_limit);
|
| 385 |
+
|
| 386 |
+
// The Total Bytes Limit minus the Current Position, or -1 if the total bytes
|
| 387 |
+
// limit is INT_MAX.
|
| 388 |
+
int BytesUntilTotalBytesLimit() const;
|
| 389 |
+
|
| 390 |
+
// Recursion Limit -------------------------------------------------
|
| 391 |
+
// To prevent corrupt or malicious messages from causing stack overflows,
|
| 392 |
+
// we must keep track of the depth of recursion when parsing embedded
|
| 393 |
+
// messages and groups. CodedInputStream keeps track of this because it
|
| 394 |
+
// is the only object that is passed down the stack during parsing.
|
| 395 |
+
|
| 396 |
+
// Sets the maximum recursion depth. The default is 100.
|
| 397 |
+
void SetRecursionLimit(int limit);
|
| 398 |
+
int RecursionBudget() { return recursion_budget_; }
|
| 399 |
+
|
| 400 |
+
static int GetDefaultRecursionLimit() { return default_recursion_limit_; }
|
| 401 |
+
|
| 402 |
+
// Increments the current recursion depth. Returns true if the depth is
|
| 403 |
+
// under the limit, false if it has gone over.
|
| 404 |
+
bool IncrementRecursionDepth();
|
| 405 |
+
|
| 406 |
+
// Decrements the recursion depth if possible.
|
| 407 |
+
void DecrementRecursionDepth();
|
| 408 |
+
|
| 409 |
+
// Decrements the recursion depth blindly. This is faster than
|
| 410 |
+
// DecrementRecursionDepth(). It should be used only if all previous
|
| 411 |
+
// increments to recursion depth were successful.
|
| 412 |
+
void UnsafeDecrementRecursionDepth();
|
| 413 |
+
|
| 414 |
+
// Shorthand for make_pair(PushLimit(byte_limit), --recursion_budget_).
|
| 415 |
+
// Using this can reduce code size and complexity in some cases. The caller
|
| 416 |
+
// is expected to check that the second part of the result is non-negative (to
|
| 417 |
+
// bail out if the depth of recursion is too high) and, if all is well, to
|
| 418 |
+
// later pass the first part of the result to PopLimit() or similar.
|
| 419 |
+
std::pair<CodedInputStream::Limit, int> IncrementRecursionDepthAndPushLimit(
|
| 420 |
+
int byte_limit);
|
| 421 |
+
|
| 422 |
+
// Shorthand for PushLimit(ReadVarint32(&length) ? length : 0).
|
| 423 |
+
Limit ReadLengthAndPushLimit();
|
| 424 |
+
|
| 425 |
+
// Helper that is equivalent to: {
|
| 426 |
+
// bool result = ConsumedEntireMessage();
|
| 427 |
+
// PopLimit(limit);
|
| 428 |
+
// UnsafeDecrementRecursionDepth();
|
| 429 |
+
// return result; }
|
| 430 |
+
// Using this can reduce code size and complexity in some cases.
|
| 431 |
+
// Do not use unless the current recursion depth is greater than zero.
|
| 432 |
+
bool DecrementRecursionDepthAndPopLimit(Limit limit);
|
| 433 |
+
|
| 434 |
+
// Helper that is equivalent to: {
|
| 435 |
+
// bool result = ConsumedEntireMessage();
|
| 436 |
+
// PopLimit(limit);
|
| 437 |
+
// return result; }
|
| 438 |
+
// Using this can reduce code size and complexity in some cases.
|
| 439 |
+
bool CheckEntireMessageConsumedAndPopLimit(Limit limit);
|
| 440 |
+
|
| 441 |
+
// Extension Registry ----------------------------------------------
|
| 442 |
+
// ADVANCED USAGE: 99.9% of people can ignore this section.
|
| 443 |
+
//
|
| 444 |
+
// By default, when parsing extensions, the parser looks for extension
|
| 445 |
+
// definitions in the pool which owns the outer message's Descriptor.
|
| 446 |
+
// However, you may call SetExtensionRegistry() to provide an alternative
|
| 447 |
+
// pool instead. This makes it possible, for example, to parse a message
|
| 448 |
+
// using a generated class, but represent some extensions using
|
| 449 |
+
// DynamicMessage.
|
| 450 |
+
|
| 451 |
+
// Set the pool used to look up extensions. Most users do not need to call
|
| 452 |
+
// this as the correct pool will be chosen automatically.
|
| 453 |
+
//
|
| 454 |
+
// WARNING: It is very easy to misuse this. Carefully read the requirements
|
| 455 |
+
// below. Do not use this unless you are sure you need it. Almost no one
|
| 456 |
+
// does.
|
| 457 |
+
//
|
| 458 |
+
// Let's say you are parsing a message into message object m, and you want
|
| 459 |
+
// to take advantage of SetExtensionRegistry(). You must follow these
|
| 460 |
+
// requirements:
|
| 461 |
+
//
|
| 462 |
+
// The given DescriptorPool must contain m->GetDescriptor(). It is not
|
| 463 |
+
// sufficient for it to simply contain a descriptor that has the same name
|
| 464 |
+
// and content -- it must be the *exact object*. In other words:
|
| 465 |
+
// assert(pool->FindMessageTypeByName(m->GetDescriptor()->full_name()) ==
|
| 466 |
+
// m->GetDescriptor());
|
| 467 |
+
// There are two ways to satisfy this requirement:
|
| 468 |
+
// 1) Use m->GetDescriptor()->pool() as the pool. This is generally useless
|
| 469 |
+
// because this is the pool that would be used anyway if you didn't call
|
| 470 |
+
// SetExtensionRegistry() at all.
|
| 471 |
+
// 2) Use a DescriptorPool which has m->GetDescriptor()->pool() as an
|
| 472 |
+
// "underlay". Read the documentation for DescriptorPool for more
|
| 473 |
+
// information about underlays.
|
| 474 |
+
//
|
| 475 |
+
// You must also provide a MessageFactory. This factory will be used to
|
| 476 |
+
// construct Message objects representing extensions. The factory's
|
| 477 |
+
// GetPrototype() MUST return non-NULL for any Descriptor which can be found
|
| 478 |
+
// through the provided pool.
|
| 479 |
+
//
|
| 480 |
+
// If the provided factory might return instances of protocol-compiler-
|
| 481 |
+
// generated (i.e. compiled-in) types, or if the outer message object m is
|
| 482 |
+
// a generated type, then the given factory MUST have this property: If
|
| 483 |
+
// GetPrototype() is given a Descriptor which resides in
|
| 484 |
+
// DescriptorPool::generated_pool(), the factory MUST return the same
|
| 485 |
+
// prototype which MessageFactory::generated_factory() would return. That
|
| 486 |
+
// is, given a descriptor for a generated type, the factory must return an
|
| 487 |
+
// instance of the generated class (NOT DynamicMessage). However, when
|
| 488 |
+
// given a descriptor for a type that is NOT in generated_pool, the factory
|
| 489 |
+
// is free to return any implementation.
|
| 490 |
+
//
|
| 491 |
+
// The reason for this requirement is that generated sub-objects may be
|
| 492 |
+
// accessed via the standard (non-reflection) extension accessor methods,
|
| 493 |
+
// and these methods will down-cast the object to the generated class type.
|
| 494 |
+
// If the object is not actually of that type, the results would be undefined.
|
| 495 |
+
// On the other hand, if an extension is not compiled in, then there is no
|
| 496 |
+
// way the code could end up accessing it via the standard accessors -- the
|
| 497 |
+
// only way to access the extension is via reflection. When using reflection,
|
| 498 |
+
// DynamicMessage and generated messages are indistinguishable, so it's fine
|
| 499 |
+
// if these objects are represented using DynamicMessage.
|
| 500 |
+
//
|
| 501 |
+
// Using DynamicMessageFactory on which you have called
|
| 502 |
+
// SetDelegateToGeneratedFactory(true) should be sufficient to satisfy the
|
| 503 |
+
// above requirement.
|
| 504 |
+
//
|
| 505 |
+
// If either pool or factory is NULL, both must be NULL.
|
| 506 |
+
//
|
| 507 |
+
// Note that this feature is ignored when parsing "lite" messages as they do
|
| 508 |
+
// not have descriptors.
|
| 509 |
+
void SetExtensionRegistry(const DescriptorPool* pool,
|
| 510 |
+
MessageFactory* factory);
|
| 511 |
+
|
| 512 |
+
// Get the DescriptorPool set via SetExtensionRegistry(), or NULL if no pool
|
| 513 |
+
// has been provided.
|
| 514 |
+
const DescriptorPool* GetExtensionPool();
|
| 515 |
+
|
| 516 |
+
// Get the MessageFactory set via SetExtensionRegistry(), or NULL if no
|
| 517 |
+
// factory has been provided.
|
| 518 |
+
MessageFactory* GetExtensionFactory();
|
| 519 |
+
|
| 520 |
+
private:
|
| 521 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodedInputStream);
|
| 522 |
+
|
| 523 |
+
const uint8_t* buffer_;
|
| 524 |
+
const uint8_t* buffer_end_; // pointer to the end of the buffer.
|
| 525 |
+
ZeroCopyInputStream* input_;
|
| 526 |
+
int total_bytes_read_; // total bytes read from input_, including
|
| 527 |
+
// the current buffer
|
| 528 |
+
|
| 529 |
+
// If total_bytes_read_ surpasses INT_MAX, we record the extra bytes here
|
| 530 |
+
// so that we can BackUp() on destruction.
|
| 531 |
+
int overflow_bytes_;
|
| 532 |
+
|
| 533 |
+
// LastTagWas() stuff.
|
| 534 |
+
uint32_t last_tag_; // result of last ReadTag() or ReadTagWithCutoff().
|
| 535 |
+
|
| 536 |
+
// This is set true by ReadTag{Fallback/Slow}() if it is called when exactly
|
| 537 |
+
// at EOF, or by ExpectAtEnd() when it returns true. This happens when we
|
| 538 |
+
// reach the end of a message and attempt to read another tag.
|
| 539 |
+
bool legitimate_message_end_;
|
| 540 |
+
|
| 541 |
+
// See EnableAliasing().
|
| 542 |
+
bool aliasing_enabled_;
|
| 543 |
+
|
| 544 |
+
// Limits
|
| 545 |
+
Limit current_limit_; // if position = -1, no limit is applied
|
| 546 |
+
|
| 547 |
+
// For simplicity, if the current buffer crosses a limit (either a normal
|
| 548 |
+
// limit created by PushLimit() or the total bytes limit), buffer_size_
|
| 549 |
+
// only tracks the number of bytes before that limit. This field
|
| 550 |
+
// contains the number of bytes after it. Note that this implies that if
|
| 551 |
+
// buffer_size_ == 0 and buffer_size_after_limit_ > 0, we know we've
|
| 552 |
+
// hit a limit. However, if both are zero, it doesn't necessarily mean
|
| 553 |
+
// we aren't at a limit -- the buffer may have ended exactly at the limit.
|
| 554 |
+
int buffer_size_after_limit_;
|
| 555 |
+
|
| 556 |
+
// Maximum number of bytes to read, period. This is unrelated to
|
| 557 |
+
// current_limit_. Set using SetTotalBytesLimit().
|
| 558 |
+
int total_bytes_limit_;
|
| 559 |
+
|
| 560 |
+
// Current recursion budget, controlled by IncrementRecursionDepth() and
|
| 561 |
+
// similar. Starts at recursion_limit_ and goes down: if this reaches
|
| 562 |
+
// -1 we are over budget.
|
| 563 |
+
int recursion_budget_;
|
| 564 |
+
// Recursion depth limit, set by SetRecursionLimit().
|
| 565 |
+
int recursion_limit_;
|
| 566 |
+
|
| 567 |
+
// See SetExtensionRegistry().
|
| 568 |
+
const DescriptorPool* extension_pool_;
|
| 569 |
+
MessageFactory* extension_factory_;
|
| 570 |
+
|
| 571 |
+
// Private member functions.
|
| 572 |
+
|
| 573 |
+
// Fallback when Skip() goes past the end of the current buffer.
|
| 574 |
+
bool SkipFallback(int count, int original_buffer_size);
|
| 575 |
+
|
| 576 |
+
// Advance the buffer by a given number of bytes.
|
| 577 |
+
void Advance(int amount);
|
| 578 |
+
|
| 579 |
+
// Back up input_ to the current buffer position.
|
| 580 |
+
void BackUpInputToCurrentPosition();
|
| 581 |
+
|
| 582 |
+
// Recomputes the value of buffer_size_after_limit_. Must be called after
|
| 583 |
+
// current_limit_ or total_bytes_limit_ changes.
|
| 584 |
+
void RecomputeBufferLimits();
|
| 585 |
+
|
| 586 |
+
// Writes an error message saying that we hit total_bytes_limit_.
|
| 587 |
+
void PrintTotalBytesLimitError();
|
| 588 |
+
|
| 589 |
+
// Called when the buffer runs out to request more data. Implies an
|
| 590 |
+
// Advance(BufferSize()).
|
| 591 |
+
bool Refresh();
|
| 592 |
+
|
| 593 |
+
// When parsing varints, we optimize for the common case of small values, and
|
| 594 |
+
// then optimize for the case when the varint fits within the current buffer
|
| 595 |
+
// piece. The Fallback method is used when we can't use the one-byte
|
| 596 |
+
// optimization. The Slow method is yet another fallback when the buffer is
|
| 597 |
+
// not large enough. Making the slow path out-of-line speeds up the common
|
| 598 |
+
// case by 10-15%. The slow path is fairly uncommon: it only triggers when a
|
| 599 |
+
// message crosses multiple buffers. Note: ReadVarint32Fallback() and
|
| 600 |
+
// ReadVarint64Fallback() are called frequently and generally not inlined, so
|
| 601 |
+
// they have been optimized to avoid "out" parameters. The former returns -1
|
| 602 |
+
// if it fails and the uint32_t it read otherwise. The latter has a bool
|
| 603 |
+
// indicating success or failure as part of its return type.
|
| 604 |
+
int64_t ReadVarint32Fallback(uint32_t first_byte_or_zero);
|
| 605 |
+
int ReadVarintSizeAsIntFallback();
|
| 606 |
+
std::pair<uint64_t, bool> ReadVarint64Fallback();
|
| 607 |
+
bool ReadVarint32Slow(uint32_t* value);
|
| 608 |
+
bool ReadVarint64Slow(uint64_t* value);
|
| 609 |
+
int ReadVarintSizeAsIntSlow();
|
| 610 |
+
bool ReadLittleEndian32Fallback(uint32_t* value);
|
| 611 |
+
bool ReadLittleEndian64Fallback(uint64_t* value);
|
| 612 |
+
|
| 613 |
+
// Fallback/slow methods for reading tags. These do not update last_tag_,
|
| 614 |
+
// but will set legitimate_message_end_ if we are at the end of the input
|
| 615 |
+
// stream.
|
| 616 |
+
uint32_t ReadTagFallback(uint32_t first_byte_or_zero);
|
| 617 |
+
uint32_t ReadTagSlow();
|
| 618 |
+
bool ReadStringFallback(std::string* buffer, int size);
|
| 619 |
+
|
| 620 |
+
// Return the size of the buffer.
|
| 621 |
+
int BufferSize() const;
|
| 622 |
+
|
| 623 |
+
static const int kDefaultTotalBytesLimit = INT_MAX;
|
| 624 |
+
|
| 625 |
+
static int default_recursion_limit_; // 100 by default.
|
| 626 |
+
|
| 627 |
+
friend class google::protobuf::ZeroCopyCodedInputStream;
|
| 628 |
+
friend class google::protobuf::internal::EpsCopyByteStream;
|
| 629 |
+
};
|
| 630 |
+
|
| 631 |
+
// EpsCopyOutputStream wraps a ZeroCopyOutputStream and exposes a new stream,
|
| 632 |
+
// which has the property you can write kSlopBytes (16 bytes) from the current
|
| 633 |
+
// position without bounds checks. The cursor into the stream is managed by
|
| 634 |
+
// the user of the class and is an explicit parameter in the methods. Careful
|
| 635 |
+
// use of this class, ie. keep ptr a local variable, eliminates the need to
|
| 636 |
+
// for the compiler to sync the ptr value between register and memory.
|
| 637 |
+
class PROTOBUF_EXPORT EpsCopyOutputStream {
|
| 638 |
+
public:
|
| 639 |
+
enum { kSlopBytes = 16 };
|
| 640 |
+
|
| 641 |
+
// Initialize from a stream.
|
| 642 |
+
EpsCopyOutputStream(ZeroCopyOutputStream* stream, bool deterministic,
|
| 643 |
+
uint8_t** pp)
|
| 644 |
+
: end_(buffer_),
|
| 645 |
+
stream_(stream),
|
| 646 |
+
is_serialization_deterministic_(deterministic) {
|
| 647 |
+
*pp = buffer_;
|
| 648 |
+
}
|
| 649 |
+
|
| 650 |
+
// Only for array serialization. No overflow protection, end_ will be the
|
| 651 |
+
// pointed to the end of the array. When using this the total size is already
|
| 652 |
+
// known, so no need to maintain the slop region.
|
| 653 |
+
EpsCopyOutputStream(void* data, int size, bool deterministic)
|
| 654 |
+
: end_(static_cast<uint8_t*>(data) + size),
|
| 655 |
+
buffer_end_(nullptr),
|
| 656 |
+
stream_(nullptr),
|
| 657 |
+
is_serialization_deterministic_(deterministic) {}
|
| 658 |
+
|
| 659 |
+
// Initialize from stream but with the first buffer already given (eager).
|
| 660 |
+
EpsCopyOutputStream(void* data, int size, ZeroCopyOutputStream* stream,
|
| 661 |
+
bool deterministic, uint8_t** pp)
|
| 662 |
+
: stream_(stream), is_serialization_deterministic_(deterministic) {
|
| 663 |
+
*pp = SetInitialBuffer(data, size);
|
| 664 |
+
}
|
| 665 |
+
|
| 666 |
+
// Flush everything that's written into the underlying ZeroCopyOutputStream
|
| 667 |
+
// and trims the underlying stream to the location of ptr.
|
| 668 |
+
uint8_t* Trim(uint8_t* ptr);
|
| 669 |
+
|
| 670 |
+
// After this it's guaranteed you can safely write kSlopBytes to ptr. This
|
| 671 |
+
// will never fail! The underlying stream can produce an error. Use HadError
|
| 672 |
+
// to check for errors.
|
| 673 |
+
PROTOBUF_NODISCARD uint8_t* EnsureSpace(uint8_t* ptr) {
|
| 674 |
+
if (PROTOBUF_PREDICT_FALSE(ptr >= end_)) {
|
| 675 |
+
return EnsureSpaceFallback(ptr);
|
| 676 |
+
}
|
| 677 |
+
return ptr;
|
| 678 |
+
}
|
| 679 |
+
|
| 680 |
+
uint8_t* WriteRaw(const void* data, int size, uint8_t* ptr) {
|
| 681 |
+
if (PROTOBUF_PREDICT_FALSE(end_ - ptr < size)) {
|
| 682 |
+
return WriteRawFallback(data, size, ptr);
|
| 683 |
+
}
|
| 684 |
+
std::memcpy(ptr, data, size);
|
| 685 |
+
return ptr + size;
|
| 686 |
+
}
|
| 687 |
+
// Writes the buffer specified by data, size to the stream. Possibly by
|
| 688 |
+
// aliasing the buffer (ie. not copying the data). The caller is responsible
|
| 689 |
+
// to make sure the buffer is alive for the duration of the
|
| 690 |
+
// ZeroCopyOutputStream.
|
| 691 |
+
#ifndef NDEBUG
|
| 692 |
+
PROTOBUF_NOINLINE
|
| 693 |
+
#endif
|
| 694 |
+
uint8_t* WriteRawMaybeAliased(const void* data, int size, uint8_t* ptr) {
|
| 695 |
+
if (aliasing_enabled_) {
|
| 696 |
+
return WriteAliasedRaw(data, size, ptr);
|
| 697 |
+
} else {
|
| 698 |
+
return WriteRaw(data, size, ptr);
|
| 699 |
+
}
|
| 700 |
+
}
|
| 701 |
+
|
| 702 |
+
|
| 703 |
+
#ifndef NDEBUG
|
| 704 |
+
PROTOBUF_NOINLINE
|
| 705 |
+
#endif
|
| 706 |
+
uint8_t* WriteStringMaybeAliased(uint32_t num, const std::string& s,
|
| 707 |
+
uint8_t* ptr) {
|
| 708 |
+
std::ptrdiff_t size = s.size();
|
| 709 |
+
if (PROTOBUF_PREDICT_FALSE(
|
| 710 |
+
size >= 128 || end_ - ptr + 16 - TagSize(num << 3) - 1 < size)) {
|
| 711 |
+
return WriteStringMaybeAliasedOutline(num, s, ptr);
|
| 712 |
+
}
|
| 713 |
+
ptr = UnsafeVarint((num << 3) | 2, ptr);
|
| 714 |
+
*ptr++ = static_cast<uint8_t>(size);
|
| 715 |
+
std::memcpy(ptr, s.data(), size);
|
| 716 |
+
return ptr + size;
|
| 717 |
+
}
|
| 718 |
+
uint8_t* WriteBytesMaybeAliased(uint32_t num, const std::string& s,
|
| 719 |
+
uint8_t* ptr) {
|
| 720 |
+
return WriteStringMaybeAliased(num, s, ptr);
|
| 721 |
+
}
|
| 722 |
+
|
| 723 |
+
template <typename T>
|
| 724 |
+
PROTOBUF_ALWAYS_INLINE uint8_t* WriteString(uint32_t num, const T& s,
|
| 725 |
+
uint8_t* ptr) {
|
| 726 |
+
std::ptrdiff_t size = s.size();
|
| 727 |
+
if (PROTOBUF_PREDICT_FALSE(
|
| 728 |
+
size >= 128 || end_ - ptr + 16 - TagSize(num << 3) - 1 < size)) {
|
| 729 |
+
return WriteStringOutline(num, s, ptr);
|
| 730 |
+
}
|
| 731 |
+
ptr = UnsafeVarint((num << 3) | 2, ptr);
|
| 732 |
+
*ptr++ = static_cast<uint8_t>(size);
|
| 733 |
+
std::memcpy(ptr, s.data(), size);
|
| 734 |
+
return ptr + size;
|
| 735 |
+
}
|
| 736 |
+
template <typename T>
|
| 737 |
+
#ifndef NDEBUG
|
| 738 |
+
PROTOBUF_NOINLINE
|
| 739 |
+
#endif
|
| 740 |
+
uint8_t* WriteBytes(uint32_t num, const T& s, uint8_t* ptr) {
|
| 741 |
+
return WriteString(num, s, ptr);
|
| 742 |
+
}
|
| 743 |
+
|
| 744 |
+
template <typename T>
|
| 745 |
+
PROTOBUF_ALWAYS_INLINE uint8_t* WriteInt32Packed(int num, const T& r,
|
| 746 |
+
int size, uint8_t* ptr) {
|
| 747 |
+
return WriteVarintPacked(num, r, size, ptr, Encode64);
|
| 748 |
+
}
|
| 749 |
+
template <typename T>
|
| 750 |
+
PROTOBUF_ALWAYS_INLINE uint8_t* WriteUInt32Packed(int num, const T& r,
|
| 751 |
+
int size, uint8_t* ptr) {
|
| 752 |
+
return WriteVarintPacked(num, r, size, ptr, Encode32);
|
| 753 |
+
}
|
| 754 |
+
template <typename T>
|
| 755 |
+
PROTOBUF_ALWAYS_INLINE uint8_t* WriteSInt32Packed(int num, const T& r,
|
| 756 |
+
int size, uint8_t* ptr) {
|
| 757 |
+
return WriteVarintPacked(num, r, size, ptr, ZigZagEncode32);
|
| 758 |
+
}
|
| 759 |
+
template <typename T>
|
| 760 |
+
PROTOBUF_ALWAYS_INLINE uint8_t* WriteInt64Packed(int num, const T& r,
|
| 761 |
+
int size, uint8_t* ptr) {
|
| 762 |
+
return WriteVarintPacked(num, r, size, ptr, Encode64);
|
| 763 |
+
}
|
| 764 |
+
template <typename T>
|
| 765 |
+
PROTOBUF_ALWAYS_INLINE uint8_t* WriteUInt64Packed(int num, const T& r,
|
| 766 |
+
int size, uint8_t* ptr) {
|
| 767 |
+
return WriteVarintPacked(num, r, size, ptr, Encode64);
|
| 768 |
+
}
|
| 769 |
+
template <typename T>
|
| 770 |
+
PROTOBUF_ALWAYS_INLINE uint8_t* WriteSInt64Packed(int num, const T& r,
|
| 771 |
+
int size, uint8_t* ptr) {
|
| 772 |
+
return WriteVarintPacked(num, r, size, ptr, ZigZagEncode64);
|
| 773 |
+
}
|
| 774 |
+
template <typename T>
|
| 775 |
+
PROTOBUF_ALWAYS_INLINE uint8_t* WriteEnumPacked(int num, const T& r, int size,
|
| 776 |
+
uint8_t* ptr) {
|
| 777 |
+
return WriteVarintPacked(num, r, size, ptr, Encode64);
|
| 778 |
+
}
|
| 779 |
+
|
| 780 |
+
template <typename T>
|
| 781 |
+
PROTOBUF_ALWAYS_INLINE uint8_t* WriteFixedPacked(int num, const T& r,
|
| 782 |
+
uint8_t* ptr) {
|
| 783 |
+
ptr = EnsureSpace(ptr);
|
| 784 |
+
constexpr auto element_size = sizeof(typename T::value_type);
|
| 785 |
+
auto size = r.size() * element_size;
|
| 786 |
+
ptr = WriteLengthDelim(num, size, ptr);
|
| 787 |
+
return WriteRawLittleEndian<element_size>(r.data(), static_cast<int>(size),
|
| 788 |
+
ptr);
|
| 789 |
+
}
|
| 790 |
+
|
| 791 |
+
// Returns true if there was an underlying I/O error since this object was
|
| 792 |
+
// created.
|
| 793 |
+
bool HadError() const { return had_error_; }
|
| 794 |
+
|
| 795 |
+
// Instructs the EpsCopyOutputStream to allow the underlying
|
| 796 |
+
// ZeroCopyOutputStream to hold pointers to the original structure instead of
|
| 797 |
+
// copying, if it supports it (i.e. output->AllowsAliasing() is true). If the
|
| 798 |
+
// underlying stream does not support aliasing, then enabling it has no
|
| 799 |
+
// affect. For now, this only affects the behavior of
|
| 800 |
+
// WriteRawMaybeAliased().
|
| 801 |
+
//
|
| 802 |
+
// NOTE: It is caller's responsibility to ensure that the chunk of memory
|
| 803 |
+
// remains live until all of the data has been consumed from the stream.
|
| 804 |
+
void EnableAliasing(bool enabled);
|
| 805 |
+
|
| 806 |
+
// See documentation on CodedOutputStream::SetSerializationDeterministic.
|
| 807 |
+
void SetSerializationDeterministic(bool value) {
|
| 808 |
+
is_serialization_deterministic_ = value;
|
| 809 |
+
}
|
| 810 |
+
|
| 811 |
+
// See documentation on CodedOutputStream::IsSerializationDeterministic.
|
| 812 |
+
bool IsSerializationDeterministic() const {
|
| 813 |
+
return is_serialization_deterministic_;
|
| 814 |
+
}
|
| 815 |
+
|
| 816 |
+
// The number of bytes written to the stream at position ptr, relative to the
|
| 817 |
+
// stream's overall position.
|
| 818 |
+
int64_t ByteCount(uint8_t* ptr) const;
|
| 819 |
+
|
| 820 |
+
|
| 821 |
+
private:
|
| 822 |
+
uint8_t* end_;
|
| 823 |
+
uint8_t* buffer_end_ = buffer_;
|
| 824 |
+
uint8_t buffer_[2 * kSlopBytes];
|
| 825 |
+
ZeroCopyOutputStream* stream_;
|
| 826 |
+
bool had_error_ = false;
|
| 827 |
+
bool aliasing_enabled_ = false; // See EnableAliasing().
|
| 828 |
+
bool is_serialization_deterministic_;
|
| 829 |
+
bool skip_check_consistency = false;
|
| 830 |
+
|
| 831 |
+
uint8_t* EnsureSpaceFallback(uint8_t* ptr);
|
| 832 |
+
inline uint8_t* Next();
|
| 833 |
+
int Flush(uint8_t* ptr);
|
| 834 |
+
std::ptrdiff_t GetSize(uint8_t* ptr) const {
|
| 835 |
+
GOOGLE_DCHECK(ptr <= end_ + kSlopBytes); // NOLINT
|
| 836 |
+
return end_ + kSlopBytes - ptr;
|
| 837 |
+
}
|
| 838 |
+
|
| 839 |
+
uint8_t* Error() {
|
| 840 |
+
had_error_ = true;
|
| 841 |
+
// We use the patch buffer to always guarantee space to write to.
|
| 842 |
+
end_ = buffer_ + kSlopBytes;
|
| 843 |
+
return buffer_;
|
| 844 |
+
}
|
| 845 |
+
|
| 846 |
+
static constexpr int TagSize(uint32_t tag) {
|
| 847 |
+
return (tag < (1 << 7)) ? 1
|
| 848 |
+
: (tag < (1 << 14)) ? 2
|
| 849 |
+
: (tag < (1 << 21)) ? 3
|
| 850 |
+
: (tag < (1 << 28)) ? 4
|
| 851 |
+
: 5;
|
| 852 |
+
}
|
| 853 |
+
|
| 854 |
+
PROTOBUF_ALWAYS_INLINE uint8_t* WriteTag(uint32_t num, uint32_t wt,
|
| 855 |
+
uint8_t* ptr) {
|
| 856 |
+
GOOGLE_DCHECK(ptr < end_); // NOLINT
|
| 857 |
+
return UnsafeVarint((num << 3) | wt, ptr);
|
| 858 |
+
}
|
| 859 |
+
|
| 860 |
+
PROTOBUF_ALWAYS_INLINE uint8_t* WriteLengthDelim(int num, uint32_t size,
|
| 861 |
+
uint8_t* ptr) {
|
| 862 |
+
ptr = WriteTag(num, 2, ptr);
|
| 863 |
+
return UnsafeWriteSize(size, ptr);
|
| 864 |
+
}
|
| 865 |
+
|
| 866 |
+
uint8_t* WriteRawFallback(const void* data, int size, uint8_t* ptr);
|
| 867 |
+
|
| 868 |
+
uint8_t* WriteAliasedRaw(const void* data, int size, uint8_t* ptr);
|
| 869 |
+
|
| 870 |
+
uint8_t* WriteStringMaybeAliasedOutline(uint32_t num, const std::string& s,
|
| 871 |
+
uint8_t* ptr);
|
| 872 |
+
uint8_t* WriteStringOutline(uint32_t num, const std::string& s, uint8_t* ptr);
|
| 873 |
+
|
| 874 |
+
template <typename T, typename E>
|
| 875 |
+
PROTOBUF_ALWAYS_INLINE uint8_t* WriteVarintPacked(int num, const T& r,
|
| 876 |
+
int size, uint8_t* ptr,
|
| 877 |
+
const E& encode) {
|
| 878 |
+
ptr = EnsureSpace(ptr);
|
| 879 |
+
ptr = WriteLengthDelim(num, size, ptr);
|
| 880 |
+
auto it = r.data();
|
| 881 |
+
auto end = it + r.size();
|
| 882 |
+
do {
|
| 883 |
+
ptr = EnsureSpace(ptr);
|
| 884 |
+
ptr = UnsafeVarint(encode(*it++), ptr);
|
| 885 |
+
} while (it < end);
|
| 886 |
+
return ptr;
|
| 887 |
+
}
|
| 888 |
+
|
| 889 |
+
static uint32_t Encode32(uint32_t v) { return v; }
|
| 890 |
+
static uint64_t Encode64(uint64_t v) { return v; }
|
| 891 |
+
static uint32_t ZigZagEncode32(int32_t v) {
|
| 892 |
+
return (static_cast<uint32_t>(v) << 1) ^ static_cast<uint32_t>(v >> 31);
|
| 893 |
+
}
|
| 894 |
+
static uint64_t ZigZagEncode64(int64_t v) {
|
| 895 |
+
return (static_cast<uint64_t>(v) << 1) ^ static_cast<uint64_t>(v >> 63);
|
| 896 |
+
}
|
| 897 |
+
|
| 898 |
+
template <typename T>
|
| 899 |
+
PROTOBUF_ALWAYS_INLINE static uint8_t* UnsafeVarint(T value, uint8_t* ptr) {
|
| 900 |
+
static_assert(std::is_unsigned<T>::value,
|
| 901 |
+
"Varint serialization must be unsigned");
|
| 902 |
+
ptr[0] = static_cast<uint8_t>(value);
|
| 903 |
+
if (value < 0x80) {
|
| 904 |
+
return ptr + 1;
|
| 905 |
+
}
|
| 906 |
+
// Turn on continuation bit in the byte we just wrote.
|
| 907 |
+
ptr[0] |= static_cast<uint8_t>(0x80);
|
| 908 |
+
value >>= 7;
|
| 909 |
+
ptr[1] = static_cast<uint8_t>(value);
|
| 910 |
+
if (value < 0x80) {
|
| 911 |
+
return ptr + 2;
|
| 912 |
+
}
|
| 913 |
+
ptr += 2;
|
| 914 |
+
do {
|
| 915 |
+
// Turn on continuation bit in the byte we just wrote.
|
| 916 |
+
ptr[-1] |= static_cast<uint8_t>(0x80);
|
| 917 |
+
value >>= 7;
|
| 918 |
+
*ptr = static_cast<uint8_t>(value);
|
| 919 |
+
++ptr;
|
| 920 |
+
} while (value >= 0x80);
|
| 921 |
+
return ptr;
|
| 922 |
+
}
|
| 923 |
+
|
| 924 |
+
PROTOBUF_ALWAYS_INLINE static uint8_t* UnsafeWriteSize(uint32_t value,
|
| 925 |
+
uint8_t* ptr) {
|
| 926 |
+
while (PROTOBUF_PREDICT_FALSE(value >= 0x80)) {
|
| 927 |
+
*ptr = static_cast<uint8_t>(value | 0x80);
|
| 928 |
+
value >>= 7;
|
| 929 |
+
++ptr;
|
| 930 |
+
}
|
| 931 |
+
*ptr++ = static_cast<uint8_t>(value);
|
| 932 |
+
return ptr;
|
| 933 |
+
}
|
| 934 |
+
|
| 935 |
+
template <int S>
|
| 936 |
+
uint8_t* WriteRawLittleEndian(const void* data, int size, uint8_t* ptr);
|
| 937 |
+
#if !defined(PROTOBUF_LITTLE_ENDIAN) || \
|
| 938 |
+
defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)
|
| 939 |
+
uint8_t* WriteRawLittleEndian32(const void* data, int size, uint8_t* ptr);
|
| 940 |
+
uint8_t* WriteRawLittleEndian64(const void* data, int size, uint8_t* ptr);
|
| 941 |
+
#endif
|
| 942 |
+
|
| 943 |
+
// These methods are for CodedOutputStream. Ideally they should be private
|
| 944 |
+
// but to match current behavior of CodedOutputStream as close as possible
|
| 945 |
+
// we allow it some functionality.
|
| 946 |
+
public:
|
| 947 |
+
uint8_t* SetInitialBuffer(void* data, int size) {
|
| 948 |
+
auto ptr = static_cast<uint8_t*>(data);
|
| 949 |
+
if (size > kSlopBytes) {
|
| 950 |
+
end_ = ptr + size - kSlopBytes;
|
| 951 |
+
buffer_end_ = nullptr;
|
| 952 |
+
return ptr;
|
| 953 |
+
} else {
|
| 954 |
+
end_ = buffer_ + size;
|
| 955 |
+
buffer_end_ = ptr;
|
| 956 |
+
return buffer_;
|
| 957 |
+
}
|
| 958 |
+
}
|
| 959 |
+
|
| 960 |
+
private:
|
| 961 |
+
// Needed by CodedOutputStream HadError. HadError needs to flush the patch
|
| 962 |
+
// buffers to ensure there is no error as of yet.
|
| 963 |
+
uint8_t* FlushAndResetBuffer(uint8_t*);
|
| 964 |
+
|
| 965 |
+
// The following functions mimic the old CodedOutputStream behavior as close
|
| 966 |
+
// as possible. They flush the current state to the stream, behave as
|
| 967 |
+
// the old CodedOutputStream and then return to normal operation.
|
| 968 |
+
bool Skip(int count, uint8_t** pp);
|
| 969 |
+
bool GetDirectBufferPointer(void** data, int* size, uint8_t** pp);
|
| 970 |
+
uint8_t* GetDirectBufferForNBytesAndAdvance(int size, uint8_t** pp);
|
| 971 |
+
|
| 972 |
+
friend class CodedOutputStream;
|
| 973 |
+
};
|
| 974 |
+
|
| 975 |
+
template <>
|
| 976 |
+
inline uint8_t* EpsCopyOutputStream::WriteRawLittleEndian<1>(const void* data,
|
| 977 |
+
int size,
|
| 978 |
+
uint8_t* ptr) {
|
| 979 |
+
return WriteRaw(data, size, ptr);
|
| 980 |
+
}
|
| 981 |
+
template <>
|
| 982 |
+
inline uint8_t* EpsCopyOutputStream::WriteRawLittleEndian<4>(const void* data,
|
| 983 |
+
int size,
|
| 984 |
+
uint8_t* ptr) {
|
| 985 |
+
#if defined(PROTOBUF_LITTLE_ENDIAN) && \
|
| 986 |
+
!defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)
|
| 987 |
+
return WriteRaw(data, size, ptr);
|
| 988 |
+
#else
|
| 989 |
+
return WriteRawLittleEndian32(data, size, ptr);
|
| 990 |
+
#endif
|
| 991 |
+
}
|
| 992 |
+
template <>
|
| 993 |
+
inline uint8_t* EpsCopyOutputStream::WriteRawLittleEndian<8>(const void* data,
|
| 994 |
+
int size,
|
| 995 |
+
uint8_t* ptr) {
|
| 996 |
+
#if defined(PROTOBUF_LITTLE_ENDIAN) && \
|
| 997 |
+
!defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)
|
| 998 |
+
return WriteRaw(data, size, ptr);
|
| 999 |
+
#else
|
| 1000 |
+
return WriteRawLittleEndian64(data, size, ptr);
|
| 1001 |
+
#endif
|
| 1002 |
+
}
|
| 1003 |
+
|
| 1004 |
+
// Class which encodes and writes binary data which is composed of varint-
|
| 1005 |
+
// encoded integers and fixed-width pieces. Wraps a ZeroCopyOutputStream.
|
| 1006 |
+
// Most users will not need to deal with CodedOutputStream.
|
| 1007 |
+
//
|
| 1008 |
+
// Most methods of CodedOutputStream which return a bool return false if an
|
| 1009 |
+
// underlying I/O error occurs. Once such a failure occurs, the
|
| 1010 |
+
// CodedOutputStream is broken and is no longer useful. The Write* methods do
|
| 1011 |
+
// not return the stream status, but will invalidate the stream if an error
|
| 1012 |
+
// occurs. The client can probe HadError() to determine the status.
|
| 1013 |
+
//
|
| 1014 |
+
// Note that every method of CodedOutputStream which writes some data has
|
| 1015 |
+
// a corresponding static "ToArray" version. These versions write directly
|
| 1016 |
+
// to the provided buffer, returning a pointer past the last written byte.
|
| 1017 |
+
// They require that the buffer has sufficient capacity for the encoded data.
|
| 1018 |
+
// This allows an optimization where we check if an output stream has enough
|
| 1019 |
+
// space for an entire message before we start writing and, if there is, we
|
| 1020 |
+
// call only the ToArray methods to avoid doing bound checks for each
|
| 1021 |
+
// individual value.
|
| 1022 |
+
// i.e., in the example above:
|
| 1023 |
+
//
|
| 1024 |
+
// CodedOutputStream* coded_output = new CodedOutputStream(raw_output);
|
| 1025 |
+
// int magic_number = 1234;
|
| 1026 |
+
// char text[] = "Hello world!";
|
| 1027 |
+
//
|
| 1028 |
+
// int coded_size = sizeof(magic_number) +
|
| 1029 |
+
// CodedOutputStream::VarintSize32(strlen(text)) +
|
| 1030 |
+
// strlen(text);
|
| 1031 |
+
//
|
| 1032 |
+
// uint8_t* buffer =
|
| 1033 |
+
// coded_output->GetDirectBufferForNBytesAndAdvance(coded_size);
|
| 1034 |
+
// if (buffer != nullptr) {
|
| 1035 |
+
// // The output stream has enough space in the buffer: write directly to
|
| 1036 |
+
// // the array.
|
| 1037 |
+
// buffer = CodedOutputStream::WriteLittleEndian32ToArray(magic_number,
|
| 1038 |
+
// buffer);
|
| 1039 |
+
// buffer = CodedOutputStream::WriteVarint32ToArray(strlen(text), buffer);
|
| 1040 |
+
// buffer = CodedOutputStream::WriteRawToArray(text, strlen(text), buffer);
|
| 1041 |
+
// } else {
|
| 1042 |
+
// // Make bound-checked writes, which will ask the underlying stream for
|
| 1043 |
+
// // more space as needed.
|
| 1044 |
+
// coded_output->WriteLittleEndian32(magic_number);
|
| 1045 |
+
// coded_output->WriteVarint32(strlen(text));
|
| 1046 |
+
// coded_output->WriteRaw(text, strlen(text));
|
| 1047 |
+
// }
|
| 1048 |
+
//
|
| 1049 |
+
// delete coded_output;
|
| 1050 |
+
class PROTOBUF_EXPORT CodedOutputStream {
|
| 1051 |
+
public:
|
| 1052 |
+
// Creates a CodedOutputStream that writes to the given `stream`.
|
| 1053 |
+
// The provided stream must publicly derive from `ZeroCopyOutputStream`.
|
| 1054 |
+
template <class Stream, class = typename std::enable_if<std::is_base_of<
|
| 1055 |
+
ZeroCopyOutputStream, Stream>::value>::type>
|
| 1056 |
+
explicit CodedOutputStream(Stream* stream);
|
| 1057 |
+
|
| 1058 |
+
// Creates a CodedOutputStream that writes to the given `stream`, and does
|
| 1059 |
+
// an 'eager initialization' of the internal state if `eager_init` is true.
|
| 1060 |
+
// The provided stream must publicly derive from `ZeroCopyOutputStream`.
|
| 1061 |
+
template <class Stream, class = typename std::enable_if<std::is_base_of<
|
| 1062 |
+
ZeroCopyOutputStream, Stream>::value>::type>
|
| 1063 |
+
CodedOutputStream(Stream* stream, bool eager_init);
|
| 1064 |
+
|
| 1065 |
+
// Destroy the CodedOutputStream and position the underlying
|
| 1066 |
+
// ZeroCopyOutputStream immediately after the last byte written.
|
| 1067 |
+
~CodedOutputStream();
|
| 1068 |
+
|
| 1069 |
+
// Returns true if there was an underlying I/O error since this object was
|
| 1070 |
+
// created. On should call Trim before this function in order to catch all
|
| 1071 |
+
// errors.
|
| 1072 |
+
bool HadError() {
|
| 1073 |
+
cur_ = impl_.FlushAndResetBuffer(cur_);
|
| 1074 |
+
GOOGLE_DCHECK(cur_);
|
| 1075 |
+
return impl_.HadError();
|
| 1076 |
+
}
|
| 1077 |
+
|
| 1078 |
+
// Trims any unused space in the underlying buffer so that its size matches
|
| 1079 |
+
// the number of bytes written by this stream. The underlying buffer will
|
| 1080 |
+
// automatically be trimmed when this stream is destroyed; this call is only
|
| 1081 |
+
// necessary if the underlying buffer is accessed *before* the stream is
|
| 1082 |
+
// destroyed.
|
| 1083 |
+
void Trim() { cur_ = impl_.Trim(cur_); }
|
| 1084 |
+
|
| 1085 |
+
// Skips a number of bytes, leaving the bytes unmodified in the underlying
|
| 1086 |
+
// buffer. Returns false if an underlying write error occurs. This is
|
| 1087 |
+
// mainly useful with GetDirectBufferPointer().
|
| 1088 |
+
// Note of caution, the skipped bytes may contain uninitialized data. The
|
| 1089 |
+
// caller must make sure that the skipped bytes are properly initialized,
|
| 1090 |
+
// otherwise you might leak bytes from your heap.
|
| 1091 |
+
bool Skip(int count) { return impl_.Skip(count, &cur_); }
|
| 1092 |
+
|
| 1093 |
+
// Sets *data to point directly at the unwritten part of the
|
| 1094 |
+
// CodedOutputStream's underlying buffer, and *size to the size of that
|
| 1095 |
+
// buffer, but does not advance the stream's current position. This will
|
| 1096 |
+
// always either produce a non-empty buffer or return false. If the caller
|
| 1097 |
+
// writes any data to this buffer, it should then call Skip() to skip over
|
| 1098 |
+
// the consumed bytes. This may be useful for implementing external fast
|
| 1099 |
+
// serialization routines for types of data not covered by the
|
| 1100 |
+
// CodedOutputStream interface.
|
| 1101 |
+
bool GetDirectBufferPointer(void** data, int* size) {
|
| 1102 |
+
return impl_.GetDirectBufferPointer(data, size, &cur_);
|
| 1103 |
+
}
|
| 1104 |
+
|
| 1105 |
+
// If there are at least "size" bytes available in the current buffer,
|
| 1106 |
+
// returns a pointer directly into the buffer and advances over these bytes.
|
| 1107 |
+
// The caller may then write directly into this buffer (e.g. using the
|
| 1108 |
+
// *ToArray static methods) rather than go through CodedOutputStream. If
|
| 1109 |
+
// there are not enough bytes available, returns NULL. The return pointer is
|
| 1110 |
+
// invalidated as soon as any other non-const method of CodedOutputStream
|
| 1111 |
+
// is called.
|
| 1112 |
+
inline uint8_t* GetDirectBufferForNBytesAndAdvance(int size) {
|
| 1113 |
+
return impl_.GetDirectBufferForNBytesAndAdvance(size, &cur_);
|
| 1114 |
+
}
|
| 1115 |
+
|
| 1116 |
+
// Write raw bytes, copying them from the given buffer.
|
| 1117 |
+
void WriteRaw(const void* buffer, int size) {
|
| 1118 |
+
cur_ = impl_.WriteRaw(buffer, size, cur_);
|
| 1119 |
+
}
|
| 1120 |
+
// Like WriteRaw() but will try to write aliased data if aliasing is
|
| 1121 |
+
// turned on.
|
| 1122 |
+
void WriteRawMaybeAliased(const void* data, int size);
|
| 1123 |
+
// Like WriteRaw() but writing directly to the target array.
|
| 1124 |
+
// This is _not_ inlined, as the compiler often optimizes memcpy into inline
|
| 1125 |
+
// copy loops. Since this gets called by every field with string or bytes
|
| 1126 |
+
// type, inlining may lead to a significant amount of code bloat, with only a
|
| 1127 |
+
// minor performance gain.
|
| 1128 |
+
static uint8_t* WriteRawToArray(const void* buffer, int size,
|
| 1129 |
+
uint8_t* target);
|
| 1130 |
+
|
| 1131 |
+
// Equivalent to WriteRaw(str.data(), str.size()).
|
| 1132 |
+
void WriteString(const std::string& str);
|
| 1133 |
+
// Like WriteString() but writing directly to the target array.
|
| 1134 |
+
static uint8_t* WriteStringToArray(const std::string& str, uint8_t* target);
|
| 1135 |
+
// Write the varint-encoded size of str followed by str.
|
| 1136 |
+
static uint8_t* WriteStringWithSizeToArray(const std::string& str,
|
| 1137 |
+
uint8_t* target);
|
| 1138 |
+
|
| 1139 |
+
|
| 1140 |
+
// Write a 32-bit little-endian integer.
|
| 1141 |
+
void WriteLittleEndian32(uint32_t value) {
|
| 1142 |
+
cur_ = impl_.EnsureSpace(cur_);
|
| 1143 |
+
SetCur(WriteLittleEndian32ToArray(value, Cur()));
|
| 1144 |
+
}
|
| 1145 |
+
// Like WriteLittleEndian32() but writing directly to the target array.
|
| 1146 |
+
static uint8_t* WriteLittleEndian32ToArray(uint32_t value, uint8_t* target);
|
| 1147 |
+
// Write a 64-bit little-endian integer.
|
| 1148 |
+
void WriteLittleEndian64(uint64_t value) {
|
| 1149 |
+
cur_ = impl_.EnsureSpace(cur_);
|
| 1150 |
+
SetCur(WriteLittleEndian64ToArray(value, Cur()));
|
| 1151 |
+
}
|
| 1152 |
+
// Like WriteLittleEndian64() but writing directly to the target array.
|
| 1153 |
+
static uint8_t* WriteLittleEndian64ToArray(uint64_t value, uint8_t* target);
|
| 1154 |
+
|
| 1155 |
+
// Write an unsigned integer with Varint encoding. Writing a 32-bit value
|
| 1156 |
+
// is equivalent to casting it to uint64_t and writing it as a 64-bit value,
|
| 1157 |
+
// but may be more efficient.
|
| 1158 |
+
void WriteVarint32(uint32_t value);
|
| 1159 |
+
// Like WriteVarint32() but writing directly to the target array.
|
| 1160 |
+
static uint8_t* WriteVarint32ToArray(uint32_t value, uint8_t* target);
|
| 1161 |
+
// Like WriteVarint32() but writing directly to the target array, and with
|
| 1162 |
+
// the less common-case paths being out of line rather than inlined.
|
| 1163 |
+
static uint8_t* WriteVarint32ToArrayOutOfLine(uint32_t value,
|
| 1164 |
+
uint8_t* target);
|
| 1165 |
+
// Write an unsigned integer with Varint encoding.
|
| 1166 |
+
void WriteVarint64(uint64_t value);
|
| 1167 |
+
// Like WriteVarint64() but writing directly to the target array.
|
| 1168 |
+
static uint8_t* WriteVarint64ToArray(uint64_t value, uint8_t* target);
|
| 1169 |
+
|
| 1170 |
+
// Equivalent to WriteVarint32() except when the value is negative,
|
| 1171 |
+
// in which case it must be sign-extended to a full 10 bytes.
|
| 1172 |
+
void WriteVarint32SignExtended(int32_t value);
|
| 1173 |
+
// Like WriteVarint32SignExtended() but writing directly to the target array.
|
| 1174 |
+
static uint8_t* WriteVarint32SignExtendedToArray(int32_t value,
|
| 1175 |
+
uint8_t* target);
|
| 1176 |
+
|
| 1177 |
+
// This is identical to WriteVarint32(), but optimized for writing tags.
|
| 1178 |
+
// In particular, if the input is a compile-time constant, this method
|
| 1179 |
+
// compiles down to a couple instructions.
|
| 1180 |
+
// Always inline because otherwise the aforementioned optimization can't work,
|
| 1181 |
+
// but GCC by default doesn't want to inline this.
|
| 1182 |
+
void WriteTag(uint32_t value);
|
| 1183 |
+
// Like WriteTag() but writing directly to the target array.
|
| 1184 |
+
PROTOBUF_ALWAYS_INLINE
|
| 1185 |
+
static uint8_t* WriteTagToArray(uint32_t value, uint8_t* target);
|
| 1186 |
+
|
| 1187 |
+
// Returns the number of bytes needed to encode the given value as a varint.
|
| 1188 |
+
static size_t VarintSize32(uint32_t value);
|
| 1189 |
+
// Returns the number of bytes needed to encode the given value as a varint.
|
| 1190 |
+
static size_t VarintSize64(uint64_t value);
|
| 1191 |
+
|
| 1192 |
+
// If negative, 10 bytes. Otherwise, same as VarintSize32().
|
| 1193 |
+
static size_t VarintSize32SignExtended(int32_t value);
|
| 1194 |
+
|
| 1195 |
+
// Same as above, plus one. The additional one comes at no compute cost.
|
| 1196 |
+
static size_t VarintSize32PlusOne(uint32_t value);
|
| 1197 |
+
static size_t VarintSize64PlusOne(uint64_t value);
|
| 1198 |
+
static size_t VarintSize32SignExtendedPlusOne(int32_t value);
|
| 1199 |
+
|
| 1200 |
+
// Compile-time equivalent of VarintSize32().
|
| 1201 |
+
template <uint32_t Value>
|
| 1202 |
+
struct StaticVarintSize32 {
|
| 1203 |
+
static const size_t value = (Value < (1 << 7)) ? 1
|
| 1204 |
+
: (Value < (1 << 14)) ? 2
|
| 1205 |
+
: (Value < (1 << 21)) ? 3
|
| 1206 |
+
: (Value < (1 << 28)) ? 4
|
| 1207 |
+
: 5;
|
| 1208 |
+
};
|
| 1209 |
+
|
| 1210 |
+
// Returns the total number of bytes written since this object was created.
|
| 1211 |
+
int ByteCount() const {
|
| 1212 |
+
return static_cast<int>(impl_.ByteCount(cur_) - start_count_);
|
| 1213 |
+
}
|
| 1214 |
+
|
| 1215 |
+
// Instructs the CodedOutputStream to allow the underlying
|
| 1216 |
+
// ZeroCopyOutputStream to hold pointers to the original structure instead of
|
| 1217 |
+
// copying, if it supports it (i.e. output->AllowsAliasing() is true). If the
|
| 1218 |
+
// underlying stream does not support aliasing, then enabling it has no
|
| 1219 |
+
// affect. For now, this only affects the behavior of
|
| 1220 |
+
// WriteRawMaybeAliased().
|
| 1221 |
+
//
|
| 1222 |
+
// NOTE: It is caller's responsibility to ensure that the chunk of memory
|
| 1223 |
+
// remains live until all of the data has been consumed from the stream.
|
| 1224 |
+
void EnableAliasing(bool enabled) { impl_.EnableAliasing(enabled); }
|
| 1225 |
+
|
| 1226 |
+
// Indicate to the serializer whether the user wants deterministic
|
| 1227 |
+
// serialization. The default when this is not called comes from the global
|
| 1228 |
+
// default, controlled by SetDefaultSerializationDeterministic.
|
| 1229 |
+
//
|
| 1230 |
+
// What deterministic serialization means is entirely up to the driver of the
|
| 1231 |
+
// serialization process (i.e. the caller of methods like WriteVarint32). In
|
| 1232 |
+
// the case of serializing a proto buffer message using one of the methods of
|
| 1233 |
+
// MessageLite, this means that for a given binary equal messages will always
|
| 1234 |
+
// be serialized to the same bytes. This implies:
|
| 1235 |
+
//
|
| 1236 |
+
// * Repeated serialization of a message will return the same bytes.
|
| 1237 |
+
//
|
| 1238 |
+
// * Different processes running the same binary (including on different
|
| 1239 |
+
// machines) will serialize equal messages to the same bytes.
|
| 1240 |
+
//
|
| 1241 |
+
// Note that this is *not* canonical across languages. It is also unstable
|
| 1242 |
+
// across different builds with intervening message definition changes, due to
|
| 1243 |
+
// unknown fields. Users who need canonical serialization (e.g. persistent
|
| 1244 |
+
// storage in a canonical form, fingerprinting) should define their own
|
| 1245 |
+
// canonicalization specification and implement the serializer using
|
| 1246 |
+
// reflection APIs rather than relying on this API.
|
| 1247 |
+
void SetSerializationDeterministic(bool value) {
|
| 1248 |
+
impl_.SetSerializationDeterministic(value);
|
| 1249 |
+
}
|
| 1250 |
+
|
| 1251 |
+
// Return whether the user wants deterministic serialization. See above.
|
| 1252 |
+
bool IsSerializationDeterministic() const {
|
| 1253 |
+
return impl_.IsSerializationDeterministic();
|
| 1254 |
+
}
|
| 1255 |
+
|
| 1256 |
+
static bool IsDefaultSerializationDeterministic() {
|
| 1257 |
+
return default_serialization_deterministic_.load(
|
| 1258 |
+
std::memory_order_relaxed) != 0;
|
| 1259 |
+
}
|
| 1260 |
+
|
| 1261 |
+
template <typename Func>
|
| 1262 |
+
void Serialize(const Func& func);
|
| 1263 |
+
|
| 1264 |
+
uint8_t* Cur() const { return cur_; }
|
| 1265 |
+
void SetCur(uint8_t* ptr) { cur_ = ptr; }
|
| 1266 |
+
EpsCopyOutputStream* EpsCopy() { return &impl_; }
|
| 1267 |
+
|
| 1268 |
+
private:
|
| 1269 |
+
template <class Stream>
|
| 1270 |
+
void InitEagerly(Stream* stream);
|
| 1271 |
+
|
| 1272 |
+
EpsCopyOutputStream impl_;
|
| 1273 |
+
uint8_t* cur_;
|
| 1274 |
+
int64_t start_count_;
|
| 1275 |
+
static std::atomic<bool> default_serialization_deterministic_;
|
| 1276 |
+
|
| 1277 |
+
// See above. Other projects may use "friend" to allow them to call this.
|
| 1278 |
+
// After SetDefaultSerializationDeterministic() completes, all protocol
|
| 1279 |
+
// buffer serializations will be deterministic by default. Thread safe.
|
| 1280 |
+
// However, the meaning of "after" is subtle here: to be safe, each thread
|
| 1281 |
+
// that wants deterministic serialization by default needs to call
|
| 1282 |
+
// SetDefaultSerializationDeterministic() or ensure on its own that another
|
| 1283 |
+
// thread has done so.
|
| 1284 |
+
friend void internal::MapTestForceDeterministic();
|
| 1285 |
+
static void SetDefaultSerializationDeterministic() {
|
| 1286 |
+
default_serialization_deterministic_.store(true, std::memory_order_relaxed);
|
| 1287 |
+
}
|
| 1288 |
+
// REQUIRES: value >= 0x80, and that (value & 7f) has been written to *target.
|
| 1289 |
+
static uint8_t* WriteVarint32ToArrayOutOfLineHelper(uint32_t value,
|
| 1290 |
+
uint8_t* target);
|
| 1291 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodedOutputStream);
|
| 1292 |
+
};
|
| 1293 |
+
|
| 1294 |
+
// inline methods ====================================================
|
| 1295 |
+
// The vast majority of varints are only one byte. These inline
|
| 1296 |
+
// methods optimize for that case.
|
| 1297 |
+
|
| 1298 |
+
inline bool CodedInputStream::ReadVarint32(uint32_t* value) {
|
| 1299 |
+
uint32_t v = 0;
|
| 1300 |
+
if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_)) {
|
| 1301 |
+
v = *buffer_;
|
| 1302 |
+
if (v < 0x80) {
|
| 1303 |
+
*value = v;
|
| 1304 |
+
Advance(1);
|
| 1305 |
+
return true;
|
| 1306 |
+
}
|
| 1307 |
+
}
|
| 1308 |
+
int64_t result = ReadVarint32Fallback(v);
|
| 1309 |
+
*value = static_cast<uint32_t>(result);
|
| 1310 |
+
return result >= 0;
|
| 1311 |
+
}
|
| 1312 |
+
|
| 1313 |
+
inline bool CodedInputStream::ReadVarint64(uint64_t* value) {
|
| 1314 |
+
if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_) && *buffer_ < 0x80) {
|
| 1315 |
+
*value = *buffer_;
|
| 1316 |
+
Advance(1);
|
| 1317 |
+
return true;
|
| 1318 |
+
}
|
| 1319 |
+
std::pair<uint64_t, bool> p = ReadVarint64Fallback();
|
| 1320 |
+
*value = p.first;
|
| 1321 |
+
return p.second;
|
| 1322 |
+
}
|
| 1323 |
+
|
| 1324 |
+
inline bool CodedInputStream::ReadVarintSizeAsInt(int* value) {
|
| 1325 |
+
if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_)) {
|
| 1326 |
+
int v = *buffer_;
|
| 1327 |
+
if (v < 0x80) {
|
| 1328 |
+
*value = v;
|
| 1329 |
+
Advance(1);
|
| 1330 |
+
return true;
|
| 1331 |
+
}
|
| 1332 |
+
}
|
| 1333 |
+
*value = ReadVarintSizeAsIntFallback();
|
| 1334 |
+
return *value >= 0;
|
| 1335 |
+
}
|
| 1336 |
+
|
| 1337 |
+
// static
|
| 1338 |
+
inline const uint8_t* CodedInputStream::ReadLittleEndian32FromArray(
|
| 1339 |
+
const uint8_t* buffer, uint32_t* value) {
|
| 1340 |
+
#if defined(PROTOBUF_LITTLE_ENDIAN) && \
|
| 1341 |
+
!defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)
|
| 1342 |
+
memcpy(value, buffer, sizeof(*value));
|
| 1343 |
+
return buffer + sizeof(*value);
|
| 1344 |
+
#else
|
| 1345 |
+
*value = (static_cast<uint32_t>(buffer[0])) |
|
| 1346 |
+
(static_cast<uint32_t>(buffer[1]) << 8) |
|
| 1347 |
+
(static_cast<uint32_t>(buffer[2]) << 16) |
|
| 1348 |
+
(static_cast<uint32_t>(buffer[3]) << 24);
|
| 1349 |
+
return buffer + sizeof(*value);
|
| 1350 |
+
#endif
|
| 1351 |
+
}
|
| 1352 |
+
// static
|
| 1353 |
+
inline const uint8_t* CodedInputStream::ReadLittleEndian64FromArray(
|
| 1354 |
+
const uint8_t* buffer, uint64_t* value) {
|
| 1355 |
+
#if defined(PROTOBUF_LITTLE_ENDIAN) && \
|
| 1356 |
+
!defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)
|
| 1357 |
+
memcpy(value, buffer, sizeof(*value));
|
| 1358 |
+
return buffer + sizeof(*value);
|
| 1359 |
+
#else
|
| 1360 |
+
uint32_t part0 = (static_cast<uint32_t>(buffer[0])) |
|
| 1361 |
+
(static_cast<uint32_t>(buffer[1]) << 8) |
|
| 1362 |
+
(static_cast<uint32_t>(buffer[2]) << 16) |
|
| 1363 |
+
(static_cast<uint32_t>(buffer[3]) << 24);
|
| 1364 |
+
uint32_t part1 = (static_cast<uint32_t>(buffer[4])) |
|
| 1365 |
+
(static_cast<uint32_t>(buffer[5]) << 8) |
|
| 1366 |
+
(static_cast<uint32_t>(buffer[6]) << 16) |
|
| 1367 |
+
(static_cast<uint32_t>(buffer[7]) << 24);
|
| 1368 |
+
*value = static_cast<uint64_t>(part0) | (static_cast<uint64_t>(part1) << 32);
|
| 1369 |
+
return buffer + sizeof(*value);
|
| 1370 |
+
#endif
|
| 1371 |
+
}
|
| 1372 |
+
|
| 1373 |
+
inline bool CodedInputStream::ReadLittleEndian32(uint32_t* value) {
|
| 1374 |
+
#if defined(PROTOBUF_LITTLE_ENDIAN) && \
|
| 1375 |
+
!defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)
|
| 1376 |
+
if (PROTOBUF_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
|
| 1377 |
+
buffer_ = ReadLittleEndian32FromArray(buffer_, value);
|
| 1378 |
+
return true;
|
| 1379 |
+
} else {
|
| 1380 |
+
return ReadLittleEndian32Fallback(value);
|
| 1381 |
+
}
|
| 1382 |
+
#else
|
| 1383 |
+
return ReadLittleEndian32Fallback(value);
|
| 1384 |
+
#endif
|
| 1385 |
+
}
|
| 1386 |
+
|
| 1387 |
+
inline bool CodedInputStream::ReadLittleEndian64(uint64_t* value) {
|
| 1388 |
+
#if defined(PROTOBUF_LITTLE_ENDIAN) && \
|
| 1389 |
+
!defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)
|
| 1390 |
+
if (PROTOBUF_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
|
| 1391 |
+
buffer_ = ReadLittleEndian64FromArray(buffer_, value);
|
| 1392 |
+
return true;
|
| 1393 |
+
} else {
|
| 1394 |
+
return ReadLittleEndian64Fallback(value);
|
| 1395 |
+
}
|
| 1396 |
+
#else
|
| 1397 |
+
return ReadLittleEndian64Fallback(value);
|
| 1398 |
+
#endif
|
| 1399 |
+
}
|
| 1400 |
+
|
| 1401 |
+
inline uint32_t CodedInputStream::ReadTagNoLastTag() {
|
| 1402 |
+
uint32_t v = 0;
|
| 1403 |
+
if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_)) {
|
| 1404 |
+
v = *buffer_;
|
| 1405 |
+
if (v < 0x80) {
|
| 1406 |
+
Advance(1);
|
| 1407 |
+
return v;
|
| 1408 |
+
}
|
| 1409 |
+
}
|
| 1410 |
+
v = ReadTagFallback(v);
|
| 1411 |
+
return v;
|
| 1412 |
+
}
|
| 1413 |
+
|
| 1414 |
+
inline std::pair<uint32_t, bool> CodedInputStream::ReadTagWithCutoffNoLastTag(
|
| 1415 |
+
uint32_t cutoff) {
|
| 1416 |
+
// In performance-sensitive code we can expect cutoff to be a compile-time
|
| 1417 |
+
// constant, and things like "cutoff >= kMax1ByteVarint" to be evaluated at
|
| 1418 |
+
// compile time.
|
| 1419 |
+
uint32_t first_byte_or_zero = 0;
|
| 1420 |
+
if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_)) {
|
| 1421 |
+
// Hot case: buffer_ non_empty, buffer_[0] in [1, 128).
|
| 1422 |
+
// TODO(gpike): Is it worth rearranging this? E.g., if the number of fields
|
| 1423 |
+
// is large enough then is it better to check for the two-byte case first?
|
| 1424 |
+
first_byte_or_zero = buffer_[0];
|
| 1425 |
+
if (static_cast<int8_t>(buffer_[0]) > 0) {
|
| 1426 |
+
const uint32_t kMax1ByteVarint = 0x7f;
|
| 1427 |
+
uint32_t tag = buffer_[0];
|
| 1428 |
+
Advance(1);
|
| 1429 |
+
return std::make_pair(tag, cutoff >= kMax1ByteVarint || tag <= cutoff);
|
| 1430 |
+
}
|
| 1431 |
+
// Other hot case: cutoff >= 0x80, buffer_ has at least two bytes available,
|
| 1432 |
+
// and tag is two bytes. The latter is tested by bitwise-and-not of the
|
| 1433 |
+
// first byte and the second byte.
|
| 1434 |
+
if (cutoff >= 0x80 && PROTOBUF_PREDICT_TRUE(buffer_ + 1 < buffer_end_) &&
|
| 1435 |
+
PROTOBUF_PREDICT_TRUE((buffer_[0] & ~buffer_[1]) >= 0x80)) {
|
| 1436 |
+
const uint32_t kMax2ByteVarint = (0x7f << 7) + 0x7f;
|
| 1437 |
+
uint32_t tag = (1u << 7) * buffer_[1] + (buffer_[0] - 0x80);
|
| 1438 |
+
Advance(2);
|
| 1439 |
+
// It might make sense to test for tag == 0 now, but it is so rare that
|
| 1440 |
+
// that we don't bother. A varint-encoded 0 should be one byte unless
|
| 1441 |
+
// the encoder lost its mind. The second part of the return value of
|
| 1442 |
+
// this function is allowed to be either true or false if the tag is 0,
|
| 1443 |
+
// so we don't have to check for tag == 0. We may need to check whether
|
| 1444 |
+
// it exceeds cutoff.
|
| 1445 |
+
bool at_or_below_cutoff = cutoff >= kMax2ByteVarint || tag <= cutoff;
|
| 1446 |
+
return std::make_pair(tag, at_or_below_cutoff);
|
| 1447 |
+
}
|
| 1448 |
+
}
|
| 1449 |
+
// Slow path
|
| 1450 |
+
const uint32_t tag = ReadTagFallback(first_byte_or_zero);
|
| 1451 |
+
return std::make_pair(tag, static_cast<uint32_t>(tag - 1) < cutoff);
|
| 1452 |
+
}
|
| 1453 |
+
|
| 1454 |
+
inline bool CodedInputStream::LastTagWas(uint32_t expected) {
|
| 1455 |
+
return last_tag_ == expected;
|
| 1456 |
+
}
|
| 1457 |
+
|
| 1458 |
+
inline bool CodedInputStream::ConsumedEntireMessage() {
|
| 1459 |
+
return legitimate_message_end_;
|
| 1460 |
+
}
|
| 1461 |
+
|
| 1462 |
+
inline bool CodedInputStream::ExpectTag(uint32_t expected) {
|
| 1463 |
+
if (expected < (1 << 7)) {
|
| 1464 |
+
if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_) &&
|
| 1465 |
+
buffer_[0] == expected) {
|
| 1466 |
+
Advance(1);
|
| 1467 |
+
return true;
|
| 1468 |
+
} else {
|
| 1469 |
+
return false;
|
| 1470 |
+
}
|
| 1471 |
+
} else if (expected < (1 << 14)) {
|
| 1472 |
+
if (PROTOBUF_PREDICT_TRUE(BufferSize() >= 2) &&
|
| 1473 |
+
buffer_[0] == static_cast<uint8_t>(expected | 0x80) &&
|
| 1474 |
+
buffer_[1] == static_cast<uint8_t>(expected >> 7)) {
|
| 1475 |
+
Advance(2);
|
| 1476 |
+
return true;
|
| 1477 |
+
} else {
|
| 1478 |
+
return false;
|
| 1479 |
+
}
|
| 1480 |
+
} else {
|
| 1481 |
+
// Don't bother optimizing for larger values.
|
| 1482 |
+
return false;
|
| 1483 |
+
}
|
| 1484 |
+
}
|
| 1485 |
+
|
| 1486 |
+
inline const uint8_t* CodedInputStream::ExpectTagFromArray(
|
| 1487 |
+
const uint8_t* buffer, uint32_t expected) {
|
| 1488 |
+
if (expected < (1 << 7)) {
|
| 1489 |
+
if (buffer[0] == expected) {
|
| 1490 |
+
return buffer + 1;
|
| 1491 |
+
}
|
| 1492 |
+
} else if (expected < (1 << 14)) {
|
| 1493 |
+
if (buffer[0] == static_cast<uint8_t>(expected | 0x80) &&
|
| 1494 |
+
buffer[1] == static_cast<uint8_t>(expected >> 7)) {
|
| 1495 |
+
return buffer + 2;
|
| 1496 |
+
}
|
| 1497 |
+
}
|
| 1498 |
+
return nullptr;
|
| 1499 |
+
}
|
| 1500 |
+
|
| 1501 |
+
inline void CodedInputStream::GetDirectBufferPointerInline(const void** data,
|
| 1502 |
+
int* size) {
|
| 1503 |
+
*data = buffer_;
|
| 1504 |
+
*size = static_cast<int>(buffer_end_ - buffer_);
|
| 1505 |
+
}
|
| 1506 |
+
|
| 1507 |
+
inline bool CodedInputStream::ExpectAtEnd() {
|
| 1508 |
+
// If we are at a limit we know no more bytes can be read. Otherwise, it's
|
| 1509 |
+
// hard to say without calling Refresh(), and we'd rather not do that.
|
| 1510 |
+
|
| 1511 |
+
if (buffer_ == buffer_end_ && ((buffer_size_after_limit_ != 0) ||
|
| 1512 |
+
(total_bytes_read_ == current_limit_))) {
|
| 1513 |
+
last_tag_ = 0; // Pretend we called ReadTag()...
|
| 1514 |
+
legitimate_message_end_ = true; // ... and it hit EOF.
|
| 1515 |
+
return true;
|
| 1516 |
+
} else {
|
| 1517 |
+
return false;
|
| 1518 |
+
}
|
| 1519 |
+
}
|
| 1520 |
+
|
| 1521 |
+
inline int CodedInputStream::CurrentPosition() const {
|
| 1522 |
+
return total_bytes_read_ - (BufferSize() + buffer_size_after_limit_);
|
| 1523 |
+
}
|
| 1524 |
+
|
| 1525 |
+
inline void CodedInputStream::Advance(int amount) { buffer_ += amount; }
|
| 1526 |
+
|
| 1527 |
+
inline void CodedInputStream::SetRecursionLimit(int limit) {
|
| 1528 |
+
recursion_budget_ += limit - recursion_limit_;
|
| 1529 |
+
recursion_limit_ = limit;
|
| 1530 |
+
}
|
| 1531 |
+
|
| 1532 |
+
inline bool CodedInputStream::IncrementRecursionDepth() {
|
| 1533 |
+
--recursion_budget_;
|
| 1534 |
+
return recursion_budget_ >= 0;
|
| 1535 |
+
}
|
| 1536 |
+
|
| 1537 |
+
inline void CodedInputStream::DecrementRecursionDepth() {
|
| 1538 |
+
if (recursion_budget_ < recursion_limit_) ++recursion_budget_;
|
| 1539 |
+
}
|
| 1540 |
+
|
| 1541 |
+
inline void CodedInputStream::UnsafeDecrementRecursionDepth() {
|
| 1542 |
+
assert(recursion_budget_ < recursion_limit_);
|
| 1543 |
+
++recursion_budget_;
|
| 1544 |
+
}
|
| 1545 |
+
|
| 1546 |
+
inline void CodedInputStream::SetExtensionRegistry(const DescriptorPool* pool,
|
| 1547 |
+
MessageFactory* factory) {
|
| 1548 |
+
extension_pool_ = pool;
|
| 1549 |
+
extension_factory_ = factory;
|
| 1550 |
+
}
|
| 1551 |
+
|
| 1552 |
+
inline const DescriptorPool* CodedInputStream::GetExtensionPool() {
|
| 1553 |
+
return extension_pool_;
|
| 1554 |
+
}
|
| 1555 |
+
|
| 1556 |
+
inline MessageFactory* CodedInputStream::GetExtensionFactory() {
|
| 1557 |
+
return extension_factory_;
|
| 1558 |
+
}
|
| 1559 |
+
|
| 1560 |
+
inline int CodedInputStream::BufferSize() const {
|
| 1561 |
+
return static_cast<int>(buffer_end_ - buffer_);
|
| 1562 |
+
}
|
| 1563 |
+
|
| 1564 |
+
inline CodedInputStream::CodedInputStream(ZeroCopyInputStream* input)
|
| 1565 |
+
: buffer_(nullptr),
|
| 1566 |
+
buffer_end_(nullptr),
|
| 1567 |
+
input_(input),
|
| 1568 |
+
total_bytes_read_(0),
|
| 1569 |
+
overflow_bytes_(0),
|
| 1570 |
+
last_tag_(0),
|
| 1571 |
+
legitimate_message_end_(false),
|
| 1572 |
+
aliasing_enabled_(false),
|
| 1573 |
+
current_limit_(std::numeric_limits<int32_t>::max()),
|
| 1574 |
+
buffer_size_after_limit_(0),
|
| 1575 |
+
total_bytes_limit_(kDefaultTotalBytesLimit),
|
| 1576 |
+
recursion_budget_(default_recursion_limit_),
|
| 1577 |
+
recursion_limit_(default_recursion_limit_),
|
| 1578 |
+
extension_pool_(nullptr),
|
| 1579 |
+
extension_factory_(nullptr) {
|
| 1580 |
+
// Eagerly Refresh() so buffer space is immediately available.
|
| 1581 |
+
Refresh();
|
| 1582 |
+
}
|
| 1583 |
+
|
| 1584 |
+
inline CodedInputStream::CodedInputStream(const uint8_t* buffer, int size)
|
| 1585 |
+
: buffer_(buffer),
|
| 1586 |
+
buffer_end_(buffer + size),
|
| 1587 |
+
input_(nullptr),
|
| 1588 |
+
total_bytes_read_(size),
|
| 1589 |
+
overflow_bytes_(0),
|
| 1590 |
+
last_tag_(0),
|
| 1591 |
+
legitimate_message_end_(false),
|
| 1592 |
+
aliasing_enabled_(false),
|
| 1593 |
+
current_limit_(size),
|
| 1594 |
+
buffer_size_after_limit_(0),
|
| 1595 |
+
total_bytes_limit_(kDefaultTotalBytesLimit),
|
| 1596 |
+
recursion_budget_(default_recursion_limit_),
|
| 1597 |
+
recursion_limit_(default_recursion_limit_),
|
| 1598 |
+
extension_pool_(nullptr),
|
| 1599 |
+
extension_factory_(nullptr) {
|
| 1600 |
+
// Note that setting current_limit_ == size is important to prevent some
|
| 1601 |
+
// code paths from trying to access input_ and segfaulting.
|
| 1602 |
+
}
|
| 1603 |
+
|
| 1604 |
+
inline bool CodedInputStream::IsFlat() const { return input_ == nullptr; }
|
| 1605 |
+
|
| 1606 |
+
inline bool CodedInputStream::Skip(int count) {
|
| 1607 |
+
if (count < 0) return false; // security: count is often user-supplied
|
| 1608 |
+
|
| 1609 |
+
const int original_buffer_size = BufferSize();
|
| 1610 |
+
|
| 1611 |
+
if (count <= original_buffer_size) {
|
| 1612 |
+
// Just skipping within the current buffer. Easy.
|
| 1613 |
+
Advance(count);
|
| 1614 |
+
return true;
|
| 1615 |
+
}
|
| 1616 |
+
|
| 1617 |
+
return SkipFallback(count, original_buffer_size);
|
| 1618 |
+
}
|
| 1619 |
+
|
| 1620 |
+
template <class Stream, class>
|
| 1621 |
+
inline CodedOutputStream::CodedOutputStream(Stream* stream)
|
| 1622 |
+
: impl_(stream, IsDefaultSerializationDeterministic(), &cur_),
|
| 1623 |
+
start_count_(stream->ByteCount()) {
|
| 1624 |
+
InitEagerly(stream);
|
| 1625 |
+
}
|
| 1626 |
+
|
| 1627 |
+
template <class Stream, class>
|
| 1628 |
+
inline CodedOutputStream::CodedOutputStream(Stream* stream, bool eager_init)
|
| 1629 |
+
: impl_(stream, IsDefaultSerializationDeterministic(), &cur_),
|
| 1630 |
+
start_count_(stream->ByteCount()) {
|
| 1631 |
+
if (eager_init) {
|
| 1632 |
+
InitEagerly(stream);
|
| 1633 |
+
}
|
| 1634 |
+
}
|
| 1635 |
+
|
| 1636 |
+
template <class Stream>
|
| 1637 |
+
inline void CodedOutputStream::InitEagerly(Stream* stream) {
|
| 1638 |
+
void* data;
|
| 1639 |
+
int size;
|
| 1640 |
+
if (PROTOBUF_PREDICT_TRUE(stream->Next(&data, &size) && size > 0)) {
|
| 1641 |
+
cur_ = impl_.SetInitialBuffer(data, size);
|
| 1642 |
+
}
|
| 1643 |
+
}
|
| 1644 |
+
|
| 1645 |
+
inline uint8_t* CodedOutputStream::WriteVarint32ToArray(uint32_t value,
|
| 1646 |
+
uint8_t* target) {
|
| 1647 |
+
return EpsCopyOutputStream::UnsafeVarint(value, target);
|
| 1648 |
+
}
|
| 1649 |
+
|
| 1650 |
+
inline uint8_t* CodedOutputStream::WriteVarint32ToArrayOutOfLine(
|
| 1651 |
+
uint32_t value, uint8_t* target) {
|
| 1652 |
+
target[0] = static_cast<uint8_t>(value);
|
| 1653 |
+
if (value < 0x80) {
|
| 1654 |
+
return target + 1;
|
| 1655 |
+
} else {
|
| 1656 |
+
return WriteVarint32ToArrayOutOfLineHelper(value, target);
|
| 1657 |
+
}
|
| 1658 |
+
}
|
| 1659 |
+
|
| 1660 |
+
inline uint8_t* CodedOutputStream::WriteVarint64ToArray(uint64_t value,
|
| 1661 |
+
uint8_t* target) {
|
| 1662 |
+
return EpsCopyOutputStream::UnsafeVarint(value, target);
|
| 1663 |
+
}
|
| 1664 |
+
|
| 1665 |
+
inline void CodedOutputStream::WriteVarint32SignExtended(int32_t value) {
|
| 1666 |
+
WriteVarint64(static_cast<uint64_t>(value));
|
| 1667 |
+
}
|
| 1668 |
+
|
| 1669 |
+
inline uint8_t* CodedOutputStream::WriteVarint32SignExtendedToArray(
|
| 1670 |
+
int32_t value, uint8_t* target) {
|
| 1671 |
+
return WriteVarint64ToArray(static_cast<uint64_t>(value), target);
|
| 1672 |
+
}
|
| 1673 |
+
|
| 1674 |
+
inline uint8_t* CodedOutputStream::WriteLittleEndian32ToArray(uint32_t value,
|
| 1675 |
+
uint8_t* target) {
|
| 1676 |
+
#if defined(PROTOBUF_LITTLE_ENDIAN) && \
|
| 1677 |
+
!defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)
|
| 1678 |
+
memcpy(target, &value, sizeof(value));
|
| 1679 |
+
#else
|
| 1680 |
+
target[0] = static_cast<uint8_t>(value);
|
| 1681 |
+
target[1] = static_cast<uint8_t>(value >> 8);
|
| 1682 |
+
target[2] = static_cast<uint8_t>(value >> 16);
|
| 1683 |
+
target[3] = static_cast<uint8_t>(value >> 24);
|
| 1684 |
+
#endif
|
| 1685 |
+
return target + sizeof(value);
|
| 1686 |
+
}
|
| 1687 |
+
|
| 1688 |
+
inline uint8_t* CodedOutputStream::WriteLittleEndian64ToArray(uint64_t value,
|
| 1689 |
+
uint8_t* target) {
|
| 1690 |
+
#if defined(PROTOBUF_LITTLE_ENDIAN) && \
|
| 1691 |
+
!defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)
|
| 1692 |
+
memcpy(target, &value, sizeof(value));
|
| 1693 |
+
#else
|
| 1694 |
+
uint32_t part0 = static_cast<uint32_t>(value);
|
| 1695 |
+
uint32_t part1 = static_cast<uint32_t>(value >> 32);
|
| 1696 |
+
|
| 1697 |
+
target[0] = static_cast<uint8_t>(part0);
|
| 1698 |
+
target[1] = static_cast<uint8_t>(part0 >> 8);
|
| 1699 |
+
target[2] = static_cast<uint8_t>(part0 >> 16);
|
| 1700 |
+
target[3] = static_cast<uint8_t>(part0 >> 24);
|
| 1701 |
+
target[4] = static_cast<uint8_t>(part1);
|
| 1702 |
+
target[5] = static_cast<uint8_t>(part1 >> 8);
|
| 1703 |
+
target[6] = static_cast<uint8_t>(part1 >> 16);
|
| 1704 |
+
target[7] = static_cast<uint8_t>(part1 >> 24);
|
| 1705 |
+
#endif
|
| 1706 |
+
return target + sizeof(value);
|
| 1707 |
+
}
|
| 1708 |
+
|
| 1709 |
+
inline void CodedOutputStream::WriteVarint32(uint32_t value) {
|
| 1710 |
+
cur_ = impl_.EnsureSpace(cur_);
|
| 1711 |
+
SetCur(WriteVarint32ToArray(value, Cur()));
|
| 1712 |
+
}
|
| 1713 |
+
|
| 1714 |
+
inline void CodedOutputStream::WriteVarint64(uint64_t value) {
|
| 1715 |
+
cur_ = impl_.EnsureSpace(cur_);
|
| 1716 |
+
SetCur(WriteVarint64ToArray(value, Cur()));
|
| 1717 |
+
}
|
| 1718 |
+
|
| 1719 |
+
inline void CodedOutputStream::WriteTag(uint32_t value) {
|
| 1720 |
+
WriteVarint32(value);
|
| 1721 |
+
}
|
| 1722 |
+
|
| 1723 |
+
inline uint8_t* CodedOutputStream::WriteTagToArray(uint32_t value,
|
| 1724 |
+
uint8_t* target) {
|
| 1725 |
+
return WriteVarint32ToArray(value, target);
|
| 1726 |
+
}
|
| 1727 |
+
|
| 1728 |
+
inline size_t CodedOutputStream::VarintSize32(uint32_t value) {
|
| 1729 |
+
// This computes value == 0 ? 1 : floor(log2(value)) / 7 + 1
|
| 1730 |
+
// Use an explicit multiplication to implement the divide of
|
| 1731 |
+
// a number in the 1..31 range.
|
| 1732 |
+
// Explicit OR 0x1 to avoid calling Bits::Log2FloorNonZero(0), which is
|
| 1733 |
+
// undefined.
|
| 1734 |
+
uint32_t log2value = Bits::Log2FloorNonZero(value | 0x1);
|
| 1735 |
+
return static_cast<size_t>((log2value * 9 + 73) / 64);
|
| 1736 |
+
}
|
| 1737 |
+
|
| 1738 |
+
inline size_t CodedOutputStream::VarintSize32PlusOne(uint32_t value) {
|
| 1739 |
+
// Same as above, but one more.
|
| 1740 |
+
uint32_t log2value = Bits::Log2FloorNonZero(value | 0x1);
|
| 1741 |
+
return static_cast<size_t>((log2value * 9 + 73 + 64) / 64);
|
| 1742 |
+
}
|
| 1743 |
+
|
| 1744 |
+
inline size_t CodedOutputStream::VarintSize64(uint64_t value) {
|
| 1745 |
+
// This computes value == 0 ? 1 : floor(log2(value)) / 7 + 1
|
| 1746 |
+
// Use an explicit multiplication to implement the divide of
|
| 1747 |
+
// a number in the 1..63 range.
|
| 1748 |
+
// Explicit OR 0x1 to avoid calling Bits::Log2FloorNonZero(0), which is
|
| 1749 |
+
// undefined.
|
| 1750 |
+
uint32_t log2value = Bits::Log2FloorNonZero64(value | 0x1);
|
| 1751 |
+
return static_cast<size_t>((log2value * 9 + 73) / 64);
|
| 1752 |
+
}
|
| 1753 |
+
|
| 1754 |
+
inline size_t CodedOutputStream::VarintSize64PlusOne(uint64_t value) {
|
| 1755 |
+
// Same as above, but one more.
|
| 1756 |
+
uint32_t log2value = Bits::Log2FloorNonZero64(value | 0x1);
|
| 1757 |
+
return static_cast<size_t>((log2value * 9 + 73 + 64) / 64);
|
| 1758 |
+
}
|
| 1759 |
+
|
| 1760 |
+
inline size_t CodedOutputStream::VarintSize32SignExtended(int32_t value) {
|
| 1761 |
+
return VarintSize64(static_cast<uint64_t>(int64_t{value}));
|
| 1762 |
+
}
|
| 1763 |
+
|
| 1764 |
+
inline size_t CodedOutputStream::VarintSize32SignExtendedPlusOne(
|
| 1765 |
+
int32_t value) {
|
| 1766 |
+
return VarintSize64PlusOne(static_cast<uint64_t>(int64_t{value}));
|
| 1767 |
+
}
|
| 1768 |
+
|
| 1769 |
+
inline void CodedOutputStream::WriteString(const std::string& str) {
|
| 1770 |
+
WriteRaw(str.data(), static_cast<int>(str.size()));
|
| 1771 |
+
}
|
| 1772 |
+
|
| 1773 |
+
inline void CodedOutputStream::WriteRawMaybeAliased(const void* data,
|
| 1774 |
+
int size) {
|
| 1775 |
+
cur_ = impl_.WriteRawMaybeAliased(data, size, cur_);
|
| 1776 |
+
}
|
| 1777 |
+
|
| 1778 |
+
inline uint8_t* CodedOutputStream::WriteRawToArray(const void* data, int size,
|
| 1779 |
+
uint8_t* target) {
|
| 1780 |
+
memcpy(target, data, size);
|
| 1781 |
+
return target + size;
|
| 1782 |
+
}
|
| 1783 |
+
|
| 1784 |
+
inline uint8_t* CodedOutputStream::WriteStringToArray(const std::string& str,
|
| 1785 |
+
uint8_t* target) {
|
| 1786 |
+
return WriteRawToArray(str.data(), static_cast<int>(str.size()), target);
|
| 1787 |
+
}
|
| 1788 |
+
|
| 1789 |
+
} // namespace io
|
| 1790 |
+
} // namespace protobuf
|
| 1791 |
+
} // namespace google
|
| 1792 |
+
|
| 1793 |
+
#if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)
|
| 1794 |
+
#pragma runtime_checks("c", restore)
|
| 1795 |
+
#endif // _MSC_VER && !defined(__INTEL_COMPILER)
|
| 1796 |
+
|
| 1797 |
+
#include <google/protobuf/port_undef.inc>
|
| 1798 |
+
|
| 1799 |
+
#endif // GOOGLE_PROTOBUF_IO_CODED_STREAM_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/io/gzip_stream.h
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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ribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// Author: brianolson@google.com (Brian Olson)
|
| 32 |
+
//
|
| 33 |
+
// This file contains the definition for classes GzipInputStream and
|
| 34 |
+
// GzipOutputStream.
|
| 35 |
+
//
|
| 36 |
+
// GzipInputStream decompresses data from an underlying
|
| 37 |
+
// ZeroCopyInputStream and provides the decompressed data as a
|
| 38 |
+
// ZeroCopyInputStream.
|
| 39 |
+
//
|
| 40 |
+
// GzipOutputStream is an ZeroCopyOutputStream that compresses data to
|
| 41 |
+
// an underlying ZeroCopyOutputStream.
|
| 42 |
+
|
| 43 |
+
#ifndef GOOGLE_PROTOBUF_IO_GZIP_STREAM_H__
|
| 44 |
+
#define GOOGLE_PROTOBUF_IO_GZIP_STREAM_H__
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
#include <google/protobuf/stubs/common.h>
|
| 48 |
+
#include <google/protobuf/io/zero_copy_stream.h>
|
| 49 |
+
#include <google/protobuf/port.h>
|
| 50 |
+
#include "zlib.h"
|
| 51 |
+
|
| 52 |
+
// Must be included last.
|
| 53 |
+
#include <google/protobuf/port_def.inc>
|
| 54 |
+
|
| 55 |
+
namespace google {
|
| 56 |
+
namespace protobuf {
|
| 57 |
+
namespace io {
|
| 58 |
+
|
| 59 |
+
// A ZeroCopyInputStream that reads compressed data through zlib
|
| 60 |
+
class PROTOBUF_EXPORT GzipInputStream PROTOBUF_FUTURE_FINAL
|
| 61 |
+
: public ZeroCopyInputStream {
|
| 62 |
+
public:
|
| 63 |
+
// Format key for constructor
|
| 64 |
+
enum Format {
|
| 65 |
+
// zlib will autodetect gzip header or deflate stream
|
| 66 |
+
AUTO = 0,
|
| 67 |
+
|
| 68 |
+
// GZIP streams have some extra header data for file attributes.
|
| 69 |
+
GZIP = 1,
|
| 70 |
+
|
| 71 |
+
// Simpler zlib stream format.
|
| 72 |
+
ZLIB = 2,
|
| 73 |
+
};
|
| 74 |
+
|
| 75 |
+
// buffer_size and format may be -1 for default of 64kB and GZIP format
|
| 76 |
+
explicit GzipInputStream(ZeroCopyInputStream* sub_stream,
|
| 77 |
+
Format format = AUTO, int buffer_size = -1);
|
| 78 |
+
virtual ~GzipInputStream();
|
| 79 |
+
|
| 80 |
+
// Return last error message or NULL if no error.
|
| 81 |
+
inline const char* ZlibErrorMessage() const { return zcontext_.msg; }
|
| 82 |
+
inline int ZlibErrorCode() const { return zerror_; }
|
| 83 |
+
|
| 84 |
+
// implements ZeroCopyInputStream ----------------------------------
|
| 85 |
+
bool Next(const void** data, int* size) override;
|
| 86 |
+
void BackUp(int count) override;
|
| 87 |
+
bool Skip(int count) override;
|
| 88 |
+
int64_t ByteCount() const override;
|
| 89 |
+
|
| 90 |
+
private:
|
| 91 |
+
Format format_;
|
| 92 |
+
|
| 93 |
+
ZeroCopyInputStream* sub_stream_;
|
| 94 |
+
|
| 95 |
+
z_stream zcontext_;
|
| 96 |
+
int zerror_;
|
| 97 |
+
|
| 98 |
+
void* output_buffer_;
|
| 99 |
+
void* output_position_;
|
| 100 |
+
size_t output_buffer_length_;
|
| 101 |
+
int64_t byte_count_;
|
| 102 |
+
|
| 103 |
+
int Inflate(int flush);
|
| 104 |
+
void DoNextOutput(const void** data, int* size);
|
| 105 |
+
|
| 106 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GzipInputStream);
|
| 107 |
+
};
|
| 108 |
+
|
| 109 |
+
class PROTOBUF_EXPORT GzipOutputStream PROTOBUF_FUTURE_FINAL
|
| 110 |
+
: public ZeroCopyOutputStream {
|
| 111 |
+
public:
|
| 112 |
+
// Format key for constructor
|
| 113 |
+
enum Format {
|
| 114 |
+
// GZIP streams have some extra header data for file attributes.
|
| 115 |
+
GZIP = 1,
|
| 116 |
+
|
| 117 |
+
// Simpler zlib stream format.
|
| 118 |
+
ZLIB = 2,
|
| 119 |
+
};
|
| 120 |
+
|
| 121 |
+
struct PROTOBUF_EXPORT Options {
|
| 122 |
+
// Defaults to GZIP.
|
| 123 |
+
Format format;
|
| 124 |
+
|
| 125 |
+
// What size buffer to use internally. Defaults to 64kB.
|
| 126 |
+
int buffer_size;
|
| 127 |
+
|
| 128 |
+
// A number between 0 and 9, where 0 is no compression and 9 is best
|
| 129 |
+
// compression. Defaults to Z_DEFAULT_COMPRESSION (see zlib.h).
|
| 130 |
+
int compression_level;
|
| 131 |
+
|
| 132 |
+
// Defaults to Z_DEFAULT_STRATEGY. Can also be set to Z_FILTERED,
|
| 133 |
+
// Z_HUFFMAN_ONLY, or Z_RLE. See the documentation for deflateInit2 in
|
| 134 |
+
// zlib.h for definitions of these constants.
|
| 135 |
+
int compression_strategy;
|
| 136 |
+
|
| 137 |
+
Options(); // Initializes with default values.
|
| 138 |
+
};
|
| 139 |
+
|
| 140 |
+
// Create a GzipOutputStream with default options.
|
| 141 |
+
explicit GzipOutputStream(ZeroCopyOutputStream* sub_stream);
|
| 142 |
+
|
| 143 |
+
// Create a GzipOutputStream with the given options.
|
| 144 |
+
GzipOutputStream(ZeroCopyOutputStream* sub_stream, const Options& options);
|
| 145 |
+
|
| 146 |
+
virtual ~GzipOutputStream();
|
| 147 |
+
|
| 148 |
+
// Return last error message or NULL if no error.
|
| 149 |
+
inline const char* ZlibErrorMessage() const { return zcontext_.msg; }
|
| 150 |
+
inline int ZlibErrorCode() const { return zerror_; }
|
| 151 |
+
|
| 152 |
+
// Flushes data written so far to zipped data in the underlying stream.
|
| 153 |
+
// It is the caller's responsibility to flush the underlying stream if
|
| 154 |
+
// necessary.
|
| 155 |
+
// Compression may be less efficient stopping and starting around flushes.
|
| 156 |
+
// Returns true if no error.
|
| 157 |
+
//
|
| 158 |
+
// Please ensure that block size is > 6. Here is an excerpt from the zlib
|
| 159 |
+
// doc that explains why:
|
| 160 |
+
//
|
| 161 |
+
// In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that avail_out
|
| 162 |
+
// is greater than six to avoid repeated flush markers due to
|
| 163 |
+
// avail_out == 0 on return.
|
| 164 |
+
bool Flush();
|
| 165 |
+
|
| 166 |
+
// Writes out all data and closes the gzip stream.
|
| 167 |
+
// It is the caller's responsibility to close the underlying stream if
|
| 168 |
+
// necessary.
|
| 169 |
+
// Returns true if no error.
|
| 170 |
+
bool Close();
|
| 171 |
+
|
| 172 |
+
// implements ZeroCopyOutputStream ---------------------------------
|
| 173 |
+
bool Next(void** data, int* size) override;
|
| 174 |
+
void BackUp(int count) override;
|
| 175 |
+
int64_t ByteCount() const override;
|
| 176 |
+
|
| 177 |
+
private:
|
| 178 |
+
ZeroCopyOutputStream* sub_stream_;
|
| 179 |
+
// Result from calling Next() on sub_stream_
|
| 180 |
+
void* sub_data_;
|
| 181 |
+
int sub_data_size_;
|
| 182 |
+
|
| 183 |
+
z_stream zcontext_;
|
| 184 |
+
int zerror_;
|
| 185 |
+
void* input_buffer_;
|
| 186 |
+
size_t input_buffer_length_;
|
| 187 |
+
|
| 188 |
+
// Shared constructor code.
|
| 189 |
+
void Init(ZeroCopyOutputStream* sub_stream, const Options& options);
|
| 190 |
+
|
| 191 |
+
// Do some compression.
|
| 192 |
+
// Takes zlib flush mode.
|
| 193 |
+
// Returns zlib error code.
|
| 194 |
+
int Deflate(int flush);
|
| 195 |
+
|
| 196 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GzipOutputStream);
|
| 197 |
+
};
|
| 198 |
+
|
| 199 |
+
} // namespace io
|
| 200 |
+
} // namespace protobuf
|
| 201 |
+
} // namespace google
|
| 202 |
+
|
| 203 |
+
#include <google/protobuf/port_undef.inc>
|
| 204 |
+
|
| 205 |
+
#endif // GOOGLE_PROTOBUF_IO_GZIP_STREAM_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/io/io_win32.h
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// Author: laszlocsomor@google.com (Laszlo Csomor)
|
| 32 |
+
// Based on original Protocol Buffers design by
|
| 33 |
+
// Sanjay Ghemawat, Jeff Dean, and others.
|
| 34 |
+
|
| 35 |
+
// This file contains the declarations for Windows implementations of
|
| 36 |
+
// commonly used POSIX functions such as open(2) and access(2), as well
|
| 37 |
+
// as macro definitions for flags of these functions.
|
| 38 |
+
//
|
| 39 |
+
// By including this file you'll redefine open/access/etc. to
|
| 40 |
+
// ::google::protobuf::io::win32::{open/access/etc.}.
|
| 41 |
+
// Make sure you don't include a header that attempts to redeclare or
|
| 42 |
+
// redefine these functions, that'll lead to confusing compilation
|
| 43 |
+
// errors. It's best to #include this file as the last one to ensure that.
|
| 44 |
+
//
|
| 45 |
+
// This file is only used on Windows, it's empty on other platforms.
|
| 46 |
+
|
| 47 |
+
#ifndef GOOGLE_PROTOBUF_IO_IO_WIN32_H__
|
| 48 |
+
#define GOOGLE_PROTOBUF_IO_IO_WIN32_H__
|
| 49 |
+
|
| 50 |
+
#if defined(_WIN32)
|
| 51 |
+
|
| 52 |
+
#include <functional>
|
| 53 |
+
#include <string>
|
| 54 |
+
|
| 55 |
+
#include <google/protobuf/port.h>
|
| 56 |
+
|
| 57 |
+
// Must be included last.
|
| 58 |
+
#include <google/protobuf/port_def.inc>
|
| 59 |
+
|
| 60 |
+
// Compilers on Windows other than MSVC (e.g. Cygwin, MinGW32) define the
|
| 61 |
+
// following functions already, except for mkdir.
|
| 62 |
+
namespace google {
|
| 63 |
+
namespace protobuf {
|
| 64 |
+
namespace io {
|
| 65 |
+
namespace win32 {
|
| 66 |
+
|
| 67 |
+
PROTOBUF_EXPORT FILE* fopen(const char* path, const char* mode);
|
| 68 |
+
PROTOBUF_EXPORT int access(const char* path, int mode);
|
| 69 |
+
PROTOBUF_EXPORT int chdir(const char* path);
|
| 70 |
+
PROTOBUF_EXPORT int close(int fd);
|
| 71 |
+
PROTOBUF_EXPORT int dup(int fd);
|
| 72 |
+
PROTOBUF_EXPORT int dup2(int fd1, int fd2);
|
| 73 |
+
PROTOBUF_EXPORT int mkdir(const char* path, int _mode);
|
| 74 |
+
PROTOBUF_EXPORT int open(const char* path, int flags, int mode = 0);
|
| 75 |
+
PROTOBUF_EXPORT int read(int fd, void* buffer, size_t size);
|
| 76 |
+
PROTOBUF_EXPORT int setmode(int fd, int mode);
|
| 77 |
+
PROTOBUF_EXPORT int stat(const char* path, struct _stat* buffer);
|
| 78 |
+
PROTOBUF_EXPORT int write(int fd, const void* buffer, size_t size);
|
| 79 |
+
PROTOBUF_EXPORT std::wstring testonly_utf8_to_winpath(const char* path);
|
| 80 |
+
|
| 81 |
+
enum class ExpandWildcardsResult {
|
| 82 |
+
kSuccess = 0,
|
| 83 |
+
kErrorNoMatchingFile = 1,
|
| 84 |
+
kErrorInputPathConversion = 2,
|
| 85 |
+
kErrorOutputPathConversion = 3,
|
| 86 |
+
};
|
| 87 |
+
|
| 88 |
+
// Expand wildcards in a path pattern, feed the result to a consumer function.
|
| 89 |
+
//
|
| 90 |
+
// `path` must be a valid, Windows-style path. It may be absolute, or relative
|
| 91 |
+
// to the current working directory, and it may contain wildcards ("*" and "?")
|
| 92 |
+
// in the last path segment. This function passes all matching file names to
|
| 93 |
+
// `consume`. The resulting paths may not be absolute nor normalized.
|
| 94 |
+
//
|
| 95 |
+
// The function returns a value from `ExpandWildcardsResult`.
|
| 96 |
+
PROTOBUF_EXPORT ExpandWildcardsResult ExpandWildcards(
|
| 97 |
+
const std::string& path, std::function<void(const std::string&)> consume);
|
| 98 |
+
|
| 99 |
+
namespace strings {
|
| 100 |
+
|
| 101 |
+
// Convert from UTF-16 to Active-Code-Page-encoded or to UTF-8-encoded text.
|
| 102 |
+
PROTOBUF_EXPORT bool wcs_to_mbs(const wchar_t* s, std::string* out,
|
| 103 |
+
bool outUtf8);
|
| 104 |
+
|
| 105 |
+
// Convert from Active-Code-Page-encoded or UTF-8-encoded text to UTF-16.
|
| 106 |
+
PROTOBUF_EXPORT bool mbs_to_wcs(const char* s, std::wstring* out, bool inUtf8);
|
| 107 |
+
|
| 108 |
+
// Convert from UTF-8-encoded text to UTF-16.
|
| 109 |
+
PROTOBUF_EXPORT bool utf8_to_wcs(const char* input, std::wstring* out);
|
| 110 |
+
|
| 111 |
+
// Convert from UTF-16-encoded text to UTF-8.
|
| 112 |
+
PROTOBUF_EXPORT bool wcs_to_utf8(const wchar_t* input, std::string* out);
|
| 113 |
+
|
| 114 |
+
} // namespace strings
|
| 115 |
+
|
| 116 |
+
} // namespace win32
|
| 117 |
+
} // namespace io
|
| 118 |
+
} // namespace protobuf
|
| 119 |
+
} // namespace google
|
| 120 |
+
|
| 121 |
+
#ifndef W_OK
|
| 122 |
+
#define W_OK 02 // not defined by MSVC for whatever reason
|
| 123 |
+
#endif
|
| 124 |
+
|
| 125 |
+
#ifndef F_OK
|
| 126 |
+
#define F_OK 00 // not defined by MSVC for whatever reason
|
| 127 |
+
#endif
|
| 128 |
+
|
| 129 |
+
#ifndef STDIN_FILENO
|
| 130 |
+
#define STDIN_FILENO 0
|
| 131 |
+
#endif
|
| 132 |
+
|
| 133 |
+
#ifndef STDOUT_FILENO
|
| 134 |
+
#define STDOUT_FILENO 1
|
| 135 |
+
#endif
|
| 136 |
+
|
| 137 |
+
#include <google/protobuf/port_undef.inc>
|
| 138 |
+
|
| 139 |
+
#endif // defined(_WIN32)
|
| 140 |
+
|
| 141 |
+
#endif // GOOGLE_PROTOBUF_IO_IO_WIN32_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/io/package_info.h
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// Author: kenton@google.com (Kenton Varda)
|
| 32 |
+
// Based on original Protocol Buffers design by
|
| 33 |
+
// Sanjay Ghemawat, Jeff Dean, and others.
|
| 34 |
+
//
|
| 35 |
+
// This file exists solely to document the google::protobuf::io namespace.
|
| 36 |
+
// It is not compiled into anything, but it may be read by an automated
|
| 37 |
+
// documentation generator.
|
| 38 |
+
|
| 39 |
+
namespace google {
|
| 40 |
+
namespace protobuf {
|
| 41 |
+
|
| 42 |
+
// Auxiliary classes used for I/O.
|
| 43 |
+
//
|
| 44 |
+
// The Protocol Buffer library uses the classes in this package to deal with
|
| 45 |
+
// I/O and encoding/decoding raw bytes. Most users will not need to
|
| 46 |
+
// deal with this package. However, users who want to adapt the system to
|
| 47 |
+
// work with their own I/O abstractions -- e.g., to allow Protocol Buffers
|
| 48 |
+
// to be read from a different kind of input stream without the need for a
|
| 49 |
+
// temporary buffer -- should take a closer look.
|
| 50 |
+
namespace io {}
|
| 51 |
+
|
| 52 |
+
} // namespace protobuf
|
| 53 |
+
} // namespace google
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/io/printer.h
ADDED
|
@@ -0,0 +1,387 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// Author: kenton@google.com (Kenton Varda)
|
| 32 |
+
// Based on original Protocol Buffers design by
|
| 33 |
+
// Sanjay Ghemawat, Jeff Dean, and others.
|
| 34 |
+
//
|
| 35 |
+
// Utility class for writing text to a ZeroCopyOutputStream.
|
| 36 |
+
|
| 37 |
+
#ifndef GOOGLE_PROTOBUF_IO_PRINTER_H__
|
| 38 |
+
#define GOOGLE_PROTOBUF_IO_PRINTER_H__
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
#include <map>
|
| 42 |
+
#include <string>
|
| 43 |
+
#include <vector>
|
| 44 |
+
|
| 45 |
+
#include <google/protobuf/stubs/common.h>
|
| 46 |
+
|
| 47 |
+
// Must be included last.
|
| 48 |
+
#include <google/protobuf/port_def.inc>
|
| 49 |
+
|
| 50 |
+
namespace google {
|
| 51 |
+
namespace protobuf {
|
| 52 |
+
namespace io {
|
| 53 |
+
|
| 54 |
+
class ZeroCopyOutputStream; // zero_copy_stream.h
|
| 55 |
+
|
| 56 |
+
// Records annotations about a Printer's output.
|
| 57 |
+
class PROTOBUF_EXPORT AnnotationCollector {
|
| 58 |
+
public:
|
| 59 |
+
// Annotation is a offset range and a payload pair.
|
| 60 |
+
typedef std::pair<std::pair<size_t, size_t>, std::string> Annotation;
|
| 61 |
+
|
| 62 |
+
// Records that the bytes in file_path beginning with begin_offset and ending
|
| 63 |
+
// before end_offset are associated with the SourceCodeInfo-style path.
|
| 64 |
+
virtual void AddAnnotation(size_t begin_offset, size_t end_offset,
|
| 65 |
+
const std::string& file_path,
|
| 66 |
+
const std::vector<int>& path) = 0;
|
| 67 |
+
|
| 68 |
+
// TODO(gerbens) I don't see why we need virtuals here. Just a vector of
|
| 69 |
+
// range, payload pairs stored in a context should suffice.
|
| 70 |
+
virtual void AddAnnotationNew(Annotation& /* a */) {}
|
| 71 |
+
|
| 72 |
+
virtual ~AnnotationCollector() {}
|
| 73 |
+
};
|
| 74 |
+
|
| 75 |
+
// Records annotations about a Printer's output to the given protocol buffer,
|
| 76 |
+
// assuming that the buffer has an ::Annotation message exposing path,
|
| 77 |
+
// source_file, begin and end fields.
|
| 78 |
+
template <typename AnnotationProto>
|
| 79 |
+
class AnnotationProtoCollector : public AnnotationCollector {
|
| 80 |
+
public:
|
| 81 |
+
// annotation_proto is the protocol buffer to which new Annotations should be
|
| 82 |
+
// added. It is not owned by the AnnotationProtoCollector.
|
| 83 |
+
explicit AnnotationProtoCollector(AnnotationProto* annotation_proto)
|
| 84 |
+
: annotation_proto_(annotation_proto) {}
|
| 85 |
+
|
| 86 |
+
// Override for AnnotationCollector::AddAnnotation.
|
| 87 |
+
void AddAnnotation(size_t begin_offset, size_t end_offset,
|
| 88 |
+
const std::string& file_path,
|
| 89 |
+
const std::vector<int>& path) override {
|
| 90 |
+
typename AnnotationProto::Annotation* annotation =
|
| 91 |
+
annotation_proto_->add_annotation();
|
| 92 |
+
for (int i = 0; i < path.size(); ++i) {
|
| 93 |
+
annotation->add_path(path[i]);
|
| 94 |
+
}
|
| 95 |
+
annotation->set_source_file(file_path);
|
| 96 |
+
annotation->set_begin(begin_offset);
|
| 97 |
+
annotation->set_end(end_offset);
|
| 98 |
+
}
|
| 99 |
+
// Override for AnnotationCollector::AddAnnotation.
|
| 100 |
+
void AddAnnotationNew(Annotation& a) override {
|
| 101 |
+
auto* annotation = annotation_proto_->add_annotation();
|
| 102 |
+
annotation->ParseFromString(a.second);
|
| 103 |
+
annotation->set_begin(a.first.first);
|
| 104 |
+
annotation->set_end(a.first.second);
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
private:
|
| 108 |
+
// The protocol buffer to which new annotations should be added.
|
| 109 |
+
AnnotationProto* const annotation_proto_;
|
| 110 |
+
};
|
| 111 |
+
|
| 112 |
+
// This simple utility class assists in code generation. It basically
|
| 113 |
+
// allows the caller to define a set of variables and then output some
|
| 114 |
+
// text with variable substitutions. Example usage:
|
| 115 |
+
//
|
| 116 |
+
// Printer printer(output, '$');
|
| 117 |
+
// map<string, string> vars;
|
| 118 |
+
// vars["name"] = "Bob";
|
| 119 |
+
// printer.Print(vars, "My name is $name$.");
|
| 120 |
+
//
|
| 121 |
+
// The above writes "My name is Bob." to the output stream.
|
| 122 |
+
//
|
| 123 |
+
// Printer aggressively enforces correct usage, crashing (with assert failures)
|
| 124 |
+
// in the case of undefined variables in debug builds. This helps greatly in
|
| 125 |
+
// debugging code which uses it.
|
| 126 |
+
//
|
| 127 |
+
// If a Printer is constructed with an AnnotationCollector, it will provide it
|
| 128 |
+
// with annotations that connect the Printer's output to paths that can identify
|
| 129 |
+
// various descriptors. In the above example, if person_ is a descriptor that
|
| 130 |
+
// identifies Bob, we can associate the output string "My name is Bob." with
|
| 131 |
+
// a source path pointing to that descriptor with:
|
| 132 |
+
//
|
| 133 |
+
// printer.Annotate("name", person_);
|
| 134 |
+
//
|
| 135 |
+
// The AnnotationCollector will be sent an annotation linking the output range
|
| 136 |
+
// covering "Bob" to the logical path provided by person_. Tools may use
|
| 137 |
+
// this association to (for example) link "Bob" in the output back to the
|
| 138 |
+
// source file that defined the person_ descriptor identifying Bob.
|
| 139 |
+
//
|
| 140 |
+
// Annotate can only examine variables substituted during the last call to
|
| 141 |
+
// Print. It is invalid to refer to a variable that was used multiple times
|
| 142 |
+
// in a single Print call.
|
| 143 |
+
//
|
| 144 |
+
// In full generality, one may specify a range of output text using a beginning
|
| 145 |
+
// substitution variable and an ending variable. The resulting annotation will
|
| 146 |
+
// span from the first character of the substituted value for the beginning
|
| 147 |
+
// variable to the last character of the substituted value for the ending
|
| 148 |
+
// variable. For example, the Annotate call above is equivalent to this one:
|
| 149 |
+
//
|
| 150 |
+
// printer.Annotate("name", "name", person_);
|
| 151 |
+
//
|
| 152 |
+
// This is useful if multiple variables combine to form a single span of output
|
| 153 |
+
// that should be annotated with the same source path. For example:
|
| 154 |
+
//
|
| 155 |
+
// Printer printer(output, '$');
|
| 156 |
+
// map<string, string> vars;
|
| 157 |
+
// vars["first"] = "Alice";
|
| 158 |
+
// vars["last"] = "Smith";
|
| 159 |
+
// printer.Print(vars, "My name is $first$ $last$.");
|
| 160 |
+
// printer.Annotate("first", "last", person_);
|
| 161 |
+
//
|
| 162 |
+
// This code would associate the span covering "Alice Smith" in the output with
|
| 163 |
+
// the person_ descriptor.
|
| 164 |
+
//
|
| 165 |
+
// Note that the beginning variable must come before (or overlap with, in the
|
| 166 |
+
// case of zero-sized substitution values) the ending variable.
|
| 167 |
+
//
|
| 168 |
+
// It is also sometimes useful to use variables with zero-sized values as
|
| 169 |
+
// markers. This avoids issues with multiple references to the same variable
|
| 170 |
+
// and also allows annotation ranges to span literal text from the Print
|
| 171 |
+
// templates:
|
| 172 |
+
//
|
| 173 |
+
// Printer printer(output, '$');
|
| 174 |
+
// map<string, string> vars;
|
| 175 |
+
// vars["foo"] = "bar";
|
| 176 |
+
// vars["function"] = "call";
|
| 177 |
+
// vars["mark"] = "";
|
| 178 |
+
// printer.Print(vars, "$function$($foo$,$foo$)$mark$");
|
| 179 |
+
// printer.Annotate("function", "mark", call_);
|
| 180 |
+
//
|
| 181 |
+
// This code associates the span covering "call(bar,bar)" in the output with the
|
| 182 |
+
// call_ descriptor.
|
| 183 |
+
|
| 184 |
+
class PROTOBUF_EXPORT Printer {
|
| 185 |
+
public:
|
| 186 |
+
// Create a printer that writes text to the given output stream. Use the
|
| 187 |
+
// given character as the delimiter for variables.
|
| 188 |
+
Printer(ZeroCopyOutputStream* output, char variable_delimiter);
|
| 189 |
+
|
| 190 |
+
// Create a printer that writes text to the given output stream. Use the
|
| 191 |
+
// given character as the delimiter for variables. If annotation_collector
|
| 192 |
+
// is not null, Printer will provide it with annotations about code written
|
| 193 |
+
// to the stream. annotation_collector is not owned by Printer.
|
| 194 |
+
Printer(ZeroCopyOutputStream* output, char variable_delimiter,
|
| 195 |
+
AnnotationCollector* annotation_collector);
|
| 196 |
+
|
| 197 |
+
~Printer();
|
| 198 |
+
|
| 199 |
+
// Link a substitution variable emitted by the last call to Print to the
|
| 200 |
+
// object described by descriptor.
|
| 201 |
+
template <typename SomeDescriptor>
|
| 202 |
+
void Annotate(const char* varname, const SomeDescriptor* descriptor) {
|
| 203 |
+
Annotate(varname, varname, descriptor);
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
// Link the output range defined by the substitution variables as emitted by
|
| 207 |
+
// the last call to Print to the object described by descriptor. The range
|
| 208 |
+
// begins at begin_varname's value and ends after the last character of the
|
| 209 |
+
// value substituted for end_varname.
|
| 210 |
+
template <typename SomeDescriptor>
|
| 211 |
+
void Annotate(const char* begin_varname, const char* end_varname,
|
| 212 |
+
const SomeDescriptor* descriptor) {
|
| 213 |
+
if (annotation_collector_ == NULL) {
|
| 214 |
+
// Annotations aren't turned on for this Printer, so don't pay the cost
|
| 215 |
+
// of building the location path.
|
| 216 |
+
return;
|
| 217 |
+
}
|
| 218 |
+
std::vector<int> path;
|
| 219 |
+
descriptor->GetLocationPath(&path);
|
| 220 |
+
Annotate(begin_varname, end_varname, descriptor->file()->name(), path);
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
// Link a substitution variable emitted by the last call to Print to the file
|
| 224 |
+
// with path file_name.
|
| 225 |
+
void Annotate(const char* varname, const std::string& file_name) {
|
| 226 |
+
Annotate(varname, varname, file_name);
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
// Link the output range defined by the substitution variables as emitted by
|
| 230 |
+
// the last call to Print to the file with path file_name. The range begins
|
| 231 |
+
// at begin_varname's value and ends after the last character of the value
|
| 232 |
+
// substituted for end_varname.
|
| 233 |
+
void Annotate(const char* begin_varname, const char* end_varname,
|
| 234 |
+
const std::string& file_name) {
|
| 235 |
+
if (annotation_collector_ == NULL) {
|
| 236 |
+
// Annotations aren't turned on for this Printer.
|
| 237 |
+
return;
|
| 238 |
+
}
|
| 239 |
+
std::vector<int> empty_path;
|
| 240 |
+
Annotate(begin_varname, end_varname, file_name, empty_path);
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
// Print some text after applying variable substitutions. If a particular
|
| 244 |
+
// variable in the text is not defined, this will crash. Variables to be
|
| 245 |
+
// substituted are identified by their names surrounded by delimiter
|
| 246 |
+
// characters (as given to the constructor). The variable bindings are
|
| 247 |
+
// defined by the given map.
|
| 248 |
+
void Print(const std::map<std::string, std::string>& variables,
|
| 249 |
+
const char* text);
|
| 250 |
+
|
| 251 |
+
// Like the first Print(), except the substitutions are given as parameters.
|
| 252 |
+
template <typename... Args>
|
| 253 |
+
void Print(const char* text, const Args&... args) {
|
| 254 |
+
std::map<std::string, std::string> vars;
|
| 255 |
+
PrintInternal(&vars, text, args...);
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
// Indent text by two spaces. After calling Indent(), two spaces will be
|
| 259 |
+
// inserted at the beginning of each line of text. Indent() may be called
|
| 260 |
+
// multiple times to produce deeper indents.
|
| 261 |
+
void Indent();
|
| 262 |
+
|
| 263 |
+
// Reduces the current indent level by two spaces, or crashes if the indent
|
| 264 |
+
// level is zero.
|
| 265 |
+
void Outdent();
|
| 266 |
+
|
| 267 |
+
// Write a string to the output buffer.
|
| 268 |
+
// This method does not look for newlines to add indentation.
|
| 269 |
+
void PrintRaw(const std::string& data);
|
| 270 |
+
|
| 271 |
+
// Write a zero-delimited string to output buffer.
|
| 272 |
+
// This method does not look for newlines to add indentation.
|
| 273 |
+
void PrintRaw(const char* data);
|
| 274 |
+
|
| 275 |
+
// Write some bytes to the output buffer.
|
| 276 |
+
// This method does not look for newlines to add indentation.
|
| 277 |
+
void WriteRaw(const char* data, int size);
|
| 278 |
+
|
| 279 |
+
// FormatInternal is a helper function not meant to use directly, use
|
| 280 |
+
// compiler::cpp::Formatter instead. This function is meant to support
|
| 281 |
+
// formatting text using named variables (eq. "$foo$) from a lookup map (vars)
|
| 282 |
+
// and variables directly supplied by arguments (eq "$1$" meaning first
|
| 283 |
+
// argument which is the zero index element of args).
|
| 284 |
+
void FormatInternal(const std::vector<std::string>& args,
|
| 285 |
+
const std::map<std::string, std::string>& vars,
|
| 286 |
+
const char* format);
|
| 287 |
+
|
| 288 |
+
// True if any write to the underlying stream failed. (We don't just
|
| 289 |
+
// crash in this case because this is an I/O failure, not a programming
|
| 290 |
+
// error.)
|
| 291 |
+
bool failed() const { return failed_; }
|
| 292 |
+
|
| 293 |
+
private:
|
| 294 |
+
// Link the output range defined by the substitution variables as emitted by
|
| 295 |
+
// the last call to Print to the object found at the SourceCodeInfo-style path
|
| 296 |
+
// in a file with path file_path. The range begins at the start of
|
| 297 |
+
// begin_varname's value and ends after the last character of the value
|
| 298 |
+
// substituted for end_varname. Note that begin_varname and end_varname
|
| 299 |
+
// may refer to the same variable.
|
| 300 |
+
void Annotate(const char* begin_varname, const char* end_varname,
|
| 301 |
+
const std::string& file_path, const std::vector<int>& path);
|
| 302 |
+
|
| 303 |
+
// Base case
|
| 304 |
+
void PrintInternal(std::map<std::string, std::string>* vars,
|
| 305 |
+
const char* text) {
|
| 306 |
+
Print(*vars, text);
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
template <typename... Args>
|
| 310 |
+
void PrintInternal(std::map<std::string, std::string>* vars, const char* text,
|
| 311 |
+
const char* key, const std::string& value,
|
| 312 |
+
const Args&... args) {
|
| 313 |
+
(*vars)[key] = value;
|
| 314 |
+
PrintInternal(vars, text, args...);
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
// Copy size worth of bytes from data to buffer_.
|
| 318 |
+
void CopyToBuffer(const char* data, int size);
|
| 319 |
+
|
| 320 |
+
void push_back(char c) {
|
| 321 |
+
if (failed_) return;
|
| 322 |
+
if (buffer_size_ == 0) {
|
| 323 |
+
if (!Next()) return;
|
| 324 |
+
}
|
| 325 |
+
*buffer_++ = c;
|
| 326 |
+
buffer_size_--;
|
| 327 |
+
offset_++;
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
bool Next();
|
| 331 |
+
|
| 332 |
+
inline void IndentIfAtStart();
|
| 333 |
+
const char* WriteVariable(
|
| 334 |
+
const std::vector<std::string>& args,
|
| 335 |
+
const std::map<std::string, std::string>& vars, const char* format,
|
| 336 |
+
int* arg_index,
|
| 337 |
+
std::vector<AnnotationCollector::Annotation>* annotations);
|
| 338 |
+
|
| 339 |
+
const char variable_delimiter_;
|
| 340 |
+
|
| 341 |
+
ZeroCopyOutputStream* const output_;
|
| 342 |
+
char* buffer_;
|
| 343 |
+
int buffer_size_;
|
| 344 |
+
// The current position, in bytes, in the output stream. This is equivalent
|
| 345 |
+
// to the total number of bytes that have been written so far. This value is
|
| 346 |
+
// used to calculate annotation ranges in the substitutions_ map below.
|
| 347 |
+
size_t offset_;
|
| 348 |
+
|
| 349 |
+
std::string indent_;
|
| 350 |
+
bool at_start_of_line_;
|
| 351 |
+
bool failed_;
|
| 352 |
+
|
| 353 |
+
// A map from variable name to [start, end) offsets in the output buffer.
|
| 354 |
+
// These refer to the offsets used for a variable after the last call to
|
| 355 |
+
// Print. If a variable was used more than once, the entry used in
|
| 356 |
+
// this map is set to a negative-length span. For singly-used variables, the
|
| 357 |
+
// start offset is the beginning of the substitution; the end offset is the
|
| 358 |
+
// last byte of the substitution plus one (such that (end - start) is the
|
| 359 |
+
// length of the substituted string).
|
| 360 |
+
std::map<std::string, std::pair<size_t, size_t> > substitutions_;
|
| 361 |
+
|
| 362 |
+
// Keeps track of the keys in substitutions_ that need to be updated when
|
| 363 |
+
// indents are inserted. These are keys that refer to the beginning of the
|
| 364 |
+
// current line.
|
| 365 |
+
std::vector<std::string> line_start_variables_;
|
| 366 |
+
|
| 367 |
+
// Returns true and sets range to the substitution range in the output for
|
| 368 |
+
// varname if varname was used once in the last call to Print. If varname
|
| 369 |
+
// was not used, or if it was used multiple times, returns false (and
|
| 370 |
+
// fails a debug assertion).
|
| 371 |
+
bool GetSubstitutionRange(const char* varname,
|
| 372 |
+
std::pair<size_t, size_t>* range);
|
| 373 |
+
|
| 374 |
+
// If non-null, annotation_collector_ is used to store annotations about
|
| 375 |
+
// generated code.
|
| 376 |
+
AnnotationCollector* const annotation_collector_;
|
| 377 |
+
|
| 378 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Printer);
|
| 379 |
+
};
|
| 380 |
+
|
| 381 |
+
} // namespace io
|
| 382 |
+
} // namespace protobuf
|
| 383 |
+
} // namespace google
|
| 384 |
+
|
| 385 |
+
#include <google/protobuf/port_undef.inc>
|
| 386 |
+
|
| 387 |
+
#endif // GOOGLE_PROTOBUF_IO_PRINTER_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/io/strtod.h
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// A locale-independent version of strtod(), used to parse floating
|
| 32 |
+
// point default values in .proto files, where the decimal separator
|
| 33 |
+
// is always a dot.
|
| 34 |
+
|
| 35 |
+
#ifndef GOOGLE_PROTOBUF_IO_STRTOD_H__
|
| 36 |
+
#define GOOGLE_PROTOBUF_IO_STRTOD_H__
|
| 37 |
+
|
| 38 |
+
namespace google {
|
| 39 |
+
namespace protobuf {
|
| 40 |
+
namespace io {
|
| 41 |
+
|
| 42 |
+
// A locale-independent version of the standard strtod(), which always
|
| 43 |
+
// uses a dot as the decimal separator.
|
| 44 |
+
double NoLocaleStrtod(const char* str, char** endptr);
|
| 45 |
+
|
| 46 |
+
// Casts a double value to a float value. If the value is outside of the
|
| 47 |
+
// representable range of float, it will be converted to positive or negative
|
| 48 |
+
// infinity.
|
| 49 |
+
float SafeDoubleToFloat(double value);
|
| 50 |
+
|
| 51 |
+
} // namespace io
|
| 52 |
+
} // namespace protobuf
|
| 53 |
+
} // namespace google
|
| 54 |
+
|
| 55 |
+
#endif // GOOGLE_PROTOBUF_IO_STRTOD_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/io/tokenizer.h
ADDED
|
@@ -0,0 +1,442 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// Author: kenton@google.com (Kenton Varda)
|
| 32 |
+
// Based on original Protocol Buffers design by
|
| 33 |
+
// Sanjay Ghemawat, Jeff Dean, and others.
|
| 34 |
+
//
|
| 35 |
+
// Class for parsing tokenized text from a ZeroCopyInputStream.
|
| 36 |
+
|
| 37 |
+
#ifndef GOOGLE_PROTOBUF_IO_TOKENIZER_H__
|
| 38 |
+
#define GOOGLE_PROTOBUF_IO_TOKENIZER_H__
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
#include <string>
|
| 42 |
+
#include <vector>
|
| 43 |
+
|
| 44 |
+
#include <google/protobuf/stubs/common.h>
|
| 45 |
+
#include <google/protobuf/stubs/logging.h>
|
| 46 |
+
|
| 47 |
+
// Must be included last.
|
| 48 |
+
#include <google/protobuf/port_def.inc>
|
| 49 |
+
|
| 50 |
+
namespace google {
|
| 51 |
+
namespace protobuf {
|
| 52 |
+
namespace io {
|
| 53 |
+
|
| 54 |
+
class ZeroCopyInputStream; // zero_copy_stream.h
|
| 55 |
+
|
| 56 |
+
// Defined in this file.
|
| 57 |
+
class ErrorCollector;
|
| 58 |
+
class Tokenizer;
|
| 59 |
+
|
| 60 |
+
// By "column number", the proto compiler refers to a count of the number
|
| 61 |
+
// of bytes before a given byte, except that a tab character advances to
|
| 62 |
+
// the next multiple of 8 bytes. Note in particular that column numbers
|
| 63 |
+
// are zero-based, while many user interfaces use one-based column numbers.
|
| 64 |
+
typedef int ColumnNumber;
|
| 65 |
+
|
| 66 |
+
// Abstract interface for an object which collects the errors that occur
|
| 67 |
+
// during parsing. A typical implementation might simply print the errors
|
| 68 |
+
// to stdout.
|
| 69 |
+
class PROTOBUF_EXPORT ErrorCollector {
|
| 70 |
+
public:
|
| 71 |
+
inline ErrorCollector() {}
|
| 72 |
+
virtual ~ErrorCollector();
|
| 73 |
+
|
| 74 |
+
// Indicates that there was an error in the input at the given line and
|
| 75 |
+
// column numbers. The numbers are zero-based, so you may want to add
|
| 76 |
+
// 1 to each before printing them.
|
| 77 |
+
virtual void AddError(int line, ColumnNumber column,
|
| 78 |
+
const std::string& message) = 0;
|
| 79 |
+
|
| 80 |
+
// Indicates that there was a warning in the input at the given line and
|
| 81 |
+
// column numbers. The numbers are zero-based, so you may want to add
|
| 82 |
+
// 1 to each before printing them.
|
| 83 |
+
virtual void AddWarning(int /* line */, ColumnNumber /* column */,
|
| 84 |
+
const std::string& /* message */) {}
|
| 85 |
+
|
| 86 |
+
private:
|
| 87 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ErrorCollector);
|
| 88 |
+
};
|
| 89 |
+
|
| 90 |
+
// This class converts a stream of raw text into a stream of tokens for
|
| 91 |
+
// the protocol definition parser to parse. The tokens recognized are
|
| 92 |
+
// similar to those that make up the C language; see the TokenType enum for
|
| 93 |
+
// precise descriptions. Whitespace and comments are skipped. By default,
|
| 94 |
+
// C- and C++-style comments are recognized, but other styles can be used by
|
| 95 |
+
// calling set_comment_style().
|
| 96 |
+
class PROTOBUF_EXPORT Tokenizer {
|
| 97 |
+
public:
|
| 98 |
+
// Construct a Tokenizer that reads and tokenizes text from the given
|
| 99 |
+
// input stream and writes errors to the given error_collector.
|
| 100 |
+
// The caller keeps ownership of input and error_collector.
|
| 101 |
+
Tokenizer(ZeroCopyInputStream* input, ErrorCollector* error_collector);
|
| 102 |
+
~Tokenizer();
|
| 103 |
+
|
| 104 |
+
enum TokenType {
|
| 105 |
+
TYPE_START, // Next() has not yet been called.
|
| 106 |
+
TYPE_END, // End of input reached. "text" is empty.
|
| 107 |
+
|
| 108 |
+
TYPE_IDENTIFIER, // A sequence of letters, digits, and underscores, not
|
| 109 |
+
// starting with a digit. It is an error for a number
|
| 110 |
+
// to be followed by an identifier with no space in
|
| 111 |
+
// between.
|
| 112 |
+
TYPE_INTEGER, // A sequence of digits representing an integer. Normally
|
| 113 |
+
// the digits are decimal, but a prefix of "0x" indicates
|
| 114 |
+
// a hex number and a leading zero indicates octal, just
|
| 115 |
+
// like with C numeric literals. A leading negative sign
|
| 116 |
+
// is NOT included in the token; it's up to the parser to
|
| 117 |
+
// interpret the unary minus operator on its own.
|
| 118 |
+
TYPE_FLOAT, // A floating point literal, with a fractional part and/or
|
| 119 |
+
// an exponent. Always in decimal. Again, never
|
| 120 |
+
// negative.
|
| 121 |
+
TYPE_STRING, // A quoted sequence of escaped characters. Either single
|
| 122 |
+
// or double quotes can be used, but they must match.
|
| 123 |
+
// A string literal cannot cross a line break.
|
| 124 |
+
TYPE_SYMBOL, // Any other printable character, like '!' or '+'.
|
| 125 |
+
// Symbols are always a single character, so "!+$%" is
|
| 126 |
+
// four tokens.
|
| 127 |
+
TYPE_WHITESPACE, // A sequence of whitespace. This token type is only
|
| 128 |
+
// produced if report_whitespace() is true. It is not
|
| 129 |
+
// reported for whitespace within comments or strings.
|
| 130 |
+
TYPE_NEWLINE, // A newline (\n). This token type is only
|
| 131 |
+
// produced if report_whitespace() is true and
|
| 132 |
+
// report_newlines() is true. It is not reported for
|
| 133 |
+
// newlines in comments or strings.
|
| 134 |
+
};
|
| 135 |
+
|
| 136 |
+
// Structure representing a token read from the token stream.
|
| 137 |
+
struct Token {
|
| 138 |
+
TokenType type;
|
| 139 |
+
std::string text; // The exact text of the token as it appeared in
|
| 140 |
+
// the input. e.g. tokens of TYPE_STRING will still
|
| 141 |
+
// be escaped and in quotes.
|
| 142 |
+
|
| 143 |
+
// "line" and "column" specify the position of the first character of
|
| 144 |
+
// the token within the input stream. They are zero-based.
|
| 145 |
+
int line;
|
| 146 |
+
ColumnNumber column;
|
| 147 |
+
ColumnNumber end_column;
|
| 148 |
+
};
|
| 149 |
+
|
| 150 |
+
// Get the current token. This is updated when Next() is called. Before
|
| 151 |
+
// the first call to Next(), current() has type TYPE_START and no contents.
|
| 152 |
+
const Token& current();
|
| 153 |
+
|
| 154 |
+
// Return the previous token -- i.e. what current() returned before the
|
| 155 |
+
// previous call to Next().
|
| 156 |
+
const Token& previous();
|
| 157 |
+
|
| 158 |
+
// Advance to the next token. Returns false if the end of the input is
|
| 159 |
+
// reached.
|
| 160 |
+
bool Next();
|
| 161 |
+
|
| 162 |
+
// Like Next(), but also collects comments which appear between the previous
|
| 163 |
+
// and next tokens.
|
| 164 |
+
//
|
| 165 |
+
// Comments which appear to be attached to the previous token are stored
|
| 166 |
+
// in *prev_tailing_comments. Comments which appear to be attached to the
|
| 167 |
+
// next token are stored in *next_leading_comments. Comments appearing in
|
| 168 |
+
// between which do not appear to be attached to either will be added to
|
| 169 |
+
// detached_comments. Any of these parameters can be NULL to simply discard
|
| 170 |
+
// the comments.
|
| 171 |
+
//
|
| 172 |
+
// A series of line comments appearing on consecutive lines, with no other
|
| 173 |
+
// tokens appearing on those lines, will be treated as a single comment.
|
| 174 |
+
//
|
| 175 |
+
// Only the comment content is returned; comment markers (e.g. //) are
|
| 176 |
+
// stripped out. For block comments, leading whitespace and an asterisk will
|
| 177 |
+
// be stripped from the beginning of each line other than the first. Newlines
|
| 178 |
+
// are included in the output.
|
| 179 |
+
//
|
| 180 |
+
// Examples:
|
| 181 |
+
//
|
| 182 |
+
// optional int32 foo = 1; // Comment attached to foo.
|
| 183 |
+
// // Comment attached to bar.
|
| 184 |
+
// optional int32 bar = 2;
|
| 185 |
+
//
|
| 186 |
+
// optional string baz = 3;
|
| 187 |
+
// // Comment attached to baz.
|
| 188 |
+
// // Another line attached to baz.
|
| 189 |
+
//
|
| 190 |
+
// // Comment attached to qux.
|
| 191 |
+
// //
|
| 192 |
+
// // Another line attached to qux.
|
| 193 |
+
// optional double qux = 4;
|
| 194 |
+
//
|
| 195 |
+
// // Detached comment. This is not attached to qux or corge
|
| 196 |
+
// // because there are blank lines separating it from both.
|
| 197 |
+
//
|
| 198 |
+
// optional string corge = 5;
|
| 199 |
+
// /* Block comment attached
|
| 200 |
+
// * to corge. Leading asterisks
|
| 201 |
+
// * will be removed. */
|
| 202 |
+
// /* Block comment attached to
|
| 203 |
+
// * grault. */
|
| 204 |
+
// optional int32 grault = 6;
|
| 205 |
+
bool NextWithComments(std::string* prev_trailing_comments,
|
| 206 |
+
std::vector<std::string>* detached_comments,
|
| 207 |
+
std::string* next_leading_comments);
|
| 208 |
+
|
| 209 |
+
// Parse helpers ---------------------------------------------------
|
| 210 |
+
|
| 211 |
+
// Parses a TYPE_FLOAT token. This never fails, so long as the text actually
|
| 212 |
+
// comes from a TYPE_FLOAT token parsed by Tokenizer. If it doesn't, the
|
| 213 |
+
// result is undefined (possibly an assert failure).
|
| 214 |
+
static double ParseFloat(const std::string& text);
|
| 215 |
+
|
| 216 |
+
// Parses a TYPE_STRING token. This never fails, so long as the text actually
|
| 217 |
+
// comes from a TYPE_STRING token parsed by Tokenizer. If it doesn't, the
|
| 218 |
+
// result is undefined (possibly an assert failure).
|
| 219 |
+
static void ParseString(const std::string& text, std::string* output);
|
| 220 |
+
|
| 221 |
+
// Identical to ParseString, but appends to output.
|
| 222 |
+
static void ParseStringAppend(const std::string& text, std::string* output);
|
| 223 |
+
|
| 224 |
+
// Parses a TYPE_INTEGER token. Returns false if the result would be
|
| 225 |
+
// greater than max_value. Otherwise, returns true and sets *output to the
|
| 226 |
+
// result. If the text is not from a Token of type TYPE_INTEGER originally
|
| 227 |
+
// parsed by a Tokenizer, the result is undefined (possibly an assert
|
| 228 |
+
// failure).
|
| 229 |
+
static bool ParseInteger(const std::string& text, uint64_t max_value,
|
| 230 |
+
uint64_t* output);
|
| 231 |
+
|
| 232 |
+
// Options ---------------------------------------------------------
|
| 233 |
+
|
| 234 |
+
// Set true to allow floats to be suffixed with the letter 'f'. Tokens
|
| 235 |
+
// which would otherwise be integers but which have the 'f' suffix will be
|
| 236 |
+
// forced to be interpreted as floats. For all other purposes, the 'f' is
|
| 237 |
+
// ignored.
|
| 238 |
+
void set_allow_f_after_float(bool value) { allow_f_after_float_ = value; }
|
| 239 |
+
|
| 240 |
+
// Valid values for set_comment_style().
|
| 241 |
+
enum CommentStyle {
|
| 242 |
+
// Line comments begin with "//", block comments are delimited by "/*" and
|
| 243 |
+
// "*/".
|
| 244 |
+
CPP_COMMENT_STYLE,
|
| 245 |
+
// Line comments begin with "#". No way to write block comments.
|
| 246 |
+
SH_COMMENT_STYLE
|
| 247 |
+
};
|
| 248 |
+
|
| 249 |
+
// Sets the comment style.
|
| 250 |
+
void set_comment_style(CommentStyle style) { comment_style_ = style; }
|
| 251 |
+
|
| 252 |
+
// Whether to require whitespace between a number and a field name.
|
| 253 |
+
// Default is true. Do not use this; for Google-internal cleanup only.
|
| 254 |
+
void set_require_space_after_number(bool require) {
|
| 255 |
+
require_space_after_number_ = require;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
// Whether to allow string literals to span multiple lines. Default is false.
|
| 259 |
+
// Do not use this; for Google-internal cleanup only.
|
| 260 |
+
void set_allow_multiline_strings(bool allow) {
|
| 261 |
+
allow_multiline_strings_ = allow;
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
// If true, whitespace tokens are reported by Next().
|
| 265 |
+
// Note: `set_report_whitespace(false)` implies `set_report_newlines(false)`.
|
| 266 |
+
bool report_whitespace() const;
|
| 267 |
+
void set_report_whitespace(bool report);
|
| 268 |
+
|
| 269 |
+
// If true, newline tokens are reported by Next().
|
| 270 |
+
// Note: `set_report_newlines(true)` implies `set_report_whitespace(true)`.
|
| 271 |
+
bool report_newlines() const;
|
| 272 |
+
void set_report_newlines(bool report);
|
| 273 |
+
|
| 274 |
+
// External helper: validate an identifier.
|
| 275 |
+
static bool IsIdentifier(const std::string& text);
|
| 276 |
+
|
| 277 |
+
// -----------------------------------------------------------------
|
| 278 |
+
private:
|
| 279 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Tokenizer);
|
| 280 |
+
|
| 281 |
+
Token current_; // Returned by current().
|
| 282 |
+
Token previous_; // Returned by previous().
|
| 283 |
+
|
| 284 |
+
ZeroCopyInputStream* input_;
|
| 285 |
+
ErrorCollector* error_collector_;
|
| 286 |
+
|
| 287 |
+
char current_char_; // == buffer_[buffer_pos_], updated by NextChar().
|
| 288 |
+
const char* buffer_; // Current buffer returned from input_.
|
| 289 |
+
int buffer_size_; // Size of buffer_.
|
| 290 |
+
int buffer_pos_; // Current position within the buffer.
|
| 291 |
+
bool read_error_; // Did we previously encounter a read error?
|
| 292 |
+
|
| 293 |
+
// Line and column number of current_char_ within the whole input stream.
|
| 294 |
+
int line_;
|
| 295 |
+
ColumnNumber column_;
|
| 296 |
+
|
| 297 |
+
// String to which text should be appended as we advance through it.
|
| 298 |
+
// Call RecordTo(&str) to start recording and StopRecording() to stop.
|
| 299 |
+
// E.g. StartToken() calls RecordTo(¤t_.text). record_start_ is the
|
| 300 |
+
// position within the current buffer where recording started.
|
| 301 |
+
std::string* record_target_;
|
| 302 |
+
int record_start_;
|
| 303 |
+
|
| 304 |
+
// Options.
|
| 305 |
+
bool allow_f_after_float_;
|
| 306 |
+
CommentStyle comment_style_;
|
| 307 |
+
bool require_space_after_number_;
|
| 308 |
+
bool allow_multiline_strings_;
|
| 309 |
+
bool report_whitespace_ = false;
|
| 310 |
+
bool report_newlines_ = false;
|
| 311 |
+
|
| 312 |
+
// Since we count columns we need to interpret tabs somehow. We'll take
|
| 313 |
+
// the standard 8-character definition for lack of any way to do better.
|
| 314 |
+
// This must match the documentation of ColumnNumber.
|
| 315 |
+
static const int kTabWidth = 8;
|
| 316 |
+
|
| 317 |
+
// -----------------------------------------------------------------
|
| 318 |
+
// Helper methods.
|
| 319 |
+
|
| 320 |
+
// Consume this character and advance to the next one.
|
| 321 |
+
void NextChar();
|
| 322 |
+
|
| 323 |
+
// Read a new buffer from the input.
|
| 324 |
+
void Refresh();
|
| 325 |
+
|
| 326 |
+
inline void RecordTo(std::string* target);
|
| 327 |
+
inline void StopRecording();
|
| 328 |
+
|
| 329 |
+
// Called when the current character is the first character of a new
|
| 330 |
+
// token (not including whitespace or comments).
|
| 331 |
+
inline void StartToken();
|
| 332 |
+
// Called when the current character is the first character after the
|
| 333 |
+
// end of the last token. After this returns, current_.text will
|
| 334 |
+
// contain all text consumed since StartToken() was called.
|
| 335 |
+
inline void EndToken();
|
| 336 |
+
|
| 337 |
+
// Convenience method to add an error at the current line and column.
|
| 338 |
+
void AddError(const std::string& message) {
|
| 339 |
+
error_collector_->AddError(line_, column_, message);
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
// -----------------------------------------------------------------
|
| 343 |
+
// The following four methods are used to consume tokens of specific
|
| 344 |
+
// types. They are actually used to consume all characters *after*
|
| 345 |
+
// the first, since the calling function consumes the first character
|
| 346 |
+
// in order to decide what kind of token is being read.
|
| 347 |
+
|
| 348 |
+
// Read and consume a string, ending when the given delimiter is
|
| 349 |
+
// consumed.
|
| 350 |
+
void ConsumeString(char delimiter);
|
| 351 |
+
|
| 352 |
+
// Read and consume a number, returning TYPE_FLOAT or TYPE_INTEGER
|
| 353 |
+
// depending on what was read. This needs to know if the first
|
| 354 |
+
// character was a zero in order to correctly recognize hex and octal
|
| 355 |
+
// numbers.
|
| 356 |
+
// It also needs to know if the first character was a . to parse floating
|
| 357 |
+
// point correctly.
|
| 358 |
+
TokenType ConsumeNumber(bool started_with_zero, bool started_with_dot);
|
| 359 |
+
|
| 360 |
+
// Consume the rest of a line.
|
| 361 |
+
void ConsumeLineComment(std::string* content);
|
| 362 |
+
// Consume until "*/".
|
| 363 |
+
void ConsumeBlockComment(std::string* content);
|
| 364 |
+
|
| 365 |
+
enum NextCommentStatus {
|
| 366 |
+
// Started a line comment.
|
| 367 |
+
LINE_COMMENT,
|
| 368 |
+
|
| 369 |
+
// Started a block comment.
|
| 370 |
+
BLOCK_COMMENT,
|
| 371 |
+
|
| 372 |
+
// Consumed a slash, then realized it wasn't a comment. current_ has
|
| 373 |
+
// been filled in with a slash token. The caller should return it.
|
| 374 |
+
SLASH_NOT_COMMENT,
|
| 375 |
+
|
| 376 |
+
// We do not appear to be starting a comment here.
|
| 377 |
+
NO_COMMENT
|
| 378 |
+
};
|
| 379 |
+
|
| 380 |
+
// If we're at the start of a new comment, consume it and return what kind
|
| 381 |
+
// of comment it is.
|
| 382 |
+
NextCommentStatus TryConsumeCommentStart();
|
| 383 |
+
|
| 384 |
+
// If we're looking at a TYPE_WHITESPACE token and `report_whitespace_` is
|
| 385 |
+
// true, consume it and return true.
|
| 386 |
+
bool TryConsumeWhitespace();
|
| 387 |
+
|
| 388 |
+
// If we're looking at a TYPE_NEWLINE token and `report_newlines_` is true,
|
| 389 |
+
// consume it and return true.
|
| 390 |
+
bool TryConsumeNewline();
|
| 391 |
+
|
| 392 |
+
// -----------------------------------------------------------------
|
| 393 |
+
// These helper methods make the parsing code more readable. The
|
| 394 |
+
// "character classes" referred to are defined at the top of the .cc file.
|
| 395 |
+
// Basically it is a C++ class with one method:
|
| 396 |
+
// static bool InClass(char c);
|
| 397 |
+
// The method returns true if c is a member of this "class", like "Letter"
|
| 398 |
+
// or "Digit".
|
| 399 |
+
|
| 400 |
+
// Returns true if the current character is of the given character
|
| 401 |
+
// class, but does not consume anything.
|
| 402 |
+
template <typename CharacterClass>
|
| 403 |
+
inline bool LookingAt();
|
| 404 |
+
|
| 405 |
+
// If the current character is in the given class, consume it and return
|
| 406 |
+
// true. Otherwise return false.
|
| 407 |
+
// e.g. TryConsumeOne<Letter>()
|
| 408 |
+
template <typename CharacterClass>
|
| 409 |
+
inline bool TryConsumeOne();
|
| 410 |
+
|
| 411 |
+
// Like above, but try to consume the specific character indicated.
|
| 412 |
+
inline bool TryConsume(char c);
|
| 413 |
+
|
| 414 |
+
// Consume zero or more of the given character class.
|
| 415 |
+
template <typename CharacterClass>
|
| 416 |
+
inline void ConsumeZeroOrMore();
|
| 417 |
+
|
| 418 |
+
// Consume one or more of the given character class or log the given
|
| 419 |
+
// error message.
|
| 420 |
+
// e.g. ConsumeOneOrMore<Digit>("Expected digits.");
|
| 421 |
+
template <typename CharacterClass>
|
| 422 |
+
inline void ConsumeOneOrMore(const char* error);
|
| 423 |
+
};
|
| 424 |
+
|
| 425 |
+
// inline methods ====================================================
|
| 426 |
+
inline const Tokenizer::Token& Tokenizer::current() { return current_; }
|
| 427 |
+
|
| 428 |
+
inline const Tokenizer::Token& Tokenizer::previous() { return previous_; }
|
| 429 |
+
|
| 430 |
+
inline void Tokenizer::ParseString(const std::string& text,
|
| 431 |
+
std::string* output) {
|
| 432 |
+
output->clear();
|
| 433 |
+
ParseStringAppend(text, output);
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
+
} // namespace io
|
| 437 |
+
} // namespace protobuf
|
| 438 |
+
} // namespace google
|
| 439 |
+
|
| 440 |
+
#include <google/protobuf/port_undef.inc>
|
| 441 |
+
|
| 442 |
+
#endif // GOOGLE_PROTOBUF_IO_TOKENIZER_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/io/zero_copy_stream.h
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// Author: kenton@google.com (Kenton Varda)
|
| 32 |
+
// Based on original Protocol Buffers design by
|
| 33 |
+
// Sanjay Ghemawat, Jeff Dean, and others.
|
| 34 |
+
//
|
| 35 |
+
// This file contains the ZeroCopyInputStream and ZeroCopyOutputStream
|
| 36 |
+
// interfaces, which represent abstract I/O streams to and from which
|
| 37 |
+
// protocol buffers can be read and written. For a few simple
|
| 38 |
+
// implementations of these interfaces, see zero_copy_stream_impl.h.
|
| 39 |
+
//
|
| 40 |
+
// These interfaces are different from classic I/O streams in that they
|
| 41 |
+
// try to minimize the amount of data copying that needs to be done.
|
| 42 |
+
// To accomplish this, responsibility for allocating buffers is moved to
|
| 43 |
+
// the stream object, rather than being the responsibility of the caller.
|
| 44 |
+
// So, the stream can return a buffer which actually points directly into
|
| 45 |
+
// the final data structure where the bytes are to be stored, and the caller
|
| 46 |
+
// can interact directly with that buffer, eliminating an intermediate copy
|
| 47 |
+
// operation.
|
| 48 |
+
//
|
| 49 |
+
// As an example, consider the common case in which you are reading bytes
|
| 50 |
+
// from an array that is already in memory (or perhaps an mmap()ed file).
|
| 51 |
+
// With classic I/O streams, you would do something like:
|
| 52 |
+
// char buffer[BUFFER_SIZE];
|
| 53 |
+
// input->Read(buffer, BUFFER_SIZE);
|
| 54 |
+
// DoSomething(buffer, BUFFER_SIZE);
|
| 55 |
+
// Then, the stream basically just calls memcpy() to copy the data from
|
| 56 |
+
// the array into your buffer. With a ZeroCopyInputStream, you would do
|
| 57 |
+
// this instead:
|
| 58 |
+
// const void* buffer;
|
| 59 |
+
// int size;
|
| 60 |
+
// input->Next(&buffer, &size);
|
| 61 |
+
// DoSomething(buffer, size);
|
| 62 |
+
// Here, no copy is performed. The input stream returns a pointer directly
|
| 63 |
+
// into the backing array, and the caller ends up reading directly from it.
|
| 64 |
+
//
|
| 65 |
+
// If you want to be able to read the old-fashion way, you can create
|
| 66 |
+
// a CodedInputStream or CodedOutputStream wrapping these objects and use
|
| 67 |
+
// their ReadRaw()/WriteRaw() methods. These will, of course, add a copy
|
| 68 |
+
// step, but Coded*Stream will handle buffering so at least it will be
|
| 69 |
+
// reasonably efficient.
|
| 70 |
+
//
|
| 71 |
+
// ZeroCopyInputStream example:
|
| 72 |
+
// // Read in a file and print its contents to stdout.
|
| 73 |
+
// int fd = open("myfile", O_RDONLY);
|
| 74 |
+
// ZeroCopyInputStream* input = new FileInputStream(fd);
|
| 75 |
+
//
|
| 76 |
+
// const void* buffer;
|
| 77 |
+
// int size;
|
| 78 |
+
// while (input->Next(&buffer, &size)) {
|
| 79 |
+
// cout.write(buffer, size);
|
| 80 |
+
// }
|
| 81 |
+
//
|
| 82 |
+
// delete input;
|
| 83 |
+
// close(fd);
|
| 84 |
+
//
|
| 85 |
+
// ZeroCopyOutputStream example:
|
| 86 |
+
// // Copy the contents of "infile" to "outfile", using plain read() for
|
| 87 |
+
// // "infile" but a ZeroCopyOutputStream for "outfile".
|
| 88 |
+
// int infd = open("infile", O_RDONLY);
|
| 89 |
+
// int outfd = open("outfile", O_WRONLY);
|
| 90 |
+
// ZeroCopyOutputStream* output = new FileOutputStream(outfd);
|
| 91 |
+
//
|
| 92 |
+
// void* buffer;
|
| 93 |
+
// int size;
|
| 94 |
+
// while (output->Next(&buffer, &size)) {
|
| 95 |
+
// int bytes = read(infd, buffer, size);
|
| 96 |
+
// if (bytes < size) {
|
| 97 |
+
// // Reached EOF.
|
| 98 |
+
// output->BackUp(size - bytes);
|
| 99 |
+
// break;
|
| 100 |
+
// }
|
| 101 |
+
// }
|
| 102 |
+
//
|
| 103 |
+
// delete output;
|
| 104 |
+
// close(infd);
|
| 105 |
+
// close(outfd);
|
| 106 |
+
|
| 107 |
+
#ifndef GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_H__
|
| 108 |
+
#define GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_H__
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
#include <google/protobuf/stubs/common.h>
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
// Must be included last.
|
| 115 |
+
#include <google/protobuf/port_def.inc>
|
| 116 |
+
|
| 117 |
+
namespace google {
|
| 118 |
+
namespace protobuf {
|
| 119 |
+
namespace io {
|
| 120 |
+
|
| 121 |
+
// Defined in this file.
|
| 122 |
+
class ZeroCopyInputStream;
|
| 123 |
+
class ZeroCopyOutputStream;
|
| 124 |
+
|
| 125 |
+
// Abstract interface similar to an input stream but designed to minimize
|
| 126 |
+
// copying.
|
| 127 |
+
class PROTOBUF_EXPORT ZeroCopyInputStream {
|
| 128 |
+
public:
|
| 129 |
+
ZeroCopyInputStream() {}
|
| 130 |
+
virtual ~ZeroCopyInputStream() {}
|
| 131 |
+
|
| 132 |
+
// Obtains a chunk of data from the stream.
|
| 133 |
+
//
|
| 134 |
+
// Preconditions:
|
| 135 |
+
// * "size" and "data" are not NULL.
|
| 136 |
+
//
|
| 137 |
+
// Postconditions:
|
| 138 |
+
// * If the returned value is false, there is no more data to return or
|
| 139 |
+
// an error occurred. All errors are permanent.
|
| 140 |
+
// * Otherwise, "size" points to the actual number of bytes read and "data"
|
| 141 |
+
// points to a pointer to a buffer containing these bytes.
|
| 142 |
+
// * Ownership of this buffer remains with the stream, and the buffer
|
| 143 |
+
// remains valid only until some other method of the stream is called
|
| 144 |
+
// or the stream is destroyed.
|
| 145 |
+
// * It is legal for the returned buffer to have zero size, as long
|
| 146 |
+
// as repeatedly calling Next() eventually yields a buffer with non-zero
|
| 147 |
+
// size.
|
| 148 |
+
virtual bool Next(const void** data, int* size) = 0;
|
| 149 |
+
|
| 150 |
+
// Backs up a number of bytes, so that the next call to Next() returns
|
| 151 |
+
// data again that was already returned by the last call to Next(). This
|
| 152 |
+
// is useful when writing procedures that are only supposed to read up
|
| 153 |
+
// to a certain point in the input, then return. If Next() returns a
|
| 154 |
+
// buffer that goes beyond what you wanted to read, you can use BackUp()
|
| 155 |
+
// to return to the point where you intended to finish.
|
| 156 |
+
//
|
| 157 |
+
// This method can be called with `count = 0` to finalize (flush) any
|
| 158 |
+
// previously returned buffer. For example, a file output stream can
|
| 159 |
+
// flush buffers returned from a previous call to Next() upon such
|
| 160 |
+
// BackUp(0) invocations. ZeroCopyOutputStream callers should always
|
| 161 |
+
// invoke BackUp() after a final Next() call, even if there is no
|
| 162 |
+
// excess buffer data to be backed up to indicate a flush point.
|
| 163 |
+
//
|
| 164 |
+
// Preconditions:
|
| 165 |
+
// * The last method called must have been Next().
|
| 166 |
+
// * count must be less than or equal to the size of the last buffer
|
| 167 |
+
// returned by Next().
|
| 168 |
+
//
|
| 169 |
+
// Postconditions:
|
| 170 |
+
// * The last "count" bytes of the last buffer returned by Next() will be
|
| 171 |
+
// pushed back into the stream. Subsequent calls to Next() will return
|
| 172 |
+
// the same data again before producing new data.
|
| 173 |
+
virtual void BackUp(int count) = 0;
|
| 174 |
+
|
| 175 |
+
// Skips a number of bytes. Returns false if the end of the stream is
|
| 176 |
+
// reached or some input error occurred. In the end-of-stream case, the
|
| 177 |
+
// stream is advanced to the end of the stream (so ByteCount() will return
|
| 178 |
+
// the total size of the stream).
|
| 179 |
+
virtual bool Skip(int count) = 0;
|
| 180 |
+
|
| 181 |
+
// Returns the total number of bytes read since this object was created.
|
| 182 |
+
virtual int64_t ByteCount() const = 0;
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
private:
|
| 186 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ZeroCopyInputStream);
|
| 187 |
+
};
|
| 188 |
+
|
| 189 |
+
// Abstract interface similar to an output stream but designed to minimize
|
| 190 |
+
// copying.
|
| 191 |
+
class PROTOBUF_EXPORT ZeroCopyOutputStream {
|
| 192 |
+
public:
|
| 193 |
+
ZeroCopyOutputStream() {}
|
| 194 |
+
virtual ~ZeroCopyOutputStream() {}
|
| 195 |
+
|
| 196 |
+
// Obtains a buffer into which data can be written. Any data written
|
| 197 |
+
// into this buffer will eventually (maybe instantly, maybe later on)
|
| 198 |
+
// be written to the output.
|
| 199 |
+
//
|
| 200 |
+
// Preconditions:
|
| 201 |
+
// * "size" and "data" are not NULL.
|
| 202 |
+
//
|
| 203 |
+
// Postconditions:
|
| 204 |
+
// * If the returned value is false, an error occurred. All errors are
|
| 205 |
+
// permanent.
|
| 206 |
+
// * Otherwise, "size" points to the actual number of bytes in the buffer
|
| 207 |
+
// and "data" points to the buffer.
|
| 208 |
+
// * Ownership of this buffer remains with the stream, and the buffer
|
| 209 |
+
// remains valid only until some other method of the stream is called
|
| 210 |
+
// or the stream is destroyed.
|
| 211 |
+
// * Any data which the caller stores in this buffer will eventually be
|
| 212 |
+
// written to the output (unless BackUp() is called).
|
| 213 |
+
// * It is legal for the returned buffer to have zero size, as long
|
| 214 |
+
// as repeatedly calling Next() eventually yields a buffer with non-zero
|
| 215 |
+
// size.
|
| 216 |
+
virtual bool Next(void** data, int* size) = 0;
|
| 217 |
+
|
| 218 |
+
// Backs up a number of bytes, so that the end of the last buffer returned
|
| 219 |
+
// by Next() is not actually written. This is needed when you finish
|
| 220 |
+
// writing all the data you want to write, but the last buffer was bigger
|
| 221 |
+
// than you needed. You don't want to write a bunch of garbage after the
|
| 222 |
+
// end of your data, so you use BackUp() to back up.
|
| 223 |
+
//
|
| 224 |
+
// Preconditions:
|
| 225 |
+
// * The last method called must have been Next().
|
| 226 |
+
// * count must be less than or equal to the size of the last buffer
|
| 227 |
+
// returned by Next().
|
| 228 |
+
// * The caller must not have written anything to the last "count" bytes
|
| 229 |
+
// of that buffer.
|
| 230 |
+
//
|
| 231 |
+
// Postconditions:
|
| 232 |
+
// * The last "count" bytes of the last buffer returned by Next() will be
|
| 233 |
+
// ignored.
|
| 234 |
+
virtual void BackUp(int count) = 0;
|
| 235 |
+
|
| 236 |
+
// Returns the total number of bytes written since this object was created.
|
| 237 |
+
virtual int64_t ByteCount() const = 0;
|
| 238 |
+
|
| 239 |
+
// Write a given chunk of data to the output. Some output streams may
|
| 240 |
+
// implement this in a way that avoids copying. Check AllowsAliasing() before
|
| 241 |
+
// calling WriteAliasedRaw(). It will GOOGLE_CHECK fail if WriteAliasedRaw() is
|
| 242 |
+
// called on a stream that does not allow aliasing.
|
| 243 |
+
//
|
| 244 |
+
// NOTE: It is caller's responsibility to ensure that the chunk of memory
|
| 245 |
+
// remains live until all of the data has been consumed from the stream.
|
| 246 |
+
virtual bool WriteAliasedRaw(const void* data, int size);
|
| 247 |
+
virtual bool AllowsAliasing() const { return false; }
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
private:
|
| 251 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ZeroCopyOutputStream);
|
| 252 |
+
};
|
| 253 |
+
|
| 254 |
+
} // namespace io
|
| 255 |
+
} // namespace protobuf
|
| 256 |
+
} // namespace google
|
| 257 |
+
|
| 258 |
+
#include <google/protobuf/port_undef.inc>
|
| 259 |
+
|
| 260 |
+
#endif // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/io/zero_copy_stream_impl.h
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// Author: kenton@google.com (Kenton Varda)
|
| 32 |
+
// Based on original Protocol Buffers design by
|
| 33 |
+
// Sanjay Ghemawat, Jeff Dean, and others.
|
| 34 |
+
//
|
| 35 |
+
// This file contains common implementations of the interfaces defined in
|
| 36 |
+
// zero_copy_stream.h which are only included in the full (non-lite)
|
| 37 |
+
// protobuf library. These implementations include Unix file descriptors
|
| 38 |
+
// and C++ iostreams. See also: zero_copy_stream_impl_lite.h
|
| 39 |
+
|
| 40 |
+
#ifndef GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_H__
|
| 41 |
+
#define GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_H__
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
#include <iosfwd>
|
| 45 |
+
#include <string>
|
| 46 |
+
|
| 47 |
+
#include <google/protobuf/stubs/common.h>
|
| 48 |
+
#include <google/protobuf/io/zero_copy_stream.h>
|
| 49 |
+
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
|
| 50 |
+
|
| 51 |
+
// Must be included last.
|
| 52 |
+
#include <google/protobuf/port_def.inc>
|
| 53 |
+
|
| 54 |
+
namespace google {
|
| 55 |
+
namespace protobuf {
|
| 56 |
+
namespace io {
|
| 57 |
+
|
| 58 |
+
// ===================================================================
|
| 59 |
+
|
| 60 |
+
// A ZeroCopyInputStream which reads from a file descriptor.
|
| 61 |
+
//
|
| 62 |
+
// FileInputStream is preferred over using an ifstream with IstreamInputStream.
|
| 63 |
+
// The latter will introduce an extra layer of buffering, harming performance.
|
| 64 |
+
// Also, it's conceivable that FileInputStream could someday be enhanced
|
| 65 |
+
// to use zero-copy file descriptors on OSs which support them.
|
| 66 |
+
class PROTOBUF_EXPORT FileInputStream PROTOBUF_FUTURE_FINAL
|
| 67 |
+
: public ZeroCopyInputStream {
|
| 68 |
+
public:
|
| 69 |
+
// Creates a stream that reads from the given Unix file descriptor.
|
| 70 |
+
// If a block_size is given, it specifies the number of bytes that
|
| 71 |
+
// should be read and returned with each call to Next(). Otherwise,
|
| 72 |
+
// a reasonable default is used.
|
| 73 |
+
explicit FileInputStream(int file_descriptor, int block_size = -1);
|
| 74 |
+
|
| 75 |
+
// Flushes any buffers and closes the underlying file. Returns false if
|
| 76 |
+
// an error occurs during the process; use GetErrno() to examine the error.
|
| 77 |
+
// Even if an error occurs, the file descriptor is closed when this returns.
|
| 78 |
+
bool Close();
|
| 79 |
+
|
| 80 |
+
// By default, the file descriptor is not closed when the stream is
|
| 81 |
+
// destroyed. Call SetCloseOnDelete(true) to change that. WARNING:
|
| 82 |
+
// This leaves no way for the caller to detect if close() fails. If
|
| 83 |
+
// detecting close() errors is important to you, you should arrange
|
| 84 |
+
// to close the descriptor yourself.
|
| 85 |
+
void SetCloseOnDelete(bool value) { copying_input_.SetCloseOnDelete(value); }
|
| 86 |
+
|
| 87 |
+
// If an I/O error has occurred on this file descriptor, this is the
|
| 88 |
+
// errno from that error. Otherwise, this is zero. Once an error
|
| 89 |
+
// occurs, the stream is broken and all subsequent operations will
|
| 90 |
+
// fail.
|
| 91 |
+
int GetErrno() const { return copying_input_.GetErrno(); }
|
| 92 |
+
|
| 93 |
+
// implements ZeroCopyInputStream ----------------------------------
|
| 94 |
+
bool Next(const void** data, int* size) override;
|
| 95 |
+
void BackUp(int count) override;
|
| 96 |
+
bool Skip(int count) override;
|
| 97 |
+
int64_t ByteCount() const override;
|
| 98 |
+
|
| 99 |
+
private:
|
| 100 |
+
class PROTOBUF_EXPORT CopyingFileInputStream PROTOBUF_FUTURE_FINAL
|
| 101 |
+
: public CopyingInputStream {
|
| 102 |
+
public:
|
| 103 |
+
CopyingFileInputStream(int file_descriptor);
|
| 104 |
+
~CopyingFileInputStream() override;
|
| 105 |
+
|
| 106 |
+
bool Close();
|
| 107 |
+
void SetCloseOnDelete(bool value) { close_on_delete_ = value; }
|
| 108 |
+
int GetErrno() const { return errno_; }
|
| 109 |
+
|
| 110 |
+
// implements CopyingInputStream ---------------------------------
|
| 111 |
+
int Read(void* buffer, int size) override;
|
| 112 |
+
int Skip(int count) override;
|
| 113 |
+
|
| 114 |
+
private:
|
| 115 |
+
// The file descriptor.
|
| 116 |
+
const int file_;
|
| 117 |
+
bool close_on_delete_;
|
| 118 |
+
bool is_closed_;
|
| 119 |
+
|
| 120 |
+
// The errno of the I/O error, if one has occurred. Otherwise, zero.
|
| 121 |
+
int errno_;
|
| 122 |
+
|
| 123 |
+
// Did we try to seek once and fail? If so, we assume this file descriptor
|
| 124 |
+
// doesn't support seeking and won't try again.
|
| 125 |
+
bool previous_seek_failed_;
|
| 126 |
+
|
| 127 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingFileInputStream);
|
| 128 |
+
};
|
| 129 |
+
|
| 130 |
+
CopyingFileInputStream copying_input_;
|
| 131 |
+
CopyingInputStreamAdaptor impl_;
|
| 132 |
+
|
| 133 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileInputStream);
|
| 134 |
+
};
|
| 135 |
+
|
| 136 |
+
// ===================================================================
|
| 137 |
+
|
| 138 |
+
// A ZeroCopyOutputStream which writes to a file descriptor.
|
| 139 |
+
//
|
| 140 |
+
// FileOutputStream is preferred over using an ofstream with
|
| 141 |
+
// OstreamOutputStream. The latter will introduce an extra layer of buffering,
|
| 142 |
+
// harming performance. Also, it's conceivable that FileOutputStream could
|
| 143 |
+
// someday be enhanced to use zero-copy file descriptors on OSs which
|
| 144 |
+
// support them.
|
| 145 |
+
class PROTOBUF_EXPORT FileOutputStream PROTOBUF_FUTURE_FINAL
|
| 146 |
+
: public CopyingOutputStreamAdaptor {
|
| 147 |
+
public:
|
| 148 |
+
// Creates a stream that writes to the given Unix file descriptor.
|
| 149 |
+
// If a block_size is given, it specifies the size of the buffers
|
| 150 |
+
// that should be returned by Next(). Otherwise, a reasonable default
|
| 151 |
+
// is used.
|
| 152 |
+
explicit FileOutputStream(int file_descriptor, int block_size = -1);
|
| 153 |
+
|
| 154 |
+
~FileOutputStream() override;
|
| 155 |
+
|
| 156 |
+
// Flushes any buffers and closes the underlying file. Returns false if
|
| 157 |
+
// an error occurs during the process; use GetErrno() to examine the error.
|
| 158 |
+
// Even if an error occurs, the file descriptor is closed when this returns.
|
| 159 |
+
bool Close();
|
| 160 |
+
|
| 161 |
+
// By default, the file descriptor is not closed when the stream is
|
| 162 |
+
// destroyed. Call SetCloseOnDelete(true) to change that. WARNING:
|
| 163 |
+
// This leaves no way for the caller to detect if close() fails. If
|
| 164 |
+
// detecting close() errors is important to you, you should arrange
|
| 165 |
+
// to close the descriptor yourself.
|
| 166 |
+
void SetCloseOnDelete(bool value) { copying_output_.SetCloseOnDelete(value); }
|
| 167 |
+
|
| 168 |
+
// If an I/O error has occurred on this file descriptor, this is the
|
| 169 |
+
// errno from that error. Otherwise, this is zero. Once an error
|
| 170 |
+
// occurs, the stream is broken and all subsequent operations will
|
| 171 |
+
// fail.
|
| 172 |
+
int GetErrno() const { return copying_output_.GetErrno(); }
|
| 173 |
+
|
| 174 |
+
private:
|
| 175 |
+
class PROTOBUF_EXPORT CopyingFileOutputStream PROTOBUF_FUTURE_FINAL
|
| 176 |
+
: public CopyingOutputStream {
|
| 177 |
+
public:
|
| 178 |
+
CopyingFileOutputStream(int file_descriptor);
|
| 179 |
+
~CopyingFileOutputStream() override;
|
| 180 |
+
|
| 181 |
+
bool Close();
|
| 182 |
+
void SetCloseOnDelete(bool value) { close_on_delete_ = value; }
|
| 183 |
+
int GetErrno() const { return errno_; }
|
| 184 |
+
|
| 185 |
+
// implements CopyingOutputStream --------------------------------
|
| 186 |
+
bool Write(const void* buffer, int size) override;
|
| 187 |
+
|
| 188 |
+
private:
|
| 189 |
+
// The file descriptor.
|
| 190 |
+
const int file_;
|
| 191 |
+
bool close_on_delete_;
|
| 192 |
+
bool is_closed_;
|
| 193 |
+
|
| 194 |
+
// The errno of the I/O error, if one has occurred. Otherwise, zero.
|
| 195 |
+
int errno_;
|
| 196 |
+
|
| 197 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingFileOutputStream);
|
| 198 |
+
};
|
| 199 |
+
|
| 200 |
+
CopyingFileOutputStream copying_output_;
|
| 201 |
+
|
| 202 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileOutputStream);
|
| 203 |
+
};
|
| 204 |
+
|
| 205 |
+
// ===================================================================
|
| 206 |
+
|
| 207 |
+
// A ZeroCopyInputStream which reads from a C++ istream.
|
| 208 |
+
//
|
| 209 |
+
// Note that for reading files (or anything represented by a file descriptor),
|
| 210 |
+
// FileInputStream is more efficient.
|
| 211 |
+
class PROTOBUF_EXPORT IstreamInputStream PROTOBUF_FUTURE_FINAL
|
| 212 |
+
: public ZeroCopyInputStream {
|
| 213 |
+
public:
|
| 214 |
+
// Creates a stream that reads from the given C++ istream.
|
| 215 |
+
// If a block_size is given, it specifies the number of bytes that
|
| 216 |
+
// should be read and returned with each call to Next(). Otherwise,
|
| 217 |
+
// a reasonable default is used.
|
| 218 |
+
explicit IstreamInputStream(std::istream* stream, int block_size = -1);
|
| 219 |
+
|
| 220 |
+
// implements ZeroCopyInputStream ----------------------------------
|
| 221 |
+
bool Next(const void** data, int* size) override;
|
| 222 |
+
void BackUp(int count) override;
|
| 223 |
+
bool Skip(int count) override;
|
| 224 |
+
int64_t ByteCount() const override;
|
| 225 |
+
|
| 226 |
+
private:
|
| 227 |
+
class PROTOBUF_EXPORT CopyingIstreamInputStream PROTOBUF_FUTURE_FINAL
|
| 228 |
+
: public CopyingInputStream {
|
| 229 |
+
public:
|
| 230 |
+
CopyingIstreamInputStream(std::istream* input);
|
| 231 |
+
~CopyingIstreamInputStream() override;
|
| 232 |
+
|
| 233 |
+
// implements CopyingInputStream ---------------------------------
|
| 234 |
+
int Read(void* buffer, int size) override;
|
| 235 |
+
// (We use the default implementation of Skip().)
|
| 236 |
+
|
| 237 |
+
private:
|
| 238 |
+
// The stream.
|
| 239 |
+
std::istream* input_;
|
| 240 |
+
|
| 241 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingIstreamInputStream);
|
| 242 |
+
};
|
| 243 |
+
|
| 244 |
+
CopyingIstreamInputStream copying_input_;
|
| 245 |
+
CopyingInputStreamAdaptor impl_;
|
| 246 |
+
|
| 247 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(IstreamInputStream);
|
| 248 |
+
};
|
| 249 |
+
|
| 250 |
+
// ===================================================================
|
| 251 |
+
|
| 252 |
+
// A ZeroCopyOutputStream which writes to a C++ ostream.
|
| 253 |
+
//
|
| 254 |
+
// Note that for writing files (or anything represented by a file descriptor),
|
| 255 |
+
// FileOutputStream is more efficient.
|
| 256 |
+
class PROTOBUF_EXPORT OstreamOutputStream PROTOBUF_FUTURE_FINAL
|
| 257 |
+
: public ZeroCopyOutputStream {
|
| 258 |
+
public:
|
| 259 |
+
// Creates a stream that writes to the given C++ ostream.
|
| 260 |
+
// If a block_size is given, it specifies the size of the buffers
|
| 261 |
+
// that should be returned by Next(). Otherwise, a reasonable default
|
| 262 |
+
// is used.
|
| 263 |
+
explicit OstreamOutputStream(std::ostream* stream, int block_size = -1);
|
| 264 |
+
~OstreamOutputStream() override;
|
| 265 |
+
|
| 266 |
+
// implements ZeroCopyOutputStream ---------------------------------
|
| 267 |
+
bool Next(void** data, int* size) override;
|
| 268 |
+
void BackUp(int count) override;
|
| 269 |
+
int64_t ByteCount() const override;
|
| 270 |
+
|
| 271 |
+
private:
|
| 272 |
+
class PROTOBUF_EXPORT CopyingOstreamOutputStream PROTOBUF_FUTURE_FINAL
|
| 273 |
+
: public CopyingOutputStream {
|
| 274 |
+
public:
|
| 275 |
+
CopyingOstreamOutputStream(std::ostream* output);
|
| 276 |
+
~CopyingOstreamOutputStream() override;
|
| 277 |
+
|
| 278 |
+
// implements CopyingOutputStream --------------------------------
|
| 279 |
+
bool Write(const void* buffer, int size) override;
|
| 280 |
+
|
| 281 |
+
private:
|
| 282 |
+
// The stream.
|
| 283 |
+
std::ostream* output_;
|
| 284 |
+
|
| 285 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingOstreamOutputStream);
|
| 286 |
+
};
|
| 287 |
+
|
| 288 |
+
CopyingOstreamOutputStream copying_output_;
|
| 289 |
+
CopyingOutputStreamAdaptor impl_;
|
| 290 |
+
|
| 291 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(OstreamOutputStream);
|
| 292 |
+
};
|
| 293 |
+
|
| 294 |
+
// ===================================================================
|
| 295 |
+
|
| 296 |
+
// A ZeroCopyInputStream which reads from several other streams in sequence.
|
| 297 |
+
// ConcatenatingInputStream is unable to distinguish between end-of-stream
|
| 298 |
+
// and read errors in the underlying streams, so it assumes any errors mean
|
| 299 |
+
// end-of-stream. So, if the underlying streams fail for any other reason,
|
| 300 |
+
// ConcatenatingInputStream may do odd things. It is suggested that you do
|
| 301 |
+
// not use ConcatenatingInputStream on streams that might produce read errors
|
| 302 |
+
// other than end-of-stream.
|
| 303 |
+
class PROTOBUF_EXPORT ConcatenatingInputStream PROTOBUF_FUTURE_FINAL
|
| 304 |
+
: public ZeroCopyInputStream {
|
| 305 |
+
public:
|
| 306 |
+
// All streams passed in as well as the array itself must remain valid
|
| 307 |
+
// until the ConcatenatingInputStream is destroyed.
|
| 308 |
+
ConcatenatingInputStream(ZeroCopyInputStream* const streams[], int count);
|
| 309 |
+
~ConcatenatingInputStream() override = default;
|
| 310 |
+
|
| 311 |
+
// implements ZeroCopyInputStream ----------------------------------
|
| 312 |
+
bool Next(const void** data, int* size) override;
|
| 313 |
+
void BackUp(int count) override;
|
| 314 |
+
bool Skip(int count) override;
|
| 315 |
+
int64_t ByteCount() const override;
|
| 316 |
+
|
| 317 |
+
|
| 318 |
+
private:
|
| 319 |
+
// As streams are retired, streams_ is incremented and count_ is
|
| 320 |
+
// decremented.
|
| 321 |
+
ZeroCopyInputStream* const* streams_;
|
| 322 |
+
int stream_count_;
|
| 323 |
+
int64_t bytes_retired_; // Bytes read from previous streams.
|
| 324 |
+
|
| 325 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ConcatenatingInputStream);
|
| 326 |
+
};
|
| 327 |
+
|
| 328 |
+
// ===================================================================
|
| 329 |
+
|
| 330 |
+
} // namespace io
|
| 331 |
+
} // namespace protobuf
|
| 332 |
+
} // namespace google
|
| 333 |
+
|
| 334 |
+
#include <google/protobuf/port_undef.inc>
|
| 335 |
+
|
| 336 |
+
#endif // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/io/zero_copy_stream_impl_lite.h
ADDED
|
@@ -0,0 +1,413 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// Author: kenton@google.com (Kenton Varda)
|
| 32 |
+
// Based on original Protocol Buffers design by
|
| 33 |
+
// Sanjay Ghemawat, Jeff Dean, and others.
|
| 34 |
+
//
|
| 35 |
+
// This file contains common implementations of the interfaces defined in
|
| 36 |
+
// zero_copy_stream.h which are included in the "lite" protobuf library.
|
| 37 |
+
// These implementations cover I/O on raw arrays and strings, as well as
|
| 38 |
+
// adaptors which make it easy to implement streams based on traditional
|
| 39 |
+
// streams. Of course, many users will probably want to write their own
|
| 40 |
+
// implementations of these interfaces specific to the particular I/O
|
| 41 |
+
// abstractions they prefer to use, but these should cover the most common
|
| 42 |
+
// cases.
|
| 43 |
+
|
| 44 |
+
#ifndef GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__
|
| 45 |
+
#define GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
#include <iosfwd>
|
| 49 |
+
#include <memory>
|
| 50 |
+
#include <string>
|
| 51 |
+
|
| 52 |
+
#include <google/protobuf/stubs/callback.h>
|
| 53 |
+
#include <google/protobuf/stubs/common.h>
|
| 54 |
+
#include <google/protobuf/io/zero_copy_stream.h>
|
| 55 |
+
#include <google/protobuf/stubs/stl_util.h>
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
// Must be included last.
|
| 59 |
+
#include <google/protobuf/port_def.inc>
|
| 60 |
+
|
| 61 |
+
namespace google {
|
| 62 |
+
namespace protobuf {
|
| 63 |
+
namespace io {
|
| 64 |
+
|
| 65 |
+
// ===================================================================
|
| 66 |
+
|
| 67 |
+
// A ZeroCopyInputStream backed by an in-memory array of bytes.
|
| 68 |
+
class PROTOBUF_EXPORT ArrayInputStream PROTOBUF_FUTURE_FINAL
|
| 69 |
+
: public ZeroCopyInputStream {
|
| 70 |
+
public:
|
| 71 |
+
// Create an InputStream that returns the bytes pointed to by "data".
|
| 72 |
+
// "data" remains the property of the caller but must remain valid until
|
| 73 |
+
// the stream is destroyed. If a block_size is given, calls to Next()
|
| 74 |
+
// will return data blocks no larger than the given size. Otherwise, the
|
| 75 |
+
// first call to Next() returns the entire array. block_size is mainly
|
| 76 |
+
// useful for testing; in production you would probably never want to set
|
| 77 |
+
// it.
|
| 78 |
+
ArrayInputStream(const void* data, int size, int block_size = -1);
|
| 79 |
+
~ArrayInputStream() override = default;
|
| 80 |
+
|
| 81 |
+
// implements ZeroCopyInputStream ----------------------------------
|
| 82 |
+
bool Next(const void** data, int* size) override;
|
| 83 |
+
void BackUp(int count) override;
|
| 84 |
+
bool Skip(int count) override;
|
| 85 |
+
int64_t ByteCount() const override;
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
private:
|
| 89 |
+
const uint8_t* const data_; // The byte array.
|
| 90 |
+
const int size_; // Total size of the array.
|
| 91 |
+
const int block_size_; // How many bytes to return at a time.
|
| 92 |
+
|
| 93 |
+
int position_;
|
| 94 |
+
int last_returned_size_; // How many bytes we returned last time Next()
|
| 95 |
+
// was called (used for error checking only).
|
| 96 |
+
|
| 97 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ArrayInputStream);
|
| 98 |
+
};
|
| 99 |
+
|
| 100 |
+
// ===================================================================
|
| 101 |
+
|
| 102 |
+
// A ZeroCopyOutputStream backed by an in-memory array of bytes.
|
| 103 |
+
class PROTOBUF_EXPORT ArrayOutputStream PROTOBUF_FUTURE_FINAL
|
| 104 |
+
: public ZeroCopyOutputStream {
|
| 105 |
+
public:
|
| 106 |
+
// Create an OutputStream that writes to the bytes pointed to by "data".
|
| 107 |
+
// "data" remains the property of the caller but must remain valid until
|
| 108 |
+
// the stream is destroyed. If a block_size is given, calls to Next()
|
| 109 |
+
// will return data blocks no larger than the given size. Otherwise, the
|
| 110 |
+
// first call to Next() returns the entire array. block_size is mainly
|
| 111 |
+
// useful for testing; in production you would probably never want to set
|
| 112 |
+
// it.
|
| 113 |
+
ArrayOutputStream(void* data, int size, int block_size = -1);
|
| 114 |
+
~ArrayOutputStream() override = default;
|
| 115 |
+
|
| 116 |
+
// implements ZeroCopyOutputStream ---------------------------------
|
| 117 |
+
bool Next(void** data, int* size) override;
|
| 118 |
+
void BackUp(int count) override;
|
| 119 |
+
int64_t ByteCount() const override;
|
| 120 |
+
|
| 121 |
+
private:
|
| 122 |
+
uint8_t* const data_; // The byte array.
|
| 123 |
+
const int size_; // Total size of the array.
|
| 124 |
+
const int block_size_; // How many bytes to return at a time.
|
| 125 |
+
|
| 126 |
+
int position_;
|
| 127 |
+
int last_returned_size_; // How many bytes we returned last time Next()
|
| 128 |
+
// was called (used for error checking only).
|
| 129 |
+
|
| 130 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ArrayOutputStream);
|
| 131 |
+
};
|
| 132 |
+
|
| 133 |
+
// ===================================================================
|
| 134 |
+
|
| 135 |
+
// A ZeroCopyOutputStream which appends bytes to a string.
|
| 136 |
+
class PROTOBUF_EXPORT StringOutputStream PROTOBUF_FUTURE_FINAL
|
| 137 |
+
: public ZeroCopyOutputStream {
|
| 138 |
+
public:
|
| 139 |
+
// Create a StringOutputStream which appends bytes to the given string.
|
| 140 |
+
// The string remains property of the caller, but it is mutated in arbitrary
|
| 141 |
+
// ways and MUST NOT be accessed in any way until you're done with the
|
| 142 |
+
// stream. Either be sure there's no further usage, or (safest) destroy the
|
| 143 |
+
// stream before using the contents.
|
| 144 |
+
//
|
| 145 |
+
// Hint: If you call target->reserve(n) before creating the stream,
|
| 146 |
+
// the first call to Next() will return at least n bytes of buffer
|
| 147 |
+
// space.
|
| 148 |
+
explicit StringOutputStream(std::string* target);
|
| 149 |
+
~StringOutputStream() override = default;
|
| 150 |
+
|
| 151 |
+
// implements ZeroCopyOutputStream ---------------------------------
|
| 152 |
+
bool Next(void** data, int* size) override;
|
| 153 |
+
void BackUp(int count) override;
|
| 154 |
+
int64_t ByteCount() const override;
|
| 155 |
+
|
| 156 |
+
private:
|
| 157 |
+
static constexpr size_t kMinimumSize = 16;
|
| 158 |
+
|
| 159 |
+
std::string* target_;
|
| 160 |
+
|
| 161 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringOutputStream);
|
| 162 |
+
};
|
| 163 |
+
|
| 164 |
+
// Note: There is no StringInputStream. Instead, just create an
|
| 165 |
+
// ArrayInputStream as follows:
|
| 166 |
+
// ArrayInputStream input(str.data(), str.size());
|
| 167 |
+
|
| 168 |
+
// ===================================================================
|
| 169 |
+
|
| 170 |
+
// A generic traditional input stream interface.
|
| 171 |
+
//
|
| 172 |
+
// Lots of traditional input streams (e.g. file descriptors, C stdio
|
| 173 |
+
// streams, and C++ iostreams) expose an interface where every read
|
| 174 |
+
// involves copying bytes into a buffer. If you want to take such an
|
| 175 |
+
// interface and make a ZeroCopyInputStream based on it, simply implement
|
| 176 |
+
// CopyingInputStream and then use CopyingInputStreamAdaptor.
|
| 177 |
+
//
|
| 178 |
+
// CopyingInputStream implementations should avoid buffering if possible.
|
| 179 |
+
// CopyingInputStreamAdaptor does its own buffering and will read data
|
| 180 |
+
// in large blocks.
|
| 181 |
+
class PROTOBUF_EXPORT CopyingInputStream {
|
| 182 |
+
public:
|
| 183 |
+
virtual ~CopyingInputStream() {}
|
| 184 |
+
|
| 185 |
+
// Reads up to "size" bytes into the given buffer. Returns the number of
|
| 186 |
+
// bytes read. Read() waits until at least one byte is available, or
|
| 187 |
+
// returns zero if no bytes will ever become available (EOF), or -1 if a
|
| 188 |
+
// permanent read error occurred.
|
| 189 |
+
virtual int Read(void* buffer, int size) = 0;
|
| 190 |
+
|
| 191 |
+
// Skips the next "count" bytes of input. Returns the number of bytes
|
| 192 |
+
// actually skipped. This will always be exactly equal to "count" unless
|
| 193 |
+
// EOF was reached or a permanent read error occurred.
|
| 194 |
+
//
|
| 195 |
+
// The default implementation just repeatedly calls Read() into a scratch
|
| 196 |
+
// buffer.
|
| 197 |
+
virtual int Skip(int count);
|
| 198 |
+
};
|
| 199 |
+
|
| 200 |
+
// A ZeroCopyInputStream which reads from a CopyingInputStream. This is
|
| 201 |
+
// useful for implementing ZeroCopyInputStreams that read from traditional
|
| 202 |
+
// streams. Note that this class is not really zero-copy.
|
| 203 |
+
//
|
| 204 |
+
// If you want to read from file descriptors or C++ istreams, this is
|
| 205 |
+
// already implemented for you: use FileInputStream or IstreamInputStream
|
| 206 |
+
// respectively.
|
| 207 |
+
class PROTOBUF_EXPORT CopyingInputStreamAdaptor : public ZeroCopyInputStream {
|
| 208 |
+
public:
|
| 209 |
+
// Creates a stream that reads from the given CopyingInputStream.
|
| 210 |
+
// If a block_size is given, it specifies the number of bytes that
|
| 211 |
+
// should be read and returned with each call to Next(). Otherwise,
|
| 212 |
+
// a reasonable default is used. The caller retains ownership of
|
| 213 |
+
// copying_stream unless SetOwnsCopyingStream(true) is called.
|
| 214 |
+
explicit CopyingInputStreamAdaptor(CopyingInputStream* copying_stream,
|
| 215 |
+
int block_size = -1);
|
| 216 |
+
~CopyingInputStreamAdaptor() override;
|
| 217 |
+
|
| 218 |
+
// Call SetOwnsCopyingStream(true) to tell the CopyingInputStreamAdaptor to
|
| 219 |
+
// delete the underlying CopyingInputStream when it is destroyed.
|
| 220 |
+
void SetOwnsCopyingStream(bool value) { owns_copying_stream_ = value; }
|
| 221 |
+
|
| 222 |
+
// implements ZeroCopyInputStream ----------------------------------
|
| 223 |
+
bool Next(const void** data, int* size) override;
|
| 224 |
+
void BackUp(int count) override;
|
| 225 |
+
bool Skip(int count) override;
|
| 226 |
+
int64_t ByteCount() const override;
|
| 227 |
+
|
| 228 |
+
private:
|
| 229 |
+
// Insures that buffer_ is not NULL.
|
| 230 |
+
void AllocateBufferIfNeeded();
|
| 231 |
+
// Frees the buffer and resets buffer_used_.
|
| 232 |
+
void FreeBuffer();
|
| 233 |
+
|
| 234 |
+
// The underlying copying stream.
|
| 235 |
+
CopyingInputStream* copying_stream_;
|
| 236 |
+
bool owns_copying_stream_;
|
| 237 |
+
|
| 238 |
+
// True if we have seen a permanent error from the underlying stream.
|
| 239 |
+
bool failed_;
|
| 240 |
+
|
| 241 |
+
// The current position of copying_stream_, relative to the point where
|
| 242 |
+
// we started reading.
|
| 243 |
+
int64_t position_;
|
| 244 |
+
|
| 245 |
+
// Data is read into this buffer. It may be NULL if no buffer is currently
|
| 246 |
+
// in use. Otherwise, it points to an array of size buffer_size_.
|
| 247 |
+
std::unique_ptr<uint8_t[]> buffer_;
|
| 248 |
+
const int buffer_size_;
|
| 249 |
+
|
| 250 |
+
// Number of valid bytes currently in the buffer (i.e. the size last
|
| 251 |
+
// returned by Next()). 0 <= buffer_used_ <= buffer_size_.
|
| 252 |
+
int buffer_used_;
|
| 253 |
+
|
| 254 |
+
// Number of bytes in the buffer which were backed up over by a call to
|
| 255 |
+
// BackUp(). These need to be returned again.
|
| 256 |
+
// 0 <= backup_bytes_ <= buffer_used_
|
| 257 |
+
int backup_bytes_;
|
| 258 |
+
|
| 259 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingInputStreamAdaptor);
|
| 260 |
+
};
|
| 261 |
+
|
| 262 |
+
// ===================================================================
|
| 263 |
+
|
| 264 |
+
// A generic traditional output stream interface.
|
| 265 |
+
//
|
| 266 |
+
// Lots of traditional output streams (e.g. file descriptors, C stdio
|
| 267 |
+
// streams, and C++ iostreams) expose an interface where every write
|
| 268 |
+
// involves copying bytes from a buffer. If you want to take such an
|
| 269 |
+
// interface and make a ZeroCopyOutputStream based on it, simply implement
|
| 270 |
+
// CopyingOutputStream and then use CopyingOutputStreamAdaptor.
|
| 271 |
+
//
|
| 272 |
+
// CopyingOutputStream implementations should avoid buffering if possible.
|
| 273 |
+
// CopyingOutputStreamAdaptor does its own buffering and will write data
|
| 274 |
+
// in large blocks.
|
| 275 |
+
class PROTOBUF_EXPORT CopyingOutputStream {
|
| 276 |
+
public:
|
| 277 |
+
virtual ~CopyingOutputStream() {}
|
| 278 |
+
|
| 279 |
+
// Writes "size" bytes from the given buffer to the output. Returns true
|
| 280 |
+
// if successful, false on a write error.
|
| 281 |
+
virtual bool Write(const void* buffer, int size) = 0;
|
| 282 |
+
};
|
| 283 |
+
|
| 284 |
+
// A ZeroCopyOutputStream which writes to a CopyingOutputStream. This is
|
| 285 |
+
// useful for implementing ZeroCopyOutputStreams that write to traditional
|
| 286 |
+
// streams. Note that this class is not really zero-copy.
|
| 287 |
+
//
|
| 288 |
+
// If you want to write to file descriptors or C++ ostreams, this is
|
| 289 |
+
// already implemented for you: use FileOutputStream or OstreamOutputStream
|
| 290 |
+
// respectively.
|
| 291 |
+
class PROTOBUF_EXPORT CopyingOutputStreamAdaptor : public ZeroCopyOutputStream {
|
| 292 |
+
public:
|
| 293 |
+
// Creates a stream that writes to the given Unix file descriptor.
|
| 294 |
+
// If a block_size is given, it specifies the size of the buffers
|
| 295 |
+
// that should be returned by Next(). Otherwise, a reasonable default
|
| 296 |
+
// is used.
|
| 297 |
+
explicit CopyingOutputStreamAdaptor(CopyingOutputStream* copying_stream,
|
| 298 |
+
int block_size = -1);
|
| 299 |
+
~CopyingOutputStreamAdaptor() override;
|
| 300 |
+
|
| 301 |
+
// Writes all pending data to the underlying stream. Returns false if a
|
| 302 |
+
// write error occurred on the underlying stream. (The underlying
|
| 303 |
+
// stream itself is not necessarily flushed.)
|
| 304 |
+
bool Flush();
|
| 305 |
+
|
| 306 |
+
// Call SetOwnsCopyingStream(true) to tell the CopyingOutputStreamAdaptor to
|
| 307 |
+
// delete the underlying CopyingOutputStream when it is destroyed.
|
| 308 |
+
void SetOwnsCopyingStream(bool value) { owns_copying_stream_ = value; }
|
| 309 |
+
|
| 310 |
+
// implements ZeroCopyOutputStream ---------------------------------
|
| 311 |
+
bool Next(void** data, int* size) override;
|
| 312 |
+
void BackUp(int count) override;
|
| 313 |
+
int64_t ByteCount() const override;
|
| 314 |
+
bool WriteAliasedRaw(const void* data, int size) override;
|
| 315 |
+
bool AllowsAliasing() const override { return true; }
|
| 316 |
+
|
| 317 |
+
private:
|
| 318 |
+
// Write the current buffer, if it is present.
|
| 319 |
+
bool WriteBuffer();
|
| 320 |
+
// Insures that buffer_ is not NULL.
|
| 321 |
+
void AllocateBufferIfNeeded();
|
| 322 |
+
// Frees the buffer.
|
| 323 |
+
void FreeBuffer();
|
| 324 |
+
|
| 325 |
+
// The underlying copying stream.
|
| 326 |
+
CopyingOutputStream* copying_stream_;
|
| 327 |
+
bool owns_copying_stream_;
|
| 328 |
+
|
| 329 |
+
// True if we have seen a permanent error from the underlying stream.
|
| 330 |
+
bool failed_;
|
| 331 |
+
|
| 332 |
+
// The current position of copying_stream_, relative to the point where
|
| 333 |
+
// we started writing.
|
| 334 |
+
int64_t position_;
|
| 335 |
+
|
| 336 |
+
// Data is written from this buffer. It may be NULL if no buffer is
|
| 337 |
+
// currently in use. Otherwise, it points to an array of size buffer_size_.
|
| 338 |
+
std::unique_ptr<uint8_t[]> buffer_;
|
| 339 |
+
const int buffer_size_;
|
| 340 |
+
|
| 341 |
+
// Number of valid bytes currently in the buffer (i.e. the size last
|
| 342 |
+
// returned by Next()). When BackUp() is called, we just reduce this.
|
| 343 |
+
// 0 <= buffer_used_ <= buffer_size_.
|
| 344 |
+
int buffer_used_;
|
| 345 |
+
|
| 346 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingOutputStreamAdaptor);
|
| 347 |
+
};
|
| 348 |
+
|
| 349 |
+
// ===================================================================
|
| 350 |
+
|
| 351 |
+
// A ZeroCopyInputStream which wraps some other stream and limits it to
|
| 352 |
+
// a particular byte count.
|
| 353 |
+
class PROTOBUF_EXPORT LimitingInputStream PROTOBUF_FUTURE_FINAL
|
| 354 |
+
: public ZeroCopyInputStream {
|
| 355 |
+
public:
|
| 356 |
+
LimitingInputStream(ZeroCopyInputStream* input, int64_t limit);
|
| 357 |
+
~LimitingInputStream() override;
|
| 358 |
+
|
| 359 |
+
// implements ZeroCopyInputStream ----------------------------------
|
| 360 |
+
bool Next(const void** data, int* size) override;
|
| 361 |
+
void BackUp(int count) override;
|
| 362 |
+
bool Skip(int count) override;
|
| 363 |
+
int64_t ByteCount() const override;
|
| 364 |
+
|
| 365 |
+
|
| 366 |
+
private:
|
| 367 |
+
ZeroCopyInputStream* input_;
|
| 368 |
+
int64_t limit_; // Decreases as we go, becomes negative if we overshoot.
|
| 369 |
+
int64_t prior_bytes_read_; // Bytes read on underlying stream at construction
|
| 370 |
+
|
| 371 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LimitingInputStream);
|
| 372 |
+
};
|
| 373 |
+
|
| 374 |
+
|
| 375 |
+
// ===================================================================
|
| 376 |
+
|
| 377 |
+
// mutable_string_data() and as_string_data() are workarounds to improve
|
| 378 |
+
// the performance of writing new data to an existing string. Unfortunately
|
| 379 |
+
// the methods provided by the string class are suboptimal, and using memcpy()
|
| 380 |
+
// is mildly annoying because it requires its pointer args to be non-NULL even
|
| 381 |
+
// if we ask it to copy 0 bytes. Furthermore, string_as_array() has the
|
| 382 |
+
// property that it always returns NULL if its arg is the empty string, exactly
|
| 383 |
+
// what we want to avoid if we're using it in conjunction with memcpy()!
|
| 384 |
+
// With C++11, the desired memcpy() boils down to memcpy(..., &(*s)[0], size),
|
| 385 |
+
// where s is a string*. Without C++11, &(*s)[0] is not guaranteed to be safe,
|
| 386 |
+
// so we use string_as_array(), and live with the extra logic that tests whether
|
| 387 |
+
// *s is empty.
|
| 388 |
+
|
| 389 |
+
// Return a pointer to mutable characters underlying the given string. The
|
| 390 |
+
// return value is valid until the next time the string is resized. We
|
| 391 |
+
// trust the caller to treat the return value as an array of length s->size().
|
| 392 |
+
inline char* mutable_string_data(std::string* s) {
|
| 393 |
+
// This should be simpler & faster than string_as_array() because the latter
|
| 394 |
+
// is guaranteed to return NULL when *s is empty, so it has to check for that.
|
| 395 |
+
return &(*s)[0];
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
// as_string_data(s) is equivalent to
|
| 399 |
+
// ({ char* p = mutable_string_data(s); make_pair(p, p != NULL); })
|
| 400 |
+
// Sometimes it's faster: in some scenarios p cannot be NULL, and then the
|
| 401 |
+
// code can avoid that check.
|
| 402 |
+
inline std::pair<char*, bool> as_string_data(std::string* s) {
|
| 403 |
+
char* p = mutable_string_data(s);
|
| 404 |
+
return std::make_pair(p, true);
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
} // namespace io
|
| 408 |
+
} // namespace protobuf
|
| 409 |
+
} // namespace google
|
| 410 |
+
|
| 411 |
+
#include <google/protobuf/port_undef.inc>
|
| 412 |
+
|
| 413 |
+
#endif // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/map_lite_test_util.h
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_MAP_LITE_TEST_UTIL_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_MAP_LITE_TEST_UTIL_H__
|
| 33 |
+
|
| 34 |
+
#include <google/protobuf/map_lite_unittest.pb.h>
|
| 35 |
+
|
| 36 |
+
namespace google {
|
| 37 |
+
namespace protobuf {
|
| 38 |
+
|
| 39 |
+
class MapLiteTestUtil {
|
| 40 |
+
public:
|
| 41 |
+
// Set every field in the TestMapLite message to a unique value.
|
| 42 |
+
static void SetMapFields(protobuf_unittest::TestMapLite* message);
|
| 43 |
+
|
| 44 |
+
// Set every field in the TestArenaMapLite message to a unique value.
|
| 45 |
+
static void SetArenaMapFields(protobuf_unittest::TestArenaMapLite* message);
|
| 46 |
+
|
| 47 |
+
// Set every field in the message to a default value.
|
| 48 |
+
static void SetMapFieldsInitialized(protobuf_unittest::TestMapLite* message);
|
| 49 |
+
|
| 50 |
+
// Modify all the map fields of the message (which should already have been
|
| 51 |
+
// initialized with SetMapFields()).
|
| 52 |
+
static void ModifyMapFields(protobuf_unittest::TestMapLite* message);
|
| 53 |
+
|
| 54 |
+
// Check that all fields have the values that they should have after
|
| 55 |
+
// SetMapFields() is called.
|
| 56 |
+
static void ExpectMapFieldsSet(const protobuf_unittest::TestMapLite& message);
|
| 57 |
+
|
| 58 |
+
// Check that all fields have the values that they should have after
|
| 59 |
+
// SetMapFields() is called for TestArenaMapLite.
|
| 60 |
+
static void ExpectArenaMapFieldsSet(
|
| 61 |
+
const protobuf_unittest::TestArenaMapLite& message);
|
| 62 |
+
|
| 63 |
+
// Check that all fields have the values that they should have after
|
| 64 |
+
// SetMapFieldsInitialized() is called.
|
| 65 |
+
static void ExpectMapFieldsSetInitialized(
|
| 66 |
+
const protobuf_unittest::TestMapLite& message);
|
| 67 |
+
|
| 68 |
+
// Expect that the message is modified as would be expected from
|
| 69 |
+
// ModifyMapFields().
|
| 70 |
+
static void ExpectMapFieldsModified(
|
| 71 |
+
const protobuf_unittest::TestMapLite& message);
|
| 72 |
+
|
| 73 |
+
// Check that all fields are empty.
|
| 74 |
+
static void ExpectClear(const protobuf_unittest::TestMapLite& message);
|
| 75 |
+
};
|
| 76 |
+
|
| 77 |
+
} // namespace protobuf
|
| 78 |
+
} // namespace google
|
| 79 |
+
|
| 80 |
+
#endif // GOOGLE_PROTOBUF_MAP_LITE_TEST_UTIL_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/map_test_util.h
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_MAP_TEST_UTIL_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_MAP_TEST_UTIL_H__
|
| 33 |
+
|
| 34 |
+
#include <google/protobuf/map_unittest.pb.h>
|
| 35 |
+
#include <google/protobuf/reflection_tester.h>
|
| 36 |
+
|
| 37 |
+
#define UNITTEST ::protobuf_unittest
|
| 38 |
+
#define BRIDGE_UNITTEST ::google::protobuf::bridge_unittest
|
| 39 |
+
|
| 40 |
+
// Must be included after defining UNITTEST, etc.
|
| 41 |
+
#include <google/protobuf/map_test_util.inc>
|
| 42 |
+
|
| 43 |
+
#undef UNITTEST
|
| 44 |
+
#undef BRIDGE_UNITTEST
|
| 45 |
+
|
| 46 |
+
#endif // GOOGLE_PROTOBUF_MAP_TEST_UTIL_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/map_test_util.inc
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#include <google/protobuf/descriptor.h>
|
| 32 |
+
#include <google/protobuf/map_test_util_impl.h>
|
| 33 |
+
#include <google/protobuf/message.h>
|
| 34 |
+
|
| 35 |
+
namespace google {
|
| 36 |
+
namespace protobuf {
|
| 37 |
+
|
| 38 |
+
class MapTestUtil {
|
| 39 |
+
public:
|
| 40 |
+
// Set every field in the TestMap message to a unique value.
|
| 41 |
+
static void SetMapFields(UNITTEST::TestMap* message);
|
| 42 |
+
|
| 43 |
+
// Set every field in the TestArenaMap message to a unique value.
|
| 44 |
+
static void SetArenaMapFields(UNITTEST::TestArenaMap* message);
|
| 45 |
+
|
| 46 |
+
// Set every field in the message to a default value.
|
| 47 |
+
static void SetMapFieldsInitialized(UNITTEST::TestMap* message);
|
| 48 |
+
|
| 49 |
+
// Modify all the map fields of the message (which should already have been
|
| 50 |
+
// initialized with SetMapFields()).
|
| 51 |
+
static void ModifyMapFields(UNITTEST::TestMap* message);
|
| 52 |
+
|
| 53 |
+
// Check that all fields have the values that they should have after
|
| 54 |
+
// SetMapFields() is called.
|
| 55 |
+
static void ExpectMapFieldsSet(const UNITTEST::TestMap& message);
|
| 56 |
+
|
| 57 |
+
// Check that all fields have the values that they should have after
|
| 58 |
+
// SetMapFields() is called for TestArenaMap.
|
| 59 |
+
static void ExpectArenaMapFieldsSet(const UNITTEST::TestArenaMap& message);
|
| 60 |
+
|
| 61 |
+
// Check that all fields have the values that they should have after
|
| 62 |
+
// SetMapFieldsInitialized() is called.
|
| 63 |
+
static void ExpectMapFieldsSetInitialized(const UNITTEST::TestMap& message);
|
| 64 |
+
|
| 65 |
+
// Expect that the message is modified as would be expected from
|
| 66 |
+
// ModifyMapFields().
|
| 67 |
+
static void ExpectMapFieldsModified(const UNITTEST::TestMap& message);
|
| 68 |
+
|
| 69 |
+
// Check that all fields are empty.
|
| 70 |
+
static void ExpectClear(const UNITTEST::TestMap& message);
|
| 71 |
+
|
| 72 |
+
// Check that all map fields have the given size.
|
| 73 |
+
static void ExpectMapsSize(const UNITTEST::TestMap& message, int size);
|
| 74 |
+
|
| 75 |
+
// Get pointers of map entries at given index.
|
| 76 |
+
static std::vector<const Message*> GetMapEntries(
|
| 77 |
+
const UNITTEST::TestMap& message, int index);
|
| 78 |
+
|
| 79 |
+
// Get pointers of map entries from release.
|
| 80 |
+
static std::vector<const Message*> GetMapEntriesFromRelease(
|
| 81 |
+
UNITTEST::TestMap* message);
|
| 82 |
+
};
|
| 83 |
+
|
| 84 |
+
inline void MapTestUtil::SetMapFields(UNITTEST::TestMap* message) {
|
| 85 |
+
MapTestUtilImpl::SetMapFields<UNITTEST::MapEnum, UNITTEST::MAP_ENUM_BAR,
|
| 86 |
+
UNITTEST::MAP_ENUM_BAZ>(message);
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
inline void MapTestUtil::SetArenaMapFields(UNITTEST::TestArenaMap* message) {
|
| 90 |
+
MapTestUtilImpl::SetArenaMapFields<UNITTEST::MapEnum, UNITTEST::MAP_ENUM_BAR,
|
| 91 |
+
UNITTEST::MAP_ENUM_BAZ>(message);
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
inline void MapTestUtil::SetMapFieldsInitialized(UNITTEST::TestMap* message) {
|
| 95 |
+
MapTestUtilImpl::SetMapFieldsInitialized(message);
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
inline void MapTestUtil::ModifyMapFields(UNITTEST::TestMap* message) {
|
| 99 |
+
MapTestUtilImpl::ModifyMapFields<UNITTEST::MapEnum, UNITTEST::MAP_ENUM_FOO>(
|
| 100 |
+
message);
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
inline void MapTestUtil::ExpectClear(const UNITTEST::TestMap& message) {
|
| 104 |
+
MapTestUtilImpl::ExpectClear(message);
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
inline void MapTestUtil::ExpectMapFieldsSet(const UNITTEST::TestMap& message) {
|
| 108 |
+
MapTestUtilImpl::ExpectMapFieldsSet<UNITTEST::MapEnum, UNITTEST::MAP_ENUM_BAR,
|
| 109 |
+
UNITTEST::MAP_ENUM_BAZ>(message);
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
inline void MapTestUtil::ExpectArenaMapFieldsSet(
|
| 113 |
+
const UNITTEST::TestArenaMap& message) {
|
| 114 |
+
MapTestUtilImpl::ExpectArenaMapFieldsSet<
|
| 115 |
+
UNITTEST::MapEnum, UNITTEST::MAP_ENUM_BAR, UNITTEST::MAP_ENUM_BAZ>(
|
| 116 |
+
message);
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
inline void MapTestUtil::ExpectMapFieldsSetInitialized(
|
| 120 |
+
const UNITTEST::TestMap& message) {
|
| 121 |
+
MapTestUtilImpl::ExpectMapFieldsSetInitialized<UNITTEST::MapEnum,
|
| 122 |
+
UNITTEST::MAP_ENUM_FOO>(
|
| 123 |
+
message);
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
inline void MapTestUtil::ExpectMapFieldsModified(
|
| 127 |
+
const UNITTEST::TestMap& message) {
|
| 128 |
+
MapTestUtilImpl::ExpectMapFieldsModified<
|
| 129 |
+
UNITTEST::MapEnum, UNITTEST::MAP_ENUM_BAR, UNITTEST::MAP_ENUM_FOO>(
|
| 130 |
+
message);
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
inline void MapTestUtil::ExpectMapsSize(const UNITTEST::TestMap& message,
|
| 134 |
+
int size) {
|
| 135 |
+
const Descriptor* descriptor = message.GetDescriptor();
|
| 136 |
+
|
| 137 |
+
EXPECT_EQ(size, message.GetReflection()->FieldSize(
|
| 138 |
+
message, descriptor->FindFieldByName("map_int32_int32")));
|
| 139 |
+
EXPECT_EQ(size, message.GetReflection()->FieldSize(
|
| 140 |
+
message, descriptor->FindFieldByName("map_int64_int64")));
|
| 141 |
+
EXPECT_EQ(size,
|
| 142 |
+
message.GetReflection()->FieldSize(
|
| 143 |
+
message, descriptor->FindFieldByName("map_uint32_uint32")));
|
| 144 |
+
EXPECT_EQ(size,
|
| 145 |
+
message.GetReflection()->FieldSize(
|
| 146 |
+
message, descriptor->FindFieldByName("map_uint64_uint64")));
|
| 147 |
+
EXPECT_EQ(size,
|
| 148 |
+
message.GetReflection()->FieldSize(
|
| 149 |
+
message, descriptor->FindFieldByName("map_sint32_sint32")));
|
| 150 |
+
EXPECT_EQ(size,
|
| 151 |
+
message.GetReflection()->FieldSize(
|
| 152 |
+
message, descriptor->FindFieldByName("map_sint64_sint64")));
|
| 153 |
+
EXPECT_EQ(size,
|
| 154 |
+
message.GetReflection()->FieldSize(
|
| 155 |
+
message, descriptor->FindFieldByName("map_fixed32_fixed32")));
|
| 156 |
+
EXPECT_EQ(size,
|
| 157 |
+
message.GetReflection()->FieldSize(
|
| 158 |
+
message, descriptor->FindFieldByName("map_fixed64_fixed64")));
|
| 159 |
+
EXPECT_EQ(size,
|
| 160 |
+
message.GetReflection()->FieldSize(
|
| 161 |
+
message, descriptor->FindFieldByName("map_sfixed32_sfixed32")));
|
| 162 |
+
EXPECT_EQ(size,
|
| 163 |
+
message.GetReflection()->FieldSize(
|
| 164 |
+
message, descriptor->FindFieldByName("map_sfixed64_sfixed64")));
|
| 165 |
+
EXPECT_EQ(size, message.GetReflection()->FieldSize(
|
| 166 |
+
message, descriptor->FindFieldByName("map_int32_float")));
|
| 167 |
+
EXPECT_EQ(size,
|
| 168 |
+
message.GetReflection()->FieldSize(
|
| 169 |
+
message, descriptor->FindFieldByName("map_int32_double")));
|
| 170 |
+
EXPECT_EQ(size, message.GetReflection()->FieldSize(
|
| 171 |
+
message, descriptor->FindFieldByName("map_bool_bool")));
|
| 172 |
+
EXPECT_EQ(size,
|
| 173 |
+
message.GetReflection()->FieldSize(
|
| 174 |
+
message, descriptor->FindFieldByName("map_string_string")));
|
| 175 |
+
EXPECT_EQ(size, message.GetReflection()->FieldSize(
|
| 176 |
+
message, descriptor->FindFieldByName("map_int32_bytes")));
|
| 177 |
+
EXPECT_EQ(
|
| 178 |
+
size,
|
| 179 |
+
message.GetReflection()->FieldSize(
|
| 180 |
+
message, descriptor->FindFieldByName("map_int32_foreign_message")));
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
inline std::vector<const Message*> MapTestUtil::GetMapEntries(
|
| 184 |
+
const UNITTEST::TestMap& message, int index) {
|
| 185 |
+
const Descriptor* descriptor = message.GetDescriptor();
|
| 186 |
+
std::vector<const Message*> result;
|
| 187 |
+
|
| 188 |
+
result.push_back(&message.GetReflection()->GetRepeatedMessage(
|
| 189 |
+
message, descriptor->FindFieldByName("map_int32_int32"), index));
|
| 190 |
+
result.push_back(&message.GetReflection()->GetRepeatedMessage(
|
| 191 |
+
message, descriptor->FindFieldByName("map_int64_int64"), index));
|
| 192 |
+
result.push_back(&message.GetReflection()->GetRepeatedMessage(
|
| 193 |
+
message, descriptor->FindFieldByName("map_uint32_uint32"), index));
|
| 194 |
+
result.push_back(&message.GetReflection()->GetRepeatedMessage(
|
| 195 |
+
message, descriptor->FindFieldByName("map_uint64_uint64"), index));
|
| 196 |
+
result.push_back(&message.GetReflection()->GetRepeatedMessage(
|
| 197 |
+
message, descriptor->FindFieldByName("map_sint32_sint32"), index));
|
| 198 |
+
result.push_back(&message.GetReflection()->GetRepeatedMessage(
|
| 199 |
+
message, descriptor->FindFieldByName("map_sint64_sint64"), index));
|
| 200 |
+
result.push_back(&message.GetReflection()->GetRepeatedMessage(
|
| 201 |
+
message, descriptor->FindFieldByName("map_fixed32_fixed32"), index));
|
| 202 |
+
result.push_back(&message.GetReflection()->GetRepeatedMessage(
|
| 203 |
+
message, descriptor->FindFieldByName("map_fixed64_fixed64"), index));
|
| 204 |
+
result.push_back(&message.GetReflection()->GetRepeatedMessage(
|
| 205 |
+
message, descriptor->FindFieldByName("map_sfixed32_sfixed32"), index));
|
| 206 |
+
result.push_back(&message.GetReflection()->GetRepeatedMessage(
|
| 207 |
+
message, descriptor->FindFieldByName("map_sfixed64_sfixed64"), index));
|
| 208 |
+
result.push_back(&message.GetReflection()->GetRepeatedMessage(
|
| 209 |
+
message, descriptor->FindFieldByName("map_int32_float"), index));
|
| 210 |
+
result.push_back(&message.GetReflection()->GetRepeatedMessage(
|
| 211 |
+
message, descriptor->FindFieldByName("map_int32_double"), index));
|
| 212 |
+
result.push_back(&message.GetReflection()->GetRepeatedMessage(
|
| 213 |
+
message, descriptor->FindFieldByName("map_bool_bool"), index));
|
| 214 |
+
result.push_back(&message.GetReflection()->GetRepeatedMessage(
|
| 215 |
+
message, descriptor->FindFieldByName("map_string_string"), index));
|
| 216 |
+
result.push_back(&message.GetReflection()->GetRepeatedMessage(
|
| 217 |
+
message, descriptor->FindFieldByName("map_int32_bytes"), index));
|
| 218 |
+
result.push_back(&message.GetReflection()->GetRepeatedMessage(
|
| 219 |
+
message, descriptor->FindFieldByName("map_int32_enum"), index));
|
| 220 |
+
result.push_back(&message.GetReflection()->GetRepeatedMessage(
|
| 221 |
+
message, descriptor->FindFieldByName("map_int32_foreign_message"),
|
| 222 |
+
index));
|
| 223 |
+
|
| 224 |
+
return result;
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
inline std::vector<const Message*> MapTestUtil::GetMapEntriesFromRelease(
|
| 228 |
+
UNITTEST::TestMap* message) {
|
| 229 |
+
const Descriptor* descriptor = message->GetDescriptor();
|
| 230 |
+
std::vector<const Message*> result;
|
| 231 |
+
|
| 232 |
+
result.push_back(message->GetReflection()->ReleaseLast(
|
| 233 |
+
message, descriptor->FindFieldByName("map_int32_int32")));
|
| 234 |
+
result.push_back(message->GetReflection()->ReleaseLast(
|
| 235 |
+
message, descriptor->FindFieldByName("map_int64_int64")));
|
| 236 |
+
result.push_back(message->GetReflection()->ReleaseLast(
|
| 237 |
+
message, descriptor->FindFieldByName("map_uint32_uint32")));
|
| 238 |
+
result.push_back(message->GetReflection()->ReleaseLast(
|
| 239 |
+
message, descriptor->FindFieldByName("map_uint64_uint64")));
|
| 240 |
+
result.push_back(message->GetReflection()->ReleaseLast(
|
| 241 |
+
message, descriptor->FindFieldByName("map_sint32_sint32")));
|
| 242 |
+
result.push_back(message->GetReflection()->ReleaseLast(
|
| 243 |
+
message, descriptor->FindFieldByName("map_sint64_sint64")));
|
| 244 |
+
result.push_back(message->GetReflection()->ReleaseLast(
|
| 245 |
+
message, descriptor->FindFieldByName("map_fixed32_fixed32")));
|
| 246 |
+
result.push_back(message->GetReflection()->ReleaseLast(
|
| 247 |
+
message, descriptor->FindFieldByName("map_fixed64_fixed64")));
|
| 248 |
+
result.push_back(message->GetReflection()->ReleaseLast(
|
| 249 |
+
message, descriptor->FindFieldByName("map_sfixed32_sfixed32")));
|
| 250 |
+
result.push_back(message->GetReflection()->ReleaseLast(
|
| 251 |
+
message, descriptor->FindFieldByName("map_sfixed64_sfixed64")));
|
| 252 |
+
result.push_back(message->GetReflection()->ReleaseLast(
|
| 253 |
+
message, descriptor->FindFieldByName("map_int32_float")));
|
| 254 |
+
result.push_back(message->GetReflection()->ReleaseLast(
|
| 255 |
+
message, descriptor->FindFieldByName("map_int32_double")));
|
| 256 |
+
result.push_back(message->GetReflection()->ReleaseLast(
|
| 257 |
+
message, descriptor->FindFieldByName("map_bool_bool")));
|
| 258 |
+
result.push_back(message->GetReflection()->ReleaseLast(
|
| 259 |
+
message, descriptor->FindFieldByName("map_string_string")));
|
| 260 |
+
result.push_back(message->GetReflection()->ReleaseLast(
|
| 261 |
+
message, descriptor->FindFieldByName("map_int32_bytes")));
|
| 262 |
+
result.push_back(message->GetReflection()->ReleaseLast(
|
| 263 |
+
message, descriptor->FindFieldByName("map_int32_enum")));
|
| 264 |
+
result.push_back(message->GetReflection()->ReleaseLast(
|
| 265 |
+
message, descriptor->FindFieldByName("map_int32_foreign_message")));
|
| 266 |
+
|
| 267 |
+
return result;
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
} // namespace protobuf
|
| 271 |
+
} // namespace google
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/map_test_util_impl.h
ADDED
|
@@ -0,0 +1,476 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_MAP_TEST_UTIL_IMPL_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_MAP_TEST_UTIL_IMPL_H__
|
| 33 |
+
|
| 34 |
+
#include <google/protobuf/stubs/logging.h>
|
| 35 |
+
#include <google/protobuf/stubs/common.h>
|
| 36 |
+
#include <gtest/gtest.h>
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
namespace protobuf_unittest {} // namespace protobuf_unittest
|
| 40 |
+
|
| 41 |
+
namespace google {
|
| 42 |
+
namespace protobuf {
|
| 43 |
+
|
| 44 |
+
namespace unittest = ::protobuf_unittest;
|
| 45 |
+
|
| 46 |
+
class MapTestUtilImpl {
|
| 47 |
+
public:
|
| 48 |
+
// Set every field in the TestMap message to a unique value.
|
| 49 |
+
template <typename EnumType, EnumType enum_value0, EnumType enum_value1,
|
| 50 |
+
typename MapMessage>
|
| 51 |
+
static void SetMapFields(MapMessage* message);
|
| 52 |
+
|
| 53 |
+
// Set every field in the TestArenaMap message to a unique value.
|
| 54 |
+
template <typename EnumType, EnumType enum_value0, EnumType enum_value1,
|
| 55 |
+
typename MapMessage>
|
| 56 |
+
static void SetArenaMapFields(MapMessage* message);
|
| 57 |
+
|
| 58 |
+
// Set every field in the message to a default value.
|
| 59 |
+
template <typename MapMessage>
|
| 60 |
+
static void SetMapFieldsInitialized(MapMessage* message);
|
| 61 |
+
|
| 62 |
+
// Modify all the map fields of the message (which should already have been
|
| 63 |
+
// initialized with SetMapFields()).
|
| 64 |
+
template <typename EnumType, EnumType enum_value, typename MapMessage>
|
| 65 |
+
static void ModifyMapFields(MapMessage* message);
|
| 66 |
+
|
| 67 |
+
// Check that all fields have the values that they should have after
|
| 68 |
+
// SetMapFields() is called.
|
| 69 |
+
template <typename EnumType, EnumType enum_value0, EnumType enum_value1,
|
| 70 |
+
typename MapMessage>
|
| 71 |
+
static void ExpectMapFieldsSet(const MapMessage& message);
|
| 72 |
+
|
| 73 |
+
// Check that all fields have the values that they should have after
|
| 74 |
+
// SetMapFields() is called for TestArenaMap.
|
| 75 |
+
template <typename EnumType, EnumType enum_value0, EnumType enum_value1,
|
| 76 |
+
typename MapMessage>
|
| 77 |
+
static void ExpectArenaMapFieldsSet(const MapMessage& message);
|
| 78 |
+
|
| 79 |
+
// Check that all fields have the values that they should have after
|
| 80 |
+
// SetMapFieldsInitialized() is called.
|
| 81 |
+
template <typename EnumType, EnumType enum_value, typename MapMessage>
|
| 82 |
+
static void ExpectMapFieldsSetInitialized(const MapMessage& message);
|
| 83 |
+
|
| 84 |
+
// Expect that the message is modified as would be expected from
|
| 85 |
+
// ModifyMapFields().
|
| 86 |
+
template <typename EnumType, EnumType enum_value0, EnumType enum_value1,
|
| 87 |
+
typename MapMessage>
|
| 88 |
+
static void ExpectMapFieldsModified(const MapMessage& message);
|
| 89 |
+
|
| 90 |
+
// Check that all fields are empty.
|
| 91 |
+
template <typename MapMessage>
|
| 92 |
+
static void ExpectClear(const MapMessage& message);
|
| 93 |
+
|
| 94 |
+
// // Check that all map fields have the given size.
|
| 95 |
+
// template <typename MapMessage>
|
| 96 |
+
// static void ExpectMapsSize(const MapMessage& message, int size);
|
| 97 |
+
|
| 98 |
+
// // Get pointers of map entries at given index.
|
| 99 |
+
// static std::vector<const Message*> GetMapEntries(
|
| 100 |
+
// const MapMessage& message, int index);
|
| 101 |
+
|
| 102 |
+
// // Get pointers of map entries from release.
|
| 103 |
+
// static std::vector<const Message*> GetMapEntriesFromRelease(
|
| 104 |
+
// MapMessage* message);
|
| 105 |
+
};
|
| 106 |
+
|
| 107 |
+
template <typename EnumType, EnumType enum_value0, EnumType enum_value1,
|
| 108 |
+
typename MapMessage>
|
| 109 |
+
void MapTestUtilImpl::SetMapFields(MapMessage* message) {
|
| 110 |
+
// Add first element.
|
| 111 |
+
(*message->mutable_map_int32_int32())[0] = 0;
|
| 112 |
+
(*message->mutable_map_int64_int64())[0] = 0;
|
| 113 |
+
(*message->mutable_map_uint32_uint32())[0] = 0;
|
| 114 |
+
(*message->mutable_map_uint64_uint64())[0] = 0;
|
| 115 |
+
(*message->mutable_map_sint32_sint32())[0] = 0;
|
| 116 |
+
(*message->mutable_map_sint64_sint64())[0] = 0;
|
| 117 |
+
(*message->mutable_map_fixed32_fixed32())[0] = 0;
|
| 118 |
+
(*message->mutable_map_fixed64_fixed64())[0] = 0;
|
| 119 |
+
(*message->mutable_map_sfixed32_sfixed32())[0] = 0;
|
| 120 |
+
(*message->mutable_map_sfixed64_sfixed64())[0] = 0;
|
| 121 |
+
(*message->mutable_map_int32_float())[0] = 0.0;
|
| 122 |
+
(*message->mutable_map_int32_double())[0] = 0.0;
|
| 123 |
+
(*message->mutable_map_bool_bool())[0] = false;
|
| 124 |
+
(*message->mutable_map_string_string())["0"] = "0";
|
| 125 |
+
(*message->mutable_map_int32_bytes())[0] = "0";
|
| 126 |
+
(*message->mutable_map_int32_enum())[0] = enum_value0;
|
| 127 |
+
(*message->mutable_map_int32_foreign_message())[0].set_c(0);
|
| 128 |
+
|
| 129 |
+
// Add second element
|
| 130 |
+
(*message->mutable_map_int32_int32())[1] = 1;
|
| 131 |
+
(*message->mutable_map_int64_int64())[1] = 1;
|
| 132 |
+
(*message->mutable_map_uint32_uint32())[1] = 1;
|
| 133 |
+
(*message->mutable_map_uint64_uint64())[1] = 1;
|
| 134 |
+
(*message->mutable_map_sint32_sint32())[1] = 1;
|
| 135 |
+
(*message->mutable_map_sint64_sint64())[1] = 1;
|
| 136 |
+
(*message->mutable_map_fixed32_fixed32())[1] = 1;
|
| 137 |
+
(*message->mutable_map_fixed64_fixed64())[1] = 1;
|
| 138 |
+
(*message->mutable_map_sfixed32_sfixed32())[1] = 1;
|
| 139 |
+
(*message->mutable_map_sfixed64_sfixed64())[1] = 1;
|
| 140 |
+
(*message->mutable_map_int32_float())[1] = 1.0;
|
| 141 |
+
(*message->mutable_map_int32_double())[1] = 1.0;
|
| 142 |
+
(*message->mutable_map_bool_bool())[1] = true;
|
| 143 |
+
(*message->mutable_map_string_string())["1"] = "1";
|
| 144 |
+
(*message->mutable_map_int32_bytes())[1] = "1";
|
| 145 |
+
(*message->mutable_map_int32_enum())[1] = enum_value1;
|
| 146 |
+
(*message->mutable_map_int32_foreign_message())[1].set_c(1);
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
template <typename EnumType, EnumType enum_value0, EnumType enum_value1,
|
| 150 |
+
typename MapMessage>
|
| 151 |
+
void MapTestUtilImpl::SetArenaMapFields(MapMessage* message) {
|
| 152 |
+
// Add first element.
|
| 153 |
+
(*message->mutable_map_int32_int32())[0] = 0;
|
| 154 |
+
(*message->mutable_map_int64_int64())[0] = 0;
|
| 155 |
+
(*message->mutable_map_uint32_uint32())[0] = 0;
|
| 156 |
+
(*message->mutable_map_uint64_uint64())[0] = 0;
|
| 157 |
+
(*message->mutable_map_sint32_sint32())[0] = 0;
|
| 158 |
+
(*message->mutable_map_sint64_sint64())[0] = 0;
|
| 159 |
+
(*message->mutable_map_fixed32_fixed32())[0] = 0;
|
| 160 |
+
(*message->mutable_map_fixed64_fixed64())[0] = 0;
|
| 161 |
+
(*message->mutable_map_sfixed32_sfixed32())[0] = 0;
|
| 162 |
+
(*message->mutable_map_sfixed64_sfixed64())[0] = 0;
|
| 163 |
+
(*message->mutable_map_int32_float())[0] = 0.0;
|
| 164 |
+
(*message->mutable_map_int32_double())[0] = 0.0;
|
| 165 |
+
(*message->mutable_map_bool_bool())[0] = false;
|
| 166 |
+
(*message->mutable_map_string_string())["0"] = "0";
|
| 167 |
+
(*message->mutable_map_int32_bytes())[0] = "0";
|
| 168 |
+
(*message->mutable_map_int32_enum())[0] = enum_value0;
|
| 169 |
+
(*message->mutable_map_int32_foreign_message())[0].set_c(0);
|
| 170 |
+
|
| 171 |
+
// Add second element
|
| 172 |
+
(*message->mutable_map_int32_int32())[1] = 1;
|
| 173 |
+
(*message->mutable_map_int64_int64())[1] = 1;
|
| 174 |
+
(*message->mutable_map_uint32_uint32())[1] = 1;
|
| 175 |
+
(*message->mutable_map_uint64_uint64())[1] = 1;
|
| 176 |
+
(*message->mutable_map_sint32_sint32())[1] = 1;
|
| 177 |
+
(*message->mutable_map_sint64_sint64())[1] = 1;
|
| 178 |
+
(*message->mutable_map_fixed32_fixed32())[1] = 1;
|
| 179 |
+
(*message->mutable_map_fixed64_fixed64())[1] = 1;
|
| 180 |
+
(*message->mutable_map_sfixed32_sfixed32())[1] = 1;
|
| 181 |
+
(*message->mutable_map_sfixed64_sfixed64())[1] = 1;
|
| 182 |
+
(*message->mutable_map_int32_float())[1] = 1.0;
|
| 183 |
+
(*message->mutable_map_int32_double())[1] = 1.0;
|
| 184 |
+
(*message->mutable_map_bool_bool())[1] = true;
|
| 185 |
+
(*message->mutable_map_string_string())["1"] = "1";
|
| 186 |
+
(*message->mutable_map_int32_bytes())[1] = "1";
|
| 187 |
+
(*message->mutable_map_int32_enum())[1] = enum_value1;
|
| 188 |
+
(*message->mutable_map_int32_foreign_message())[1].set_c(1);
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
template <typename MapMessage>
|
| 192 |
+
void MapTestUtilImpl::SetMapFieldsInitialized(MapMessage* message) {
|
| 193 |
+
// Add first element using bracket operator, which should assign default
|
| 194 |
+
// value automatically.
|
| 195 |
+
(*message->mutable_map_int32_int32())[0];
|
| 196 |
+
(*message->mutable_map_int64_int64())[0];
|
| 197 |
+
(*message->mutable_map_uint32_uint32())[0];
|
| 198 |
+
(*message->mutable_map_uint64_uint64())[0];
|
| 199 |
+
(*message->mutable_map_sint32_sint32())[0];
|
| 200 |
+
(*message->mutable_map_sint64_sint64())[0];
|
| 201 |
+
(*message->mutable_map_fixed32_fixed32())[0];
|
| 202 |
+
(*message->mutable_map_fixed64_fixed64())[0];
|
| 203 |
+
(*message->mutable_map_sfixed32_sfixed32())[0];
|
| 204 |
+
(*message->mutable_map_sfixed64_sfixed64())[0];
|
| 205 |
+
(*message->mutable_map_int32_float())[0];
|
| 206 |
+
(*message->mutable_map_int32_double())[0];
|
| 207 |
+
(*message->mutable_map_bool_bool())[0];
|
| 208 |
+
(*message->mutable_map_string_string())["0"];
|
| 209 |
+
(*message->mutable_map_int32_bytes())[0];
|
| 210 |
+
(*message->mutable_map_int32_enum())[0];
|
| 211 |
+
(*message->mutable_map_int32_foreign_message())[0];
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
template <typename EnumType, EnumType enum_value, typename MapMessage>
|
| 215 |
+
void MapTestUtilImpl::ModifyMapFields(MapMessage* message) {
|
| 216 |
+
(*message->mutable_map_int32_int32())[1] = 2;
|
| 217 |
+
(*message->mutable_map_int64_int64())[1] = 2;
|
| 218 |
+
(*message->mutable_map_uint32_uint32())[1] = 2;
|
| 219 |
+
(*message->mutable_map_uint64_uint64())[1] = 2;
|
| 220 |
+
(*message->mutable_map_sint32_sint32())[1] = 2;
|
| 221 |
+
(*message->mutable_map_sint64_sint64())[1] = 2;
|
| 222 |
+
(*message->mutable_map_fixed32_fixed32())[1] = 2;
|
| 223 |
+
(*message->mutable_map_fixed64_fixed64())[1] = 2;
|
| 224 |
+
(*message->mutable_map_sfixed32_sfixed32())[1] = 2;
|
| 225 |
+
(*message->mutable_map_sfixed64_sfixed64())[1] = 2;
|
| 226 |
+
(*message->mutable_map_int32_float())[1] = 2.0;
|
| 227 |
+
(*message->mutable_map_int32_double())[1] = 2.0;
|
| 228 |
+
(*message->mutable_map_bool_bool())[1] = false;
|
| 229 |
+
(*message->mutable_map_string_string())["1"] = "2";
|
| 230 |
+
(*message->mutable_map_int32_bytes())[1] = "2";
|
| 231 |
+
(*message->mutable_map_int32_enum())[1] = enum_value;
|
| 232 |
+
(*message->mutable_map_int32_foreign_message())[1].set_c(2);
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
template <typename MapMessage>
|
| 236 |
+
void MapTestUtilImpl::ExpectClear(const MapMessage& message) {
|
| 237 |
+
EXPECT_EQ(0, message.map_int32_int32().size());
|
| 238 |
+
EXPECT_EQ(0, message.map_int64_int64().size());
|
| 239 |
+
EXPECT_EQ(0, message.map_uint32_uint32().size());
|
| 240 |
+
EXPECT_EQ(0, message.map_uint64_uint64().size());
|
| 241 |
+
EXPECT_EQ(0, message.map_sint32_sint32().size());
|
| 242 |
+
EXPECT_EQ(0, message.map_sint64_sint64().size());
|
| 243 |
+
EXPECT_EQ(0, message.map_fixed32_fixed32().size());
|
| 244 |
+
EXPECT_EQ(0, message.map_fixed64_fixed64().size());
|
| 245 |
+
EXPECT_EQ(0, message.map_sfixed32_sfixed32().size());
|
| 246 |
+
EXPECT_EQ(0, message.map_sfixed64_sfixed64().size());
|
| 247 |
+
EXPECT_EQ(0, message.map_int32_float().size());
|
| 248 |
+
EXPECT_EQ(0, message.map_int32_double().size());
|
| 249 |
+
EXPECT_EQ(0, message.map_bool_bool().size());
|
| 250 |
+
EXPECT_EQ(0, message.map_string_string().size());
|
| 251 |
+
EXPECT_EQ(0, message.map_int32_bytes().size());
|
| 252 |
+
EXPECT_EQ(0, message.map_int32_enum().size());
|
| 253 |
+
EXPECT_EQ(0, message.map_int32_foreign_message().size());
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
template <typename EnumType, EnumType enum_value0, EnumType enum_value1,
|
| 257 |
+
typename MapMessage>
|
| 258 |
+
void MapTestUtilImpl::ExpectMapFieldsSet(const MapMessage& message) {
|
| 259 |
+
ASSERT_EQ(2, message.map_int32_int32().size());
|
| 260 |
+
ASSERT_EQ(2, message.map_int64_int64().size());
|
| 261 |
+
ASSERT_EQ(2, message.map_uint32_uint32().size());
|
| 262 |
+
ASSERT_EQ(2, message.map_uint64_uint64().size());
|
| 263 |
+
ASSERT_EQ(2, message.map_sint32_sint32().size());
|
| 264 |
+
ASSERT_EQ(2, message.map_sint64_sint64().size());
|
| 265 |
+
ASSERT_EQ(2, message.map_fixed32_fixed32().size());
|
| 266 |
+
ASSERT_EQ(2, message.map_fixed64_fixed64().size());
|
| 267 |
+
ASSERT_EQ(2, message.map_sfixed32_sfixed32().size());
|
| 268 |
+
ASSERT_EQ(2, message.map_sfixed64_sfixed64().size());
|
| 269 |
+
ASSERT_EQ(2, message.map_int32_float().size());
|
| 270 |
+
ASSERT_EQ(2, message.map_int32_double().size());
|
| 271 |
+
ASSERT_EQ(2, message.map_bool_bool().size());
|
| 272 |
+
ASSERT_EQ(2, message.map_string_string().size());
|
| 273 |
+
ASSERT_EQ(2, message.map_int32_bytes().size());
|
| 274 |
+
ASSERT_EQ(2, message.map_int32_enum().size());
|
| 275 |
+
ASSERT_EQ(2, message.map_int32_foreign_message().size());
|
| 276 |
+
|
| 277 |
+
EXPECT_EQ(0, message.map_int32_int32().at(0));
|
| 278 |
+
EXPECT_EQ(0, message.map_int64_int64().at(0));
|
| 279 |
+
EXPECT_EQ(0, message.map_uint32_uint32().at(0));
|
| 280 |
+
EXPECT_EQ(0, message.map_uint64_uint64().at(0));
|
| 281 |
+
EXPECT_EQ(0, message.map_sint32_sint32().at(0));
|
| 282 |
+
EXPECT_EQ(0, message.map_sint64_sint64().at(0));
|
| 283 |
+
EXPECT_EQ(0, message.map_fixed32_fixed32().at(0));
|
| 284 |
+
EXPECT_EQ(0, message.map_fixed64_fixed64().at(0));
|
| 285 |
+
EXPECT_EQ(0, message.map_sfixed32_sfixed32().at(0));
|
| 286 |
+
EXPECT_EQ(0, message.map_sfixed64_sfixed64().at(0));
|
| 287 |
+
EXPECT_EQ(0, message.map_int32_float().at(0));
|
| 288 |
+
EXPECT_EQ(0, message.map_int32_double().at(0));
|
| 289 |
+
EXPECT_EQ(false, message.map_bool_bool().at(0));
|
| 290 |
+
EXPECT_EQ("0", message.map_string_string().at("0"));
|
| 291 |
+
EXPECT_EQ("0", message.map_int32_bytes().at(0));
|
| 292 |
+
EXPECT_EQ(enum_value0, message.map_int32_enum().at(0));
|
| 293 |
+
EXPECT_EQ(0, message.map_int32_foreign_message().at(0).c());
|
| 294 |
+
|
| 295 |
+
EXPECT_EQ(1, message.map_int32_int32().at(1));
|
| 296 |
+
EXPECT_EQ(1, message.map_int64_int64().at(1));
|
| 297 |
+
EXPECT_EQ(1, message.map_uint32_uint32().at(1));
|
| 298 |
+
EXPECT_EQ(1, message.map_uint64_uint64().at(1));
|
| 299 |
+
EXPECT_EQ(1, message.map_sint32_sint32().at(1));
|
| 300 |
+
EXPECT_EQ(1, message.map_sint64_sint64().at(1));
|
| 301 |
+
EXPECT_EQ(1, message.map_fixed32_fixed32().at(1));
|
| 302 |
+
EXPECT_EQ(1, message.map_fixed64_fixed64().at(1));
|
| 303 |
+
EXPECT_EQ(1, message.map_sfixed32_sfixed32().at(1));
|
| 304 |
+
EXPECT_EQ(1, message.map_sfixed64_sfixed64().at(1));
|
| 305 |
+
EXPECT_EQ(1, message.map_int32_float().at(1));
|
| 306 |
+
EXPECT_EQ(1, message.map_int32_double().at(1));
|
| 307 |
+
EXPECT_EQ(true, message.map_bool_bool().at(1));
|
| 308 |
+
EXPECT_EQ("1", message.map_string_string().at("1"));
|
| 309 |
+
EXPECT_EQ("1", message.map_int32_bytes().at(1));
|
| 310 |
+
EXPECT_EQ(enum_value1, message.map_int32_enum().at(1));
|
| 311 |
+
EXPECT_EQ(1, message.map_int32_foreign_message().at(1).c());
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
template <typename EnumType, EnumType enum_value0, EnumType enum_value1,
|
| 315 |
+
typename MapMessage>
|
| 316 |
+
void MapTestUtilImpl::ExpectArenaMapFieldsSet(const MapMessage& message) {
|
| 317 |
+
EXPECT_EQ(2, message.map_int32_int32().size());
|
| 318 |
+
EXPECT_EQ(2, message.map_int64_int64().size());
|
| 319 |
+
EXPECT_EQ(2, message.map_uint32_uint32().size());
|
| 320 |
+
EXPECT_EQ(2, message.map_uint64_uint64().size());
|
| 321 |
+
EXPECT_EQ(2, message.map_sint32_sint32().size());
|
| 322 |
+
EXPECT_EQ(2, message.map_sint64_sint64().size());
|
| 323 |
+
EXPECT_EQ(2, message.map_fixed32_fixed32().size());
|
| 324 |
+
EXPECT_EQ(2, message.map_fixed64_fixed64().size());
|
| 325 |
+
EXPECT_EQ(2, message.map_sfixed32_sfixed32().size());
|
| 326 |
+
EXPECT_EQ(2, message.map_sfixed64_sfixed64().size());
|
| 327 |
+
EXPECT_EQ(2, message.map_int32_float().size());
|
| 328 |
+
EXPECT_EQ(2, message.map_int32_double().size());
|
| 329 |
+
EXPECT_EQ(2, message.map_bool_bool().size());
|
| 330 |
+
EXPECT_EQ(2, message.map_string_string().size());
|
| 331 |
+
EXPECT_EQ(2, message.map_int32_bytes().size());
|
| 332 |
+
EXPECT_EQ(2, message.map_int32_enum().size());
|
| 333 |
+
EXPECT_EQ(2, message.map_int32_foreign_message().size());
|
| 334 |
+
|
| 335 |
+
EXPECT_EQ(0, message.map_int32_int32().at(0));
|
| 336 |
+
EXPECT_EQ(0, message.map_int64_int64().at(0));
|
| 337 |
+
EXPECT_EQ(0, message.map_uint32_uint32().at(0));
|
| 338 |
+
EXPECT_EQ(0, message.map_uint64_uint64().at(0));
|
| 339 |
+
EXPECT_EQ(0, message.map_sint32_sint32().at(0));
|
| 340 |
+
EXPECT_EQ(0, message.map_sint64_sint64().at(0));
|
| 341 |
+
EXPECT_EQ(0, message.map_fixed32_fixed32().at(0));
|
| 342 |
+
EXPECT_EQ(0, message.map_fixed64_fixed64().at(0));
|
| 343 |
+
EXPECT_EQ(0, message.map_sfixed32_sfixed32().at(0));
|
| 344 |
+
EXPECT_EQ(0, message.map_sfixed64_sfixed64().at(0));
|
| 345 |
+
EXPECT_EQ(0, message.map_int32_float().at(0));
|
| 346 |
+
EXPECT_EQ(0, message.map_int32_double().at(0));
|
| 347 |
+
EXPECT_EQ(false, message.map_bool_bool().at(0));
|
| 348 |
+
EXPECT_EQ("0", message.map_string_string().at("0"));
|
| 349 |
+
EXPECT_EQ("0", message.map_int32_bytes().at(0));
|
| 350 |
+
EXPECT_EQ(enum_value0, message.map_int32_enum().at(0));
|
| 351 |
+
EXPECT_EQ(0, message.map_int32_foreign_message().at(0).c());
|
| 352 |
+
|
| 353 |
+
EXPECT_EQ(1, message.map_int32_int32().at(1));
|
| 354 |
+
EXPECT_EQ(1, message.map_int64_int64().at(1));
|
| 355 |
+
EXPECT_EQ(1, message.map_uint32_uint32().at(1));
|
| 356 |
+
EXPECT_EQ(1, message.map_uint64_uint64().at(1));
|
| 357 |
+
EXPECT_EQ(1, message.map_sint32_sint32().at(1));
|
| 358 |
+
EXPECT_EQ(1, message.map_sint64_sint64().at(1));
|
| 359 |
+
EXPECT_EQ(1, message.map_fixed32_fixed32().at(1));
|
| 360 |
+
EXPECT_EQ(1, message.map_fixed64_fixed64().at(1));
|
| 361 |
+
EXPECT_EQ(1, message.map_sfixed32_sfixed32().at(1));
|
| 362 |
+
EXPECT_EQ(1, message.map_sfixed64_sfixed64().at(1));
|
| 363 |
+
EXPECT_EQ(1, message.map_int32_float().at(1));
|
| 364 |
+
EXPECT_EQ(1, message.map_int32_double().at(1));
|
| 365 |
+
EXPECT_EQ(true, message.map_bool_bool().at(1));
|
| 366 |
+
EXPECT_EQ("1", message.map_string_string().at("1"));
|
| 367 |
+
EXPECT_EQ("1", message.map_int32_bytes().at(1));
|
| 368 |
+
EXPECT_EQ(enum_value1, message.map_int32_enum().at(1));
|
| 369 |
+
EXPECT_EQ(1, message.map_int32_foreign_message().at(1).c());
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
template <typename EnumType, EnumType enum_value, typename MapMessage>
|
| 373 |
+
void MapTestUtilImpl::ExpectMapFieldsSetInitialized(const MapMessage& message) {
|
| 374 |
+
EXPECT_EQ(1, message.map_int32_int32().size());
|
| 375 |
+
EXPECT_EQ(1, message.map_int64_int64().size());
|
| 376 |
+
EXPECT_EQ(1, message.map_uint32_uint32().size());
|
| 377 |
+
EXPECT_EQ(1, message.map_uint64_uint64().size());
|
| 378 |
+
EXPECT_EQ(1, message.map_sint32_sint32().size());
|
| 379 |
+
EXPECT_EQ(1, message.map_sint64_sint64().size());
|
| 380 |
+
EXPECT_EQ(1, message.map_fixed32_fixed32().size());
|
| 381 |
+
EXPECT_EQ(1, message.map_fixed64_fixed64().size());
|
| 382 |
+
EXPECT_EQ(1, message.map_sfixed32_sfixed32().size());
|
| 383 |
+
EXPECT_EQ(1, message.map_sfixed64_sfixed64().size());
|
| 384 |
+
EXPECT_EQ(1, message.map_int32_float().size());
|
| 385 |
+
EXPECT_EQ(1, message.map_int32_double().size());
|
| 386 |
+
EXPECT_EQ(1, message.map_bool_bool().size());
|
| 387 |
+
EXPECT_EQ(1, message.map_string_string().size());
|
| 388 |
+
EXPECT_EQ(1, message.map_int32_bytes().size());
|
| 389 |
+
EXPECT_EQ(1, message.map_int32_enum().size());
|
| 390 |
+
EXPECT_EQ(1, message.map_int32_foreign_message().size());
|
| 391 |
+
|
| 392 |
+
EXPECT_EQ(0, message.map_int32_int32().at(0));
|
| 393 |
+
EXPECT_EQ(0, message.map_int64_int64().at(0));
|
| 394 |
+
EXPECT_EQ(0, message.map_uint32_uint32().at(0));
|
| 395 |
+
EXPECT_EQ(0, message.map_uint64_uint64().at(0));
|
| 396 |
+
EXPECT_EQ(0, message.map_sint32_sint32().at(0));
|
| 397 |
+
EXPECT_EQ(0, message.map_sint64_sint64().at(0));
|
| 398 |
+
EXPECT_EQ(0, message.map_fixed32_fixed32().at(0));
|
| 399 |
+
EXPECT_EQ(0, message.map_fixed64_fixed64().at(0));
|
| 400 |
+
EXPECT_EQ(0, message.map_sfixed32_sfixed32().at(0));
|
| 401 |
+
EXPECT_EQ(0, message.map_sfixed64_sfixed64().at(0));
|
| 402 |
+
EXPECT_EQ(0, message.map_int32_float().at(0));
|
| 403 |
+
EXPECT_EQ(0, message.map_int32_double().at(0));
|
| 404 |
+
EXPECT_EQ(false, message.map_bool_bool().at(0));
|
| 405 |
+
EXPECT_EQ("", message.map_string_string().at("0"));
|
| 406 |
+
EXPECT_EQ("", message.map_int32_bytes().at(0));
|
| 407 |
+
EXPECT_EQ(enum_value, message.map_int32_enum().at(0));
|
| 408 |
+
EXPECT_EQ(0, message.map_int32_foreign_message().at(0).ByteSizeLong());
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
+
template <typename EnumType, EnumType enum_value0, EnumType enum_value1,
|
| 412 |
+
typename MapMessage>
|
| 413 |
+
void MapTestUtilImpl::ExpectMapFieldsModified(const MapMessage& message) {
|
| 414 |
+
// ModifyMapFields only sets the second element of each field. In addition to
|
| 415 |
+
// verifying this, we also verify that the first element and size were *not*
|
| 416 |
+
// modified.
|
| 417 |
+
EXPECT_EQ(2, message.map_int32_int32().size());
|
| 418 |
+
EXPECT_EQ(2, message.map_int64_int64().size());
|
| 419 |
+
EXPECT_EQ(2, message.map_uint32_uint32().size());
|
| 420 |
+
EXPECT_EQ(2, message.map_uint64_uint64().size());
|
| 421 |
+
EXPECT_EQ(2, message.map_sint32_sint32().size());
|
| 422 |
+
EXPECT_EQ(2, message.map_sint64_sint64().size());
|
| 423 |
+
EXPECT_EQ(2, message.map_fixed32_fixed32().size());
|
| 424 |
+
EXPECT_EQ(2, message.map_fixed64_fixed64().size());
|
| 425 |
+
EXPECT_EQ(2, message.map_sfixed32_sfixed32().size());
|
| 426 |
+
EXPECT_EQ(2, message.map_sfixed64_sfixed64().size());
|
| 427 |
+
EXPECT_EQ(2, message.map_int32_float().size());
|
| 428 |
+
EXPECT_EQ(2, message.map_int32_double().size());
|
| 429 |
+
EXPECT_EQ(2, message.map_bool_bool().size());
|
| 430 |
+
EXPECT_EQ(2, message.map_string_string().size());
|
| 431 |
+
EXPECT_EQ(2, message.map_int32_bytes().size());
|
| 432 |
+
EXPECT_EQ(2, message.map_int32_enum().size());
|
| 433 |
+
EXPECT_EQ(2, message.map_int32_foreign_message().size());
|
| 434 |
+
|
| 435 |
+
EXPECT_EQ(0, message.map_int32_int32().at(0));
|
| 436 |
+
EXPECT_EQ(0, message.map_int64_int64().at(0));
|
| 437 |
+
EXPECT_EQ(0, message.map_uint32_uint32().at(0));
|
| 438 |
+
EXPECT_EQ(0, message.map_uint64_uint64().at(0));
|
| 439 |
+
EXPECT_EQ(0, message.map_sint32_sint32().at(0));
|
| 440 |
+
EXPECT_EQ(0, message.map_sint64_sint64().at(0));
|
| 441 |
+
EXPECT_EQ(0, message.map_fixed32_fixed32().at(0));
|
| 442 |
+
EXPECT_EQ(0, message.map_fixed64_fixed64().at(0));
|
| 443 |
+
EXPECT_EQ(0, message.map_sfixed32_sfixed32().at(0));
|
| 444 |
+
EXPECT_EQ(0, message.map_sfixed64_sfixed64().at(0));
|
| 445 |
+
EXPECT_EQ(0, message.map_int32_float().at(0));
|
| 446 |
+
EXPECT_EQ(0, message.map_int32_double().at(0));
|
| 447 |
+
EXPECT_EQ(false, message.map_bool_bool().at(0));
|
| 448 |
+
EXPECT_EQ("0", message.map_string_string().at("0"));
|
| 449 |
+
EXPECT_EQ("0", message.map_int32_bytes().at(0));
|
| 450 |
+
EXPECT_EQ(enum_value0, message.map_int32_enum().at(0));
|
| 451 |
+
EXPECT_EQ(0, message.map_int32_foreign_message().at(0).c());
|
| 452 |
+
|
| 453 |
+
// Actually verify the second (modified) elements now.
|
| 454 |
+
EXPECT_EQ(2, message.map_int32_int32().at(1));
|
| 455 |
+
EXPECT_EQ(2, message.map_int64_int64().at(1));
|
| 456 |
+
EXPECT_EQ(2, message.map_uint32_uint32().at(1));
|
| 457 |
+
EXPECT_EQ(2, message.map_uint64_uint64().at(1));
|
| 458 |
+
EXPECT_EQ(2, message.map_sint32_sint32().at(1));
|
| 459 |
+
EXPECT_EQ(2, message.map_sint64_sint64().at(1));
|
| 460 |
+
EXPECT_EQ(2, message.map_fixed32_fixed32().at(1));
|
| 461 |
+
EXPECT_EQ(2, message.map_fixed64_fixed64().at(1));
|
| 462 |
+
EXPECT_EQ(2, message.map_sfixed32_sfixed32().at(1));
|
| 463 |
+
EXPECT_EQ(2, message.map_sfixed64_sfixed64().at(1));
|
| 464 |
+
EXPECT_EQ(2, message.map_int32_float().at(1));
|
| 465 |
+
EXPECT_EQ(2, message.map_int32_double().at(1));
|
| 466 |
+
EXPECT_EQ(false, message.map_bool_bool().at(1));
|
| 467 |
+
EXPECT_EQ("2", message.map_string_string().at("1"));
|
| 468 |
+
EXPECT_EQ("2", message.map_int32_bytes().at(1));
|
| 469 |
+
EXPECT_EQ(enum_value1, message.map_int32_enum().at(1));
|
| 470 |
+
EXPECT_EQ(2, message.map_int32_foreign_message().at(1).c());
|
| 471 |
+
}
|
| 472 |
+
|
| 473 |
+
} // namespace protobuf
|
| 474 |
+
} // namespace google
|
| 475 |
+
|
| 476 |
+
#endif // GOOGLE_PROTOBUF_MAP_TEST_UTIL_IMPL_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/message_unittest.inc
ADDED
|
@@ -0,0 +1,1131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// Author: kenton@google.com (Kenton Varda)
|
| 32 |
+
// Based on original Protocol Buffers design by
|
| 33 |
+
// Sanjay Ghemawat, Jeff Dean, and others.
|
| 34 |
+
//
|
| 35 |
+
// This file needs to be included as .inc as it depends on certain macros being
|
| 36 |
+
// defined prior to its inclusion.
|
| 37 |
+
|
| 38 |
+
#include <fcntl.h>
|
| 39 |
+
#include <sys/stat.h>
|
| 40 |
+
#include <sys/types.h>
|
| 41 |
+
|
| 42 |
+
#include <cmath>
|
| 43 |
+
#include <limits>
|
| 44 |
+
|
| 45 |
+
#include <google/protobuf/message.h>
|
| 46 |
+
#ifndef _MSC_VER
|
| 47 |
+
#include <unistd.h>
|
| 48 |
+
#endif
|
| 49 |
+
#include <fstream>
|
| 50 |
+
#include <sstream>
|
| 51 |
+
|
| 52 |
+
#include <google/protobuf/stubs/logging.h>
|
| 53 |
+
#include <google/protobuf/stubs/common.h>
|
| 54 |
+
#include <google/protobuf/descriptor.pb.h>
|
| 55 |
+
#include <gmock/gmock.h>
|
| 56 |
+
#include <google/protobuf/testing/googletest.h>
|
| 57 |
+
#include <gtest/gtest.h>
|
| 58 |
+
#include <google/protobuf/stubs/logging.h>
|
| 59 |
+
#include <google/protobuf/stubs/substitute.h>
|
| 60 |
+
#include <google/protobuf/arena.h>
|
| 61 |
+
#include <google/protobuf/descriptor.h>
|
| 62 |
+
#include <google/protobuf/io/io_win32.h>
|
| 63 |
+
#include <google/protobuf/generated_message_reflection.h>
|
| 64 |
+
#include <google/protobuf/io/coded_stream.h>
|
| 65 |
+
#include <google/protobuf/io/zero_copy_stream.h>
|
| 66 |
+
#include <google/protobuf/io/zero_copy_stream_impl.h>
|
| 67 |
+
#include <google/protobuf/test_util2.h>
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
namespace google {
|
| 71 |
+
namespace protobuf {
|
| 72 |
+
|
| 73 |
+
#if defined(_WIN32)
|
| 74 |
+
// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import
|
| 75 |
+
// them like we do below.
|
| 76 |
+
using google::protobuf::io::win32::close;
|
| 77 |
+
using google::protobuf::io::win32::open;
|
| 78 |
+
#endif
|
| 79 |
+
|
| 80 |
+
#ifndef O_BINARY
|
| 81 |
+
#ifdef _O_BINARY
|
| 82 |
+
#define O_BINARY _O_BINARY
|
| 83 |
+
#else
|
| 84 |
+
#define O_BINARY 0 // If this isn't defined, the platform doesn't need it.
|
| 85 |
+
#endif
|
| 86 |
+
#endif
|
| 87 |
+
|
| 88 |
+
TEST(MESSAGE_TEST_NAME, SerializeHelpers) {
|
| 89 |
+
// TODO(kenton): Test more helpers? They're all two-liners so it seems
|
| 90 |
+
// like a waste of time.
|
| 91 |
+
|
| 92 |
+
UNITTEST::TestAllTypes message;
|
| 93 |
+
TestUtil::SetAllFields(&message);
|
| 94 |
+
std::stringstream stream;
|
| 95 |
+
|
| 96 |
+
std::string str1("foo");
|
| 97 |
+
std::string str2("bar");
|
| 98 |
+
|
| 99 |
+
EXPECT_TRUE(message.SerializeToString(&str1));
|
| 100 |
+
EXPECT_TRUE(message.AppendToString(&str2));
|
| 101 |
+
EXPECT_TRUE(message.SerializeToOstream(&stream));
|
| 102 |
+
|
| 103 |
+
EXPECT_EQ(str1.size() + 3, str2.size());
|
| 104 |
+
EXPECT_EQ("bar", str2.substr(0, 3));
|
| 105 |
+
// Don't use EXPECT_EQ because we don't want to dump raw binary data to
|
| 106 |
+
// stdout.
|
| 107 |
+
EXPECT_TRUE(str2.substr(3) == str1);
|
| 108 |
+
|
| 109 |
+
// GCC gives some sort of error if we try to just do stream.str() == str1.
|
| 110 |
+
std::string temp = stream.str();
|
| 111 |
+
EXPECT_TRUE(temp == str1);
|
| 112 |
+
|
| 113 |
+
EXPECT_TRUE(message.SerializeAsString() == str1);
|
| 114 |
+
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
TEST(MESSAGE_TEST_NAME, SerializeToBrokenOstream) {
|
| 118 |
+
std::ofstream out;
|
| 119 |
+
UNITTEST::TestAllTypes message;
|
| 120 |
+
message.set_optional_int32(123);
|
| 121 |
+
|
| 122 |
+
EXPECT_FALSE(message.SerializeToOstream(&out));
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
TEST(MESSAGE_TEST_NAME, ParseFromFileDescriptor) {
|
| 126 |
+
std::string filename =
|
| 127 |
+
TestUtil::GetTestDataPath("net/proto2/internal/testdata/golden_message");
|
| 128 |
+
int file = open(filename.c_str(), O_RDONLY | O_BINARY);
|
| 129 |
+
ASSERT_GE(file, 0);
|
| 130 |
+
|
| 131 |
+
UNITTEST::TestAllTypes message;
|
| 132 |
+
EXPECT_TRUE(message.ParseFromFileDescriptor(file));
|
| 133 |
+
TestUtil::ExpectAllFieldsSet(message);
|
| 134 |
+
|
| 135 |
+
EXPECT_GE(close(file), 0);
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
TEST(MESSAGE_TEST_NAME, ParsePackedFromFileDescriptor) {
|
| 139 |
+
std::string filename = TestUtil::GetTestDataPath(
|
| 140 |
+
"net/proto2/internal/testdata/golden_packed_fields_message");
|
| 141 |
+
int file = open(filename.c_str(), O_RDONLY | O_BINARY);
|
| 142 |
+
ASSERT_GE(file, 0);
|
| 143 |
+
|
| 144 |
+
UNITTEST::TestPackedTypes message;
|
| 145 |
+
EXPECT_TRUE(message.ParseFromFileDescriptor(file));
|
| 146 |
+
TestUtil::ExpectPackedFieldsSet(message);
|
| 147 |
+
|
| 148 |
+
EXPECT_GE(close(file), 0);
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
TEST(MESSAGE_TEST_NAME, ParseHelpers) {
|
| 152 |
+
// TODO(kenton): Test more helpers? They're all two-liners so it seems
|
| 153 |
+
// like a waste of time.
|
| 154 |
+
std::string data;
|
| 155 |
+
|
| 156 |
+
{
|
| 157 |
+
// Set up.
|
| 158 |
+
UNITTEST::TestAllTypes message;
|
| 159 |
+
TestUtil::SetAllFields(&message);
|
| 160 |
+
message.SerializeToString(&data);
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
{
|
| 164 |
+
// Test ParseFromString.
|
| 165 |
+
UNITTEST::TestAllTypes message;
|
| 166 |
+
EXPECT_TRUE(message.ParseFromString(data));
|
| 167 |
+
TestUtil::ExpectAllFieldsSet(message);
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
{
|
| 171 |
+
// Test ParseFromIstream.
|
| 172 |
+
UNITTEST::TestAllTypes message;
|
| 173 |
+
std::stringstream stream(data);
|
| 174 |
+
EXPECT_TRUE(message.ParseFromIstream(&stream));
|
| 175 |
+
EXPECT_TRUE(stream.eof());
|
| 176 |
+
TestUtil::ExpectAllFieldsSet(message);
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
{
|
| 180 |
+
// Test ParseFromBoundedZeroCopyStream.
|
| 181 |
+
std::string data_with_junk(data);
|
| 182 |
+
data_with_junk.append("some junk on the end");
|
| 183 |
+
io::ArrayInputStream stream(data_with_junk.data(), data_with_junk.size());
|
| 184 |
+
UNITTEST::TestAllTypes message;
|
| 185 |
+
EXPECT_TRUE(message.ParseFromBoundedZeroCopyStream(&stream, data.size()));
|
| 186 |
+
TestUtil::ExpectAllFieldsSet(message);
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
{
|
| 190 |
+
// Test that ParseFromBoundedZeroCopyStream fails (but doesn't crash) if
|
| 191 |
+
// EOF is reached before the expected number of bytes.
|
| 192 |
+
io::ArrayInputStream stream(data.data(), data.size());
|
| 193 |
+
UNITTEST::TestAllTypes message;
|
| 194 |
+
EXPECT_FALSE(
|
| 195 |
+
message.ParseFromBoundedZeroCopyStream(&stream, data.size() + 1));
|
| 196 |
+
}
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
TEST(MESSAGE_TEST_NAME, ParseFailsIfNotInitialized) {
|
| 200 |
+
UNITTEST::TestRequired message;
|
| 201 |
+
std::vector<std::string> errors;
|
| 202 |
+
|
| 203 |
+
{
|
| 204 |
+
ScopedMemoryLog log;
|
| 205 |
+
EXPECT_FALSE(message.ParseFromString(""));
|
| 206 |
+
errors = log.GetMessages(ERROR);
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
ASSERT_EQ(1, errors.size());
|
| 210 |
+
EXPECT_EQ(
|
| 211 |
+
"Can't parse message of type \"" + std::string(UNITTEST_PACKAGE_NAME) +
|
| 212 |
+
".TestRequired\" because it is missing required fields: a, b, c",
|
| 213 |
+
errors[0]);
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
TEST(MESSAGE_TEST_NAME, ParseFailsIfSubmessageNotInitialized) {
|
| 217 |
+
UNITTEST::TestRequiredForeign source, message;
|
| 218 |
+
source.mutable_optional_message()->set_dummy2(100);
|
| 219 |
+
std::string serialized = source.SerializePartialAsString();
|
| 220 |
+
|
| 221 |
+
EXPECT_TRUE(message.ParsePartialFromString(serialized));
|
| 222 |
+
EXPECT_FALSE(message.IsInitialized());
|
| 223 |
+
|
| 224 |
+
std::vector<std::string> errors;
|
| 225 |
+
{
|
| 226 |
+
ScopedMemoryLog log;
|
| 227 |
+
EXPECT_FALSE(message.ParseFromString(source.SerializePartialAsString()));
|
| 228 |
+
errors = log.GetMessages(ERROR);
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
EXPECT_THAT(
|
| 232 |
+
errors,
|
| 233 |
+
testing::ElementsAre(
|
| 234 |
+
"Can't parse message of type \"" +
|
| 235 |
+
std::string(UNITTEST_PACKAGE_NAME) +
|
| 236 |
+
".TestRequiredForeign\" because it is missing required fields: "
|
| 237 |
+
"optional_message.a, optional_message.b, optional_message.c"));
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
TEST(MESSAGE_TEST_NAME, ParseFailsIfExtensionNotInitialized) {
|
| 241 |
+
UNITTEST::TestChildExtension source, message;
|
| 242 |
+
auto* r = source.mutable_optional_extension()->MutableExtension(
|
| 243 |
+
UNITTEST::TestRequired::single);
|
| 244 |
+
r->set_dummy2(100);
|
| 245 |
+
std::string serialized = source.SerializePartialAsString();
|
| 246 |
+
|
| 247 |
+
EXPECT_TRUE(message.ParsePartialFromString(serialized));
|
| 248 |
+
EXPECT_FALSE(message.IsInitialized());
|
| 249 |
+
|
| 250 |
+
std::vector<std::string> errors;
|
| 251 |
+
{
|
| 252 |
+
ScopedMemoryLog log;
|
| 253 |
+
EXPECT_FALSE(message.ParseFromString(source.SerializePartialAsString()));
|
| 254 |
+
errors = log.GetMessages(ERROR);
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
EXPECT_THAT(errors,
|
| 258 |
+
testing::ElementsAre(strings::Substitute(
|
| 259 |
+
"Can't parse message of type \"$0.TestChildExtension\" "
|
| 260 |
+
"because it is missing required fields: "
|
| 261 |
+
"optional_extension.($0.TestRequired.single).a, "
|
| 262 |
+
"optional_extension.($0.TestRequired.single).b, "
|
| 263 |
+
"optional_extension.($0.TestRequired.single).c",
|
| 264 |
+
UNITTEST_PACKAGE_NAME)));
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
TEST(MESSAGE_TEST_NAME, MergeFromUninitialized) {
|
| 268 |
+
UNITTEST::TestNestedRequiredForeign o, p, q;
|
| 269 |
+
UNITTEST::TestNestedRequiredForeign* child = o.mutable_child();
|
| 270 |
+
constexpr int kDepth = 2;
|
| 271 |
+
for (int i = 0; i < kDepth; i++) {
|
| 272 |
+
child->set_dummy(i);
|
| 273 |
+
child = child->mutable_child();
|
| 274 |
+
}
|
| 275 |
+
UNITTEST::TestRequiredForeign* payload = child->mutable_payload();
|
| 276 |
+
payload->mutable_optional_message()->set_a(1);
|
| 277 |
+
payload->mutable_optional_message()->set_dummy2(100);
|
| 278 |
+
payload->mutable_optional_message()->set_dummy4(200);
|
| 279 |
+
ASSERT_TRUE(p.ParsePartialFromString(o.SerializePartialAsString()));
|
| 280 |
+
|
| 281 |
+
q.mutable_child()->set_dummy(500);
|
| 282 |
+
q = p;
|
| 283 |
+
q.ParsePartialFromString(q.SerializePartialAsString());
|
| 284 |
+
EXPECT_TRUE(TestUtil::EqualsToSerialized(q, o.SerializePartialAsString()));
|
| 285 |
+
EXPECT_TRUE(TestUtil::EqualsToSerialized(q, p.SerializePartialAsString()));
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
TEST(MESSAGE_TEST_NAME, ExplicitLazyExceedRecursionLimit) {
|
| 289 |
+
UNITTEST::NestedTestAllTypes original, parsed;
|
| 290 |
+
// Build proto with recursion depth of 3.
|
| 291 |
+
original.mutable_lazy_child()
|
| 292 |
+
->mutable_child()
|
| 293 |
+
->mutable_payload()
|
| 294 |
+
->set_optional_int32(-1);
|
| 295 |
+
std::string serialized;
|
| 296 |
+
EXPECT_TRUE(original.SerializeToString(&serialized));
|
| 297 |
+
|
| 298 |
+
// User annotated LazyField ([lazy = true]) is eagerly verified and should
|
| 299 |
+
// catch the recursion limit violation.
|
| 300 |
+
io::ArrayInputStream array_stream(serialized.data(), serialized.size());
|
| 301 |
+
io::CodedInputStream input_stream(&array_stream);
|
| 302 |
+
input_stream.SetRecursionLimit(2);
|
| 303 |
+
EXPECT_FALSE(parsed.ParseFromCodedStream(&input_stream));
|
| 304 |
+
|
| 305 |
+
// Lazy read results in parsing error which can be verified by not having
|
| 306 |
+
// expected value.
|
| 307 |
+
EXPECT_NE(parsed.lazy_child().child().payload().optional_int32(), -1);
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
TEST(MESSAGE_TEST_NAME, NestedExplicitLazyExceedRecursionLimit) {
|
| 311 |
+
UNITTEST::NestedTestAllTypes original, parsed;
|
| 312 |
+
// Build proto with recursion depth of 5, with nested annotated LazyField.
|
| 313 |
+
original.mutable_lazy_child()
|
| 314 |
+
->mutable_child()
|
| 315 |
+
->mutable_lazy_child()
|
| 316 |
+
->mutable_child()
|
| 317 |
+
->mutable_payload()
|
| 318 |
+
->set_optional_int32(-1);
|
| 319 |
+
std::string serialized;
|
| 320 |
+
EXPECT_TRUE(original.SerializeToString(&serialized));
|
| 321 |
+
|
| 322 |
+
// User annotated LazyField ([lazy = true]) is eagerly verified and should
|
| 323 |
+
// catch the recursion limit violation.
|
| 324 |
+
io::ArrayInputStream array_stream(serialized.data(), serialized.size());
|
| 325 |
+
io::CodedInputStream input_stream(&array_stream);
|
| 326 |
+
input_stream.SetRecursionLimit(4);
|
| 327 |
+
EXPECT_FALSE(parsed.ParseFromCodedStream(&input_stream));
|
| 328 |
+
|
| 329 |
+
// Lazy read results in parsing error which can be verified by not having
|
| 330 |
+
// expected value.
|
| 331 |
+
EXPECT_NE(parsed.lazy_child()
|
| 332 |
+
.child()
|
| 333 |
+
.lazy_child()
|
| 334 |
+
.child()
|
| 335 |
+
.payload()
|
| 336 |
+
.optional_int32(),
|
| 337 |
+
-1);
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
TEST(MESSAGE_TEST_NAME, ParseFailsIfSubmessageTruncated) {
|
| 341 |
+
UNITTEST::NestedTestAllTypes o, p;
|
| 342 |
+
constexpr int kDepth = 5;
|
| 343 |
+
auto* child = o.mutable_child();
|
| 344 |
+
for (int i = 0; i < kDepth; i++) {
|
| 345 |
+
child = child->mutable_child();
|
| 346 |
+
}
|
| 347 |
+
TestUtil::SetAllFields(child->mutable_payload());
|
| 348 |
+
|
| 349 |
+
std::string serialized;
|
| 350 |
+
EXPECT_TRUE(o.SerializeToString(&serialized));
|
| 351 |
+
|
| 352 |
+
// Should parse correctly.
|
| 353 |
+
EXPECT_TRUE(p.ParseFromString(serialized));
|
| 354 |
+
|
| 355 |
+
constexpr int kMaxTruncate = 50;
|
| 356 |
+
ASSERT_GT(serialized.size(), kMaxTruncate);
|
| 357 |
+
|
| 358 |
+
for (int i = 1; i < kMaxTruncate; i += 3) {
|
| 359 |
+
EXPECT_FALSE(
|
| 360 |
+
p.ParseFromString(serialized.substr(0, serialized.size() - i)));
|
| 361 |
+
}
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
TEST(MESSAGE_TEST_NAME, ParseFailsIfWireMalformed) {
|
| 365 |
+
UNITTEST::NestedTestAllTypes o, p;
|
| 366 |
+
constexpr int kDepth = 5;
|
| 367 |
+
auto* child = o.mutable_child();
|
| 368 |
+
for (int i = 0; i < kDepth; i++) {
|
| 369 |
+
child = child->mutable_child();
|
| 370 |
+
}
|
| 371 |
+
// -1 becomes \xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x1
|
| 372 |
+
child->mutable_payload()->set_optional_int32(-1);
|
| 373 |
+
|
| 374 |
+
std::string serialized;
|
| 375 |
+
EXPECT_TRUE(o.SerializeToString(&serialized));
|
| 376 |
+
|
| 377 |
+
// Should parse correctly.
|
| 378 |
+
EXPECT_TRUE(p.ParseFromString(serialized));
|
| 379 |
+
|
| 380 |
+
// Overwriting the last byte to 0xFF results in malformed wire.
|
| 381 |
+
serialized[serialized.size() - 1] = 0xFF;
|
| 382 |
+
EXPECT_FALSE(p.ParseFromString(serialized));
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
TEST(MESSAGE_TEST_NAME, ParseFailsIfOneofWireMalformed) {
|
| 386 |
+
UNITTEST::NestedTestAllTypes o, p;
|
| 387 |
+
constexpr int kDepth = 5;
|
| 388 |
+
auto* child = o.mutable_child();
|
| 389 |
+
for (int i = 0; i < kDepth; i++) {
|
| 390 |
+
child = child->mutable_child();
|
| 391 |
+
}
|
| 392 |
+
// -1 becomes \xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x1
|
| 393 |
+
child->mutable_payload()->mutable_oneof_nested_message()->set_bb(-1);
|
| 394 |
+
|
| 395 |
+
std::string serialized;
|
| 396 |
+
EXPECT_TRUE(o.SerializeToString(&serialized));
|
| 397 |
+
|
| 398 |
+
// Should parse correctly.
|
| 399 |
+
EXPECT_TRUE(p.ParseFromString(serialized));
|
| 400 |
+
|
| 401 |
+
// Overwriting the last byte to 0xFF results in malformed wire.
|
| 402 |
+
serialized[serialized.size() - 1] = 0xFF;
|
| 403 |
+
EXPECT_FALSE(p.ParseFromString(serialized));
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
TEST(MESSAGE_TEST_NAME, ParseFailsIfExtensionWireMalformed) {
|
| 407 |
+
UNITTEST::TestChildExtension o, p;
|
| 408 |
+
auto* m = o.mutable_optional_extension()->MutableExtension(
|
| 409 |
+
UNITTEST::optional_nested_message_extension);
|
| 410 |
+
|
| 411 |
+
// -1 becomes \xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x1
|
| 412 |
+
m->set_bb(-1);
|
| 413 |
+
|
| 414 |
+
std::string serialized;
|
| 415 |
+
EXPECT_TRUE(o.SerializeToString(&serialized));
|
| 416 |
+
|
| 417 |
+
// Should parse correctly.
|
| 418 |
+
EXPECT_TRUE(p.ParseFromString(serialized));
|
| 419 |
+
|
| 420 |
+
// Overwriting the last byte to 0xFF results in malformed wire.
|
| 421 |
+
serialized[serialized.size() - 1] = 0xFF;
|
| 422 |
+
EXPECT_FALSE(p.ParseFromString(serialized));
|
| 423 |
+
}
|
| 424 |
+
|
| 425 |
+
TEST(MESSAGE_TEST_NAME, UninitializedAndMalformed) {
|
| 426 |
+
UNITTEST::TestRequiredForeign o, p1, p2;
|
| 427 |
+
o.mutable_optional_message()->set_a(-1);
|
| 428 |
+
|
| 429 |
+
// -1 becomes \xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x1
|
| 430 |
+
std::string serialized;
|
| 431 |
+
EXPECT_TRUE(o.SerializePartialToString(&serialized));
|
| 432 |
+
|
| 433 |
+
// Should parse correctly.
|
| 434 |
+
EXPECT_TRUE(p1.ParsePartialFromString(serialized));
|
| 435 |
+
EXPECT_FALSE(p1.IsInitialized());
|
| 436 |
+
|
| 437 |
+
// Overwriting the last byte to 0xFF results in malformed wire.
|
| 438 |
+
serialized[serialized.size() - 1] = 0xFF;
|
| 439 |
+
EXPECT_FALSE(p2.ParseFromString(serialized));
|
| 440 |
+
EXPECT_FALSE(p2.IsInitialized());
|
| 441 |
+
}
|
| 442 |
+
|
| 443 |
+
inline UNITTEST::NestedTestAllTypes InitNestedProto(int depth) {
|
| 444 |
+
UNITTEST::NestedTestAllTypes p;
|
| 445 |
+
auto* child = p.mutable_child();
|
| 446 |
+
for (int i = 0; i < depth; i++) {
|
| 447 |
+
child->mutable_payload()->set_optional_int32(i);
|
| 448 |
+
child = child->mutable_child();
|
| 449 |
+
}
|
| 450 |
+
// -1 becomes \xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x1
|
| 451 |
+
child->mutable_payload()->set_optional_int32(-1);
|
| 452 |
+
return p;
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
// Parsing proto must not access beyond the bound.
|
| 456 |
+
TEST(MESSAGE_TEST_NAME, ParseStrictlyBoundedStream) {
|
| 457 |
+
UNITTEST::NestedTestAllTypes o, p;
|
| 458 |
+
constexpr int kDepth = 2;
|
| 459 |
+
o = InitNestedProto(kDepth);
|
| 460 |
+
TestUtil::SetAllFields(o.mutable_child()->mutable_payload());
|
| 461 |
+
o.mutable_child()->mutable_child()->mutable_payload()->set_optional_string(
|
| 462 |
+
std::string(1024, 'a'));
|
| 463 |
+
|
| 464 |
+
std::string data;
|
| 465 |
+
EXPECT_TRUE(o.SerializeToString(&data));
|
| 466 |
+
|
| 467 |
+
TestUtil::BoundedArrayInputStream stream(data.data(), data.size());
|
| 468 |
+
EXPECT_TRUE(p.ParseFromBoundedZeroCopyStream(&stream, data.size()));
|
| 469 |
+
TestUtil::ExpectAllFieldsSet(p.child().payload());
|
| 470 |
+
}
|
| 471 |
+
|
| 472 |
+
TEST(MESSAGE_TEST_NAME, AllSetMethodsOnStringField) {
|
| 473 |
+
UNITTEST::TestAllTypes msg;
|
| 474 |
+
|
| 475 |
+
|
| 476 |
+
msg.set_optional_string("Asciiz");
|
| 477 |
+
EXPECT_EQ(msg.optional_string(), "Asciiz");
|
| 478 |
+
|
| 479 |
+
msg.set_optional_string("Length delimited", 6);
|
| 480 |
+
EXPECT_EQ(msg.optional_string(), "Length");
|
| 481 |
+
|
| 482 |
+
std::string value = "std::string value 1";
|
| 483 |
+
msg.set_optional_string(value);
|
| 484 |
+
EXPECT_EQ(msg.optional_string(), "std::string value 1");
|
| 485 |
+
|
| 486 |
+
value = "std::string value 2";
|
| 487 |
+
msg.set_optional_string(std::cref(value));
|
| 488 |
+
EXPECT_EQ(msg.optional_string(), "std::string value 2");
|
| 489 |
+
|
| 490 |
+
value = "std::string value 3";
|
| 491 |
+
msg.set_optional_string(std::move(value));
|
| 492 |
+
EXPECT_EQ(msg.optional_string(), "std::string value 3");
|
| 493 |
+
}
|
| 494 |
+
|
| 495 |
+
TEST(MESSAGE_TEST_NAME, SuccessAfterParsingFailure) {
|
| 496 |
+
UNITTEST::NestedTestAllTypes o, p, q;
|
| 497 |
+
constexpr int kDepth = 5;
|
| 498 |
+
o = InitNestedProto(kDepth);
|
| 499 |
+
std::string serialized;
|
| 500 |
+
EXPECT_TRUE(o.SerializeToString(&serialized));
|
| 501 |
+
|
| 502 |
+
// Should parse correctly.
|
| 503 |
+
EXPECT_TRUE(p.ParseFromString(serialized));
|
| 504 |
+
|
| 505 |
+
// Overwriting the last byte to 0xFF results in malformed wire.
|
| 506 |
+
serialized[serialized.size() - 1] = 0xFF;
|
| 507 |
+
EXPECT_FALSE(p.ParseFromString(serialized));
|
| 508 |
+
|
| 509 |
+
// Subsequent serialization should be parsed correctly.
|
| 510 |
+
EXPECT_TRUE(q.ParseFromString(p.SerializeAsString()));
|
| 511 |
+
}
|
| 512 |
+
|
| 513 |
+
TEST(MESSAGE_TEST_NAME, ExceedRecursionLimit) {
|
| 514 |
+
UNITTEST::NestedTestAllTypes o, p;
|
| 515 |
+
const int kDepth = io::CodedInputStream::GetDefaultRecursionLimit() + 10;
|
| 516 |
+
o = InitNestedProto(kDepth);
|
| 517 |
+
std::string serialized;
|
| 518 |
+
EXPECT_TRUE(o.SerializeToString(&serialized));
|
| 519 |
+
|
| 520 |
+
// Recursion level deeper than the default.
|
| 521 |
+
EXPECT_FALSE(p.ParseFromString(serialized));
|
| 522 |
+
}
|
| 523 |
+
|
| 524 |
+
TEST(MESSAGE_TEST_NAME, SupportCustomRecursionLimitRead) {
|
| 525 |
+
UNITTEST::NestedTestAllTypes o, p;
|
| 526 |
+
const int kDepth = io::CodedInputStream::GetDefaultRecursionLimit() + 10;
|
| 527 |
+
o = InitNestedProto(kDepth);
|
| 528 |
+
std::string serialized;
|
| 529 |
+
EXPECT_TRUE(o.SerializeToString(&serialized));
|
| 530 |
+
|
| 531 |
+
// Should pass with custom limit + reads.
|
| 532 |
+
io::ArrayInputStream raw_input(serialized.data(), serialized.size());
|
| 533 |
+
io::CodedInputStream input(&raw_input);
|
| 534 |
+
input.SetRecursionLimit(kDepth + 10);
|
| 535 |
+
EXPECT_TRUE(p.ParseFromCodedStream(&input));
|
| 536 |
+
|
| 537 |
+
EXPECT_EQ(p.child().payload().optional_int32(), 0);
|
| 538 |
+
EXPECT_EQ(p.child().child().payload().optional_int32(), 1);
|
| 539 |
+
|
| 540 |
+
// Verify p serializes successfully (survives VerifyConsistency).
|
| 541 |
+
std::string result;
|
| 542 |
+
EXPECT_TRUE(p.SerializeToString(&result));
|
| 543 |
+
}
|
| 544 |
+
|
| 545 |
+
TEST(MESSAGE_TEST_NAME, SupportCustomRecursionLimitWrite) {
|
| 546 |
+
UNITTEST::NestedTestAllTypes o, p;
|
| 547 |
+
const int kDepth = io::CodedInputStream::GetDefaultRecursionLimit() + 10;
|
| 548 |
+
o = InitNestedProto(kDepth);
|
| 549 |
+
std::string serialized;
|
| 550 |
+
EXPECT_TRUE(o.SerializeToString(&serialized));
|
| 551 |
+
|
| 552 |
+
// Should pass with custom limit + writes.
|
| 553 |
+
io::ArrayInputStream raw_input(serialized.data(), serialized.size());
|
| 554 |
+
io::CodedInputStream input(&raw_input);
|
| 555 |
+
input.SetRecursionLimit(kDepth + 10);
|
| 556 |
+
EXPECT_TRUE(p.ParseFromCodedStream(&input));
|
| 557 |
+
|
| 558 |
+
EXPECT_EQ(p.mutable_child()->mutable_payload()->optional_int32(), 0);
|
| 559 |
+
EXPECT_EQ(
|
| 560 |
+
p.mutable_child()->mutable_child()->mutable_payload()->optional_int32(),
|
| 561 |
+
1);
|
| 562 |
+
}
|
| 563 |
+
|
| 564 |
+
// While deep recursion is never guaranteed, this test aims to catch potential
|
| 565 |
+
// issues with very deep recursion.
|
| 566 |
+
TEST(MESSAGE_TEST_NAME, SupportDeepRecursionLimit) {
|
| 567 |
+
UNITTEST::NestedTestAllTypes o, p;
|
| 568 |
+
constexpr int kDepth = 1000;
|
| 569 |
+
auto* child = o.mutable_child();
|
| 570 |
+
for (int i = 0; i < kDepth; i++) {
|
| 571 |
+
child = child->mutable_child();
|
| 572 |
+
}
|
| 573 |
+
child->mutable_payload()->set_optional_int32(100);
|
| 574 |
+
|
| 575 |
+
std::string serialized;
|
| 576 |
+
EXPECT_TRUE(o.SerializeToString(&serialized));
|
| 577 |
+
|
| 578 |
+
io::ArrayInputStream raw_input(serialized.data(), serialized.size());
|
| 579 |
+
io::CodedInputStream input(&raw_input);
|
| 580 |
+
input.SetRecursionLimit(1100);
|
| 581 |
+
EXPECT_TRUE(p.ParseFromCodedStream(&input));
|
| 582 |
+
}
|
| 583 |
+
|
| 584 |
+
TEST(MESSAGE_TEST_NAME, Swap) {
|
| 585 |
+
UNITTEST::NestedTestAllTypes o;
|
| 586 |
+
constexpr int kDepth = 5;
|
| 587 |
+
auto* child = o.mutable_child();
|
| 588 |
+
for (int i = 0; i < kDepth; i++) {
|
| 589 |
+
child = child->mutable_child();
|
| 590 |
+
}
|
| 591 |
+
TestUtil::SetAllFields(child->mutable_payload());
|
| 592 |
+
|
| 593 |
+
std::string serialized;
|
| 594 |
+
EXPECT_TRUE(o.SerializeToString(&serialized));
|
| 595 |
+
|
| 596 |
+
{
|
| 597 |
+
Arena arena;
|
| 598 |
+
UNITTEST::NestedTestAllTypes* p1 =
|
| 599 |
+
Arena::CreateMessage<UNITTEST::NestedTestAllTypes>(&arena);
|
| 600 |
+
|
| 601 |
+
// Should parse correctly.
|
| 602 |
+
EXPECT_TRUE(p1->ParseFromString(serialized));
|
| 603 |
+
|
| 604 |
+
UNITTEST::NestedTestAllTypes* p2 =
|
| 605 |
+
Arena::CreateMessage<UNITTEST::NestedTestAllTypes>(&arena);
|
| 606 |
+
|
| 607 |
+
p1->Swap(p2);
|
| 608 |
+
|
| 609 |
+
EXPECT_EQ(o.SerializeAsString(), p2->SerializeAsString());
|
| 610 |
+
}
|
| 611 |
+
}
|
| 612 |
+
|
| 613 |
+
TEST(MESSAGE_TEST_NAME, BypassInitializationCheckOnParse) {
|
| 614 |
+
UNITTEST::TestRequired message;
|
| 615 |
+
io::ArrayInputStream raw_input(nullptr, 0);
|
| 616 |
+
io::CodedInputStream input(&raw_input);
|
| 617 |
+
EXPECT_TRUE(message.MergePartialFromCodedStream(&input));
|
| 618 |
+
}
|
| 619 |
+
|
| 620 |
+
TEST(MESSAGE_TEST_NAME, InitializationErrorString) {
|
| 621 |
+
UNITTEST::TestRequired message;
|
| 622 |
+
EXPECT_EQ("a, b, c", message.InitializationErrorString());
|
| 623 |
+
}
|
| 624 |
+
|
| 625 |
+
TEST(MESSAGE_TEST_NAME, DynamicCastToGenerated) {
|
| 626 |
+
UNITTEST::TestAllTypes test_all_types;
|
| 627 |
+
|
| 628 |
+
Message* test_all_types_pointer = &test_all_types;
|
| 629 |
+
EXPECT_EQ(&test_all_types, DynamicCastToGenerated<UNITTEST::TestAllTypes>(
|
| 630 |
+
test_all_types_pointer));
|
| 631 |
+
EXPECT_EQ(nullptr, DynamicCastToGenerated<UNITTEST::TestRequired>(
|
| 632 |
+
test_all_types_pointer));
|
| 633 |
+
|
| 634 |
+
const Message* test_all_types_pointer_const = &test_all_types;
|
| 635 |
+
EXPECT_EQ(&test_all_types,
|
| 636 |
+
DynamicCastToGenerated<const UNITTEST::TestAllTypes>(
|
| 637 |
+
test_all_types_pointer_const));
|
| 638 |
+
EXPECT_EQ(nullptr, DynamicCastToGenerated<const UNITTEST::TestRequired>(
|
| 639 |
+
test_all_types_pointer_const));
|
| 640 |
+
|
| 641 |
+
Message* test_all_types_pointer_nullptr = nullptr;
|
| 642 |
+
EXPECT_EQ(nullptr, DynamicCastToGenerated<UNITTEST::TestAllTypes>(
|
| 643 |
+
test_all_types_pointer_nullptr));
|
| 644 |
+
}
|
| 645 |
+
|
| 646 |
+
#ifdef PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet.
|
| 647 |
+
|
| 648 |
+
TEST(MESSAGE_TEST_NAME, SerializeFailsIfNotInitialized) {
|
| 649 |
+
UNITTEST::TestRequired message;
|
| 650 |
+
std::string data;
|
| 651 |
+
EXPECT_DEBUG_DEATH(EXPECT_TRUE(message.SerializeToString(&data)),
|
| 652 |
+
"Can't serialize message of type \"" +
|
| 653 |
+
std::string(UNITTEST_PACKAGE_NAME) +
|
| 654 |
+
".TestRequired\" because "
|
| 655 |
+
"it is missing required fields: a, b, c");
|
| 656 |
+
}
|
| 657 |
+
|
| 658 |
+
TEST(MESSAGE_TEST_NAME, CheckInitialized) {
|
| 659 |
+
UNITTEST::TestRequired message;
|
| 660 |
+
EXPECT_DEATH(message.CheckInitialized(),
|
| 661 |
+
"Message of type \"" + std::string(UNITTEST_PACKAGE_NAME) +
|
| 662 |
+
".TestRequired\" is missing required "
|
| 663 |
+
"fields: a, b, c");
|
| 664 |
+
}
|
| 665 |
+
|
| 666 |
+
#endif // PROTOBUF_HAS_DEATH_TEST
|
| 667 |
+
|
| 668 |
+
namespace {
|
| 669 |
+
// An input stream that repeats a std::string's content for a number of times.
|
| 670 |
+
// It helps us create a really large input without consuming too much memory.
|
| 671 |
+
// Used to test the parsing behavior when the input size exceeds 2G or close to
|
| 672 |
+
// it.
|
| 673 |
+
class RepeatedInputStream : public io::ZeroCopyInputStream {
|
| 674 |
+
public:
|
| 675 |
+
RepeatedInputStream(const std::string& data, size_t count)
|
| 676 |
+
: data_(data), count_(count), position_(0), total_byte_count_(0) {}
|
| 677 |
+
|
| 678 |
+
bool Next(const void** data, int* size) override {
|
| 679 |
+
if (position_ == data_.size()) {
|
| 680 |
+
if (--count_ == 0) {
|
| 681 |
+
return false;
|
| 682 |
+
}
|
| 683 |
+
position_ = 0;
|
| 684 |
+
}
|
| 685 |
+
*data = &data_[position_];
|
| 686 |
+
*size = static_cast<int>(data_.size() - position_);
|
| 687 |
+
position_ = data_.size();
|
| 688 |
+
total_byte_count_ += *size;
|
| 689 |
+
return true;
|
| 690 |
+
}
|
| 691 |
+
|
| 692 |
+
void BackUp(int count) override {
|
| 693 |
+
position_ -= static_cast<size_t>(count);
|
| 694 |
+
total_byte_count_ -= count;
|
| 695 |
+
}
|
| 696 |
+
|
| 697 |
+
bool Skip(int count) override {
|
| 698 |
+
while (count > 0) {
|
| 699 |
+
const void* data;
|
| 700 |
+
int size;
|
| 701 |
+
if (!Next(&data, &size)) {
|
| 702 |
+
break;
|
| 703 |
+
}
|
| 704 |
+
if (size >= count) {
|
| 705 |
+
BackUp(size - count);
|
| 706 |
+
return true;
|
| 707 |
+
} else {
|
| 708 |
+
count -= size;
|
| 709 |
+
}
|
| 710 |
+
}
|
| 711 |
+
return false;
|
| 712 |
+
}
|
| 713 |
+
|
| 714 |
+
int64_t ByteCount() const override { return total_byte_count_; }
|
| 715 |
+
|
| 716 |
+
private:
|
| 717 |
+
std::string data_;
|
| 718 |
+
size_t count_; // The number of strings that haven't been consumed.
|
| 719 |
+
size_t position_; // Position in the std::string for the next read.
|
| 720 |
+
int64_t total_byte_count_;
|
| 721 |
+
};
|
| 722 |
+
} // namespace
|
| 723 |
+
|
| 724 |
+
TEST(MESSAGE_TEST_NAME, TestParseMessagesCloseTo2G) {
|
| 725 |
+
constexpr int32_t kint32max = std::numeric_limits<int32_t>::max();
|
| 726 |
+
|
| 727 |
+
// Create a message with a large std::string field.
|
| 728 |
+
std::string value = std::string(64 * 1024 * 1024, 'x');
|
| 729 |
+
UNITTEST::TestAllTypes message;
|
| 730 |
+
message.set_optional_string(value);
|
| 731 |
+
|
| 732 |
+
// Repeat this message in the input stream to make the total input size
|
| 733 |
+
// close to 2G.
|
| 734 |
+
std::string data = message.SerializeAsString();
|
| 735 |
+
size_t count = static_cast<size_t>(kint32max) / data.size();
|
| 736 |
+
RepeatedInputStream input(data, count);
|
| 737 |
+
|
| 738 |
+
// The parsing should succeed.
|
| 739 |
+
UNITTEST::TestAllTypes result;
|
| 740 |
+
EXPECT_TRUE(result.ParseFromZeroCopyStream(&input));
|
| 741 |
+
|
| 742 |
+
// When there are multiple occurrences of a singular field, the last one
|
| 743 |
+
// should win.
|
| 744 |
+
EXPECT_EQ(value, result.optional_string());
|
| 745 |
+
}
|
| 746 |
+
|
| 747 |
+
TEST(MESSAGE_TEST_NAME, TestParseMessagesOver2G) {
|
| 748 |
+
constexpr int32_t kint32max = std::numeric_limits<int32_t>::max();
|
| 749 |
+
|
| 750 |
+
// Create a message with a large std::string field.
|
| 751 |
+
std::string value = std::string(64 * 1024 * 1024, 'x');
|
| 752 |
+
UNITTEST::TestAllTypes message;
|
| 753 |
+
message.set_optional_string(value);
|
| 754 |
+
|
| 755 |
+
// Repeat this message in the input stream to make the total input size
|
| 756 |
+
// larger than 2G.
|
| 757 |
+
std::string data = message.SerializeAsString();
|
| 758 |
+
size_t count = static_cast<size_t>(kint32max) / data.size() + 1;
|
| 759 |
+
RepeatedInputStream input(data, count);
|
| 760 |
+
|
| 761 |
+
// The parsing should fail.
|
| 762 |
+
UNITTEST::TestAllTypes result;
|
| 763 |
+
EXPECT_FALSE(result.ParseFromZeroCopyStream(&input));
|
| 764 |
+
}
|
| 765 |
+
|
| 766 |
+
TEST(MESSAGE_TEST_NAME, BypassInitializationCheckOnSerialize) {
|
| 767 |
+
UNITTEST::TestRequired message;
|
| 768 |
+
io::ArrayOutputStream raw_output(nullptr, 0);
|
| 769 |
+
io::CodedOutputStream output(&raw_output);
|
| 770 |
+
EXPECT_TRUE(message.SerializePartialToCodedStream(&output));
|
| 771 |
+
}
|
| 772 |
+
|
| 773 |
+
TEST(MESSAGE_TEST_NAME, FindInitializationErrors) {
|
| 774 |
+
UNITTEST::TestRequired message;
|
| 775 |
+
std::vector<std::string> errors;
|
| 776 |
+
message.FindInitializationErrors(&errors);
|
| 777 |
+
ASSERT_EQ(3, errors.size());
|
| 778 |
+
EXPECT_EQ("a", errors[0]);
|
| 779 |
+
EXPECT_EQ("b", errors[1]);
|
| 780 |
+
EXPECT_EQ("c", errors[2]);
|
| 781 |
+
}
|
| 782 |
+
|
| 783 |
+
TEST(MESSAGE_TEST_NAME, ReleaseMustUseResult) {
|
| 784 |
+
UNITTEST::TestAllTypes message;
|
| 785 |
+
auto* f = new UNITTEST::ForeignMessage();
|
| 786 |
+
f->set_c(1000);
|
| 787 |
+
message.set_allocated_optional_foreign_message(f);
|
| 788 |
+
auto* mf = message.mutable_optional_foreign_message();
|
| 789 |
+
EXPECT_EQ(mf, f);
|
| 790 |
+
std::unique_ptr<UNITTEST::ForeignMessage> rf(
|
| 791 |
+
message.release_optional_foreign_message());
|
| 792 |
+
EXPECT_NE(rf.get(), nullptr);
|
| 793 |
+
}
|
| 794 |
+
|
| 795 |
+
TEST(MESSAGE_TEST_NAME, ParseFailsOnInvalidMessageEnd) {
|
| 796 |
+
UNITTEST::TestAllTypes message;
|
| 797 |
+
|
| 798 |
+
// Control case.
|
| 799 |
+
EXPECT_TRUE(message.ParseFromArray("", 0));
|
| 800 |
+
|
| 801 |
+
// The byte is a valid varint, but not a valid tag (zero).
|
| 802 |
+
EXPECT_FALSE(message.ParseFromArray("\0", 1));
|
| 803 |
+
|
| 804 |
+
// The byte is a malformed varint.
|
| 805 |
+
EXPECT_FALSE(message.ParseFromArray("\200", 1));
|
| 806 |
+
|
| 807 |
+
// The byte is an endgroup tag, but we aren't parsing a group.
|
| 808 |
+
EXPECT_FALSE(message.ParseFromArray("\014", 1));
|
| 809 |
+
}
|
| 810 |
+
|
| 811 |
+
// Regression test for b/23630858
|
| 812 |
+
TEST(MESSAGE_TEST_NAME, MessageIsStillValidAfterParseFails) {
|
| 813 |
+
UNITTEST::TestAllTypes message;
|
| 814 |
+
|
| 815 |
+
// 9 0xFFs for the "optional_uint64" field.
|
| 816 |
+
std::string invalid_data = "\x20\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF";
|
| 817 |
+
|
| 818 |
+
EXPECT_FALSE(message.ParseFromString(invalid_data));
|
| 819 |
+
message.Clear();
|
| 820 |
+
EXPECT_EQ(0, message.optional_uint64());
|
| 821 |
+
|
| 822 |
+
// invalid data for field "optional_string". Length prefix is 1 but no
|
| 823 |
+
// payload.
|
| 824 |
+
std::string invalid_string_data = "\x72\x01";
|
| 825 |
+
{
|
| 826 |
+
Arena arena;
|
| 827 |
+
UNITTEST::TestAllTypes* arena_message =
|
| 828 |
+
Arena::CreateMessage<UNITTEST::TestAllTypes>(&arena);
|
| 829 |
+
EXPECT_FALSE(arena_message->ParseFromString(invalid_string_data));
|
| 830 |
+
arena_message->Clear();
|
| 831 |
+
EXPECT_EQ("", arena_message->optional_string());
|
| 832 |
+
}
|
| 833 |
+
}
|
| 834 |
+
|
| 835 |
+
|
| 836 |
+
namespace {
|
| 837 |
+
|
| 838 |
+
void ExpectMessageMerged(const UNITTEST::TestAllTypes& message) {
|
| 839 |
+
EXPECT_EQ(3, message.optional_int32());
|
| 840 |
+
EXPECT_EQ(2, message.optional_int64());
|
| 841 |
+
EXPECT_EQ("hello", message.optional_string());
|
| 842 |
+
}
|
| 843 |
+
|
| 844 |
+
void AssignParsingMergeMessages(UNITTEST::TestAllTypes* msg1,
|
| 845 |
+
UNITTEST::TestAllTypes* msg2,
|
| 846 |
+
UNITTEST::TestAllTypes* msg3) {
|
| 847 |
+
msg1->set_optional_int32(1);
|
| 848 |
+
msg2->set_optional_int64(2);
|
| 849 |
+
msg3->set_optional_int32(3);
|
| 850 |
+
msg3->set_optional_string("hello");
|
| 851 |
+
}
|
| 852 |
+
|
| 853 |
+
} // namespace
|
| 854 |
+
|
| 855 |
+
// Test that if an optional or required message/group field appears multiple
|
| 856 |
+
// times in the input, they need to be merged.
|
| 857 |
+
TEST(MESSAGE_TEST_NAME, ParsingMerge) {
|
| 858 |
+
UNITTEST::TestParsingMerge::RepeatedFieldsGenerator generator;
|
| 859 |
+
UNITTEST::TestAllTypes* msg1;
|
| 860 |
+
UNITTEST::TestAllTypes* msg2;
|
| 861 |
+
UNITTEST::TestAllTypes* msg3;
|
| 862 |
+
|
| 863 |
+
#define ASSIGN_REPEATED_FIELD(FIELD) \
|
| 864 |
+
msg1 = generator.add_##FIELD(); \
|
| 865 |
+
msg2 = generator.add_##FIELD(); \
|
| 866 |
+
msg3 = generator.add_##FIELD(); \
|
| 867 |
+
AssignParsingMergeMessages(msg1, msg2, msg3)
|
| 868 |
+
|
| 869 |
+
ASSIGN_REPEATED_FIELD(field1);
|
| 870 |
+
ASSIGN_REPEATED_FIELD(field2);
|
| 871 |
+
ASSIGN_REPEATED_FIELD(field3);
|
| 872 |
+
ASSIGN_REPEATED_FIELD(ext1);
|
| 873 |
+
ASSIGN_REPEATED_FIELD(ext2);
|
| 874 |
+
|
| 875 |
+
#undef ASSIGN_REPEATED_FIELD
|
| 876 |
+
#define ASSIGN_REPEATED_GROUP(FIELD) \
|
| 877 |
+
msg1 = generator.add_##FIELD()->mutable_field1(); \
|
| 878 |
+
msg2 = generator.add_##FIELD()->mutable_field1(); \
|
| 879 |
+
msg3 = generator.add_##FIELD()->mutable_field1(); \
|
| 880 |
+
AssignParsingMergeMessages(msg1, msg2, msg3)
|
| 881 |
+
|
| 882 |
+
ASSIGN_REPEATED_GROUP(group1);
|
| 883 |
+
ASSIGN_REPEATED_GROUP(group2);
|
| 884 |
+
|
| 885 |
+
#undef ASSIGN_REPEATED_GROUP
|
| 886 |
+
|
| 887 |
+
std::string buffer;
|
| 888 |
+
generator.SerializeToString(&buffer);
|
| 889 |
+
UNITTEST::TestParsingMerge parsing_merge;
|
| 890 |
+
parsing_merge.ParseFromString(buffer);
|
| 891 |
+
|
| 892 |
+
// Required and optional fields should be merged.
|
| 893 |
+
ExpectMessageMerged(parsing_merge.required_all_types());
|
| 894 |
+
ExpectMessageMerged(parsing_merge.optional_all_types());
|
| 895 |
+
ExpectMessageMerged(parsing_merge.optionalgroup().optional_group_all_types());
|
| 896 |
+
ExpectMessageMerged(
|
| 897 |
+
parsing_merge.GetExtension(UNITTEST::TestParsingMerge::optional_ext));
|
| 898 |
+
|
| 899 |
+
// Repeated fields should not be merged.
|
| 900 |
+
EXPECT_EQ(3, parsing_merge.repeated_all_types_size());
|
| 901 |
+
EXPECT_EQ(3, parsing_merge.repeatedgroup_size());
|
| 902 |
+
EXPECT_EQ(
|
| 903 |
+
3, parsing_merge.ExtensionSize(UNITTEST::TestParsingMerge::repeated_ext));
|
| 904 |
+
}
|
| 905 |
+
|
| 906 |
+
TEST(MESSAGE_TEST_NAME, MergeFrom) {
|
| 907 |
+
UNITTEST::TestAllTypes source, dest;
|
| 908 |
+
|
| 909 |
+
// Optional fields
|
| 910 |
+
source.set_optional_int32(1); // only source
|
| 911 |
+
source.set_optional_int64(2); // both source and dest
|
| 912 |
+
dest.set_optional_int64(3);
|
| 913 |
+
dest.set_optional_uint32(4); // only dest
|
| 914 |
+
|
| 915 |
+
// Optional fields with defaults
|
| 916 |
+
source.set_default_int32(13); // only source
|
| 917 |
+
source.set_default_int64(14); // both source and dest
|
| 918 |
+
dest.set_default_int64(15);
|
| 919 |
+
dest.set_default_uint32(16); // only dest
|
| 920 |
+
|
| 921 |
+
// Repeated fields
|
| 922 |
+
source.add_repeated_int32(5); // only source
|
| 923 |
+
source.add_repeated_int32(6);
|
| 924 |
+
source.add_repeated_int64(7); // both source and dest
|
| 925 |
+
source.add_repeated_int64(8);
|
| 926 |
+
dest.add_repeated_int64(9);
|
| 927 |
+
dest.add_repeated_int64(10);
|
| 928 |
+
dest.add_repeated_uint32(11); // only dest
|
| 929 |
+
dest.add_repeated_uint32(12);
|
| 930 |
+
|
| 931 |
+
dest.MergeFrom(source);
|
| 932 |
+
|
| 933 |
+
// Optional fields: source overwrites dest if source is specified
|
| 934 |
+
EXPECT_EQ(1, dest.optional_int32()); // only source: use source
|
| 935 |
+
EXPECT_EQ(2, dest.optional_int64()); // source and dest: use source
|
| 936 |
+
EXPECT_EQ(4, dest.optional_uint32()); // only dest: use dest
|
| 937 |
+
EXPECT_EQ(0, dest.optional_uint64()); // neither: use default
|
| 938 |
+
|
| 939 |
+
// Optional fields with defaults
|
| 940 |
+
EXPECT_EQ(13, dest.default_int32()); // only source: use source
|
| 941 |
+
EXPECT_EQ(14, dest.default_int64()); // source and dest: use source
|
| 942 |
+
EXPECT_EQ(16, dest.default_uint32()); // only dest: use dest
|
| 943 |
+
EXPECT_EQ(44, dest.default_uint64()); // neither: use default
|
| 944 |
+
|
| 945 |
+
// Repeated fields: concatenate source onto the end of dest
|
| 946 |
+
ASSERT_EQ(2, dest.repeated_int32_size());
|
| 947 |
+
EXPECT_EQ(5, dest.repeated_int32(0));
|
| 948 |
+
EXPECT_EQ(6, dest.repeated_int32(1));
|
| 949 |
+
ASSERT_EQ(4, dest.repeated_int64_size());
|
| 950 |
+
EXPECT_EQ(9, dest.repeated_int64(0));
|
| 951 |
+
EXPECT_EQ(10, dest.repeated_int64(1));
|
| 952 |
+
EXPECT_EQ(7, dest.repeated_int64(2));
|
| 953 |
+
EXPECT_EQ(8, dest.repeated_int64(3));
|
| 954 |
+
ASSERT_EQ(2, dest.repeated_uint32_size());
|
| 955 |
+
EXPECT_EQ(11, dest.repeated_uint32(0));
|
| 956 |
+
EXPECT_EQ(12, dest.repeated_uint32(1));
|
| 957 |
+
ASSERT_EQ(0, dest.repeated_uint64_size());
|
| 958 |
+
}
|
| 959 |
+
|
| 960 |
+
TEST(MESSAGE_TEST_NAME, IsInitialized) {
|
| 961 |
+
UNITTEST::TestIsInitialized msg;
|
| 962 |
+
EXPECT_TRUE(msg.IsInitialized());
|
| 963 |
+
UNITTEST::TestIsInitialized::SubMessage* sub_message =
|
| 964 |
+
msg.mutable_sub_message();
|
| 965 |
+
EXPECT_TRUE(msg.IsInitialized());
|
| 966 |
+
UNITTEST::TestIsInitialized::SubMessage::SubGroup* sub_group =
|
| 967 |
+
sub_message->mutable_subgroup();
|
| 968 |
+
EXPECT_FALSE(msg.IsInitialized());
|
| 969 |
+
sub_group->set_i(1);
|
| 970 |
+
EXPECT_TRUE(msg.IsInitialized());
|
| 971 |
+
}
|
| 972 |
+
|
| 973 |
+
TEST(MESSAGE_TEST_NAME, IsInitializedSplitBytestream) {
|
| 974 |
+
UNITTEST::TestRequired ab, c;
|
| 975 |
+
ab.set_a(1);
|
| 976 |
+
ab.set_b(2);
|
| 977 |
+
c.set_c(3);
|
| 978 |
+
|
| 979 |
+
// The protobuf represented by the concatenated string has all required
|
| 980 |
+
// fields (a,b,c) set.
|
| 981 |
+
std::string bytes =
|
| 982 |
+
ab.SerializePartialAsString() + c.SerializePartialAsString();
|
| 983 |
+
|
| 984 |
+
UNITTEST::TestRequired concatenated;
|
| 985 |
+
EXPECT_TRUE(concatenated.ParsePartialFromString(bytes));
|
| 986 |
+
EXPECT_TRUE(concatenated.IsInitialized());
|
| 987 |
+
|
| 988 |
+
UNITTEST::TestRequiredForeign fab, fc;
|
| 989 |
+
fab.mutable_optional_message()->set_a(1);
|
| 990 |
+
fab.mutable_optional_message()->set_b(2);
|
| 991 |
+
fc.mutable_optional_message()->set_c(3);
|
| 992 |
+
|
| 993 |
+
bytes =
|
| 994 |
+
fab.SerializePartialAsString() + fc.SerializePartialAsString();
|
| 995 |
+
|
| 996 |
+
UNITTEST::TestRequiredForeign fconcatenated;
|
| 997 |
+
EXPECT_TRUE(fconcatenated.ParsePartialFromString(bytes));
|
| 998 |
+
EXPECT_TRUE(fconcatenated.IsInitialized());
|
| 999 |
+
}
|
| 1000 |
+
|
| 1001 |
+
TEST(MESSAGE_FACTORY_TEST_NAME, GeneratedFactoryLookup) {
|
| 1002 |
+
EXPECT_EQ(MessageFactory::generated_factory()->GetPrototype(
|
| 1003 |
+
UNITTEST::TestAllTypes::descriptor()),
|
| 1004 |
+
&UNITTEST::TestAllTypes::default_instance());
|
| 1005 |
+
}
|
| 1006 |
+
|
| 1007 |
+
TEST(MESSAGE_FACTORY_TEST_NAME, GeneratedFactoryUnknownType) {
|
| 1008 |
+
// Construct a new descriptor.
|
| 1009 |
+
DescriptorPool pool;
|
| 1010 |
+
FileDescriptorProto file;
|
| 1011 |
+
file.set_name("foo.proto");
|
| 1012 |
+
file.add_message_type()->set_name("Foo");
|
| 1013 |
+
const Descriptor* descriptor = pool.BuildFile(file)->message_type(0);
|
| 1014 |
+
|
| 1015 |
+
// Trying to construct it should return nullptr.
|
| 1016 |
+
EXPECT_TRUE(MessageFactory::generated_factory()->GetPrototype(descriptor) ==
|
| 1017 |
+
nullptr);
|
| 1018 |
+
}
|
| 1019 |
+
|
| 1020 |
+
TEST(MESSAGE_TEST_NAME, MOMIParserEdgeCases) {
|
| 1021 |
+
{
|
| 1022 |
+
UNITTEST::TestAllTypes msg;
|
| 1023 |
+
// Parser ends in last 16 bytes of buffer due to a 0.
|
| 1024 |
+
std::string data;
|
| 1025 |
+
// 12 bytes of data
|
| 1026 |
+
for (int i = 0; i < 4; i++) data += "\370\1\1";
|
| 1027 |
+
// 13 byte is terminator
|
| 1028 |
+
data += '\0'; // Terminator
|
| 1029 |
+
// followed by the rest of the stream
|
| 1030 |
+
// space is ascii 32 so no end group
|
| 1031 |
+
data += std::string(30, ' ');
|
| 1032 |
+
io::ArrayInputStream zcis(data.data(), data.size(), 17);
|
| 1033 |
+
io::CodedInputStream cis(&zcis);
|
| 1034 |
+
EXPECT_TRUE(msg.MergePartialFromCodedStream(&cis));
|
| 1035 |
+
EXPECT_EQ(cis.CurrentPosition(), 3 * 4 + 1);
|
| 1036 |
+
}
|
| 1037 |
+
{
|
| 1038 |
+
// Parser ends in last 16 bytes of buffer due to a end-group.
|
| 1039 |
+
// Must use a message that is a group. Otherwise ending on a group end is
|
| 1040 |
+
// a failure.
|
| 1041 |
+
UNITTEST::TestAllTypes::OptionalGroup msg;
|
| 1042 |
+
std::string data;
|
| 1043 |
+
for (int i = 0; i < 3; i++) data += "\370\1\1";
|
| 1044 |
+
data += '\14'; // Octal end-group tag 12 (1 * 8 + 4(
|
| 1045 |
+
data += std::string(30, ' ');
|
| 1046 |
+
io::ArrayInputStream zcis(data.data(), data.size(), 17);
|
| 1047 |
+
io::CodedInputStream cis(&zcis);
|
| 1048 |
+
EXPECT_TRUE(msg.MergePartialFromCodedStream(&cis));
|
| 1049 |
+
EXPECT_EQ(cis.CurrentPosition(), 3 * 3 + 1);
|
| 1050 |
+
EXPECT_TRUE(cis.LastTagWas(12));
|
| 1051 |
+
}
|
| 1052 |
+
{
|
| 1053 |
+
// Parser ends in last 16 bytes of buffer due to a end-group. But is inside
|
| 1054 |
+
// a length delimited field.
|
| 1055 |
+
// a failure.
|
| 1056 |
+
UNITTEST::TestAllTypes::OptionalGroup msg;
|
| 1057 |
+
std::string data;
|
| 1058 |
+
data += "\22\3foo";
|
| 1059 |
+
data += '\14'; // Octal end-group tag 12 (1 * 8 + 4(
|
| 1060 |
+
data += std::string(30, ' ');
|
| 1061 |
+
io::ArrayInputStream zcis(data.data(), data.size(), 17);
|
| 1062 |
+
io::CodedInputStream cis(&zcis);
|
| 1063 |
+
EXPECT_TRUE(msg.MergePartialFromCodedStream(&cis));
|
| 1064 |
+
EXPECT_EQ(cis.CurrentPosition(), 6);
|
| 1065 |
+
EXPECT_TRUE(cis.LastTagWas(12));
|
| 1066 |
+
}
|
| 1067 |
+
{
|
| 1068 |
+
// Parser fails when ending on 0 if from ZeroCopyInputStream
|
| 1069 |
+
UNITTEST::TestAllTypes msg;
|
| 1070 |
+
std::string data;
|
| 1071 |
+
// 12 bytes of data
|
| 1072 |
+
for (int i = 0; i < 4; i++) data += "\370\1\1";
|
| 1073 |
+
// 13 byte is terminator
|
| 1074 |
+
data += '\0'; // Terminator
|
| 1075 |
+
data += std::string(30, ' ');
|
| 1076 |
+
io::ArrayInputStream zcis(data.data(), data.size(), 17);
|
| 1077 |
+
EXPECT_FALSE(msg.ParsePartialFromZeroCopyStream(&zcis));
|
| 1078 |
+
}
|
| 1079 |
+
}
|
| 1080 |
+
|
| 1081 |
+
|
| 1082 |
+
TEST(MESSAGE_TEST_NAME, CheckSerializationWhenInterleavedExtensions) {
|
| 1083 |
+
UNITTEST::TestExtensionRangeSerialize in_message;
|
| 1084 |
+
|
| 1085 |
+
in_message.set_foo_one(1);
|
| 1086 |
+
in_message.set_foo_two(2);
|
| 1087 |
+
in_message.set_foo_three(3);
|
| 1088 |
+
in_message.set_foo_four(4);
|
| 1089 |
+
|
| 1090 |
+
in_message.SetExtension(UNITTEST::TestExtensionRangeSerialize::bar_one, 1);
|
| 1091 |
+
in_message.SetExtension(UNITTEST::TestExtensionRangeSerialize::bar_two, 2);
|
| 1092 |
+
in_message.SetExtension(UNITTEST::TestExtensionRangeSerialize::bar_three, 3);
|
| 1093 |
+
in_message.SetExtension(UNITTEST::TestExtensionRangeSerialize::bar_four, 4);
|
| 1094 |
+
in_message.SetExtension(UNITTEST::TestExtensionRangeSerialize::bar_five, 5);
|
| 1095 |
+
|
| 1096 |
+
std::string buffer;
|
| 1097 |
+
in_message.SerializeToString(&buffer);
|
| 1098 |
+
|
| 1099 |
+
UNITTEST::TestExtensionRangeSerialize out_message;
|
| 1100 |
+
out_message.ParseFromString(buffer);
|
| 1101 |
+
|
| 1102 |
+
EXPECT_EQ(1, out_message.foo_one());
|
| 1103 |
+
EXPECT_EQ(2, out_message.foo_two());
|
| 1104 |
+
EXPECT_EQ(3, out_message.foo_three());
|
| 1105 |
+
EXPECT_EQ(4, out_message.foo_four());
|
| 1106 |
+
|
| 1107 |
+
EXPECT_EQ(1, out_message.GetExtension(UNITTEST::TestExtensionRangeSerialize::bar_one));
|
| 1108 |
+
EXPECT_EQ(2, out_message.GetExtension(UNITTEST::TestExtensionRangeSerialize::bar_two));
|
| 1109 |
+
EXPECT_EQ(3, out_message.GetExtension(UNITTEST::TestExtensionRangeSerialize::bar_three));
|
| 1110 |
+
EXPECT_EQ(4, out_message.GetExtension(UNITTEST::TestExtensionRangeSerialize::bar_four));
|
| 1111 |
+
EXPECT_EQ(5, out_message.GetExtension(UNITTEST::TestExtensionRangeSerialize::bar_five));
|
| 1112 |
+
}
|
| 1113 |
+
|
| 1114 |
+
TEST(MESSAGE_TEST_NAME, PreservesFloatingPointNegative0) {
|
| 1115 |
+
UNITTEST::TestAllTypes in_message;
|
| 1116 |
+
in_message.set_optional_float(-0.0f);
|
| 1117 |
+
in_message.set_optional_double(-0.0);
|
| 1118 |
+
std::string serialized;
|
| 1119 |
+
EXPECT_TRUE(in_message.SerializeToString(&serialized));
|
| 1120 |
+
UNITTEST::TestAllTypes out_message;
|
| 1121 |
+
EXPECT_TRUE(out_message.ParseFromString(serialized));
|
| 1122 |
+
EXPECT_EQ(in_message.optional_float(), out_message.optional_float());
|
| 1123 |
+
EXPECT_EQ(std::signbit(in_message.optional_float()),
|
| 1124 |
+
std::signbit(out_message.optional_float()));
|
| 1125 |
+
EXPECT_EQ(in_message.optional_double(), out_message.optional_double());
|
| 1126 |
+
EXPECT_EQ(std::signbit(in_message.optional_double()),
|
| 1127 |
+
std::signbit(out_message.optional_double()));
|
| 1128 |
+
}
|
| 1129 |
+
|
| 1130 |
+
} // namespace protobuf
|
| 1131 |
+
} // namespace google
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/metadata_lite.h
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_METADATA_LITE_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_METADATA_LITE_H__
|
| 33 |
+
|
| 34 |
+
#include <string>
|
| 35 |
+
#include <google/protobuf/stubs/common.h>
|
| 36 |
+
#include <google/protobuf/arena.h>
|
| 37 |
+
#include <google/protobuf/port.h>
|
| 38 |
+
|
| 39 |
+
// Must be included last.
|
| 40 |
+
#include <google/protobuf/port_def.inc>
|
| 41 |
+
|
| 42 |
+
#ifdef SWIG
|
| 43 |
+
#error "You cannot SWIG proto headers"
|
| 44 |
+
#endif
|
| 45 |
+
|
| 46 |
+
namespace google {
|
| 47 |
+
namespace protobuf {
|
| 48 |
+
namespace internal {
|
| 49 |
+
|
| 50 |
+
// This is the representation for messages that support arena allocation. It
|
| 51 |
+
// uses a tagged pointer to either store the owning Arena pointer, if there are
|
| 52 |
+
// no unknown fields, or a pointer to a block of memory with both the owning
|
| 53 |
+
// Arena pointer and the UnknownFieldSet, if there are unknown fields. Besides,
|
| 54 |
+
// it also uses the tag to distinguish whether the owning Arena pointer is also
|
| 55 |
+
// used by sub-structure allocation. This optimization allows for
|
| 56 |
+
// "zero-overhead" storage of the Arena pointer, relative to the above baseline
|
| 57 |
+
// implementation.
|
| 58 |
+
//
|
| 59 |
+
// The tagged pointer uses the least two significant bits to disambiguate cases.
|
| 60 |
+
// It uses bit 0 == 0 to indicate an arena pointer and bit 0 == 1 to indicate a
|
| 61 |
+
// UFS+Arena-container pointer. Besides it uses bit 1 == 0 to indicate arena
|
| 62 |
+
// allocation and bit 1 == 1 to indicate heap allocation.
|
| 63 |
+
class PROTOBUF_EXPORT InternalMetadata {
|
| 64 |
+
public:
|
| 65 |
+
constexpr InternalMetadata() : ptr_(0) {}
|
| 66 |
+
explicit InternalMetadata(Arena* arena, bool is_message_owned = false) {
|
| 67 |
+
SetArena(arena, is_message_owned);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
void SetArena(Arena* arena, bool is_message_owned) {
|
| 71 |
+
ptr_ = is_message_owned
|
| 72 |
+
? reinterpret_cast<intptr_t>(arena) | kMessageOwnedArenaTagMask
|
| 73 |
+
: reinterpret_cast<intptr_t>(arena);
|
| 74 |
+
GOOGLE_DCHECK(!is_message_owned || arena != nullptr);
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
// To keep the ABI identical between debug and non-debug builds,
|
| 78 |
+
// the destructor is always defined here even though it may delegate
|
| 79 |
+
// to a non-inline private method.
|
| 80 |
+
// (see https://github.com/protocolbuffers/protobuf/issues/9947)
|
| 81 |
+
~InternalMetadata() {
|
| 82 |
+
#if defined(NDEBUG) || defined(_MSC_VER)
|
| 83 |
+
if (HasMessageOwnedArenaTag()) {
|
| 84 |
+
delete reinterpret_cast<Arena*>(ptr_ - kMessageOwnedArenaTagMask);
|
| 85 |
+
}
|
| 86 |
+
#else
|
| 87 |
+
CheckedDestruct();
|
| 88 |
+
#endif
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
template <typename T>
|
| 92 |
+
void Delete() {
|
| 93 |
+
// Note that Delete<> should be called not more than once.
|
| 94 |
+
if (have_unknown_fields()) {
|
| 95 |
+
DeleteOutOfLineHelper<T>();
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
// DeleteReturnArena will delete the unknown fields only if they weren't
|
| 100 |
+
// allocated on an arena. Then it updates the flags so that if you call
|
| 101 |
+
// have_unknown_fields(), it will return false. Finally, it returns the
|
| 102 |
+
// current value of arena(). It is designed to be used as part of a
|
| 103 |
+
// Message class's destructor call, so that when control eventually gets
|
| 104 |
+
// to ~InternalMetadata(), we don't need to check for have_unknown_fields()
|
| 105 |
+
// again.
|
| 106 |
+
template <typename T>
|
| 107 |
+
Arena* DeleteReturnArena() {
|
| 108 |
+
if (have_unknown_fields()) {
|
| 109 |
+
return DeleteOutOfLineHelper<T>();
|
| 110 |
+
} else {
|
| 111 |
+
return PtrValue<Arena>();
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
PROTOBUF_NDEBUG_INLINE Arena* owning_arena() const {
|
| 116 |
+
return HasMessageOwnedArenaTag() ? nullptr : arena();
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
PROTOBUF_NDEBUG_INLINE Arena* user_arena() const {
|
| 120 |
+
Arena* a = arena();
|
| 121 |
+
return a && !a->IsMessageOwned() ? a : nullptr;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
PROTOBUF_NDEBUG_INLINE Arena* arena() const {
|
| 125 |
+
if (PROTOBUF_PREDICT_FALSE(have_unknown_fields())) {
|
| 126 |
+
return PtrValue<ContainerBase>()->arena;
|
| 127 |
+
} else {
|
| 128 |
+
return PtrValue<Arena>();
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
PROTOBUF_NDEBUG_INLINE bool have_unknown_fields() const {
|
| 133 |
+
return HasUnknownFieldsTag();
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
PROTOBUF_NDEBUG_INLINE void* raw_arena_ptr() const {
|
| 137 |
+
return reinterpret_cast<void*>(ptr_);
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
template <typename T>
|
| 141 |
+
PROTOBUF_NDEBUG_INLINE const T& unknown_fields(
|
| 142 |
+
const T& (*default_instance)()) const {
|
| 143 |
+
if (PROTOBUF_PREDICT_FALSE(have_unknown_fields())) {
|
| 144 |
+
return PtrValue<Container<T>>()->unknown_fields;
|
| 145 |
+
} else {
|
| 146 |
+
return default_instance();
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
template <typename T>
|
| 151 |
+
PROTOBUF_NDEBUG_INLINE T* mutable_unknown_fields() {
|
| 152 |
+
if (PROTOBUF_PREDICT_TRUE(have_unknown_fields())) {
|
| 153 |
+
return &PtrValue<Container<T>>()->unknown_fields;
|
| 154 |
+
} else {
|
| 155 |
+
return mutable_unknown_fields_slow<T>();
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
template <typename T>
|
| 160 |
+
PROTOBUF_NDEBUG_INLINE void Swap(InternalMetadata* other) {
|
| 161 |
+
// Semantics here are that we swap only the unknown fields, not the arena
|
| 162 |
+
// pointer. We cannot simply swap ptr_ with other->ptr_ because we need to
|
| 163 |
+
// maintain our own arena ptr. Also, our ptr_ and other's ptr_ may be in
|
| 164 |
+
// different states (direct arena pointer vs. container with UFS) so we
|
| 165 |
+
// cannot simply swap ptr_ and then restore the arena pointers. We reuse
|
| 166 |
+
// UFS's swap implementation instead.
|
| 167 |
+
if (have_unknown_fields() || other->have_unknown_fields()) {
|
| 168 |
+
DoSwap<T>(other->mutable_unknown_fields<T>());
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
PROTOBUF_NDEBUG_INLINE void InternalSwap(InternalMetadata* other) {
|
| 173 |
+
std::swap(ptr_, other->ptr_);
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
template <typename T>
|
| 177 |
+
PROTOBUF_NDEBUG_INLINE void MergeFrom(const InternalMetadata& other) {
|
| 178 |
+
if (other.have_unknown_fields()) {
|
| 179 |
+
DoMergeFrom<T>(other.unknown_fields<T>(nullptr));
|
| 180 |
+
}
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
template <typename T>
|
| 184 |
+
PROTOBUF_NDEBUG_INLINE void Clear() {
|
| 185 |
+
if (have_unknown_fields()) {
|
| 186 |
+
DoClear<T>();
|
| 187 |
+
}
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
private:
|
| 191 |
+
intptr_t ptr_;
|
| 192 |
+
|
| 193 |
+
// Tagged pointer implementation.
|
| 194 |
+
static constexpr intptr_t kUnknownFieldsTagMask = 1;
|
| 195 |
+
static constexpr intptr_t kMessageOwnedArenaTagMask = 2;
|
| 196 |
+
static constexpr intptr_t kPtrTagMask =
|
| 197 |
+
kUnknownFieldsTagMask | kMessageOwnedArenaTagMask;
|
| 198 |
+
static constexpr intptr_t kPtrValueMask = ~kPtrTagMask;
|
| 199 |
+
|
| 200 |
+
// Accessors for pointer tag and pointer value.
|
| 201 |
+
PROTOBUF_ALWAYS_INLINE bool HasUnknownFieldsTag() const {
|
| 202 |
+
return ptr_ & kUnknownFieldsTagMask;
|
| 203 |
+
}
|
| 204 |
+
PROTOBUF_ALWAYS_INLINE bool HasMessageOwnedArenaTag() const {
|
| 205 |
+
return ptr_ & kMessageOwnedArenaTagMask;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
template <typename U>
|
| 209 |
+
U* PtrValue() const {
|
| 210 |
+
return reinterpret_cast<U*>(ptr_ & kPtrValueMask);
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
// If ptr_'s tag is kTagContainer, it points to an instance of this struct.
|
| 214 |
+
struct ContainerBase {
|
| 215 |
+
Arena* arena;
|
| 216 |
+
};
|
| 217 |
+
|
| 218 |
+
template <typename T>
|
| 219 |
+
struct Container : public ContainerBase {
|
| 220 |
+
T unknown_fields;
|
| 221 |
+
};
|
| 222 |
+
|
| 223 |
+
template <typename T>
|
| 224 |
+
PROTOBUF_NOINLINE Arena* DeleteOutOfLineHelper() {
|
| 225 |
+
if (auto* a = arena()) {
|
| 226 |
+
// Subtle: we want to preserve the message-owned arena flag, while at the
|
| 227 |
+
// same time replacing the pointer to Container<T> with a pointer to the
|
| 228 |
+
// arena.
|
| 229 |
+
intptr_t message_owned_arena_tag = ptr_ & kMessageOwnedArenaTagMask;
|
| 230 |
+
ptr_ = reinterpret_cast<intptr_t>(a) | message_owned_arena_tag;
|
| 231 |
+
return a;
|
| 232 |
+
} else {
|
| 233 |
+
delete PtrValue<Container<T>>();
|
| 234 |
+
ptr_ = 0;
|
| 235 |
+
return nullptr;
|
| 236 |
+
}
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
template <typename T>
|
| 240 |
+
PROTOBUF_NOINLINE T* mutable_unknown_fields_slow() {
|
| 241 |
+
Arena* my_arena = arena();
|
| 242 |
+
Container<T>* container = Arena::Create<Container<T>>(my_arena);
|
| 243 |
+
intptr_t message_owned_arena_tag = ptr_ & kMessageOwnedArenaTagMask;
|
| 244 |
+
// Two-step assignment works around a bug in clang's static analyzer:
|
| 245 |
+
// https://bugs.llvm.org/show_bug.cgi?id=34198.
|
| 246 |
+
ptr_ = reinterpret_cast<intptr_t>(container);
|
| 247 |
+
ptr_ |= kUnknownFieldsTagMask | message_owned_arena_tag;
|
| 248 |
+
container->arena = my_arena;
|
| 249 |
+
return &(container->unknown_fields);
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
// Templated functions.
|
| 253 |
+
|
| 254 |
+
template <typename T>
|
| 255 |
+
PROTOBUF_NOINLINE void DoClear() {
|
| 256 |
+
mutable_unknown_fields<T>()->Clear();
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
template <typename T>
|
| 260 |
+
PROTOBUF_NOINLINE void DoMergeFrom(const T& other) {
|
| 261 |
+
mutable_unknown_fields<T>()->MergeFrom(other);
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
template <typename T>
|
| 265 |
+
PROTOBUF_NOINLINE void DoSwap(T* other) {
|
| 266 |
+
mutable_unknown_fields<T>()->Swap(other);
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
// Private helper with debug checks for ~InternalMetadata()
|
| 270 |
+
void CheckedDestruct();
|
| 271 |
+
};
|
| 272 |
+
|
| 273 |
+
// String Template specializations.
|
| 274 |
+
|
| 275 |
+
template <>
|
| 276 |
+
PROTOBUF_EXPORT void InternalMetadata::DoClear<std::string>();
|
| 277 |
+
template <>
|
| 278 |
+
PROTOBUF_EXPORT void InternalMetadata::DoMergeFrom<std::string>(
|
| 279 |
+
const std::string& other);
|
| 280 |
+
template <>
|
| 281 |
+
PROTOBUF_EXPORT void InternalMetadata::DoSwap<std::string>(std::string* other);
|
| 282 |
+
|
| 283 |
+
// This helper RAII class is needed to efficiently parse unknown fields. We
|
| 284 |
+
// should only call mutable_unknown_fields if there are actual unknown fields.
|
| 285 |
+
// The obvious thing to just use a stack string and swap it at the end of
|
| 286 |
+
// the parse won't work, because the destructor of StringOutputStream needs to
|
| 287 |
+
// be called before we can modify the string (it check-fails). Using
|
| 288 |
+
// LiteUnknownFieldSetter setter(&_internal_metadata_);
|
| 289 |
+
// StringOutputStream stream(setter.buffer());
|
| 290 |
+
// guarantees that the string is only swapped after stream is destroyed.
|
| 291 |
+
class PROTOBUF_EXPORT LiteUnknownFieldSetter {
|
| 292 |
+
public:
|
| 293 |
+
explicit LiteUnknownFieldSetter(InternalMetadata* metadata)
|
| 294 |
+
: metadata_(metadata) {
|
| 295 |
+
if (metadata->have_unknown_fields()) {
|
| 296 |
+
buffer_.swap(*metadata->mutable_unknown_fields<std::string>());
|
| 297 |
+
}
|
| 298 |
+
}
|
| 299 |
+
~LiteUnknownFieldSetter() {
|
| 300 |
+
if (!buffer_.empty())
|
| 301 |
+
metadata_->mutable_unknown_fields<std::string>()->swap(buffer_);
|
| 302 |
+
}
|
| 303 |
+
std::string* buffer() { return &buffer_; }
|
| 304 |
+
|
| 305 |
+
private:
|
| 306 |
+
InternalMetadata* metadata_;
|
| 307 |
+
std::string buffer_;
|
| 308 |
+
};
|
| 309 |
+
|
| 310 |
+
} // namespace internal
|
| 311 |
+
} // namespace protobuf
|
| 312 |
+
} // namespace google
|
| 313 |
+
|
| 314 |
+
#include <google/protobuf/port_undef.inc>
|
| 315 |
+
|
| 316 |
+
#endif // GOOGLE_PROTOBUF_METADATA_LITE_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/parse_context.h
ADDED
|
@@ -0,0 +1,1025 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_PARSE_CONTEXT_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_PARSE_CONTEXT_H__
|
| 33 |
+
|
| 34 |
+
#include <cstdint>
|
| 35 |
+
#include <cstring>
|
| 36 |
+
#include <string>
|
| 37 |
+
#include <type_traits>
|
| 38 |
+
|
| 39 |
+
#include <google/protobuf/io/coded_stream.h>
|
| 40 |
+
#include <google/protobuf/io/zero_copy_stream.h>
|
| 41 |
+
#include <google/protobuf/arena.h>
|
| 42 |
+
#include <google/protobuf/port.h>
|
| 43 |
+
#include <google/protobuf/stubs/strutil.h>
|
| 44 |
+
#include <google/protobuf/arenastring.h>
|
| 45 |
+
#include <google/protobuf/endian.h>
|
| 46 |
+
#include <google/protobuf/implicit_weak_message.h>
|
| 47 |
+
#include <google/protobuf/inlined_string_field.h>
|
| 48 |
+
#include <google/protobuf/metadata_lite.h>
|
| 49 |
+
#include <google/protobuf/repeated_field.h>
|
| 50 |
+
#include <google/protobuf/wire_format_lite.h>
|
| 51 |
+
|
| 52 |
+
// Must be included last.
|
| 53 |
+
#include <google/protobuf/port_def.inc>
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
namespace google {
|
| 57 |
+
namespace protobuf {
|
| 58 |
+
|
| 59 |
+
class UnknownFieldSet;
|
| 60 |
+
class DescriptorPool;
|
| 61 |
+
class MessageFactory;
|
| 62 |
+
|
| 63 |
+
namespace internal {
|
| 64 |
+
|
| 65 |
+
// Template code below needs to know about the existence of these functions.
|
| 66 |
+
PROTOBUF_EXPORT void WriteVarint(uint32_t num, uint64_t val, std::string* s);
|
| 67 |
+
PROTOBUF_EXPORT void WriteLengthDelimited(uint32_t num, StringPiece val,
|
| 68 |
+
std::string* s);
|
| 69 |
+
// Inline because it is just forwarding to s->WriteVarint
|
| 70 |
+
inline void WriteVarint(uint32_t num, uint64_t val, UnknownFieldSet* s);
|
| 71 |
+
inline void WriteLengthDelimited(uint32_t num, StringPiece val,
|
| 72 |
+
UnknownFieldSet* s);
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
// The basic abstraction the parser is designed for is a slight modification
|
| 76 |
+
// of the ZeroCopyInputStream (ZCIS) abstraction. A ZCIS presents a serialized
|
| 77 |
+
// stream as a series of buffers that concatenate to the full stream.
|
| 78 |
+
// Pictorially a ZCIS presents a stream in chunks like so
|
| 79 |
+
// [---------------------------------------------------------------]
|
| 80 |
+
// [---------------------] chunk 1
|
| 81 |
+
// [----------------------------] chunk 2
|
| 82 |
+
// chunk 3 [--------------]
|
| 83 |
+
//
|
| 84 |
+
// Where the '-' represent the bytes which are vertically lined up with the
|
| 85 |
+
// bytes of the stream. The proto parser requires its input to be presented
|
| 86 |
+
// similarly with the extra
|
| 87 |
+
// property that each chunk has kSlopBytes past its end that overlaps with the
|
| 88 |
+
// first kSlopBytes of the next chunk, or if there is no next chunk at least its
|
| 89 |
+
// still valid to read those bytes. Again, pictorially, we now have
|
| 90 |
+
//
|
| 91 |
+
// [---------------------------------------------------------------]
|
| 92 |
+
// [-------------------....] chunk 1
|
| 93 |
+
// [------------------------....] chunk 2
|
| 94 |
+
// chunk 3 [------------------..**]
|
| 95 |
+
// chunk 4 [--****]
|
| 96 |
+
// Here '-' mean the bytes of the stream or chunk and '.' means bytes past the
|
| 97 |
+
// chunk that match up with the start of the next chunk. Above each chunk has
|
| 98 |
+
// 4 '.' after the chunk. In the case these 'overflow' bytes represents bytes
|
| 99 |
+
// past the stream, indicated by '*' above, their values are unspecified. It is
|
| 100 |
+
// still legal to read them (ie. should not segfault). Reading past the
|
| 101 |
+
// end should be detected by the user and indicated as an error.
|
| 102 |
+
//
|
| 103 |
+
// The reason for this, admittedly, unconventional invariant is to ruthlessly
|
| 104 |
+
// optimize the protobuf parser. Having an overlap helps in two important ways.
|
| 105 |
+
// Firstly it alleviates having to performing bounds checks if a piece of code
|
| 106 |
+
// is guaranteed to not read more than kSlopBytes. Secondly, and more
|
| 107 |
+
// importantly, the protobuf wireformat is such that reading a key/value pair is
|
| 108 |
+
// always less than 16 bytes. This removes the need to change to next buffer in
|
| 109 |
+
// the middle of reading primitive values. Hence there is no need to store and
|
| 110 |
+
// load the current position.
|
| 111 |
+
|
| 112 |
+
class PROTOBUF_EXPORT EpsCopyInputStream {
|
| 113 |
+
public:
|
| 114 |
+
enum { kSlopBytes = 16, kMaxCordBytesToCopy = 512 };
|
| 115 |
+
|
| 116 |
+
explicit EpsCopyInputStream(bool enable_aliasing)
|
| 117 |
+
: aliasing_(enable_aliasing ? kOnPatch : kNoAliasing) {}
|
| 118 |
+
|
| 119 |
+
void BackUp(const char* ptr) {
|
| 120 |
+
GOOGLE_DCHECK(ptr <= buffer_end_ + kSlopBytes);
|
| 121 |
+
int count;
|
| 122 |
+
if (next_chunk_ == buffer_) {
|
| 123 |
+
count = static_cast<int>(buffer_end_ + kSlopBytes - ptr);
|
| 124 |
+
} else {
|
| 125 |
+
count = size_ + static_cast<int>(buffer_end_ - ptr);
|
| 126 |
+
}
|
| 127 |
+
if (count > 0) StreamBackUp(count);
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
// If return value is negative it's an error
|
| 131 |
+
PROTOBUF_NODISCARD int PushLimit(const char* ptr, int limit) {
|
| 132 |
+
GOOGLE_DCHECK(limit >= 0 && limit <= INT_MAX - kSlopBytes);
|
| 133 |
+
// This add is safe due to the invariant above, because
|
| 134 |
+
// ptr - buffer_end_ <= kSlopBytes.
|
| 135 |
+
limit += static_cast<int>(ptr - buffer_end_);
|
| 136 |
+
limit_end_ = buffer_end_ + (std::min)(0, limit);
|
| 137 |
+
auto old_limit = limit_;
|
| 138 |
+
limit_ = limit;
|
| 139 |
+
return old_limit - limit;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
PROTOBUF_NODISCARD bool PopLimit(int delta) {
|
| 143 |
+
if (PROTOBUF_PREDICT_FALSE(!EndedAtLimit())) return false;
|
| 144 |
+
limit_ = limit_ + delta;
|
| 145 |
+
// TODO(gerbens) We could remove this line and hoist the code to
|
| 146 |
+
// DoneFallback. Study the perf/bin-size effects.
|
| 147 |
+
limit_end_ = buffer_end_ + (std::min)(0, limit_);
|
| 148 |
+
return true;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
PROTOBUF_NODISCARD const char* Skip(const char* ptr, int size) {
|
| 152 |
+
if (size <= buffer_end_ + kSlopBytes - ptr) {
|
| 153 |
+
return ptr + size;
|
| 154 |
+
}
|
| 155 |
+
return SkipFallback(ptr, size);
|
| 156 |
+
}
|
| 157 |
+
PROTOBUF_NODISCARD const char* ReadString(const char* ptr, int size,
|
| 158 |
+
std::string* s) {
|
| 159 |
+
if (size <= buffer_end_ + kSlopBytes - ptr) {
|
| 160 |
+
s->assign(ptr, size);
|
| 161 |
+
return ptr + size;
|
| 162 |
+
}
|
| 163 |
+
return ReadStringFallback(ptr, size, s);
|
| 164 |
+
}
|
| 165 |
+
PROTOBUF_NODISCARD const char* AppendString(const char* ptr, int size,
|
| 166 |
+
std::string* s) {
|
| 167 |
+
if (size <= buffer_end_ + kSlopBytes - ptr) {
|
| 168 |
+
s->append(ptr, size);
|
| 169 |
+
return ptr + size;
|
| 170 |
+
}
|
| 171 |
+
return AppendStringFallback(ptr, size, s);
|
| 172 |
+
}
|
| 173 |
+
// Implemented in arenastring.cc
|
| 174 |
+
PROTOBUF_NODISCARD const char* ReadArenaString(const char* ptr,
|
| 175 |
+
ArenaStringPtr* s,
|
| 176 |
+
Arena* arena);
|
| 177 |
+
|
| 178 |
+
template <typename Tag, typename T>
|
| 179 |
+
PROTOBUF_NODISCARD const char* ReadRepeatedFixed(const char* ptr,
|
| 180 |
+
Tag expected_tag,
|
| 181 |
+
RepeatedField<T>* out);
|
| 182 |
+
|
| 183 |
+
template <typename T>
|
| 184 |
+
PROTOBUF_NODISCARD const char* ReadPackedFixed(const char* ptr, int size,
|
| 185 |
+
RepeatedField<T>* out);
|
| 186 |
+
template <typename Add>
|
| 187 |
+
PROTOBUF_NODISCARD const char* ReadPackedVarint(const char* ptr, Add add);
|
| 188 |
+
|
| 189 |
+
uint32_t LastTag() const { return last_tag_minus_1_ + 1; }
|
| 190 |
+
bool ConsumeEndGroup(uint32_t start_tag) {
|
| 191 |
+
bool res = last_tag_minus_1_ == start_tag;
|
| 192 |
+
last_tag_minus_1_ = 0;
|
| 193 |
+
return res;
|
| 194 |
+
}
|
| 195 |
+
bool EndedAtLimit() const { return last_tag_minus_1_ == 0; }
|
| 196 |
+
bool EndedAtEndOfStream() const { return last_tag_minus_1_ == 1; }
|
| 197 |
+
void SetLastTag(uint32_t tag) { last_tag_minus_1_ = tag - 1; }
|
| 198 |
+
void SetEndOfStream() { last_tag_minus_1_ = 1; }
|
| 199 |
+
bool IsExceedingLimit(const char* ptr) {
|
| 200 |
+
return ptr > limit_end_ &&
|
| 201 |
+
(next_chunk_ == nullptr || ptr - buffer_end_ > limit_);
|
| 202 |
+
}
|
| 203 |
+
bool AliasingEnabled() const { return aliasing_ != kNoAliasing; }
|
| 204 |
+
int BytesUntilLimit(const char* ptr) const {
|
| 205 |
+
return limit_ + static_cast<int>(buffer_end_ - ptr);
|
| 206 |
+
}
|
| 207 |
+
// Returns true if more data is available, if false is returned one has to
|
| 208 |
+
// call Done for further checks.
|
| 209 |
+
bool DataAvailable(const char* ptr) { return ptr < limit_end_; }
|
| 210 |
+
|
| 211 |
+
protected:
|
| 212 |
+
// Returns true is limit (either an explicit limit or end of stream) is
|
| 213 |
+
// reached. It aligns *ptr across buffer seams.
|
| 214 |
+
// If limit is exceeded it returns true and ptr is set to null.
|
| 215 |
+
bool DoneWithCheck(const char** ptr, int d) {
|
| 216 |
+
GOOGLE_DCHECK(*ptr);
|
| 217 |
+
if (PROTOBUF_PREDICT_TRUE(*ptr < limit_end_)) return false;
|
| 218 |
+
int overrun = static_cast<int>(*ptr - buffer_end_);
|
| 219 |
+
GOOGLE_DCHECK_LE(overrun, kSlopBytes); // Guaranteed by parse loop.
|
| 220 |
+
if (overrun ==
|
| 221 |
+
limit_) { // No need to flip buffers if we ended on a limit.
|
| 222 |
+
// If we actually overrun the buffer and next_chunk_ is null. It means
|
| 223 |
+
// the stream ended and we passed the stream end.
|
| 224 |
+
if (overrun > 0 && next_chunk_ == nullptr) *ptr = nullptr;
|
| 225 |
+
return true;
|
| 226 |
+
}
|
| 227 |
+
auto res = DoneFallback(overrun, d);
|
| 228 |
+
*ptr = res.first;
|
| 229 |
+
return res.second;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
const char* InitFrom(StringPiece flat) {
|
| 233 |
+
overall_limit_ = 0;
|
| 234 |
+
if (flat.size() > kSlopBytes) {
|
| 235 |
+
limit_ = kSlopBytes;
|
| 236 |
+
limit_end_ = buffer_end_ = flat.data() + flat.size() - kSlopBytes;
|
| 237 |
+
next_chunk_ = buffer_;
|
| 238 |
+
if (aliasing_ == kOnPatch) aliasing_ = kNoDelta;
|
| 239 |
+
return flat.data();
|
| 240 |
+
} else {
|
| 241 |
+
std::memcpy(buffer_, flat.data(), flat.size());
|
| 242 |
+
limit_ = 0;
|
| 243 |
+
limit_end_ = buffer_end_ = buffer_ + flat.size();
|
| 244 |
+
next_chunk_ = nullptr;
|
| 245 |
+
if (aliasing_ == kOnPatch) {
|
| 246 |
+
aliasing_ = reinterpret_cast<std::uintptr_t>(flat.data()) -
|
| 247 |
+
reinterpret_cast<std::uintptr_t>(buffer_);
|
| 248 |
+
}
|
| 249 |
+
return buffer_;
|
| 250 |
+
}
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
const char* InitFrom(io::ZeroCopyInputStream* zcis);
|
| 254 |
+
|
| 255 |
+
const char* InitFrom(io::ZeroCopyInputStream* zcis, int limit) {
|
| 256 |
+
if (limit == -1) return InitFrom(zcis);
|
| 257 |
+
overall_limit_ = limit;
|
| 258 |
+
auto res = InitFrom(zcis);
|
| 259 |
+
limit_ = limit - static_cast<int>(buffer_end_ - res);
|
| 260 |
+
limit_end_ = buffer_end_ + (std::min)(0, limit_);
|
| 261 |
+
return res;
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
private:
|
| 265 |
+
const char* limit_end_; // buffer_end_ + min(limit_, 0)
|
| 266 |
+
const char* buffer_end_;
|
| 267 |
+
const char* next_chunk_;
|
| 268 |
+
int size_;
|
| 269 |
+
int limit_; // relative to buffer_end_;
|
| 270 |
+
io::ZeroCopyInputStream* zcis_ = nullptr;
|
| 271 |
+
char buffer_[2 * kSlopBytes] = {};
|
| 272 |
+
enum { kNoAliasing = 0, kOnPatch = 1, kNoDelta = 2 };
|
| 273 |
+
std::uintptr_t aliasing_ = kNoAliasing;
|
| 274 |
+
// This variable is used to communicate how the parse ended, in order to
|
| 275 |
+
// completely verify the parsed data. A wire-format parse can end because of
|
| 276 |
+
// one of the following conditions:
|
| 277 |
+
// 1) A parse can end on a pushed limit.
|
| 278 |
+
// 2) A parse can end on End Of Stream (EOS).
|
| 279 |
+
// 3) A parse can end on 0 tag (only valid for toplevel message).
|
| 280 |
+
// 4) A parse can end on an end-group tag.
|
| 281 |
+
// This variable should always be set to 0, which indicates case 1. If the
|
| 282 |
+
// parse terminated due to EOS (case 2), it's set to 1. In case the parse
|
| 283 |
+
// ended due to a terminating tag (case 3 and 4) it's set to (tag - 1).
|
| 284 |
+
// This var doesn't really belong in EpsCopyInputStream and should be part of
|
| 285 |
+
// the ParseContext, but case 2 is most easily and optimally implemented in
|
| 286 |
+
// DoneFallback.
|
| 287 |
+
uint32_t last_tag_minus_1_ = 0;
|
| 288 |
+
int overall_limit_ = INT_MAX; // Overall limit independent of pushed limits.
|
| 289 |
+
// Pretty random large number that seems like a safe allocation on most
|
| 290 |
+
// systems. TODO(gerbens) do we need to set this as build flag?
|
| 291 |
+
enum { kSafeStringSize = 50000000 };
|
| 292 |
+
|
| 293 |
+
// Advances to next buffer chunk returns a pointer to the same logical place
|
| 294 |
+
// in the stream as set by overrun. Overrun indicates the position in the slop
|
| 295 |
+
// region the parse was left (0 <= overrun <= kSlopBytes). Returns true if at
|
| 296 |
+
// limit, at which point the returned pointer maybe null if there was an
|
| 297 |
+
// error. The invariant of this function is that it's guaranteed that
|
| 298 |
+
// kSlopBytes bytes can be accessed from the returned ptr. This function might
|
| 299 |
+
// advance more buffers than one in the underlying ZeroCopyInputStream.
|
| 300 |
+
std::pair<const char*, bool> DoneFallback(int overrun, int depth);
|
| 301 |
+
// Advances to the next buffer, at most one call to Next() on the underlying
|
| 302 |
+
// ZeroCopyInputStream is made. This function DOES NOT match the returned
|
| 303 |
+
// pointer to where in the slop region the parse ends, hence no overrun
|
| 304 |
+
// parameter. This is useful for string operations where you always copy
|
| 305 |
+
// to the end of the buffer (including the slop region).
|
| 306 |
+
const char* Next();
|
| 307 |
+
// overrun is the location in the slop region the stream currently is
|
| 308 |
+
// (0 <= overrun <= kSlopBytes). To prevent flipping to the next buffer of
|
| 309 |
+
// the ZeroCopyInputStream in the case the parse will end in the last
|
| 310 |
+
// kSlopBytes of the current buffer. depth is the current depth of nested
|
| 311 |
+
// groups (or negative if the use case does not need careful tracking).
|
| 312 |
+
inline const char* NextBuffer(int overrun, int depth);
|
| 313 |
+
const char* SkipFallback(const char* ptr, int size);
|
| 314 |
+
const char* AppendStringFallback(const char* ptr, int size, std::string* str);
|
| 315 |
+
const char* ReadStringFallback(const char* ptr, int size, std::string* str);
|
| 316 |
+
bool StreamNext(const void** data) {
|
| 317 |
+
bool res = zcis_->Next(data, &size_);
|
| 318 |
+
if (res) overall_limit_ -= size_;
|
| 319 |
+
return res;
|
| 320 |
+
}
|
| 321 |
+
void StreamBackUp(int count) {
|
| 322 |
+
zcis_->BackUp(count);
|
| 323 |
+
overall_limit_ += count;
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
template <typename A>
|
| 327 |
+
const char* AppendSize(const char* ptr, int size, const A& append) {
|
| 328 |
+
int chunk_size = buffer_end_ + kSlopBytes - ptr;
|
| 329 |
+
do {
|
| 330 |
+
GOOGLE_DCHECK(size > chunk_size);
|
| 331 |
+
if (next_chunk_ == nullptr) return nullptr;
|
| 332 |
+
append(ptr, chunk_size);
|
| 333 |
+
ptr += chunk_size;
|
| 334 |
+
size -= chunk_size;
|
| 335 |
+
// TODO(gerbens) Next calls NextBuffer which generates buffers with
|
| 336 |
+
// overlap and thus incurs cost of copying the slop regions. This is not
|
| 337 |
+
// necessary for reading strings. We should just call Next buffers.
|
| 338 |
+
if (limit_ <= kSlopBytes) return nullptr;
|
| 339 |
+
ptr = Next();
|
| 340 |
+
if (ptr == nullptr) return nullptr; // passed the limit
|
| 341 |
+
ptr += kSlopBytes;
|
| 342 |
+
chunk_size = buffer_end_ + kSlopBytes - ptr;
|
| 343 |
+
} while (size > chunk_size);
|
| 344 |
+
append(ptr, size);
|
| 345 |
+
return ptr + size;
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
// AppendUntilEnd appends data until a limit (either a PushLimit or end of
|
| 349 |
+
// stream. Normal payloads are from length delimited fields which have an
|
| 350 |
+
// explicit size. Reading until limit only comes when the string takes
|
| 351 |
+
// the place of a protobuf, ie RawMessage/StringRawMessage, lazy fields and
|
| 352 |
+
// implicit weak messages. We keep these methods private and friend them.
|
| 353 |
+
template <typename A>
|
| 354 |
+
const char* AppendUntilEnd(const char* ptr, const A& append) {
|
| 355 |
+
if (ptr - buffer_end_ > limit_) return nullptr;
|
| 356 |
+
while (limit_ > kSlopBytes) {
|
| 357 |
+
size_t chunk_size = buffer_end_ + kSlopBytes - ptr;
|
| 358 |
+
append(ptr, chunk_size);
|
| 359 |
+
ptr = Next();
|
| 360 |
+
if (ptr == nullptr) return limit_end_;
|
| 361 |
+
ptr += kSlopBytes;
|
| 362 |
+
}
|
| 363 |
+
auto end = buffer_end_ + limit_;
|
| 364 |
+
GOOGLE_DCHECK(end >= ptr);
|
| 365 |
+
append(ptr, end - ptr);
|
| 366 |
+
return end;
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
PROTOBUF_NODISCARD const char* AppendString(const char* ptr,
|
| 370 |
+
std::string* str) {
|
| 371 |
+
return AppendUntilEnd(
|
| 372 |
+
ptr, [str](const char* p, ptrdiff_t s) { str->append(p, s); });
|
| 373 |
+
}
|
| 374 |
+
friend class ImplicitWeakMessage;
|
| 375 |
+
};
|
| 376 |
+
|
| 377 |
+
using LazyEagerVerifyFnType = const char* (*)(const char* ptr,
|
| 378 |
+
ParseContext* ctx);
|
| 379 |
+
using LazyEagerVerifyFnRef = std::remove_pointer<LazyEagerVerifyFnType>::type&;
|
| 380 |
+
|
| 381 |
+
// ParseContext holds all data that is global to the entire parse. Most
|
| 382 |
+
// importantly it contains the input stream, but also recursion depth and also
|
| 383 |
+
// stores the end group tag, in case a parser ended on a endgroup, to verify
|
| 384 |
+
// matching start/end group tags.
|
| 385 |
+
class PROTOBUF_EXPORT ParseContext : public EpsCopyInputStream {
|
| 386 |
+
public:
|
| 387 |
+
struct Data {
|
| 388 |
+
const DescriptorPool* pool = nullptr;
|
| 389 |
+
MessageFactory* factory = nullptr;
|
| 390 |
+
Arena* arena = nullptr;
|
| 391 |
+
};
|
| 392 |
+
|
| 393 |
+
template <typename... T>
|
| 394 |
+
ParseContext(int depth, bool aliasing, const char** start, T&&... args)
|
| 395 |
+
: EpsCopyInputStream(aliasing), depth_(depth) {
|
| 396 |
+
*start = InitFrom(std::forward<T>(args)...);
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
void TrackCorrectEnding() { group_depth_ = 0; }
|
| 400 |
+
|
| 401 |
+
bool Done(const char** ptr) { return DoneWithCheck(ptr, group_depth_); }
|
| 402 |
+
|
| 403 |
+
int depth() const { return depth_; }
|
| 404 |
+
|
| 405 |
+
Data& data() { return data_; }
|
| 406 |
+
const Data& data() const { return data_; }
|
| 407 |
+
|
| 408 |
+
const char* ParseMessage(MessageLite* msg, const char* ptr);
|
| 409 |
+
|
| 410 |
+
// Spawns a child parsing context that inherits key properties. New context
|
| 411 |
+
// inherits the following:
|
| 412 |
+
// --depth_, data_, check_required_fields_, lazy_parse_mode_
|
| 413 |
+
// The spawned context always disables aliasing (different input).
|
| 414 |
+
template <typename... T>
|
| 415 |
+
ParseContext Spawn(const char** start, T&&... args) {
|
| 416 |
+
ParseContext spawned(depth_, false, start, std::forward<T>(args)...);
|
| 417 |
+
// Transfer key context states.
|
| 418 |
+
spawned.data_ = data_;
|
| 419 |
+
return spawned;
|
| 420 |
+
}
|
| 421 |
+
|
| 422 |
+
// This overload supports those few cases where ParseMessage is called
|
| 423 |
+
// on a class that is not actually a proto message.
|
| 424 |
+
// TODO(jorg): Eliminate this use case.
|
| 425 |
+
template <typename T,
|
| 426 |
+
typename std::enable_if<!std::is_base_of<MessageLite, T>::value,
|
| 427 |
+
bool>::type = true>
|
| 428 |
+
PROTOBUF_NODISCARD const char* ParseMessage(T* msg, const char* ptr);
|
| 429 |
+
|
| 430 |
+
template <typename T>
|
| 431 |
+
PROTOBUF_NODISCARD PROTOBUF_NDEBUG_INLINE const char* ParseGroup(
|
| 432 |
+
T* msg, const char* ptr, uint32_t tag) {
|
| 433 |
+
if (--depth_ < 0) return nullptr;
|
| 434 |
+
group_depth_++;
|
| 435 |
+
ptr = msg->_InternalParse(ptr, this);
|
| 436 |
+
group_depth_--;
|
| 437 |
+
depth_++;
|
| 438 |
+
if (PROTOBUF_PREDICT_FALSE(!ConsumeEndGroup(tag))) return nullptr;
|
| 439 |
+
return ptr;
|
| 440 |
+
}
|
| 441 |
+
|
| 442 |
+
private:
|
| 443 |
+
// Out-of-line routine to save space in ParseContext::ParseMessage<T>
|
| 444 |
+
// int old;
|
| 445 |
+
// ptr = ReadSizeAndPushLimitAndDepth(ptr, &old)
|
| 446 |
+
// is equivalent to:
|
| 447 |
+
// int size = ReadSize(&ptr);
|
| 448 |
+
// if (!ptr) return nullptr;
|
| 449 |
+
// int old = PushLimit(ptr, size);
|
| 450 |
+
// if (--depth_ < 0) return nullptr;
|
| 451 |
+
PROTOBUF_NODISCARD const char* ReadSizeAndPushLimitAndDepth(const char* ptr,
|
| 452 |
+
int* old_limit);
|
| 453 |
+
|
| 454 |
+
// The context keeps an internal stack to keep track of the recursive
|
| 455 |
+
// part of the parse state.
|
| 456 |
+
// Current depth of the active parser, depth counts down.
|
| 457 |
+
// This is used to limit recursion depth (to prevent overflow on malicious
|
| 458 |
+
// data), but is also used to index in stack_ to store the current state.
|
| 459 |
+
int depth_;
|
| 460 |
+
// Unfortunately necessary for the fringe case of ending on 0 or end-group tag
|
| 461 |
+
// in the last kSlopBytes of a ZeroCopyInputStream chunk.
|
| 462 |
+
int group_depth_ = INT_MIN;
|
| 463 |
+
Data data_;
|
| 464 |
+
};
|
| 465 |
+
|
| 466 |
+
template <uint32_t tag>
|
| 467 |
+
bool ExpectTag(const char* ptr) {
|
| 468 |
+
if (tag < 128) {
|
| 469 |
+
return *ptr == static_cast<char>(tag);
|
| 470 |
+
} else {
|
| 471 |
+
static_assert(tag < 128 * 128, "We only expect tags for 1 or 2 bytes");
|
| 472 |
+
char buf[2] = {static_cast<char>(tag | 0x80), static_cast<char>(tag >> 7)};
|
| 473 |
+
return std::memcmp(ptr, buf, 2) == 0;
|
| 474 |
+
}
|
| 475 |
+
}
|
| 476 |
+
|
| 477 |
+
template <int>
|
| 478 |
+
struct EndianHelper;
|
| 479 |
+
|
| 480 |
+
template <>
|
| 481 |
+
struct EndianHelper<1> {
|
| 482 |
+
static uint8_t Load(const void* p) { return *static_cast<const uint8_t*>(p); }
|
| 483 |
+
};
|
| 484 |
+
|
| 485 |
+
template <>
|
| 486 |
+
struct EndianHelper<2> {
|
| 487 |
+
static uint16_t Load(const void* p) {
|
| 488 |
+
uint16_t tmp;
|
| 489 |
+
std::memcpy(&tmp, p, 2);
|
| 490 |
+
return little_endian::ToHost(tmp);
|
| 491 |
+
}
|
| 492 |
+
};
|
| 493 |
+
|
| 494 |
+
template <>
|
| 495 |
+
struct EndianHelper<4> {
|
| 496 |
+
static uint32_t Load(const void* p) {
|
| 497 |
+
uint32_t tmp;
|
| 498 |
+
std::memcpy(&tmp, p, 4);
|
| 499 |
+
return little_endian::ToHost(tmp);
|
| 500 |
+
}
|
| 501 |
+
};
|
| 502 |
+
|
| 503 |
+
template <>
|
| 504 |
+
struct EndianHelper<8> {
|
| 505 |
+
static uint64_t Load(const void* p) {
|
| 506 |
+
uint64_t tmp;
|
| 507 |
+
std::memcpy(&tmp, p, 8);
|
| 508 |
+
return little_endian::ToHost(tmp);
|
| 509 |
+
}
|
| 510 |
+
};
|
| 511 |
+
|
| 512 |
+
template <typename T>
|
| 513 |
+
T UnalignedLoad(const char* p) {
|
| 514 |
+
auto tmp = EndianHelper<sizeof(T)>::Load(p);
|
| 515 |
+
T res;
|
| 516 |
+
memcpy(&res, &tmp, sizeof(T));
|
| 517 |
+
return res;
|
| 518 |
+
}
|
| 519 |
+
|
| 520 |
+
PROTOBUF_EXPORT
|
| 521 |
+
std::pair<const char*, uint32_t> VarintParseSlow32(const char* p, uint32_t res);
|
| 522 |
+
PROTOBUF_EXPORT
|
| 523 |
+
std::pair<const char*, uint64_t> VarintParseSlow64(const char* p, uint32_t res);
|
| 524 |
+
|
| 525 |
+
inline const char* VarintParseSlow(const char* p, uint32_t res, uint32_t* out) {
|
| 526 |
+
auto tmp = VarintParseSlow32(p, res);
|
| 527 |
+
*out = tmp.second;
|
| 528 |
+
return tmp.first;
|
| 529 |
+
}
|
| 530 |
+
|
| 531 |
+
inline const char* VarintParseSlow(const char* p, uint32_t res, uint64_t* out) {
|
| 532 |
+
auto tmp = VarintParseSlow64(p, res);
|
| 533 |
+
*out = tmp.second;
|
| 534 |
+
return tmp.first;
|
| 535 |
+
}
|
| 536 |
+
|
| 537 |
+
template <typename T>
|
| 538 |
+
PROTOBUF_NODISCARD const char* VarintParse(const char* p, T* out) {
|
| 539 |
+
auto ptr = reinterpret_cast<const uint8_t*>(p);
|
| 540 |
+
uint32_t res = ptr[0];
|
| 541 |
+
if (!(res & 0x80)) {
|
| 542 |
+
*out = res;
|
| 543 |
+
return p + 1;
|
| 544 |
+
}
|
| 545 |
+
uint32_t byte = ptr[1];
|
| 546 |
+
res += (byte - 1) << 7;
|
| 547 |
+
if (!(byte & 0x80)) {
|
| 548 |
+
*out = res;
|
| 549 |
+
return p + 2;
|
| 550 |
+
}
|
| 551 |
+
return VarintParseSlow(p, res, out);
|
| 552 |
+
}
|
| 553 |
+
|
| 554 |
+
// Used for tags, could read up to 5 bytes which must be available.
|
| 555 |
+
// Caller must ensure its safe to call.
|
| 556 |
+
|
| 557 |
+
PROTOBUF_EXPORT
|
| 558 |
+
std::pair<const char*, uint32_t> ReadTagFallback(const char* p, uint32_t res);
|
| 559 |
+
|
| 560 |
+
// Same as ParseVarint but only accept 5 bytes at most.
|
| 561 |
+
inline const char* ReadTag(const char* p, uint32_t* out,
|
| 562 |
+
uint32_t /*max_tag*/ = 0) {
|
| 563 |
+
uint32_t res = static_cast<uint8_t>(p[0]);
|
| 564 |
+
if (res < 128) {
|
| 565 |
+
*out = res;
|
| 566 |
+
return p + 1;
|
| 567 |
+
}
|
| 568 |
+
uint32_t second = static_cast<uint8_t>(p[1]);
|
| 569 |
+
res += (second - 1) << 7;
|
| 570 |
+
if (second < 128) {
|
| 571 |
+
*out = res;
|
| 572 |
+
return p + 2;
|
| 573 |
+
}
|
| 574 |
+
auto tmp = ReadTagFallback(p, res);
|
| 575 |
+
*out = tmp.second;
|
| 576 |
+
return tmp.first;
|
| 577 |
+
}
|
| 578 |
+
|
| 579 |
+
// As above, but optimized to consume very few registers while still being fast,
|
| 580 |
+
// ReadTagInlined is useful for callers that don't mind the extra code but would
|
| 581 |
+
// like to avoid an extern function call causing spills into the stack.
|
| 582 |
+
//
|
| 583 |
+
// Two support routines for ReadTagInlined come first...
|
| 584 |
+
template <class T>
|
| 585 |
+
PROTOBUF_NODISCARD PROTOBUF_ALWAYS_INLINE constexpr T RotateLeft(
|
| 586 |
+
T x, int s) noexcept {
|
| 587 |
+
return static_cast<T>(x << (s & (std::numeric_limits<T>::digits - 1))) |
|
| 588 |
+
static_cast<T>(x >> ((-s) & (std::numeric_limits<T>::digits - 1)));
|
| 589 |
+
}
|
| 590 |
+
|
| 591 |
+
PROTOBUF_NODISCARD inline PROTOBUF_ALWAYS_INLINE uint64_t
|
| 592 |
+
RotRight7AndReplaceLowByte(uint64_t res, const char& byte) {
|
| 593 |
+
#if defined(__x86_64__) && defined(__GNUC__)
|
| 594 |
+
// This will only use one register for `res`.
|
| 595 |
+
// `byte` comes as a reference to allow the compiler to generate code like:
|
| 596 |
+
//
|
| 597 |
+
// rorq $7, %rcx
|
| 598 |
+
// movb 1(%rax), %cl
|
| 599 |
+
//
|
| 600 |
+
// which avoids loading the incoming bytes into a separate register first.
|
| 601 |
+
asm("ror $7,%0\n\t"
|
| 602 |
+
"movb %1,%b0"
|
| 603 |
+
: "+r"(res)
|
| 604 |
+
: "m"(byte));
|
| 605 |
+
#else
|
| 606 |
+
res = RotateLeft(res, -7);
|
| 607 |
+
res = res & ~0xFF;
|
| 608 |
+
res |= 0xFF & byte;
|
| 609 |
+
#endif
|
| 610 |
+
return res;
|
| 611 |
+
};
|
| 612 |
+
|
| 613 |
+
inline PROTOBUF_ALWAYS_INLINE
|
| 614 |
+
const char* ReadTagInlined(const char* ptr, uint32_t* out) {
|
| 615 |
+
uint64_t res = 0xFF & ptr[0];
|
| 616 |
+
if (PROTOBUF_PREDICT_FALSE(res >= 128)) {
|
| 617 |
+
res = RotRight7AndReplaceLowByte(res, ptr[1]);
|
| 618 |
+
if (PROTOBUF_PREDICT_FALSE(res & 0x80)) {
|
| 619 |
+
res = RotRight7AndReplaceLowByte(res, ptr[2]);
|
| 620 |
+
if (PROTOBUF_PREDICT_FALSE(res & 0x80)) {
|
| 621 |
+
res = RotRight7AndReplaceLowByte(res, ptr[3]);
|
| 622 |
+
if (PROTOBUF_PREDICT_FALSE(res & 0x80)) {
|
| 623 |
+
// Note: this wouldn't work if res were 32-bit,
|
| 624 |
+
// because then replacing the low byte would overwrite
|
| 625 |
+
// the bottom 4 bits of the result.
|
| 626 |
+
res = RotRight7AndReplaceLowByte(res, ptr[4]);
|
| 627 |
+
if (PROTOBUF_PREDICT_FALSE(res & 0x80)) {
|
| 628 |
+
// The proto format does not permit longer than 5-byte encodings for
|
| 629 |
+
// tags.
|
| 630 |
+
*out = 0;
|
| 631 |
+
return nullptr;
|
| 632 |
+
}
|
| 633 |
+
*out = static_cast<uint32_t>(RotateLeft(res, 28));
|
| 634 |
+
#if defined(__GNUC__)
|
| 635 |
+
// Note: this asm statement prevents the compiler from
|
| 636 |
+
// trying to share the "return ptr + constant" among all
|
| 637 |
+
// branches.
|
| 638 |
+
asm("" : "+r"(ptr));
|
| 639 |
+
#endif
|
| 640 |
+
return ptr + 5;
|
| 641 |
+
}
|
| 642 |
+
*out = static_cast<uint32_t>(RotateLeft(res, 21));
|
| 643 |
+
return ptr + 4;
|
| 644 |
+
}
|
| 645 |
+
*out = static_cast<uint32_t>(RotateLeft(res, 14));
|
| 646 |
+
return ptr + 3;
|
| 647 |
+
}
|
| 648 |
+
*out = static_cast<uint32_t>(RotateLeft(res, 7));
|
| 649 |
+
return ptr + 2;
|
| 650 |
+
}
|
| 651 |
+
*out = static_cast<uint32_t>(res);
|
| 652 |
+
return ptr + 1;
|
| 653 |
+
}
|
| 654 |
+
|
| 655 |
+
// Decode 2 consecutive bytes of a varint and returns the value, shifted left
|
| 656 |
+
// by 1. It simultaneous updates *ptr to *ptr + 1 or *ptr + 2 depending if the
|
| 657 |
+
// first byte's continuation bit is set.
|
| 658 |
+
// If bit 15 of return value is set (equivalent to the continuation bits of both
|
| 659 |
+
// bytes being set) the varint continues, otherwise the parse is done. On x86
|
| 660 |
+
// movsx eax, dil
|
| 661 |
+
// and edi, eax
|
| 662 |
+
// add eax, edi
|
| 663 |
+
// adc [rsi], 1
|
| 664 |
+
inline uint32_t DecodeTwoBytes(const char** ptr) {
|
| 665 |
+
uint32_t value = UnalignedLoad<uint16_t>(*ptr);
|
| 666 |
+
// Sign extend the low byte continuation bit
|
| 667 |
+
uint32_t x = static_cast<int8_t>(value);
|
| 668 |
+
value &= x; // Mask out the high byte iff no continuation
|
| 669 |
+
// This add is an amazing operation, it cancels the low byte continuation bit
|
| 670 |
+
// from y transferring it to the carry. Simultaneously it also shifts the 7
|
| 671 |
+
// LSB left by one tightly against high byte varint bits. Hence value now
|
| 672 |
+
// contains the unpacked value shifted left by 1.
|
| 673 |
+
value += x;
|
| 674 |
+
// Use the carry to update the ptr appropriately.
|
| 675 |
+
*ptr += value < x ? 2 : 1;
|
| 676 |
+
return value;
|
| 677 |
+
}
|
| 678 |
+
|
| 679 |
+
// More efficient varint parsing for big varints
|
| 680 |
+
inline const char* ParseBigVarint(const char* p, uint64_t* out) {
|
| 681 |
+
auto pnew = p;
|
| 682 |
+
auto tmp = DecodeTwoBytes(&pnew);
|
| 683 |
+
uint64_t res = tmp >> 1;
|
| 684 |
+
if (PROTOBUF_PREDICT_TRUE(static_cast<std::int16_t>(tmp) >= 0)) {
|
| 685 |
+
*out = res;
|
| 686 |
+
return pnew;
|
| 687 |
+
}
|
| 688 |
+
for (std::uint32_t i = 1; i < 5; i++) {
|
| 689 |
+
pnew = p + 2 * i;
|
| 690 |
+
tmp = DecodeTwoBytes(&pnew);
|
| 691 |
+
res += (static_cast<std::uint64_t>(tmp) - 2) << (14 * i - 1);
|
| 692 |
+
if (PROTOBUF_PREDICT_TRUE(static_cast<std::int16_t>(tmp) >= 0)) {
|
| 693 |
+
*out = res;
|
| 694 |
+
return pnew;
|
| 695 |
+
}
|
| 696 |
+
}
|
| 697 |
+
return nullptr;
|
| 698 |
+
}
|
| 699 |
+
|
| 700 |
+
PROTOBUF_EXPORT
|
| 701 |
+
std::pair<const char*, int32_t> ReadSizeFallback(const char* p, uint32_t first);
|
| 702 |
+
// Used for tags, could read up to 5 bytes which must be available. Additionally
|
| 703 |
+
// it makes sure the unsigned value fits a int32_t, otherwise returns nullptr.
|
| 704 |
+
// Caller must ensure its safe to call.
|
| 705 |
+
inline uint32_t ReadSize(const char** pp) {
|
| 706 |
+
auto p = *pp;
|
| 707 |
+
uint32_t res = static_cast<uint8_t>(p[0]);
|
| 708 |
+
if (res < 128) {
|
| 709 |
+
*pp = p + 1;
|
| 710 |
+
return res;
|
| 711 |
+
}
|
| 712 |
+
auto x = ReadSizeFallback(p, res);
|
| 713 |
+
*pp = x.first;
|
| 714 |
+
return x.second;
|
| 715 |
+
}
|
| 716 |
+
|
| 717 |
+
// Some convenience functions to simplify the generated parse loop code.
|
| 718 |
+
// Returning the value and updating the buffer pointer allows for nicer
|
| 719 |
+
// function composition. We rely on the compiler to inline this.
|
| 720 |
+
// Also in debug compiles having local scoped variables tend to generated
|
| 721 |
+
// stack frames that scale as O(num fields).
|
| 722 |
+
inline uint64_t ReadVarint64(const char** p) {
|
| 723 |
+
uint64_t tmp;
|
| 724 |
+
*p = VarintParse(*p, &tmp);
|
| 725 |
+
return tmp;
|
| 726 |
+
}
|
| 727 |
+
|
| 728 |
+
inline uint32_t ReadVarint32(const char** p) {
|
| 729 |
+
uint32_t tmp;
|
| 730 |
+
*p = VarintParse(*p, &tmp);
|
| 731 |
+
return tmp;
|
| 732 |
+
}
|
| 733 |
+
|
| 734 |
+
inline int64_t ReadVarintZigZag64(const char** p) {
|
| 735 |
+
uint64_t tmp;
|
| 736 |
+
*p = VarintParse(*p, &tmp);
|
| 737 |
+
return WireFormatLite::ZigZagDecode64(tmp);
|
| 738 |
+
}
|
| 739 |
+
|
| 740 |
+
inline int32_t ReadVarintZigZag32(const char** p) {
|
| 741 |
+
uint64_t tmp;
|
| 742 |
+
*p = VarintParse(*p, &tmp);
|
| 743 |
+
return WireFormatLite::ZigZagDecode32(static_cast<uint32_t>(tmp));
|
| 744 |
+
}
|
| 745 |
+
|
| 746 |
+
template <typename T, typename std::enable_if<
|
| 747 |
+
!std::is_base_of<MessageLite, T>::value, bool>::type>
|
| 748 |
+
PROTOBUF_NODISCARD const char* ParseContext::ParseMessage(T* msg,
|
| 749 |
+
const char* ptr) {
|
| 750 |
+
int old;
|
| 751 |
+
ptr = ReadSizeAndPushLimitAndDepth(ptr, &old);
|
| 752 |
+
ptr = ptr ? msg->_InternalParse(ptr, this) : nullptr;
|
| 753 |
+
depth_++;
|
| 754 |
+
if (!PopLimit(old)) return nullptr;
|
| 755 |
+
return ptr;
|
| 756 |
+
}
|
| 757 |
+
|
| 758 |
+
template <typename Tag, typename T>
|
| 759 |
+
const char* EpsCopyInputStream::ReadRepeatedFixed(const char* ptr,
|
| 760 |
+
Tag expected_tag,
|
| 761 |
+
RepeatedField<T>* out) {
|
| 762 |
+
do {
|
| 763 |
+
out->Add(UnalignedLoad<T>(ptr));
|
| 764 |
+
ptr += sizeof(T);
|
| 765 |
+
if (PROTOBUF_PREDICT_FALSE(ptr >= limit_end_)) return ptr;
|
| 766 |
+
} while (UnalignedLoad<Tag>(ptr) == expected_tag && (ptr += sizeof(Tag)));
|
| 767 |
+
return ptr;
|
| 768 |
+
}
|
| 769 |
+
|
| 770 |
+
// Add any of the following lines to debug which parse function is failing.
|
| 771 |
+
|
| 772 |
+
#define GOOGLE_PROTOBUF_ASSERT_RETURN(predicate, ret) \
|
| 773 |
+
if (!(predicate)) { \
|
| 774 |
+
/* ::raise(SIGINT); */ \
|
| 775 |
+
/* GOOGLE_LOG(ERROR) << "Parse failure"; */ \
|
| 776 |
+
return ret; \
|
| 777 |
+
}
|
| 778 |
+
|
| 779 |
+
#define GOOGLE_PROTOBUF_PARSER_ASSERT(predicate) \
|
| 780 |
+
GOOGLE_PROTOBUF_ASSERT_RETURN(predicate, nullptr)
|
| 781 |
+
|
| 782 |
+
template <typename T>
|
| 783 |
+
const char* EpsCopyInputStream::ReadPackedFixed(const char* ptr, int size,
|
| 784 |
+
RepeatedField<T>* out) {
|
| 785 |
+
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
| 786 |
+
int nbytes = buffer_end_ + kSlopBytes - ptr;
|
| 787 |
+
while (size > nbytes) {
|
| 788 |
+
int num = nbytes / sizeof(T);
|
| 789 |
+
int old_entries = out->size();
|
| 790 |
+
out->Reserve(old_entries + num);
|
| 791 |
+
int block_size = num * sizeof(T);
|
| 792 |
+
auto dst = out->AddNAlreadyReserved(num);
|
| 793 |
+
#ifdef PROTOBUF_LITTLE_ENDIAN
|
| 794 |
+
std::memcpy(dst, ptr, block_size);
|
| 795 |
+
#else
|
| 796 |
+
for (int i = 0; i < num; i++)
|
| 797 |
+
dst[i] = UnalignedLoad<T>(ptr + i * sizeof(T));
|
| 798 |
+
#endif
|
| 799 |
+
size -= block_size;
|
| 800 |
+
if (limit_ <= kSlopBytes) return nullptr;
|
| 801 |
+
ptr = Next();
|
| 802 |
+
if (ptr == nullptr) return nullptr;
|
| 803 |
+
ptr += kSlopBytes - (nbytes - block_size);
|
| 804 |
+
nbytes = buffer_end_ + kSlopBytes - ptr;
|
| 805 |
+
}
|
| 806 |
+
int num = size / sizeof(T);
|
| 807 |
+
int old_entries = out->size();
|
| 808 |
+
out->Reserve(old_entries + num);
|
| 809 |
+
int block_size = num * sizeof(T);
|
| 810 |
+
auto dst = out->AddNAlreadyReserved(num);
|
| 811 |
+
#ifdef PROTOBUF_LITTLE_ENDIAN
|
| 812 |
+
std::memcpy(dst, ptr, block_size);
|
| 813 |
+
#else
|
| 814 |
+
for (int i = 0; i < num; i++) dst[i] = UnalignedLoad<T>(ptr + i * sizeof(T));
|
| 815 |
+
#endif
|
| 816 |
+
ptr += block_size;
|
| 817 |
+
if (size != block_size) return nullptr;
|
| 818 |
+
return ptr;
|
| 819 |
+
}
|
| 820 |
+
|
| 821 |
+
template <typename Add>
|
| 822 |
+
const char* ReadPackedVarintArray(const char* ptr, const char* end, Add add) {
|
| 823 |
+
while (ptr < end) {
|
| 824 |
+
uint64_t varint;
|
| 825 |
+
ptr = VarintParse(ptr, &varint);
|
| 826 |
+
if (ptr == nullptr) return nullptr;
|
| 827 |
+
add(varint);
|
| 828 |
+
}
|
| 829 |
+
return ptr;
|
| 830 |
+
}
|
| 831 |
+
|
| 832 |
+
template <typename Add>
|
| 833 |
+
const char* EpsCopyInputStream::ReadPackedVarint(const char* ptr, Add add) {
|
| 834 |
+
int size = ReadSize(&ptr);
|
| 835 |
+
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
| 836 |
+
int chunk_size = buffer_end_ - ptr;
|
| 837 |
+
while (size > chunk_size) {
|
| 838 |
+
ptr = ReadPackedVarintArray(ptr, buffer_end_, add);
|
| 839 |
+
if (ptr == nullptr) return nullptr;
|
| 840 |
+
int overrun = ptr - buffer_end_;
|
| 841 |
+
GOOGLE_DCHECK(overrun >= 0 && overrun <= kSlopBytes);
|
| 842 |
+
if (size - chunk_size <= kSlopBytes) {
|
| 843 |
+
// The current buffer contains all the information needed, we don't need
|
| 844 |
+
// to flip buffers. However we must parse from a buffer with enough space
|
| 845 |
+
// so we are not prone to a buffer overflow.
|
| 846 |
+
char buf[kSlopBytes + 10] = {};
|
| 847 |
+
std::memcpy(buf, buffer_end_, kSlopBytes);
|
| 848 |
+
GOOGLE_CHECK_LE(size - chunk_size, kSlopBytes);
|
| 849 |
+
auto end = buf + (size - chunk_size);
|
| 850 |
+
auto res = ReadPackedVarintArray(buf + overrun, end, add);
|
| 851 |
+
if (res == nullptr || res != end) return nullptr;
|
| 852 |
+
return buffer_end_ + (res - buf);
|
| 853 |
+
}
|
| 854 |
+
size -= overrun + chunk_size;
|
| 855 |
+
GOOGLE_DCHECK_GT(size, 0);
|
| 856 |
+
// We must flip buffers
|
| 857 |
+
if (limit_ <= kSlopBytes) return nullptr;
|
| 858 |
+
ptr = Next();
|
| 859 |
+
if (ptr == nullptr) return nullptr;
|
| 860 |
+
ptr += overrun;
|
| 861 |
+
chunk_size = buffer_end_ - ptr;
|
| 862 |
+
}
|
| 863 |
+
auto end = ptr + size;
|
| 864 |
+
ptr = ReadPackedVarintArray(ptr, end, add);
|
| 865 |
+
return end == ptr ? ptr : nullptr;
|
| 866 |
+
}
|
| 867 |
+
|
| 868 |
+
// Helper for verification of utf8
|
| 869 |
+
PROTOBUF_EXPORT
|
| 870 |
+
bool VerifyUTF8(StringPiece s, const char* field_name);
|
| 871 |
+
|
| 872 |
+
inline bool VerifyUTF8(const std::string* s, const char* field_name) {
|
| 873 |
+
return VerifyUTF8(*s, field_name);
|
| 874 |
+
}
|
| 875 |
+
|
| 876 |
+
// All the string parsers with or without UTF checking and for all CTypes.
|
| 877 |
+
PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* InlineGreedyStringParser(
|
| 878 |
+
std::string* s, const char* ptr, ParseContext* ctx);
|
| 879 |
+
|
| 880 |
+
|
| 881 |
+
template <typename T>
|
| 882 |
+
PROTOBUF_NODISCARD const char* FieldParser(uint64_t tag, T& field_parser,
|
| 883 |
+
const char* ptr, ParseContext* ctx) {
|
| 884 |
+
uint32_t number = tag >> 3;
|
| 885 |
+
GOOGLE_PROTOBUF_PARSER_ASSERT(number != 0);
|
| 886 |
+
using WireType = internal::WireFormatLite::WireType;
|
| 887 |
+
switch (tag & 7) {
|
| 888 |
+
case WireType::WIRETYPE_VARINT: {
|
| 889 |
+
uint64_t value;
|
| 890 |
+
ptr = VarintParse(ptr, &value);
|
| 891 |
+
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
| 892 |
+
field_parser.AddVarint(number, value);
|
| 893 |
+
break;
|
| 894 |
+
}
|
| 895 |
+
case WireType::WIRETYPE_FIXED64: {
|
| 896 |
+
uint64_t value = UnalignedLoad<uint64_t>(ptr);
|
| 897 |
+
ptr += 8;
|
| 898 |
+
field_parser.AddFixed64(number, value);
|
| 899 |
+
break;
|
| 900 |
+
}
|
| 901 |
+
case WireType::WIRETYPE_LENGTH_DELIMITED: {
|
| 902 |
+
ptr = field_parser.ParseLengthDelimited(number, ptr, ctx);
|
| 903 |
+
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
| 904 |
+
break;
|
| 905 |
+
}
|
| 906 |
+
case WireType::WIRETYPE_START_GROUP: {
|
| 907 |
+
ptr = field_parser.ParseGroup(number, ptr, ctx);
|
| 908 |
+
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
| 909 |
+
break;
|
| 910 |
+
}
|
| 911 |
+
case WireType::WIRETYPE_END_GROUP: {
|
| 912 |
+
GOOGLE_LOG(FATAL) << "Can't happen";
|
| 913 |
+
break;
|
| 914 |
+
}
|
| 915 |
+
case WireType::WIRETYPE_FIXED32: {
|
| 916 |
+
uint32_t value = UnalignedLoad<uint32_t>(ptr);
|
| 917 |
+
ptr += 4;
|
| 918 |
+
field_parser.AddFixed32(number, value);
|
| 919 |
+
break;
|
| 920 |
+
}
|
| 921 |
+
default:
|
| 922 |
+
return nullptr;
|
| 923 |
+
}
|
| 924 |
+
return ptr;
|
| 925 |
+
}
|
| 926 |
+
|
| 927 |
+
template <typename T>
|
| 928 |
+
PROTOBUF_NODISCARD const char* WireFormatParser(T& field_parser,
|
| 929 |
+
const char* ptr,
|
| 930 |
+
ParseContext* ctx) {
|
| 931 |
+
while (!ctx->Done(&ptr)) {
|
| 932 |
+
uint32_t tag;
|
| 933 |
+
ptr = ReadTag(ptr, &tag);
|
| 934 |
+
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr != nullptr);
|
| 935 |
+
if (tag == 0 || (tag & 7) == 4) {
|
| 936 |
+
ctx->SetLastTag(tag);
|
| 937 |
+
return ptr;
|
| 938 |
+
}
|
| 939 |
+
ptr = FieldParser(tag, field_parser, ptr, ctx);
|
| 940 |
+
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr != nullptr);
|
| 941 |
+
}
|
| 942 |
+
return ptr;
|
| 943 |
+
}
|
| 944 |
+
|
| 945 |
+
// The packed parsers parse repeated numeric primitives directly into the
|
| 946 |
+
// corresponding field
|
| 947 |
+
|
| 948 |
+
// These are packed varints
|
| 949 |
+
PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedInt32Parser(
|
| 950 |
+
void* object, const char* ptr, ParseContext* ctx);
|
| 951 |
+
PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedUInt32Parser(
|
| 952 |
+
void* object, const char* ptr, ParseContext* ctx);
|
| 953 |
+
PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedInt64Parser(
|
| 954 |
+
void* object, const char* ptr, ParseContext* ctx);
|
| 955 |
+
PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedUInt64Parser(
|
| 956 |
+
void* object, const char* ptr, ParseContext* ctx);
|
| 957 |
+
PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedSInt32Parser(
|
| 958 |
+
void* object, const char* ptr, ParseContext* ctx);
|
| 959 |
+
PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedSInt64Parser(
|
| 960 |
+
void* object, const char* ptr, ParseContext* ctx);
|
| 961 |
+
PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedEnumParser(
|
| 962 |
+
void* object, const char* ptr, ParseContext* ctx);
|
| 963 |
+
|
| 964 |
+
template <typename T>
|
| 965 |
+
PROTOBUF_NODISCARD const char* PackedEnumParser(void* object, const char* ptr,
|
| 966 |
+
ParseContext* ctx,
|
| 967 |
+
bool (*is_valid)(int),
|
| 968 |
+
InternalMetadata* metadata,
|
| 969 |
+
int field_num) {
|
| 970 |
+
return ctx->ReadPackedVarint(
|
| 971 |
+
ptr, [object, is_valid, metadata, field_num](uint64_t val) {
|
| 972 |
+
if (is_valid(val)) {
|
| 973 |
+
static_cast<RepeatedField<int>*>(object)->Add(val);
|
| 974 |
+
} else {
|
| 975 |
+
WriteVarint(field_num, val, metadata->mutable_unknown_fields<T>());
|
| 976 |
+
}
|
| 977 |
+
});
|
| 978 |
+
}
|
| 979 |
+
|
| 980 |
+
template <typename T>
|
| 981 |
+
PROTOBUF_NODISCARD const char* PackedEnumParserArg(
|
| 982 |
+
void* object, const char* ptr, ParseContext* ctx,
|
| 983 |
+
bool (*is_valid)(const void*, int), const void* data,
|
| 984 |
+
InternalMetadata* metadata, int field_num) {
|
| 985 |
+
return ctx->ReadPackedVarint(
|
| 986 |
+
ptr, [object, is_valid, data, metadata, field_num](uint64_t val) {
|
| 987 |
+
if (is_valid(data, val)) {
|
| 988 |
+
static_cast<RepeatedField<int>*>(object)->Add(val);
|
| 989 |
+
} else {
|
| 990 |
+
WriteVarint(field_num, val, metadata->mutable_unknown_fields<T>());
|
| 991 |
+
}
|
| 992 |
+
});
|
| 993 |
+
}
|
| 994 |
+
|
| 995 |
+
PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedBoolParser(
|
| 996 |
+
void* object, const char* ptr, ParseContext* ctx);
|
| 997 |
+
PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedFixed32Parser(
|
| 998 |
+
void* object, const char* ptr, ParseContext* ctx);
|
| 999 |
+
PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedSFixed32Parser(
|
| 1000 |
+
void* object, const char* ptr, ParseContext* ctx);
|
| 1001 |
+
PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedFixed64Parser(
|
| 1002 |
+
void* object, const char* ptr, ParseContext* ctx);
|
| 1003 |
+
PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedSFixed64Parser(
|
| 1004 |
+
void* object, const char* ptr, ParseContext* ctx);
|
| 1005 |
+
PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedFloatParser(
|
| 1006 |
+
void* object, const char* ptr, ParseContext* ctx);
|
| 1007 |
+
PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* PackedDoubleParser(
|
| 1008 |
+
void* object, const char* ptr, ParseContext* ctx);
|
| 1009 |
+
|
| 1010 |
+
// This is the only recursive parser.
|
| 1011 |
+
PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* UnknownGroupLiteParse(
|
| 1012 |
+
std::string* unknown, const char* ptr, ParseContext* ctx);
|
| 1013 |
+
// This is a helper to for the UnknownGroupLiteParse but is actually also
|
| 1014 |
+
// useful in the generated code. It uses overload on std::string* vs
|
| 1015 |
+
// UnknownFieldSet* to make the generated code isomorphic between full and lite.
|
| 1016 |
+
PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* UnknownFieldParse(
|
| 1017 |
+
uint32_t tag, std::string* unknown, const char* ptr, ParseContext* ctx);
|
| 1018 |
+
|
| 1019 |
+
} // namespace internal
|
| 1020 |
+
} // namespace protobuf
|
| 1021 |
+
} // namespace google
|
| 1022 |
+
|
| 1023 |
+
#include <google/protobuf/port_undef.inc>
|
| 1024 |
+
|
| 1025 |
+
#endif // GOOGLE_PROTOBUF_PARSE_CONTEXT_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/port_def.inc
ADDED
|
@@ -0,0 +1,928 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// This file defines common macros that are used in protobuf.
|
| 32 |
+
//
|
| 33 |
+
// To hide these definitions from the outside world (and to prevent collisions
|
| 34 |
+
// if more than one version of protobuf is #included in the same project) you
|
| 35 |
+
// must follow this pattern when #including port_def.inc in a header file:
|
| 36 |
+
//
|
| 37 |
+
// #include "other_header.h"
|
| 38 |
+
// #include "message.h"
|
| 39 |
+
// // etc.
|
| 40 |
+
//
|
| 41 |
+
// #include "port_def.inc" // MUST be last header included
|
| 42 |
+
//
|
| 43 |
+
// // Definitions for this header.
|
| 44 |
+
//
|
| 45 |
+
// #include "port_undef.inc"
|
| 46 |
+
//
|
| 47 |
+
// This is a textual header with no include guard, because we want to
|
| 48 |
+
// detect/prohibit anytime it is #included twice without a corresponding
|
| 49 |
+
// #undef.
|
| 50 |
+
|
| 51 |
+
// The definitions in this file are intended to be portable across Clang,
|
| 52 |
+
// GCC, and MSVC. Function-like macros are usable without an #ifdef guard.
|
| 53 |
+
// Syntax macros (for example, attributes) are always defined, although
|
| 54 |
+
// they may be empty.
|
| 55 |
+
//
|
| 56 |
+
// Some definitions rely on the NDEBUG macro and/or (in MSVC) _DEBUG:
|
| 57 |
+
// - https://en.cppreference.com/w/c/error/assert
|
| 58 |
+
// - https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros#microsoft-specific-predefined-macros
|
| 59 |
+
//
|
| 60 |
+
// References for predefined macros:
|
| 61 |
+
// - Standard: https://en.cppreference.com/w/cpp/preprocessor/replace
|
| 62 |
+
// - Clang: https://clang.llvm.org/docs/LanguageExtensions.html
|
| 63 |
+
// (see also GCC predefined macros)
|
| 64 |
+
// - GCC: https://gcc.gnu.org/onlinedocs/cpp/Predefined-Macros.html
|
| 65 |
+
// - MSVC: https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
|
| 66 |
+
// - Interactive (Clang/GCC only): https://www.compiler-explorer.com/z/hc6jKd3sj
|
| 67 |
+
//
|
| 68 |
+
// References for attributes (and extension attributes):
|
| 69 |
+
// - Standard: https://en.cppreference.com/w/cpp/language/attributes
|
| 70 |
+
// - Clang: https://clang.llvm.org/docs/AttributeReference.html
|
| 71 |
+
// - GCC: https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html
|
| 72 |
+
// (see Clang attribute docs as well)
|
| 73 |
+
//
|
| 74 |
+
// References for standard C++ language conformance (and minimum versions):
|
| 75 |
+
// - Clang: https://clang.llvm.org/cxx_status.html
|
| 76 |
+
// - GCC: https://gcc.gnu.org/projects/cxx-status.html
|
| 77 |
+
// - MSVC: https://docs.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance
|
| 78 |
+
//
|
| 79 |
+
// Historical release notes (which can help to determine minimum versions):
|
| 80 |
+
// - Clang: https://releases.llvm.org/
|
| 81 |
+
// - GCC: https://gcc.gnu.org/releases.html
|
| 82 |
+
// - MSVC: https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes-history
|
| 83 |
+
// https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2017-relnotes-history
|
| 84 |
+
|
| 85 |
+
// Portable fallbacks for C++20 feature test macros:
|
| 86 |
+
// https://en.cppreference.com/w/cpp/feature_test
|
| 87 |
+
#ifndef __has_cpp_attribute
|
| 88 |
+
#define __has_cpp_attribute(x) 0
|
| 89 |
+
#define PROTOBUF_has_cpp_attribute_DEFINED_
|
| 90 |
+
#endif
|
| 91 |
+
|
| 92 |
+
// Portable fallback for Clang's __has_feature macro:
|
| 93 |
+
// https://clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension
|
| 94 |
+
#ifndef __has_feature
|
| 95 |
+
#define __has_feature(x) 0
|
| 96 |
+
#define PROTOBUF_has_feature_DEFINED_
|
| 97 |
+
#endif
|
| 98 |
+
|
| 99 |
+
// Portable fallback for Clang's __has_warning macro:
|
| 100 |
+
#ifndef __has_warning
|
| 101 |
+
#define __has_warning(x) 0
|
| 102 |
+
#define PROTOBUF_has_warning_DEFINED_
|
| 103 |
+
#endif
|
| 104 |
+
|
| 105 |
+
// Portable fallbacks for the __has_attribute macro (GCC and Clang):
|
| 106 |
+
// https://clang.llvm.org/docs/LanguageExtensions.html#has-attribute
|
| 107 |
+
// https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fattribute.html
|
| 108 |
+
#ifndef __has_attribute
|
| 109 |
+
#define __has_attribute(x) 0
|
| 110 |
+
#define PROTOBUF_has_attribute_DEFINED_
|
| 111 |
+
#endif
|
| 112 |
+
|
| 113 |
+
// Portable fallback for __has_builtin (GCC and Clang):
|
| 114 |
+
// https://clang.llvm.org/docs/LanguageExtensions.html#has-builtin
|
| 115 |
+
// https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fbuiltin.html
|
| 116 |
+
#ifndef __has_builtin
|
| 117 |
+
#define __has_builtin(x) 0
|
| 118 |
+
#define PROTOBUF_has_builtin_DEFINED_
|
| 119 |
+
#endif
|
| 120 |
+
|
| 121 |
+
// Portable PROTOBUF_BUILTIN_BSWAPxx definitions
|
| 122 |
+
// Code must check for availability, e.g.: `defined(PROTOBUF_BUILTIN_BSWAP32)`
|
| 123 |
+
#ifdef PROTOBUF_BUILTIN_BSWAP16
|
| 124 |
+
#error PROTOBUF_BUILTIN_BSWAP16 was previously defined
|
| 125 |
+
#endif
|
| 126 |
+
#ifdef PROTOBUF_BUILTIN_BSWAP32
|
| 127 |
+
#error PROTOBUF_BUILTIN_BSWAP32 was previously defined
|
| 128 |
+
#endif
|
| 129 |
+
#ifdef PROTOBUF_BUILTIN_BSWAP64
|
| 130 |
+
#error PROTOBUF_BUILTIN_BSWAP64 was previously defined
|
| 131 |
+
#endif
|
| 132 |
+
#if defined(__GNUC__) || __has_builtin(__builtin_bswap16)
|
| 133 |
+
#define PROTOBUF_BUILTIN_BSWAP16(x) __builtin_bswap16(x)
|
| 134 |
+
#endif
|
| 135 |
+
#if defined(__GNUC__) || __has_builtin(__builtin_bswap32)
|
| 136 |
+
#define PROTOBUF_BUILTIN_BSWAP32(x) __builtin_bswap32(x)
|
| 137 |
+
#endif
|
| 138 |
+
#if defined(__GNUC__) || __has_builtin(__builtin_bswap64)
|
| 139 |
+
#define PROTOBUF_BUILTIN_BSWAP64(x) __builtin_bswap64(x)
|
| 140 |
+
#endif
|
| 141 |
+
|
| 142 |
+
// Portable check for GCC minimum version:
|
| 143 |
+
// https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
|
| 144 |
+
#if defined(__GNUC__) && defined(__GNUC_MINOR__) \
|
| 145 |
+
&& defined(__GNUC_PATCHLEVEL__)
|
| 146 |
+
# define PROTOBUF_GNUC_MIN(x, y) \
|
| 147 |
+
(__GNUC__ > (x) || __GNUC__ == (x) && __GNUC_MINOR__ >= (y))
|
| 148 |
+
#else
|
| 149 |
+
# define PROTOBUF_GNUC_MIN(x, y) 0
|
| 150 |
+
#endif
|
| 151 |
+
|
| 152 |
+
// Portable check for MSVC minimum version:
|
| 153 |
+
// https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
|
| 154 |
+
#if defined(_MSC_VER)
|
| 155 |
+
#define PROTOBUF_MSC_VER_MIN(x) (_MSC_VER >= x)
|
| 156 |
+
#else
|
| 157 |
+
#define PROTOBUF_MSC_VER_MIN(x) 0
|
| 158 |
+
#endif
|
| 159 |
+
|
| 160 |
+
// Portable check for minimum C++ language version:
|
| 161 |
+
// https://en.cppreference.com/w/cpp/preprocessor/replace
|
| 162 |
+
// https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
|
| 163 |
+
#if !defined(_MSVC_LANG)
|
| 164 |
+
#define PROTOBUF_CPLUSPLUS_MIN(x) (__cplusplus >= x)
|
| 165 |
+
#else
|
| 166 |
+
#define PROTOBUF_CPLUSPLUS_MIN(x) (_MSVC_LANG >= x)
|
| 167 |
+
#endif
|
| 168 |
+
|
| 169 |
+
// Future versions of protobuf will include breaking changes to some APIs.
|
| 170 |
+
// This macro can be set to enable these API changes ahead of time, so that
|
| 171 |
+
// user code can be updated before upgrading versions of protobuf.
|
| 172 |
+
// PROTOBUF_FUTURE_FINAL is used on classes that are historically not marked as
|
| 173 |
+
// final, but that may be marked final in future (breaking) releases.
|
| 174 |
+
// #define PROTOBUF_FUTURE_BREAKING_CHANGES 1
|
| 175 |
+
// #define PROTOBUF_FUTURE_FINAL final
|
| 176 |
+
#define PROTOBUF_FUTURE_FINAL
|
| 177 |
+
|
| 178 |
+
#ifdef PROTOBUF_VERSION
|
| 179 |
+
#error PROTOBUF_VERSION was previously defined
|
| 180 |
+
#endif
|
| 181 |
+
#define PROTOBUF_VERSION 3021009
|
| 182 |
+
|
| 183 |
+
#ifdef PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC
|
| 184 |
+
#error PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC was previously defined
|
| 185 |
+
#endif
|
| 186 |
+
#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3021000
|
| 187 |
+
|
| 188 |
+
#ifdef PROTOBUF_MIN_PROTOC_VERSION
|
| 189 |
+
#error PROTOBUF_MIN_PROTOC_VERSION was previously defined
|
| 190 |
+
#endif
|
| 191 |
+
#define PROTOBUF_MIN_PROTOC_VERSION 3021000
|
| 192 |
+
|
| 193 |
+
#ifdef PROTOBUF_VERSION_SUFFIX
|
| 194 |
+
#error PROTOBUF_VERSION_SUFFIX was previously defined
|
| 195 |
+
#endif
|
| 196 |
+
#define PROTOBUF_VERSION_SUFFIX ""
|
| 197 |
+
|
| 198 |
+
#if defined(PROTOBUF_NAMESPACE) || defined(PROTOBUF_NAMESPACE_ID)
|
| 199 |
+
#error PROTOBUF_NAMESPACE or PROTOBUF_NAMESPACE_ID was previously defined
|
| 200 |
+
#endif
|
| 201 |
+
#define PROTOBUF_NAMESPACE "google::protobuf"
|
| 202 |
+
#define PROTOBUF_NAMESPACE_ID google::protobuf
|
| 203 |
+
#define PROTOBUF_NAMESPACE_OPEN \
|
| 204 |
+
namespace google { \
|
| 205 |
+
namespace protobuf {
|
| 206 |
+
#define PROTOBUF_NAMESPACE_CLOSE \
|
| 207 |
+
} /* namespace protobuf */ \
|
| 208 |
+
} /* namespace google */
|
| 209 |
+
|
| 210 |
+
#ifdef PROTOBUF_ALWAYS_INLINE
|
| 211 |
+
#error PROTOBUF_ALWAYS_INLINE was previously defined
|
| 212 |
+
#endif
|
| 213 |
+
// For functions we want to force inline.
|
| 214 |
+
#if defined(PROTOBUF_NO_INLINE)
|
| 215 |
+
# define PROTOBUF_ALWAYS_INLINE
|
| 216 |
+
#elif PROTOBUF_GNUC_MIN(3, 1)
|
| 217 |
+
# define PROTOBUF_ALWAYS_INLINE __attribute__((always_inline))
|
| 218 |
+
#elif defined(_MSC_VER)
|
| 219 |
+
# define PROTOBUF_ALWAYS_INLINE __forceinline
|
| 220 |
+
#else
|
| 221 |
+
# define PROTOBUF_ALWAYS_INLINE
|
| 222 |
+
#endif
|
| 223 |
+
|
| 224 |
+
#ifdef PROTOBUF_NDEBUG_INLINE
|
| 225 |
+
#error PROTOBUF_NDEBUG_INLINE was previously defined
|
| 226 |
+
#endif
|
| 227 |
+
// Avoid excessive inlining in non-optimized builds. Without other optimizations
|
| 228 |
+
// the inlining is not going to provide benefits anyway and the huge resulting
|
| 229 |
+
// functions, especially in the proto-generated serialization functions, produce
|
| 230 |
+
// stack frames so large that many tests run into stack overflows (b/32192897).
|
| 231 |
+
#if defined(NDEBUG) || (defined(_MSC_VER) && !defined(_DEBUG))
|
| 232 |
+
# define PROTOBUF_NDEBUG_INLINE PROTOBUF_ALWAYS_INLINE
|
| 233 |
+
#else
|
| 234 |
+
# define PROTOBUF_NDEBUG_INLINE
|
| 235 |
+
#endif
|
| 236 |
+
|
| 237 |
+
// Note that PROTOBUF_NOINLINE is an attribute applied to functions, to prevent
|
| 238 |
+
// them from being inlined by the compiler. This is different from
|
| 239 |
+
// PROTOBUF_NO_INLINE, which is a user-supplied macro that disables forced
|
| 240 |
+
// inlining by PROTOBUF_(ALWAYS|NDEBUG)_INLINE.
|
| 241 |
+
#ifdef PROTOBUF_NOINLINE
|
| 242 |
+
#error PROTOBUF_NOINLINE was previously defined
|
| 243 |
+
#endif
|
| 244 |
+
#if PROTOBUF_GNUC_MIN(3, 1)
|
| 245 |
+
# define PROTOBUF_NOINLINE __attribute__((noinline))
|
| 246 |
+
#elif defined(_MSC_VER)
|
| 247 |
+
// Seems to have been around since at least Visual Studio 2005
|
| 248 |
+
# define PROTOBUF_NOINLINE __declspec(noinline)
|
| 249 |
+
#endif
|
| 250 |
+
|
| 251 |
+
#ifdef PROTOBUF_MUSTTAIL
|
| 252 |
+
#error PROTOBUF_MUSTTAIL was previously defined
|
| 253 |
+
#endif
|
| 254 |
+
#ifdef PROTOBUF_TAILCALL
|
| 255 |
+
#error PROTOBUF_TAILCALL was previously defined
|
| 256 |
+
#endif
|
| 257 |
+
#if __has_cpp_attribute(clang::musttail) && !defined(__arm__) && \
|
| 258 |
+
!defined(_ARCH_PPC) && !defined(__wasm__) && \
|
| 259 |
+
!(defined(_MSC_VER) && defined(_M_IX86)) && \
|
| 260 |
+
!(defined(__NDK_MAJOR__) && __NDK_MAJOR <= 24)
|
| 261 |
+
# ifndef PROTO2_OPENSOURCE
|
| 262 |
+
// Compilation fails on ARM32: b/195943306
|
| 263 |
+
// Compilation fails on powerpc64le: b/187985113
|
| 264 |
+
// Compilation fails on X86 Windows:
|
| 265 |
+
// https://github.com/llvm/llvm-project/issues/53271
|
| 266 |
+
# endif
|
| 267 |
+
#define PROTOBUF_MUSTTAIL [[clang::musttail]]
|
| 268 |
+
#define PROTOBUF_TAILCALL true
|
| 269 |
+
#else
|
| 270 |
+
#define PROTOBUF_MUSTTAIL
|
| 271 |
+
#define PROTOBUF_TAILCALL false
|
| 272 |
+
#endif
|
| 273 |
+
|
| 274 |
+
#ifdef PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED
|
| 275 |
+
#error PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED was previously defined
|
| 276 |
+
#endif
|
| 277 |
+
#if __has_attribute(exclusive_locks_required)
|
| 278 |
+
#define PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED(...) \
|
| 279 |
+
__attribute__((exclusive_locks_required(__VA_ARGS__)))
|
| 280 |
+
#else
|
| 281 |
+
#define PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED(...)
|
| 282 |
+
#endif
|
| 283 |
+
|
| 284 |
+
#ifdef PROTOBUF_NO_THREAD_SAFETY_ANALYSIS
|
| 285 |
+
#error PROTOBUF_NO_THREAD_SAFETY_ANALYSIS was previously defined
|
| 286 |
+
#endif
|
| 287 |
+
#if __has_attribute(no_thread_safety_analysis)
|
| 288 |
+
#define PROTOBUF_NO_THREAD_SAFETY_ANALYSIS \
|
| 289 |
+
__attribute__((no_thread_safety_analysis))
|
| 290 |
+
#else
|
| 291 |
+
#define PROTOBUF_NO_THREAD_SAFETY_ANALYSIS
|
| 292 |
+
#endif
|
| 293 |
+
|
| 294 |
+
#ifdef PROTOBUF_GUARDED_BY
|
| 295 |
+
#error PROTOBUF_GUARDED_BY was previously defined
|
| 296 |
+
#endif
|
| 297 |
+
#if __has_attribute(guarded_by)
|
| 298 |
+
#define PROTOBUF_GUARDED_BY(x) __attribute__((guarded_by(x)))
|
| 299 |
+
#else
|
| 300 |
+
#define PROTOBUF_GUARDED_BY(x)
|
| 301 |
+
#endif
|
| 302 |
+
|
| 303 |
+
#ifdef PROTOBUF_LOCKS_EXCLUDED
|
| 304 |
+
#error PROTOBUF_LOCKS_EXCLUDED was previously defined
|
| 305 |
+
#endif
|
| 306 |
+
#if __has_attribute(locks_excluded)
|
| 307 |
+
#define PROTOBUF_LOCKS_EXCLUDED(...) \
|
| 308 |
+
__attribute__((locks_excluded(__VA_ARGS__)))
|
| 309 |
+
#else
|
| 310 |
+
#define PROTOBUF_LOCKS_EXCLUDED(...)
|
| 311 |
+
#endif
|
| 312 |
+
|
| 313 |
+
#ifdef PROTOBUF_COLD
|
| 314 |
+
#error PROTOBUF_COLD was previously defined
|
| 315 |
+
#endif
|
| 316 |
+
#if __has_attribute(cold) || PROTOBUF_GNUC_MIN(4, 3)
|
| 317 |
+
# define PROTOBUF_COLD __attribute__((cold))
|
| 318 |
+
#else
|
| 319 |
+
# define PROTOBUF_COLD
|
| 320 |
+
#endif
|
| 321 |
+
|
| 322 |
+
#ifdef PROTOBUF_SECTION_VARIABLE
|
| 323 |
+
#error PROTOBUF_SECTION_VARIABLE was previously defined
|
| 324 |
+
#endif
|
| 325 |
+
#if (__has_attribute(section) || defined(__GNUC__)) && defined(__ELF__)
|
| 326 |
+
// Place a variable in the given ELF section.
|
| 327 |
+
# define PROTOBUF_SECTION_VARIABLE(x) __attribute__((section(#x)))
|
| 328 |
+
#else
|
| 329 |
+
# define PROTOBUF_SECTION_VARIABLE(x)
|
| 330 |
+
#endif
|
| 331 |
+
|
| 332 |
+
#if defined(PROTOBUF_DEPRECATED)
|
| 333 |
+
#error PROTOBUF_DEPRECATED was previously defined
|
| 334 |
+
#endif
|
| 335 |
+
#if defined(PROTOBUF_DEPRECATED_MSG)
|
| 336 |
+
#error PROTOBUF_DEPRECATED_MSG was previously defined
|
| 337 |
+
#endif
|
| 338 |
+
#if __has_attribute(deprecated) || PROTOBUF_GNUC_MIN(3, 0)
|
| 339 |
+
# define PROTOBUF_DEPRECATED __attribute__((deprecated))
|
| 340 |
+
# define PROTOBUF_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
|
| 341 |
+
#elif defined(_MSC_VER)
|
| 342 |
+
# define PROTOBUF_DEPRECATED __declspec(deprecated)
|
| 343 |
+
# define PROTOBUF_DEPRECATED_MSG(msg) __declspec(deprecated(msg))
|
| 344 |
+
#else
|
| 345 |
+
# define PROTOBUF_DEPRECATED
|
| 346 |
+
# define PROTOBUF_DEPRECATED_MSG(msg)
|
| 347 |
+
#endif
|
| 348 |
+
|
| 349 |
+
#if defined(PROTOBUF_DEPRECATED_ENUM)
|
| 350 |
+
#error PROTOBUF_DEPRECATED_ENUM was previously defined
|
| 351 |
+
#endif
|
| 352 |
+
#if defined(__clang__) || PROTOBUF_GNUC_MIN(6, 0)
|
| 353 |
+
// https://gcc.gnu.org/gcc-6/changes.html
|
| 354 |
+
# define PROTOBUF_DEPRECATED_ENUM __attribute__((deprecated))
|
| 355 |
+
#else
|
| 356 |
+
# define PROTOBUF_DEPRECATED_ENUM
|
| 357 |
+
#endif
|
| 358 |
+
|
| 359 |
+
#ifdef PROTOBUF_FUNC_ALIGN
|
| 360 |
+
#error PROTOBUF_FUNC_ALIGN was previously defined
|
| 361 |
+
#endif
|
| 362 |
+
#if __has_attribute(aligned) || PROTOBUF_GNUC_MIN(4, 3)
|
| 363 |
+
#define PROTOBUF_FUNC_ALIGN(bytes) __attribute__((aligned(bytes)))
|
| 364 |
+
#else
|
| 365 |
+
#define PROTOBUF_FUNC_ALIGN(bytes)
|
| 366 |
+
#endif
|
| 367 |
+
|
| 368 |
+
#ifdef PROTOBUF_RETURNS_NONNULL
|
| 369 |
+
#error PROTOBUF_RETURNS_NONNULL was previously defined
|
| 370 |
+
#endif
|
| 371 |
+
#if __has_attribute(returns_nonnull) || PROTOBUF_GNUC_MIN(4, 9)
|
| 372 |
+
#define PROTOBUF_RETURNS_NONNULL __attribute__((returns_nonnull))
|
| 373 |
+
#else
|
| 374 |
+
#define PROTOBUF_RETURNS_NONNULL
|
| 375 |
+
#endif
|
| 376 |
+
|
| 377 |
+
#ifdef PROTOBUF_ATTRIBUTE_REINITIALIZES
|
| 378 |
+
#error PROTOBUF_ATTRIBUTE_REINITIALIZES was previously defined
|
| 379 |
+
#endif
|
| 380 |
+
#if __has_cpp_attribute(clang::reinitializes)
|
| 381 |
+
#define PROTOBUF_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]]
|
| 382 |
+
#else
|
| 383 |
+
#define PROTOBUF_ATTRIBUTE_REINITIALIZES
|
| 384 |
+
#endif
|
| 385 |
+
|
| 386 |
+
// The minimum library version which works with the current version of the
|
| 387 |
+
// headers.
|
| 388 |
+
#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3021000
|
| 389 |
+
|
| 390 |
+
#ifdef PROTOBUF_RTTI
|
| 391 |
+
#error PROTOBUF_RTTI was previously defined
|
| 392 |
+
#endif
|
| 393 |
+
#if defined(GOOGLE_PROTOBUF_NO_RTTI) && GOOGLE_PROTOBUF_NO_RTTI
|
| 394 |
+
// A user-provided definition GOOGLE_PROTOBUF_NO_RTTI=1 disables RTTI.
|
| 395 |
+
#define PROTOBUF_RTTI 0
|
| 396 |
+
#elif defined(__cpp_rtti)
|
| 397 |
+
// https://en.cppreference.com/w/cpp/feature_test
|
| 398 |
+
#define PROTOBUF_RTTI 1
|
| 399 |
+
#elif __has_feature(cxx_rtti)
|
| 400 |
+
// https://clang.llvm.org/docs/LanguageExtensions.html#c-rtti
|
| 401 |
+
#define PROTOBUF_RTTI 1
|
| 402 |
+
#elif defined(__GXX_RTTI)
|
| 403 |
+
// https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
|
| 404 |
+
#define PROTOBUF_RTTI 1
|
| 405 |
+
#elif defined(_CPPRTTI)
|
| 406 |
+
// https://docs.microsoft.com/en-us/cpp/build/reference/gr-enable-run-time-type-information
|
| 407 |
+
#define PROTOBUF_RTTI 1
|
| 408 |
+
#else
|
| 409 |
+
#define PROTOBUF_RTTI 0
|
| 410 |
+
#endif
|
| 411 |
+
|
| 412 |
+
// Returns the offset of the given field within the given aggregate type.
|
| 413 |
+
// This is equivalent to the ANSI C offsetof() macro. However, according
|
| 414 |
+
// to the C++ standard, offsetof() only works on POD types, and GCC
|
| 415 |
+
// enforces this requirement with a warning. In practice, this rule is
|
| 416 |
+
// unnecessarily strict; there is probably no compiler or platform on
|
| 417 |
+
// which the offsets of the direct fields of a class are non-constant.
|
| 418 |
+
// Fields inherited from superclasses *can* have non-constant offsets,
|
| 419 |
+
// but that's not what this macro will be used for.
|
| 420 |
+
#ifdef PROTOBUF_FIELD_OFFSET
|
| 421 |
+
#error PROTOBUF_FIELD_OFFSET was previously defined
|
| 422 |
+
#endif
|
| 423 |
+
#if defined(__clang__)
|
| 424 |
+
// For Clang we use __builtin_offsetof() and suppress the warning,
|
| 425 |
+
// to avoid Control Flow Integrity and UBSan vptr sanitizers from
|
| 426 |
+
// crashing while trying to validate the invalid reinterpret_casts.
|
| 427 |
+
#define PROTOBUF_FIELD_OFFSET(TYPE, FIELD) \
|
| 428 |
+
_Pragma("clang diagnostic push") \
|
| 429 |
+
_Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
|
| 430 |
+
__builtin_offsetof(TYPE, FIELD) \
|
| 431 |
+
_Pragma("clang diagnostic pop")
|
| 432 |
+
#elif PROTOBUF_GNUC_MIN(4, 8)
|
| 433 |
+
#define PROTOBUF_FIELD_OFFSET(TYPE, FIELD) __builtin_offsetof(TYPE, FIELD)
|
| 434 |
+
#else // defined(__clang__)
|
| 435 |
+
// Note that we calculate relative to the pointer value 16 here since if we
|
| 436 |
+
// just use zero, GCC complains about dereferencing a NULL pointer. We
|
| 437 |
+
// choose 16 rather than some other number just in case the compiler would
|
| 438 |
+
// be confused by an unaligned pointer.
|
| 439 |
+
#define PROTOBUF_FIELD_OFFSET(TYPE, FIELD) \
|
| 440 |
+
static_cast< ::uint32_t>(reinterpret_cast<const char*>( \
|
| 441 |
+
&reinterpret_cast<const TYPE*>(16)->FIELD) - \
|
| 442 |
+
reinterpret_cast<const char*>(16))
|
| 443 |
+
#endif
|
| 444 |
+
|
| 445 |
+
#ifdef PROTOBUF_EXPORT
|
| 446 |
+
#error PROTOBUF_EXPORT was previously defined
|
| 447 |
+
#endif
|
| 448 |
+
|
| 449 |
+
#if defined(PROTOBUF_USE_DLLS) && defined(_MSC_VER)
|
| 450 |
+
# if defined(LIBPROTOBUF_EXPORTS)
|
| 451 |
+
# define PROTOBUF_EXPORT __declspec(dllexport)
|
| 452 |
+
# define PROTOBUF_EXPORT_TEMPLATE_DECLARE
|
| 453 |
+
# define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllexport)
|
| 454 |
+
# else
|
| 455 |
+
# define PROTOBUF_EXPORT __declspec(dllimport)
|
| 456 |
+
# define PROTOBUF_EXPORT_TEMPLATE_DECLARE
|
| 457 |
+
# define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllimport)
|
| 458 |
+
# endif // defined(LIBPROTOBUF_EXPORTS)
|
| 459 |
+
#elif defined(PROTOBUF_USE_DLLS) && defined(LIBPROTOBUF_EXPORTS)
|
| 460 |
+
# define PROTOBUF_EXPORT __attribute__((visibility("default")))
|
| 461 |
+
# define PROTOBUF_EXPORT_TEMPLATE_DECLARE __attribute__((visibility("default")))
|
| 462 |
+
# define PROTOBUF_EXPORT_TEMPLATE_DEFINE
|
| 463 |
+
#else
|
| 464 |
+
# define PROTOBUF_EXPORT
|
| 465 |
+
# define PROTOBUF_EXPORT_TEMPLATE_DECLARE
|
| 466 |
+
# define PROTOBUF_EXPORT_TEMPLATE_DEFINE
|
| 467 |
+
#endif
|
| 468 |
+
|
| 469 |
+
#ifdef PROTOC_EXPORT
|
| 470 |
+
#error PROTOC_EXPORT was previously defined
|
| 471 |
+
#endif
|
| 472 |
+
|
| 473 |
+
#if defined(PROTOBUF_USE_DLLS) && defined(_MSC_VER)
|
| 474 |
+
# if defined(LIBPROTOC_EXPORTS)
|
| 475 |
+
# define PROTOC_EXPORT __declspec(dllexport)
|
| 476 |
+
# else
|
| 477 |
+
# define PROTOC_EXPORT __declspec(dllimport)
|
| 478 |
+
# endif // defined(LIBPROTOC_EXPORTS)
|
| 479 |
+
#elif defined(PROTOBUF_USE_DLLS) && defined(LIBPROTOC_EXPORTS)
|
| 480 |
+
# define PROTOC_EXPORT __attribute__((visibility("default")))
|
| 481 |
+
#else
|
| 482 |
+
# define PROTOC_EXPORT
|
| 483 |
+
#endif
|
| 484 |
+
|
| 485 |
+
#if defined(PROTOBUF_PREDICT_TRUE) || defined(PROTOBUF_PREDICT_FALSE)
|
| 486 |
+
#error PROTOBUF_PREDICT_(TRUE|FALSE) was previously defined
|
| 487 |
+
#endif
|
| 488 |
+
#if PROTOBUF_GNUC_MIN(3, 0)
|
| 489 |
+
# define PROTOBUF_PREDICT_TRUE(x) (__builtin_expect(false || (x), true))
|
| 490 |
+
# define PROTOBUF_PREDICT_FALSE(x) (__builtin_expect(false || (x), false))
|
| 491 |
+
#else
|
| 492 |
+
# define PROTOBUF_PREDICT_TRUE(x) (x)
|
| 493 |
+
# define PROTOBUF_PREDICT_FALSE(x) (x)
|
| 494 |
+
#endif
|
| 495 |
+
|
| 496 |
+
#ifdef PROTOBUF_NODISCARD
|
| 497 |
+
#error PROTOBUF_NODISCARD was previously defined
|
| 498 |
+
#endif
|
| 499 |
+
#if __has_cpp_attribute(nodiscard) && PROTOBUF_CPLUSPLUS_MIN(201703L)
|
| 500 |
+
#define PROTOBUF_NODISCARD [[nodiscard]]
|
| 501 |
+
#elif __has_attribute(warn_unused_result) || PROTOBUF_GNUC_MIN(4, 8)
|
| 502 |
+
#define PROTOBUF_NODISCARD __attribute__((warn_unused_result))
|
| 503 |
+
#else
|
| 504 |
+
#define PROTOBUF_NODISCARD
|
| 505 |
+
#endif
|
| 506 |
+
|
| 507 |
+
// Enable all stable experiments if this flag is set. This allows us to group
|
| 508 |
+
// all of these experiments under a single build flag, which can be enabled in
|
| 509 |
+
// the protobuf.stable-experiments TAP project.
|
| 510 |
+
#ifdef PROTOBUF_ENABLE_STABLE_EXPERIMENTS
|
| 511 |
+
#define PROTOBUF_FORCE_MESSAGE_OWNED_ARENA
|
| 512 |
+
#endif // !PROTOBUF_ENABLE_STABLE_EXPERIMENTS
|
| 513 |
+
|
| 514 |
+
#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
|
| 515 |
+
#error PROTOBUF_FORCE_COPY_IN_RELEASE was previously defined
|
| 516 |
+
#endif
|
| 517 |
+
|
| 518 |
+
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
|
| 519 |
+
#error PROTOBUF_FORCE_COPY_IN_SWAP was previously defined
|
| 520 |
+
#endif
|
| 521 |
+
|
| 522 |
+
#ifdef PROTOBUF_FORCE_COPY_IN_MOVE
|
| 523 |
+
#error PROTOBUF_FORCE_COPY_IN_MOVE was previously defined
|
| 524 |
+
#endif
|
| 525 |
+
|
| 526 |
+
#ifdef PROTOBUF_FORCE_RESET_IN_CLEAR
|
| 527 |
+
#error PROTOBUF_FORCE_RESET_IN_CLEAR was previously defined
|
| 528 |
+
#endif
|
| 529 |
+
|
| 530 |
+
// Force copy the default string to a string field so that non-optimized builds
|
| 531 |
+
// have harder-to-rely-on address stability.
|
| 532 |
+
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
| 533 |
+
#error PROTOBUF_FORCE_COPY_DEFAULT_STRING was previously defined
|
| 534 |
+
#endif
|
| 535 |
+
|
| 536 |
+
#ifdef PROTOBUF_FALLTHROUGH_INTENDED
|
| 537 |
+
#error PROTOBUF_FALLTHROUGH_INTENDED was previously defined
|
| 538 |
+
#endif
|
| 539 |
+
#if __has_cpp_attribute(fallthrough)
|
| 540 |
+
#define PROTOBUF_FALLTHROUGH_INTENDED [[fallthrough]]
|
| 541 |
+
#elif __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
|
| 542 |
+
#define PROTOBUF_FALLTHROUGH_INTENDED [[clang::fallthrough]]
|
| 543 |
+
#elif PROTOBUF_GNUC_MIN(7, 0)
|
| 544 |
+
#define PROTOBUF_FALLTHROUGH_INTENDED [[gnu::fallthrough]]
|
| 545 |
+
#else
|
| 546 |
+
#define PROTOBUF_FALLTHROUGH_INTENDED
|
| 547 |
+
#endif
|
| 548 |
+
|
| 549 |
+
// PROTOBUF_ASSUME(pred) tells the compiler that it can assume pred is true. To
|
| 550 |
+
// be safe, we also validate the assumption with a GOOGLE_DCHECK in unoptimized
|
| 551 |
+
// builds. The macro does not do anything useful if the compiler does not
|
| 552 |
+
// support __builtin_assume.
|
| 553 |
+
#ifdef PROTOBUF_ASSUME
|
| 554 |
+
#error PROTOBUF_ASSUME was previously defined
|
| 555 |
+
#endif
|
| 556 |
+
#if __has_builtin(__builtin_assume)
|
| 557 |
+
#define PROTOBUF_ASSUME(pred) \
|
| 558 |
+
GOOGLE_DCHECK(pred); \
|
| 559 |
+
__builtin_assume(pred)
|
| 560 |
+
#else
|
| 561 |
+
#define PROTOBUF_ASSUME(pred) GOOGLE_DCHECK(pred)
|
| 562 |
+
#endif
|
| 563 |
+
|
| 564 |
+
// Specify memory alignment for structs, classes, etc.
|
| 565 |
+
// Use like:
|
| 566 |
+
// class PROTOBUF_ALIGNAS(16) MyClass { ... }
|
| 567 |
+
// PROTOBUF_ALIGNAS(16) int array[4];
|
| 568 |
+
//
|
| 569 |
+
// In most places you can use the C++11 keyword "alignas", which is preferred.
|
| 570 |
+
//
|
| 571 |
+
// But compilers have trouble mixing __attribute__((...)) syntax with
|
| 572 |
+
// alignas(...) syntax.
|
| 573 |
+
//
|
| 574 |
+
// Doesn't work in clang or gcc:
|
| 575 |
+
// struct alignas(16) __attribute__((packed)) S { char c; };
|
| 576 |
+
// Works in clang but not gcc:
|
| 577 |
+
// struct __attribute__((packed)) alignas(16) S2 { char c; };
|
| 578 |
+
// Works in clang and gcc:
|
| 579 |
+
// struct alignas(16) S3 { char c; } __attribute__((packed));
|
| 580 |
+
//
|
| 581 |
+
// There are also some attributes that must be specified *before* a class
|
| 582 |
+
// definition: visibility (used for exporting functions/classes) is one of
|
| 583 |
+
// these attributes. This means that it is not possible to use alignas() with a
|
| 584 |
+
// class that is marked as exported.
|
| 585 |
+
#ifdef PROTOBUF_ALIGNAS
|
| 586 |
+
#error PROTOBUF_ALIGNAS was previously defined
|
| 587 |
+
#endif
|
| 588 |
+
#if defined(_MSC_VER)
|
| 589 |
+
#define PROTOBUF_ALIGNAS(byte_alignment) __declspec(align(byte_alignment))
|
| 590 |
+
#elif PROTOBUF_GNUC_MIN(3, 0)
|
| 591 |
+
#define PROTOBUF_ALIGNAS(byte_alignment) \
|
| 592 |
+
__attribute__((aligned(byte_alignment)))
|
| 593 |
+
#else
|
| 594 |
+
#define PROTOBUF_ALIGNAS(byte_alignment) alignas(byte_alignment)
|
| 595 |
+
#endif
|
| 596 |
+
|
| 597 |
+
#ifdef PROTOBUF_FINAL
|
| 598 |
+
#error PROTOBUF_FINAL was previously defined
|
| 599 |
+
#endif
|
| 600 |
+
#define PROTOBUF_FINAL final
|
| 601 |
+
|
| 602 |
+
#ifdef PROTOBUF_THREAD_LOCAL
|
| 603 |
+
#error PROTOBUF_THREAD_LOCAL was previously defined
|
| 604 |
+
#endif
|
| 605 |
+
#if defined(_MSC_VER)
|
| 606 |
+
#define PROTOBUF_THREAD_LOCAL __declspec(thread)
|
| 607 |
+
#else
|
| 608 |
+
#define PROTOBUF_THREAD_LOCAL __thread
|
| 609 |
+
#endif
|
| 610 |
+
|
| 611 |
+
// TODO(b/228173843): cleanup PROTOBUF_LITTLE_ENDIAN in various 3p forks.
|
| 612 |
+
#if (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
|
| 613 |
+
__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
|
| 614 |
+
#define PROTOBUF_LITTLE_ENDIAN 1
|
| 615 |
+
#ifdef PROTOBUF_BIG_ENDIAN
|
| 616 |
+
#error Conflicting PROTOBUF_BIG_ENDIAN was previously defined
|
| 617 |
+
#endif
|
| 618 |
+
#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
|
| 619 |
+
__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
| 620 |
+
#define PROTOBUF_BIG_ENDIAN 1
|
| 621 |
+
#elif defined(_WIN32) || defined(__x86_64__) || defined(__aarch64__)
|
| 622 |
+
#define PROTOBUF_LITTLE_ENDIAN 1
|
| 623 |
+
#else
|
| 624 |
+
#error "endian detection failed for current compiler"
|
| 625 |
+
#endif
|
| 626 |
+
|
| 627 |
+
// For enabling message owned arena, one major blocker is semantic change from
|
| 628 |
+
// moving to copying when there is ownership transfer (e.g., move ctor, swap,
|
| 629 |
+
// set allocated, release). This change not only causes performance regression
|
| 630 |
+
// but also breaks users code (e.g., dangling reference). For top-level
|
| 631 |
+
// messages, since it owns the arena, we can mitigate the issue by transferring
|
| 632 |
+
// ownership of arena. However, we cannot do that for nested messages. In order
|
| 633 |
+
// to tell how many usages of nested messages affected by message owned arena,
|
| 634 |
+
// we need to simulate the arena ownership.
|
| 635 |
+
// This experiment is purely for the purpose of gathering data. All code guarded
|
| 636 |
+
// by this flag is supposed to be removed after this experiment.
|
| 637 |
+
#define PROTOBUF_MESSAGE_OWNED_ARENA_EXPERIMENT
|
| 638 |
+
#ifdef PROTOBUF_CONSTINIT
|
| 639 |
+
#error PROTOBUF_CONSTINIT was previously defined
|
| 640 |
+
#endif
|
| 641 |
+
#if defined(__cpp_constinit) && !defined(_MSC_VER)
|
| 642 |
+
#define PROTOBUF_CONSTINIT constinit
|
| 643 |
+
#define PROTOBUF_CONSTEXPR constexpr
|
| 644 |
+
// Some older Clang versions incorrectly raise an error about
|
| 645 |
+
// constant-initializing weak default instance pointers. Versions 12.0 and
|
| 646 |
+
// higher seem to work, except that XCode 12.5.1 shows the error even though it
|
| 647 |
+
// uses Clang 12.0.5.
|
| 648 |
+
// Clang-cl on Windows raises error also.
|
| 649 |
+
#elif !defined(_MSC_VER) && __has_cpp_attribute(clang::require_constant_initialization) && \
|
| 650 |
+
((defined(__APPLE__) && __clang_major__ >= 13) || \
|
| 651 |
+
(!defined(__APPLE__) && __clang_major__ >= 12))
|
| 652 |
+
#define PROTOBUF_CONSTINIT [[clang::require_constant_initialization]]
|
| 653 |
+
#define PROTOBUF_CONSTEXPR constexpr
|
| 654 |
+
#elif PROTOBUF_GNUC_MIN(12, 2)
|
| 655 |
+
#define PROTOBUF_CONSTINIT __constinit
|
| 656 |
+
#define PROTOBUF_CONSTEXPR constexpr
|
| 657 |
+
// MSVC 17 currently seems to raise an error about constant-initialized pointers.
|
| 658 |
+
#elif defined(_MSC_VER) && _MSC_VER >= 1930
|
| 659 |
+
#define PROTOBUF_CONSTINIT
|
| 660 |
+
#define PROTOBUF_CONSTEXPR constexpr
|
| 661 |
+
#else
|
| 662 |
+
#define PROTOBUF_CONSTINIT
|
| 663 |
+
#define PROTOBUF_CONSTEXPR
|
| 664 |
+
#endif
|
| 665 |
+
|
| 666 |
+
// Some globals with an empty non-trivial destructor are annotated with
|
| 667 |
+
// no_destroy for performance reasons. It reduces the cost of these globals in
|
| 668 |
+
// non-opt mode and under sanitizers.
|
| 669 |
+
#ifdef PROTOBUF_ATTRIBUTE_NO_DESTROY
|
| 670 |
+
#error PROTOBUF_ATTRIBUTE_NO_DESTROY was previously defined
|
| 671 |
+
#endif
|
| 672 |
+
#if __has_cpp_attribute(clang::no_destroy)
|
| 673 |
+
#define PROTOBUF_ATTRIBUTE_NO_DESTROY [[clang::no_destroy]]
|
| 674 |
+
#else
|
| 675 |
+
#define PROTOBUF_ATTRIBUTE_NO_DESTROY
|
| 676 |
+
#endif
|
| 677 |
+
|
| 678 |
+
// Force clang to always emit complete debug info for a type.
|
| 679 |
+
// Clang uses constructor homing to determine when to emit debug info for a
|
| 680 |
+
// type. If the constructor of a type is never used, which can happen in some
|
| 681 |
+
// cases where member variables are constructed in place for optimization
|
| 682 |
+
// purposes (see b/208803175 for an example), the type will have incomplete
|
| 683 |
+
// debug info unless this attribute is used.
|
| 684 |
+
#ifdef PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG
|
| 685 |
+
#error PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG was previously defined
|
| 686 |
+
#endif
|
| 687 |
+
#if __has_cpp_attribute(clang::standalone_debug)
|
| 688 |
+
#define PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG [[clang::standalone_debug]]
|
| 689 |
+
#else
|
| 690 |
+
#define PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG
|
| 691 |
+
#endif
|
| 692 |
+
|
| 693 |
+
// Protobuf extensions and reflection require registration of the protos linked
|
| 694 |
+
// in the binary. Not until everything is registered does the runtime have a
|
| 695 |
+
// complete view on all protos. When code is using reflection or extensions
|
| 696 |
+
// in between registration calls this can lead to surprising behavior. By
|
| 697 |
+
// having the registration run first we mitigate this scenario.
|
| 698 |
+
// Highest priority is 101. We use 102 for registration, to allow code that
|
| 699 |
+
// really wants to higher priority to still beat us. Some initialization happens
|
| 700 |
+
// at higher priority, though, since it is needed before registration.
|
| 701 |
+
#ifdef PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
|
| 702 |
+
#error PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 was previously defined
|
| 703 |
+
#endif
|
| 704 |
+
#ifdef PROTOBUF_ATTRIBUTE_INIT_PRIORITY2
|
| 705 |
+
#error PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 was previously defined
|
| 706 |
+
#endif
|
| 707 |
+
#if PROTOBUF_GNUC_MIN(3, 0) && (!defined(__APPLE__) || defined(__clang__)) && \
|
| 708 |
+
!((defined(sun) || defined(__sun)) && \
|
| 709 |
+
(defined(__SVR4) || defined(__svr4__)))
|
| 710 |
+
#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 __attribute__((init_priority((101))))
|
| 711 |
+
#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 __attribute__((init_priority((102))))
|
| 712 |
+
#else
|
| 713 |
+
#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
|
| 714 |
+
#define PROTOBUF_ATTRIBUTE_INIT_PRIORITY2
|
| 715 |
+
#endif
|
| 716 |
+
|
| 717 |
+
#ifdef PROTOBUF_PRAGMA_INIT_SEG
|
| 718 |
+
#error PROTOBUF_PRAGMA_INIT_SEG was previously defined
|
| 719 |
+
#endif
|
| 720 |
+
#ifdef _MSC_VER
|
| 721 |
+
#define PROTOBUF_PRAGMA_INIT_SEG __pragma(init_seg(lib))
|
| 722 |
+
#else
|
| 723 |
+
#define PROTOBUF_PRAGMA_INIT_SEG
|
| 724 |
+
#endif
|
| 725 |
+
|
| 726 |
+
#ifdef PROTOBUF_ATTRIBUTE_WEAK
|
| 727 |
+
#error PROTOBUF_ATTRIBUTE_WEAK was previously defined
|
| 728 |
+
#endif
|
| 729 |
+
#if __has_attribute(weak) && \
|
| 730 |
+
!defined(__APPLE__) && \
|
| 731 |
+
(!defined(_WIN32) || __clang_major__ < 9) && \
|
| 732 |
+
!defined(__MINGW32__)
|
| 733 |
+
#define PROTOBUF_ATTRIBUTE_WEAK __attribute__((weak))
|
| 734 |
+
#define PROTOBUF_HAVE_ATTRIBUTE_WEAK 1
|
| 735 |
+
#else
|
| 736 |
+
#define PROTOBUF_ATTRIBUTE_WEAK
|
| 737 |
+
#define PROTOBUF_HAVE_ATTRIBUTE_WEAK 0
|
| 738 |
+
#endif
|
| 739 |
+
|
| 740 |
+
// Macros to detect sanitizers.
|
| 741 |
+
#ifdef PROTOBUF_ASAN
|
| 742 |
+
#error PROTOBUF_ASAN was previously defined
|
| 743 |
+
#endif
|
| 744 |
+
#ifdef PROTOBUF_MSAN
|
| 745 |
+
#error PROTOBUF_MSAN was previously defined
|
| 746 |
+
#endif
|
| 747 |
+
#ifdef PROTOBUF_TSAN
|
| 748 |
+
#error PROTOBUF_TSAN was previously defined
|
| 749 |
+
#endif
|
| 750 |
+
#if defined(__clang__)
|
| 751 |
+
# if __has_feature(address_sanitizer)
|
| 752 |
+
# define PROTOBUF_ASAN 1
|
| 753 |
+
# endif
|
| 754 |
+
# if __has_feature(thread_sanitizer)
|
| 755 |
+
# define PROTOBUF_TSAN 1
|
| 756 |
+
# endif
|
| 757 |
+
# if __has_feature(memory_sanitizer)
|
| 758 |
+
# define PROTOBUF_MSAN 1
|
| 759 |
+
# endif
|
| 760 |
+
#elif PROTOBUF_GNUC_MIN(3, 0)
|
| 761 |
+
// Double-guard is needed for -Wundef:
|
| 762 |
+
# ifdef __SANITIZE_ADDRESS__
|
| 763 |
+
# if __SANITIZE_ADDRESS__
|
| 764 |
+
# define PROTOBUF_ASAN 1
|
| 765 |
+
# endif
|
| 766 |
+
# endif
|
| 767 |
+
# ifdef __SANITIZE_THREAD__
|
| 768 |
+
# if __SANITIZE_THREAD__
|
| 769 |
+
# define PROTOBUF_TSAN 1
|
| 770 |
+
# endif
|
| 771 |
+
# endif
|
| 772 |
+
#endif
|
| 773 |
+
|
| 774 |
+
// Tail call table-driven parsing can be enabled by defining
|
| 775 |
+
// PROTOBUF_EXPERIMENTAL_USE_TAIL_CALL_TABLE_PARSER at compilation time. Note
|
| 776 |
+
// that this macro is for small-scale testing only, and is not supported.
|
| 777 |
+
#ifdef PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED
|
| 778 |
+
#error PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED was previously declared
|
| 779 |
+
#endif
|
| 780 |
+
#if defined(PROTOBUF_EXPERIMENTAL_USE_TAIL_CALL_TABLE_PARSER)
|
| 781 |
+
#define PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED 1
|
| 782 |
+
#endif
|
| 783 |
+
|
| 784 |
+
#define PROTOBUF_TC_PARAM_DECL \
|
| 785 |
+
::google::protobuf::MessageLite *msg, const char *ptr, \
|
| 786 |
+
::google::protobuf::internal::ParseContext *ctx, \
|
| 787 |
+
const ::google::protobuf::internal::TcParseTableBase *table, \
|
| 788 |
+
uint64_t hasbits, ::google::protobuf::internal::TcFieldData data
|
| 789 |
+
|
| 790 |
+
#ifdef PROTOBUF_UNUSED
|
| 791 |
+
#error PROTOBUF_UNUSED was previously defined
|
| 792 |
+
#endif
|
| 793 |
+
#if __has_cpp_attribute(maybe_unused) || \
|
| 794 |
+
(PROTOBUF_MSC_VER_MIN(1911) && PROTOBUF_CPLUSPLUS_MIN(201703L))
|
| 795 |
+
#define PROTOBUF_UNUSED [[maybe_unused]]
|
| 796 |
+
#elif __has_attribute(unused) || PROTOBUF_GNUC_MIN(3, 0)
|
| 797 |
+
#define PROTOBUF_UNUSED __attribute__((__unused__))
|
| 798 |
+
#else
|
| 799 |
+
#define PROTOBUF_UNUSED
|
| 800 |
+
#endif
|
| 801 |
+
|
| 802 |
+
// ThreadSafeArenaz is turned off completely in opensource builds.
|
| 803 |
+
|
| 804 |
+
// Windows declares several inconvenient macro names. We #undef them and then
|
| 805 |
+
// restore them in port_undef.inc.
|
| 806 |
+
#ifdef _MSC_VER
|
| 807 |
+
#pragma push_macro("CREATE_NEW")
|
| 808 |
+
#undef CREATE_NEW
|
| 809 |
+
#pragma push_macro("DELETE")
|
| 810 |
+
#undef DELETE
|
| 811 |
+
#pragma push_macro("DOUBLE_CLICK")
|
| 812 |
+
#undef DOUBLE_CLICK
|
| 813 |
+
#pragma push_macro("ERROR")
|
| 814 |
+
#undef ERROR
|
| 815 |
+
#pragma push_macro("ERROR_BUSY")
|
| 816 |
+
#undef ERROR_BUSY
|
| 817 |
+
#pragma push_macro("ERROR_INSTALL_FAILED")
|
| 818 |
+
#undef ERROR_INSTALL_FAILED
|
| 819 |
+
#pragma push_macro("ERROR_NOT_FOUND")
|
| 820 |
+
#undef ERROR_NOT_FOUND
|
| 821 |
+
#pragma push_macro("GetClassName")
|
| 822 |
+
#undef GetClassName
|
| 823 |
+
#pragma push_macro("GetMessage")
|
| 824 |
+
#undef GetMessage
|
| 825 |
+
#pragma push_macro("GetObject")
|
| 826 |
+
#undef GetObject
|
| 827 |
+
#pragma push_macro("IGNORE")
|
| 828 |
+
#undef IGNORE
|
| 829 |
+
#pragma push_macro("IN")
|
| 830 |
+
#undef IN
|
| 831 |
+
#pragma push_macro("INPUT_KEYBOARD")
|
| 832 |
+
#undef INPUT_KEYBOARD
|
| 833 |
+
#pragma push_macro("NO_ERROR")
|
| 834 |
+
#undef NO_ERROR
|
| 835 |
+
#pragma push_macro("OUT")
|
| 836 |
+
#undef OUT
|
| 837 |
+
#pragma push_macro("OPTIONAL")
|
| 838 |
+
#undef OPTIONAL
|
| 839 |
+
#pragma push_macro("min")
|
| 840 |
+
#undef min
|
| 841 |
+
#pragma push_macro("max")
|
| 842 |
+
#undef max
|
| 843 |
+
#pragma push_macro("NEAR")
|
| 844 |
+
#undef NEAR
|
| 845 |
+
#pragma push_macro("NO_DATA")
|
| 846 |
+
#undef NO_DATA
|
| 847 |
+
#pragma push_macro("REASON_UNKNOWN")
|
| 848 |
+
#undef REASON_UNKNOWN
|
| 849 |
+
#pragma push_macro("SERVICE_DISABLED")
|
| 850 |
+
#undef SERVICE_DISABLED
|
| 851 |
+
#pragma push_macro("SEVERITY_ERROR")
|
| 852 |
+
#undef SEVERITY_ERROR
|
| 853 |
+
#pragma push_macro("STATUS_PENDING")
|
| 854 |
+
#undef STATUS_PENDING
|
| 855 |
+
#pragma push_macro("STRICT")
|
| 856 |
+
#undef STRICT
|
| 857 |
+
#pragma push_macro("timezone")
|
| 858 |
+
#undef timezone
|
| 859 |
+
#endif // _MSC_VER
|
| 860 |
+
|
| 861 |
+
#ifdef __APPLE__
|
| 862 |
+
// Inconvenient macro names from usr/include/math.h in some macOS SDKs.
|
| 863 |
+
#pragma push_macro("DOMAIN")
|
| 864 |
+
#undef DOMAIN
|
| 865 |
+
// Inconvenient macro names from /usr/include/mach/boolean.h in some macOS SDKs.
|
| 866 |
+
#pragma push_macro("TRUE")
|
| 867 |
+
#undef TRUE
|
| 868 |
+
#pragma push_macro("FALSE")
|
| 869 |
+
#undef FALSE
|
| 870 |
+
// Inconvenient macro names from usr/include/sys/syslimits.h in some macOS SDKs.
|
| 871 |
+
#pragma push_macro("UID_MAX")
|
| 872 |
+
#undef UID_MAX
|
| 873 |
+
#endif // __APPLE__
|
| 874 |
+
|
| 875 |
+
#if defined(__clang__) || PROTOBUF_GNUC_MIN(3, 0) || defined(_MSC_VER)
|
| 876 |
+
// Don't let Objective-C Macros interfere with proto identifiers with the same
|
| 877 |
+
// name.
|
| 878 |
+
#pragma push_macro("DEBUG")
|
| 879 |
+
#undef DEBUG
|
| 880 |
+
#endif // defined(__clang__) || PROTOBUF_GNUC_MIN(3, 0) || defined(_MSC_VER)
|
| 881 |
+
|
| 882 |
+
#if PROTOBUF_GNUC_MIN(3, 0)
|
| 883 |
+
// GCC does not allow disabling diagnostics within an expression:
|
| 884 |
+
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60875, so we disable this one
|
| 885 |
+
// globally even though it's only used for PROTOBUF_FIELD_OFFSET.
|
| 886 |
+
#pragma GCC diagnostic push
|
| 887 |
+
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
|
| 888 |
+
#endif
|
| 889 |
+
|
| 890 |
+
// Silence some MSVC warnings in all our code.
|
| 891 |
+
#ifdef _MSC_VER
|
| 892 |
+
#pragma warning(push)
|
| 893 |
+
// For non-trivial unions
|
| 894 |
+
#pragma warning(disable : 4582)
|
| 895 |
+
#pragma warning(disable : 4583)
|
| 896 |
+
// For init_seg(lib)
|
| 897 |
+
#pragma warning(disable : 4073)
|
| 898 |
+
// To silence the fact that we will pop this push from another file
|
| 899 |
+
#pragma warning(disable : 5031)
|
| 900 |
+
// Conditional expression is constant
|
| 901 |
+
#pragma warning(disable: 4127)
|
| 902 |
+
// decimal digit terminates octal escape sequence
|
| 903 |
+
#pragma warning(disable: 4125)
|
| 904 |
+
#endif
|
| 905 |
+
|
| 906 |
+
// We don't want code outside port_def doing complex testing, so
|
| 907 |
+
// remove our portable condition test macros to nudge folks away from
|
| 908 |
+
// using it themselves.
|
| 909 |
+
#ifdef PROTOBUF_has_cpp_attribute_DEFINED_
|
| 910 |
+
# undef __has_cpp_attribute
|
| 911 |
+
# undef PROTOBUF_has_cpp_attribute_DEFINED_
|
| 912 |
+
#endif
|
| 913 |
+
#ifdef PROTOBUF_has_feature_DEFINED_
|
| 914 |
+
# undef __has_feature
|
| 915 |
+
# undef PROTOBUF_has_feature_DEFINED_
|
| 916 |
+
#endif
|
| 917 |
+
#ifdef PROTOBUF_has_warning_DEFINED_
|
| 918 |
+
# undef __has_warning
|
| 919 |
+
# undef PROTOBUF_has_warning_DEFINED_
|
| 920 |
+
#endif
|
| 921 |
+
#ifdef PROTOBUF_has_attribute_DEFINED_
|
| 922 |
+
# undef __has_attribute
|
| 923 |
+
# undef PROTOBUF_has_attribute_DEFINED_
|
| 924 |
+
#endif
|
| 925 |
+
#ifdef PROTOBUF_has_builtin_DEFINED_
|
| 926 |
+
# undef __has_builtin
|
| 927 |
+
# undef PROTOBUF_has_builtin_DEFINED_
|
| 928 |
+
#endif
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/reflection_ops.h
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// Author: kenton@google.com (Kenton Varda)
|
| 32 |
+
// Based on original Protocol Buffers design by
|
| 33 |
+
// Sanjay Ghemawat, Jeff Dean, and others.
|
| 34 |
+
//
|
| 35 |
+
// This header is logically internal, but is made public because it is used
|
| 36 |
+
// from protocol-compiler-generated code, which may reside in other components.
|
| 37 |
+
|
| 38 |
+
#ifndef GOOGLE_PROTOBUF_REFLECTION_OPS_H__
|
| 39 |
+
#define GOOGLE_PROTOBUF_REFLECTION_OPS_H__
|
| 40 |
+
|
| 41 |
+
#include <google/protobuf/stubs/common.h>
|
| 42 |
+
#include <google/protobuf/message.h>
|
| 43 |
+
|
| 44 |
+
#ifdef SWIG
|
| 45 |
+
#error "You cannot SWIG proto headers"
|
| 46 |
+
#endif
|
| 47 |
+
|
| 48 |
+
// Must be included last.
|
| 49 |
+
#include <google/protobuf/port_def.inc>
|
| 50 |
+
|
| 51 |
+
namespace google {
|
| 52 |
+
namespace protobuf {
|
| 53 |
+
namespace internal {
|
| 54 |
+
|
| 55 |
+
// Basic operations that can be performed using reflection.
|
| 56 |
+
// These can be used as a cheap way to implement the corresponding
|
| 57 |
+
// methods of the Message interface, though they are likely to be
|
| 58 |
+
// slower than implementations tailored for the specific message type.
|
| 59 |
+
//
|
| 60 |
+
// This class should stay limited to operations needed to implement
|
| 61 |
+
// the Message interface.
|
| 62 |
+
//
|
| 63 |
+
// This class is really a namespace that contains only static methods.
|
| 64 |
+
class PROTOBUF_EXPORT ReflectionOps {
|
| 65 |
+
public:
|
| 66 |
+
static void Copy(const Message& from, Message* to);
|
| 67 |
+
static void Merge(const Message& from, Message* to);
|
| 68 |
+
static void Clear(Message* message);
|
| 69 |
+
static bool IsInitialized(const Message& message);
|
| 70 |
+
static bool IsInitialized(const Message& message, bool check_fields,
|
| 71 |
+
bool check_descendants);
|
| 72 |
+
static void DiscardUnknownFields(Message* message);
|
| 73 |
+
|
| 74 |
+
// Finds all unset required fields in the message and adds their full
|
| 75 |
+
// paths (e.g. "foo.bar[5].baz") to *names. "prefix" will be attached to
|
| 76 |
+
// the front of each name.
|
| 77 |
+
static void FindInitializationErrors(const Message& message,
|
| 78 |
+
const std::string& prefix,
|
| 79 |
+
std::vector<std::string>* errors);
|
| 80 |
+
|
| 81 |
+
private:
|
| 82 |
+
// All methods are static. No need to construct.
|
| 83 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ReflectionOps);
|
| 84 |
+
};
|
| 85 |
+
|
| 86 |
+
} // namespace internal
|
| 87 |
+
} // namespace protobuf
|
| 88 |
+
} // namespace google
|
| 89 |
+
|
| 90 |
+
#include <google/protobuf/port_undef.inc>
|
| 91 |
+
|
| 92 |
+
#endif // GOOGLE_PROTOBUF_REFLECTION_OPS_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/source_context.pb.h
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
| 2 |
+
// source: google/protobuf/source_context.proto
|
| 3 |
+
|
| 4 |
+
#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fsource_5fcontext_2eproto
|
| 5 |
+
#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fsource_5fcontext_2eproto
|
| 6 |
+
|
| 7 |
+
#include <limits>
|
| 8 |
+
#include <string>
|
| 9 |
+
|
| 10 |
+
#include <google/protobuf/port_def.inc>
|
| 11 |
+
#if PROTOBUF_VERSION < 3021000
|
| 12 |
+
#error This file was generated by a newer version of protoc which is
|
| 13 |
+
#error incompatible with your Protocol Buffer headers. Please update
|
| 14 |
+
#error your headers.
|
| 15 |
+
#endif
|
| 16 |
+
#if 3021009 < PROTOBUF_MIN_PROTOC_VERSION
|
| 17 |
+
#error This file was generated by an older version of protoc which is
|
| 18 |
+
#error incompatible with your Protocol Buffer headers. Please
|
| 19 |
+
#error regenerate this file with a newer version of protoc.
|
| 20 |
+
#endif
|
| 21 |
+
|
| 22 |
+
#include <google/protobuf/port_undef.inc>
|
| 23 |
+
#include <google/protobuf/io/coded_stream.h>
|
| 24 |
+
#include <google/protobuf/arena.h>
|
| 25 |
+
#include <google/protobuf/arenastring.h>
|
| 26 |
+
#include <google/protobuf/generated_message_util.h>
|
| 27 |
+
#include <google/protobuf/metadata_lite.h>
|
| 28 |
+
#include <google/protobuf/generated_message_reflection.h>
|
| 29 |
+
#include <google/protobuf/message.h>
|
| 30 |
+
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
|
| 31 |
+
#include <google/protobuf/extension_set.h> // IWYU pragma: export
|
| 32 |
+
#include <google/protobuf/unknown_field_set.h>
|
| 33 |
+
// @@protoc_insertion_point(includes)
|
| 34 |
+
#include <google/protobuf/port_def.inc>
|
| 35 |
+
#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fsource_5fcontext_2eproto PROTOBUF_EXPORT
|
| 36 |
+
PROTOBUF_NAMESPACE_OPEN
|
| 37 |
+
namespace internal {
|
| 38 |
+
class AnyMetadata;
|
| 39 |
+
} // namespace internal
|
| 40 |
+
PROTOBUF_NAMESPACE_CLOSE
|
| 41 |
+
|
| 42 |
+
// Internal implementation detail -- do not use these members.
|
| 43 |
+
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto {
|
| 44 |
+
static const uint32_t offsets[];
|
| 45 |
+
};
|
| 46 |
+
PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fsource_5fcontext_2eproto;
|
| 47 |
+
PROTOBUF_NAMESPACE_OPEN
|
| 48 |
+
class SourceContext;
|
| 49 |
+
struct SourceContextDefaultTypeInternal;
|
| 50 |
+
PROTOBUF_EXPORT extern SourceContextDefaultTypeInternal _SourceContext_default_instance_;
|
| 51 |
+
PROTOBUF_NAMESPACE_CLOSE
|
| 52 |
+
PROTOBUF_NAMESPACE_OPEN
|
| 53 |
+
template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::SourceContext* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::SourceContext>(Arena*);
|
| 54 |
+
PROTOBUF_NAMESPACE_CLOSE
|
| 55 |
+
PROTOBUF_NAMESPACE_OPEN
|
| 56 |
+
|
| 57 |
+
// ===================================================================
|
| 58 |
+
|
| 59 |
+
class PROTOBUF_EXPORT SourceContext final :
|
| 60 |
+
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceContext) */ {
|
| 61 |
+
public:
|
| 62 |
+
inline SourceContext() : SourceContext(nullptr) {}
|
| 63 |
+
~SourceContext() override;
|
| 64 |
+
explicit PROTOBUF_CONSTEXPR SourceContext(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
|
| 65 |
+
|
| 66 |
+
SourceContext(const SourceContext& from);
|
| 67 |
+
SourceContext(SourceContext&& from) noexcept
|
| 68 |
+
: SourceContext() {
|
| 69 |
+
*this = ::std::move(from);
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
inline SourceContext& operator=(const SourceContext& from) {
|
| 73 |
+
CopyFrom(from);
|
| 74 |
+
return *this;
|
| 75 |
+
}
|
| 76 |
+
inline SourceContext& operator=(SourceContext&& from) noexcept {
|
| 77 |
+
if (this == &from) return *this;
|
| 78 |
+
if (GetOwningArena() == from.GetOwningArena()
|
| 79 |
+
#ifdef PROTOBUF_FORCE_COPY_IN_MOVE
|
| 80 |
+
&& GetOwningArena() != nullptr
|
| 81 |
+
#endif // !PROTOBUF_FORCE_COPY_IN_MOVE
|
| 82 |
+
) {
|
| 83 |
+
InternalSwap(&from);
|
| 84 |
+
} else {
|
| 85 |
+
CopyFrom(from);
|
| 86 |
+
}
|
| 87 |
+
return *this;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
|
| 91 |
+
return GetDescriptor();
|
| 92 |
+
}
|
| 93 |
+
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
|
| 94 |
+
return default_instance().GetMetadata().descriptor;
|
| 95 |
+
}
|
| 96 |
+
static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
|
| 97 |
+
return default_instance().GetMetadata().reflection;
|
| 98 |
+
}
|
| 99 |
+
static const SourceContext& default_instance() {
|
| 100 |
+
return *internal_default_instance();
|
| 101 |
+
}
|
| 102 |
+
static inline const SourceContext* internal_default_instance() {
|
| 103 |
+
return reinterpret_cast<const SourceContext*>(
|
| 104 |
+
&_SourceContext_default_instance_);
|
| 105 |
+
}
|
| 106 |
+
static constexpr int kIndexInFileMessages =
|
| 107 |
+
0;
|
| 108 |
+
|
| 109 |
+
friend void swap(SourceContext& a, SourceContext& b) {
|
| 110 |
+
a.Swap(&b);
|
| 111 |
+
}
|
| 112 |
+
inline void Swap(SourceContext* other) {
|
| 113 |
+
if (other == this) return;
|
| 114 |
+
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
|
| 115 |
+
if (GetOwningArena() != nullptr &&
|
| 116 |
+
GetOwningArena() == other->GetOwningArena()) {
|
| 117 |
+
#else // PROTOBUF_FORCE_COPY_IN_SWAP
|
| 118 |
+
if (GetOwningArena() == other->GetOwningArena()) {
|
| 119 |
+
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
|
| 120 |
+
InternalSwap(other);
|
| 121 |
+
} else {
|
| 122 |
+
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
+
void UnsafeArenaSwap(SourceContext* other) {
|
| 126 |
+
if (other == this) return;
|
| 127 |
+
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
|
| 128 |
+
InternalSwap(other);
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
// implements Message ----------------------------------------------
|
| 132 |
+
|
| 133 |
+
SourceContext* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final {
|
| 134 |
+
return CreateMaybeMessage<SourceContext>(arena);
|
| 135 |
+
}
|
| 136 |
+
using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom;
|
| 137 |
+
void CopyFrom(const SourceContext& from);
|
| 138 |
+
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
|
| 139 |
+
void MergeFrom( const SourceContext& from) {
|
| 140 |
+
SourceContext::MergeImpl(*this, from);
|
| 141 |
+
}
|
| 142 |
+
private:
|
| 143 |
+
static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg);
|
| 144 |
+
public:
|
| 145 |
+
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
|
| 146 |
+
bool IsInitialized() const final;
|
| 147 |
+
|
| 148 |
+
size_t ByteSizeLong() const final;
|
| 149 |
+
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
|
| 150 |
+
uint8_t* _InternalSerialize(
|
| 151 |
+
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
|
| 152 |
+
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
|
| 153 |
+
|
| 154 |
+
private:
|
| 155 |
+
void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
|
| 156 |
+
void SharedDtor();
|
| 157 |
+
void SetCachedSize(int size) const final;
|
| 158 |
+
void InternalSwap(SourceContext* other);
|
| 159 |
+
|
| 160 |
+
private:
|
| 161 |
+
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
|
| 162 |
+
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
|
| 163 |
+
return "google.protobuf.SourceContext";
|
| 164 |
+
}
|
| 165 |
+
protected:
|
| 166 |
+
explicit SourceContext(::PROTOBUF_NAMESPACE_ID::Arena* arena,
|
| 167 |
+
bool is_message_owned = false);
|
| 168 |
+
public:
|
| 169 |
+
|
| 170 |
+
static const ClassData _class_data_;
|
| 171 |
+
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final;
|
| 172 |
+
|
| 173 |
+
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
|
| 174 |
+
|
| 175 |
+
// nested types ----------------------------------------------------
|
| 176 |
+
|
| 177 |
+
// accessors -------------------------------------------------------
|
| 178 |
+
|
| 179 |
+
enum : int {
|
| 180 |
+
kFileNameFieldNumber = 1,
|
| 181 |
+
};
|
| 182 |
+
// string file_name = 1;
|
| 183 |
+
void clear_file_name();
|
| 184 |
+
const std::string& file_name() const;
|
| 185 |
+
template <typename ArgT0 = const std::string&, typename... ArgT>
|
| 186 |
+
void set_file_name(ArgT0&& arg0, ArgT... args);
|
| 187 |
+
std::string* mutable_file_name();
|
| 188 |
+
PROTOBUF_NODISCARD std::string* release_file_name();
|
| 189 |
+
void set_allocated_file_name(std::string* file_name);
|
| 190 |
+
private:
|
| 191 |
+
const std::string& _internal_file_name() const;
|
| 192 |
+
inline PROTOBUF_ALWAYS_INLINE void _internal_set_file_name(const std::string& value);
|
| 193 |
+
std::string* _internal_mutable_file_name();
|
| 194 |
+
public:
|
| 195 |
+
|
| 196 |
+
// @@protoc_insertion_point(class_scope:google.protobuf.SourceContext)
|
| 197 |
+
private:
|
| 198 |
+
class _Internal;
|
| 199 |
+
|
| 200 |
+
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
|
| 201 |
+
typedef void InternalArenaConstructable_;
|
| 202 |
+
typedef void DestructorSkippable_;
|
| 203 |
+
struct Impl_ {
|
| 204 |
+
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr file_name_;
|
| 205 |
+
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
|
| 206 |
+
};
|
| 207 |
+
union { Impl_ _impl_; };
|
| 208 |
+
friend struct ::TableStruct_google_2fprotobuf_2fsource_5fcontext_2eproto;
|
| 209 |
+
};
|
| 210 |
+
// ===================================================================
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
// ===================================================================
|
| 214 |
+
|
| 215 |
+
#ifdef __GNUC__
|
| 216 |
+
#pragma GCC diagnostic push
|
| 217 |
+
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
| 218 |
+
#endif // __GNUC__
|
| 219 |
+
// SourceContext
|
| 220 |
+
|
| 221 |
+
// string file_name = 1;
|
| 222 |
+
inline void SourceContext::clear_file_name() {
|
| 223 |
+
_impl_.file_name_.ClearToEmpty();
|
| 224 |
+
}
|
| 225 |
+
inline const std::string& SourceContext::file_name() const {
|
| 226 |
+
// @@protoc_insertion_point(field_get:google.protobuf.SourceContext.file_name)
|
| 227 |
+
return _internal_file_name();
|
| 228 |
+
}
|
| 229 |
+
template <typename ArgT0, typename... ArgT>
|
| 230 |
+
inline PROTOBUF_ALWAYS_INLINE
|
| 231 |
+
void SourceContext::set_file_name(ArgT0&& arg0, ArgT... args) {
|
| 232 |
+
|
| 233 |
+
_impl_.file_name_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
|
| 234 |
+
// @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name)
|
| 235 |
+
}
|
| 236 |
+
inline std::string* SourceContext::mutable_file_name() {
|
| 237 |
+
std::string* _s = _internal_mutable_file_name();
|
| 238 |
+
// @@protoc_insertion_point(field_mutable:google.protobuf.SourceContext.file_name)
|
| 239 |
+
return _s;
|
| 240 |
+
}
|
| 241 |
+
inline const std::string& SourceContext::_internal_file_name() const {
|
| 242 |
+
return _impl_.file_name_.Get();
|
| 243 |
+
}
|
| 244 |
+
inline void SourceContext::_internal_set_file_name(const std::string& value) {
|
| 245 |
+
|
| 246 |
+
_impl_.file_name_.Set(value, GetArenaForAllocation());
|
| 247 |
+
}
|
| 248 |
+
inline std::string* SourceContext::_internal_mutable_file_name() {
|
| 249 |
+
|
| 250 |
+
return _impl_.file_name_.Mutable(GetArenaForAllocation());
|
| 251 |
+
}
|
| 252 |
+
inline std::string* SourceContext::release_file_name() {
|
| 253 |
+
// @@protoc_insertion_point(field_release:google.protobuf.SourceContext.file_name)
|
| 254 |
+
return _impl_.file_name_.Release();
|
| 255 |
+
}
|
| 256 |
+
inline void SourceContext::set_allocated_file_name(std::string* file_name) {
|
| 257 |
+
if (file_name != nullptr) {
|
| 258 |
+
|
| 259 |
+
} else {
|
| 260 |
+
|
| 261 |
+
}
|
| 262 |
+
_impl_.file_name_.SetAllocated(file_name, GetArenaForAllocation());
|
| 263 |
+
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
| 264 |
+
if (_impl_.file_name_.IsDefault()) {
|
| 265 |
+
_impl_.file_name_.Set("", GetArenaForAllocation());
|
| 266 |
+
}
|
| 267 |
+
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
| 268 |
+
// @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name)
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
#ifdef __GNUC__
|
| 272 |
+
#pragma GCC diagnostic pop
|
| 273 |
+
#endif // __GNUC__
|
| 274 |
+
|
| 275 |
+
// @@protoc_insertion_point(namespace_scope)
|
| 276 |
+
|
| 277 |
+
PROTOBUF_NAMESPACE_CLOSE
|
| 278 |
+
|
| 279 |
+
// @@protoc_insertion_point(global_scope)
|
| 280 |
+
|
| 281 |
+
#include <google/protobuf/port_undef.inc>
|
| 282 |
+
#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fsource_5fcontext_2eproto
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/struct.pb.h
ADDED
|
@@ -0,0 +1,1177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
| 2 |
+
// source: google/protobuf/struct.proto
|
| 3 |
+
|
| 4 |
+
#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fstruct_2eproto
|
| 5 |
+
#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fstruct_2eproto
|
| 6 |
+
|
| 7 |
+
#include <limits>
|
| 8 |
+
#include <string>
|
| 9 |
+
|
| 10 |
+
#include <google/protobuf/port_def.inc>
|
| 11 |
+
#if PROTOBUF_VERSION < 3021000
|
| 12 |
+
#error This file was generated by a newer version of protoc which is
|
| 13 |
+
#error incompatible with your Protocol Buffer headers. Please update
|
| 14 |
+
#error your headers.
|
| 15 |
+
#endif
|
| 16 |
+
#if 3021009 < PROTOBUF_MIN_PROTOC_VERSION
|
| 17 |
+
#error This file was generated by an older version of protoc which is
|
| 18 |
+
#error incompatible with your Protocol Buffer headers. Please
|
| 19 |
+
#error regenerate this file with a newer version of protoc.
|
| 20 |
+
#endif
|
| 21 |
+
|
| 22 |
+
#include <google/protobuf/port_undef.inc>
|
| 23 |
+
#include <google/protobuf/io/coded_stream.h>
|
| 24 |
+
#include <google/protobuf/arena.h>
|
| 25 |
+
#include <google/protobuf/arenastring.h>
|
| 26 |
+
#include <google/protobuf/generated_message_util.h>
|
| 27 |
+
#include <google/protobuf/metadata_lite.h>
|
| 28 |
+
#include <google/protobuf/generated_message_reflection.h>
|
| 29 |
+
#include <google/protobuf/message.h>
|
| 30 |
+
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
|
| 31 |
+
#include <google/protobuf/extension_set.h> // IWYU pragma: export
|
| 32 |
+
#include <google/protobuf/map.h> // IWYU pragma: export
|
| 33 |
+
#include <google/protobuf/map_entry.h>
|
| 34 |
+
#include <google/protobuf/map_field_inl.h>
|
| 35 |
+
#include <google/protobuf/generated_enum_reflection.h>
|
| 36 |
+
#include <google/protobuf/unknown_field_set.h>
|
| 37 |
+
// @@protoc_insertion_point(includes)
|
| 38 |
+
#include <google/protobuf/port_def.inc>
|
| 39 |
+
#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fstruct_2eproto PROTOBUF_EXPORT
|
| 40 |
+
PROTOBUF_NAMESPACE_OPEN
|
| 41 |
+
namespace internal {
|
| 42 |
+
class AnyMetadata;
|
| 43 |
+
} // namespace internal
|
| 44 |
+
PROTOBUF_NAMESPACE_CLOSE
|
| 45 |
+
|
| 46 |
+
// Internal implementation detail -- do not use these members.
|
| 47 |
+
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fstruct_2eproto {
|
| 48 |
+
static const uint32_t offsets[];
|
| 49 |
+
};
|
| 50 |
+
PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fstruct_2eproto;
|
| 51 |
+
PROTOBUF_NAMESPACE_OPEN
|
| 52 |
+
class ListValue;
|
| 53 |
+
struct ListValueDefaultTypeInternal;
|
| 54 |
+
PROTOBUF_EXPORT extern ListValueDefaultTypeInternal _ListValue_default_instance_;
|
| 55 |
+
class Struct;
|
| 56 |
+
struct StructDefaultTypeInternal;
|
| 57 |
+
PROTOBUF_EXPORT extern StructDefaultTypeInternal _Struct_default_instance_;
|
| 58 |
+
class Struct_FieldsEntry_DoNotUse;
|
| 59 |
+
struct Struct_FieldsEntry_DoNotUseDefaultTypeInternal;
|
| 60 |
+
PROTOBUF_EXPORT extern Struct_FieldsEntry_DoNotUseDefaultTypeInternal _Struct_FieldsEntry_DoNotUse_default_instance_;
|
| 61 |
+
class Value;
|
| 62 |
+
struct ValueDefaultTypeInternal;
|
| 63 |
+
PROTOBUF_EXPORT extern ValueDefaultTypeInternal _Value_default_instance_;
|
| 64 |
+
PROTOBUF_NAMESPACE_CLOSE
|
| 65 |
+
PROTOBUF_NAMESPACE_OPEN
|
| 66 |
+
template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ListValue* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ListValue>(Arena*);
|
| 67 |
+
template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Struct* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Struct>(Arena*);
|
| 68 |
+
template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Struct_FieldsEntry_DoNotUse>(Arena*);
|
| 69 |
+
template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Value* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Value>(Arena*);
|
| 70 |
+
PROTOBUF_NAMESPACE_CLOSE
|
| 71 |
+
PROTOBUF_NAMESPACE_OPEN
|
| 72 |
+
|
| 73 |
+
enum NullValue : int {
|
| 74 |
+
NULL_VALUE = 0,
|
| 75 |
+
NullValue_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<int32_t>::min(),
|
| 76 |
+
NullValue_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits<int32_t>::max()
|
| 77 |
+
};
|
| 78 |
+
PROTOBUF_EXPORT bool NullValue_IsValid(int value);
|
| 79 |
+
constexpr NullValue NullValue_MIN = NULL_VALUE;
|
| 80 |
+
constexpr NullValue NullValue_MAX = NULL_VALUE;
|
| 81 |
+
constexpr int NullValue_ARRAYSIZE = NullValue_MAX + 1;
|
| 82 |
+
|
| 83 |
+
PROTOBUF_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* NullValue_descriptor();
|
| 84 |
+
template<typename T>
|
| 85 |
+
inline const std::string& NullValue_Name(T enum_t_value) {
|
| 86 |
+
static_assert(::std::is_same<T, NullValue>::value ||
|
| 87 |
+
::std::is_integral<T>::value,
|
| 88 |
+
"Incorrect type passed to function NullValue_Name.");
|
| 89 |
+
return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum(
|
| 90 |
+
NullValue_descriptor(), enum_t_value);
|
| 91 |
+
}
|
| 92 |
+
inline bool NullValue_Parse(
|
| 93 |
+
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, NullValue* value) {
|
| 94 |
+
return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<NullValue>(
|
| 95 |
+
NullValue_descriptor(), name, value);
|
| 96 |
+
}
|
| 97 |
+
// ===================================================================
|
| 98 |
+
|
| 99 |
+
class Struct_FieldsEntry_DoNotUse : public ::PROTOBUF_NAMESPACE_ID::internal::MapEntry<Struct_FieldsEntry_DoNotUse,
|
| 100 |
+
std::string, ::PROTOBUF_NAMESPACE_ID::Value,
|
| 101 |
+
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING,
|
| 102 |
+
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_MESSAGE> {
|
| 103 |
+
public:
|
| 104 |
+
typedef ::PROTOBUF_NAMESPACE_ID::internal::MapEntry<Struct_FieldsEntry_DoNotUse,
|
| 105 |
+
std::string, ::PROTOBUF_NAMESPACE_ID::Value,
|
| 106 |
+
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING,
|
| 107 |
+
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_MESSAGE> SuperType;
|
| 108 |
+
Struct_FieldsEntry_DoNotUse();
|
| 109 |
+
explicit PROTOBUF_CONSTEXPR Struct_FieldsEntry_DoNotUse(
|
| 110 |
+
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
|
| 111 |
+
explicit Struct_FieldsEntry_DoNotUse(::PROTOBUF_NAMESPACE_ID::Arena* arena);
|
| 112 |
+
void MergeFrom(const Struct_FieldsEntry_DoNotUse& other);
|
| 113 |
+
static const Struct_FieldsEntry_DoNotUse* internal_default_instance() { return reinterpret_cast<const Struct_FieldsEntry_DoNotUse*>(&_Struct_FieldsEntry_DoNotUse_default_instance_); }
|
| 114 |
+
static bool ValidateKey(std::string* s) {
|
| 115 |
+
return ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(s->data(), static_cast<int>(s->size()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.Struct.FieldsEntry.key");
|
| 116 |
+
}
|
| 117 |
+
static bool ValidateValue(void*) { return true; }
|
| 118 |
+
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
|
| 119 |
+
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
|
| 120 |
+
friend struct ::TableStruct_google_2fprotobuf_2fstruct_2eproto;
|
| 121 |
+
};
|
| 122 |
+
|
| 123 |
+
// -------------------------------------------------------------------
|
| 124 |
+
|
| 125 |
+
class PROTOBUF_EXPORT Struct final :
|
| 126 |
+
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Struct) */ {
|
| 127 |
+
public:
|
| 128 |
+
inline Struct() : Struct(nullptr) {}
|
| 129 |
+
~Struct() override;
|
| 130 |
+
explicit PROTOBUF_CONSTEXPR Struct(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
|
| 131 |
+
|
| 132 |
+
Struct(const Struct& from);
|
| 133 |
+
Struct(Struct&& from) noexcept
|
| 134 |
+
: Struct() {
|
| 135 |
+
*this = ::std::move(from);
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
inline Struct& operator=(const Struct& from) {
|
| 139 |
+
CopyFrom(from);
|
| 140 |
+
return *this;
|
| 141 |
+
}
|
| 142 |
+
inline Struct& operator=(Struct&& from) noexcept {
|
| 143 |
+
if (this == &from) return *this;
|
| 144 |
+
if (GetOwningArena() == from.GetOwningArena()
|
| 145 |
+
#ifdef PROTOBUF_FORCE_COPY_IN_MOVE
|
| 146 |
+
&& GetOwningArena() != nullptr
|
| 147 |
+
#endif // !PROTOBUF_FORCE_COPY_IN_MOVE
|
| 148 |
+
) {
|
| 149 |
+
InternalSwap(&from);
|
| 150 |
+
} else {
|
| 151 |
+
CopyFrom(from);
|
| 152 |
+
}
|
| 153 |
+
return *this;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
|
| 157 |
+
return GetDescriptor();
|
| 158 |
+
}
|
| 159 |
+
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
|
| 160 |
+
return default_instance().GetMetadata().descriptor;
|
| 161 |
+
}
|
| 162 |
+
static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
|
| 163 |
+
return default_instance().GetMetadata().reflection;
|
| 164 |
+
}
|
| 165 |
+
static const Struct& default_instance() {
|
| 166 |
+
return *internal_default_instance();
|
| 167 |
+
}
|
| 168 |
+
static inline const Struct* internal_default_instance() {
|
| 169 |
+
return reinterpret_cast<const Struct*>(
|
| 170 |
+
&_Struct_default_instance_);
|
| 171 |
+
}
|
| 172 |
+
static constexpr int kIndexInFileMessages =
|
| 173 |
+
1;
|
| 174 |
+
|
| 175 |
+
friend void swap(Struct& a, Struct& b) {
|
| 176 |
+
a.Swap(&b);
|
| 177 |
+
}
|
| 178 |
+
inline void Swap(Struct* other) {
|
| 179 |
+
if (other == this) return;
|
| 180 |
+
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
|
| 181 |
+
if (GetOwningArena() != nullptr &&
|
| 182 |
+
GetOwningArena() == other->GetOwningArena()) {
|
| 183 |
+
#else // PROTOBUF_FORCE_COPY_IN_SWAP
|
| 184 |
+
if (GetOwningArena() == other->GetOwningArena()) {
|
| 185 |
+
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
|
| 186 |
+
InternalSwap(other);
|
| 187 |
+
} else {
|
| 188 |
+
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
|
| 189 |
+
}
|
| 190 |
+
}
|
| 191 |
+
void UnsafeArenaSwap(Struct* other) {
|
| 192 |
+
if (other == this) return;
|
| 193 |
+
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
|
| 194 |
+
InternalSwap(other);
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
// implements Message ----------------------------------------------
|
| 198 |
+
|
| 199 |
+
Struct* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final {
|
| 200 |
+
return CreateMaybeMessage<Struct>(arena);
|
| 201 |
+
}
|
| 202 |
+
using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom;
|
| 203 |
+
void CopyFrom(const Struct& from);
|
| 204 |
+
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
|
| 205 |
+
void MergeFrom( const Struct& from) {
|
| 206 |
+
Struct::MergeImpl(*this, from);
|
| 207 |
+
}
|
| 208 |
+
private:
|
| 209 |
+
static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg);
|
| 210 |
+
public:
|
| 211 |
+
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
|
| 212 |
+
bool IsInitialized() const final;
|
| 213 |
+
|
| 214 |
+
size_t ByteSizeLong() const final;
|
| 215 |
+
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
|
| 216 |
+
uint8_t* _InternalSerialize(
|
| 217 |
+
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
|
| 218 |
+
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
|
| 219 |
+
|
| 220 |
+
private:
|
| 221 |
+
void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
|
| 222 |
+
void SharedDtor();
|
| 223 |
+
void SetCachedSize(int size) const final;
|
| 224 |
+
void InternalSwap(Struct* other);
|
| 225 |
+
|
| 226 |
+
private:
|
| 227 |
+
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
|
| 228 |
+
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
|
| 229 |
+
return "google.protobuf.Struct";
|
| 230 |
+
}
|
| 231 |
+
protected:
|
| 232 |
+
explicit Struct(::PROTOBUF_NAMESPACE_ID::Arena* arena,
|
| 233 |
+
bool is_message_owned = false);
|
| 234 |
+
private:
|
| 235 |
+
static void ArenaDtor(void* object);
|
| 236 |
+
public:
|
| 237 |
+
|
| 238 |
+
static const ClassData _class_data_;
|
| 239 |
+
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final;
|
| 240 |
+
|
| 241 |
+
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
|
| 242 |
+
|
| 243 |
+
// nested types ----------------------------------------------------
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
// accessors -------------------------------------------------------
|
| 247 |
+
|
| 248 |
+
enum : int {
|
| 249 |
+
kFieldsFieldNumber = 1,
|
| 250 |
+
};
|
| 251 |
+
// map<string, .google.protobuf.Value> fields = 1;
|
| 252 |
+
int fields_size() const;
|
| 253 |
+
private:
|
| 254 |
+
int _internal_fields_size() const;
|
| 255 |
+
public:
|
| 256 |
+
void clear_fields();
|
| 257 |
+
private:
|
| 258 |
+
const ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::Value >&
|
| 259 |
+
_internal_fields() const;
|
| 260 |
+
::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::Value >*
|
| 261 |
+
_internal_mutable_fields();
|
| 262 |
+
public:
|
| 263 |
+
const ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::Value >&
|
| 264 |
+
fields() const;
|
| 265 |
+
::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::Value >*
|
| 266 |
+
mutable_fields();
|
| 267 |
+
|
| 268 |
+
// @@protoc_insertion_point(class_scope:google.protobuf.Struct)
|
| 269 |
+
private:
|
| 270 |
+
class _Internal;
|
| 271 |
+
|
| 272 |
+
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
|
| 273 |
+
typedef void InternalArenaConstructable_;
|
| 274 |
+
typedef void DestructorSkippable_;
|
| 275 |
+
struct Impl_ {
|
| 276 |
+
::PROTOBUF_NAMESPACE_ID::internal::MapField<
|
| 277 |
+
Struct_FieldsEntry_DoNotUse,
|
| 278 |
+
std::string, ::PROTOBUF_NAMESPACE_ID::Value,
|
| 279 |
+
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_STRING,
|
| 280 |
+
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_MESSAGE> fields_;
|
| 281 |
+
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
|
| 282 |
+
};
|
| 283 |
+
union { Impl_ _impl_; };
|
| 284 |
+
friend struct ::TableStruct_google_2fprotobuf_2fstruct_2eproto;
|
| 285 |
+
};
|
| 286 |
+
// -------------------------------------------------------------------
|
| 287 |
+
|
| 288 |
+
class PROTOBUF_EXPORT Value final :
|
| 289 |
+
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Value) */ {
|
| 290 |
+
public:
|
| 291 |
+
inline Value() : Value(nullptr) {}
|
| 292 |
+
~Value() override;
|
| 293 |
+
explicit PROTOBUF_CONSTEXPR Value(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
|
| 294 |
+
|
| 295 |
+
Value(const Value& from);
|
| 296 |
+
Value(Value&& from) noexcept
|
| 297 |
+
: Value() {
|
| 298 |
+
*this = ::std::move(from);
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
inline Value& operator=(const Value& from) {
|
| 302 |
+
CopyFrom(from);
|
| 303 |
+
return *this;
|
| 304 |
+
}
|
| 305 |
+
inline Value& operator=(Value&& from) noexcept {
|
| 306 |
+
if (this == &from) return *this;
|
| 307 |
+
if (GetOwningArena() == from.GetOwningArena()
|
| 308 |
+
#ifdef PROTOBUF_FORCE_COPY_IN_MOVE
|
| 309 |
+
&& GetOwningArena() != nullptr
|
| 310 |
+
#endif // !PROTOBUF_FORCE_COPY_IN_MOVE
|
| 311 |
+
) {
|
| 312 |
+
InternalSwap(&from);
|
| 313 |
+
} else {
|
| 314 |
+
CopyFrom(from);
|
| 315 |
+
}
|
| 316 |
+
return *this;
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
|
| 320 |
+
return GetDescriptor();
|
| 321 |
+
}
|
| 322 |
+
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
|
| 323 |
+
return default_instance().GetMetadata().descriptor;
|
| 324 |
+
}
|
| 325 |
+
static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
|
| 326 |
+
return default_instance().GetMetadata().reflection;
|
| 327 |
+
}
|
| 328 |
+
static const Value& default_instance() {
|
| 329 |
+
return *internal_default_instance();
|
| 330 |
+
}
|
| 331 |
+
enum KindCase {
|
| 332 |
+
kNullValue = 1,
|
| 333 |
+
kNumberValue = 2,
|
| 334 |
+
kStringValue = 3,
|
| 335 |
+
kBoolValue = 4,
|
| 336 |
+
kStructValue = 5,
|
| 337 |
+
kListValue = 6,
|
| 338 |
+
KIND_NOT_SET = 0,
|
| 339 |
+
};
|
| 340 |
+
|
| 341 |
+
static inline const Value* internal_default_instance() {
|
| 342 |
+
return reinterpret_cast<const Value*>(
|
| 343 |
+
&_Value_default_instance_);
|
| 344 |
+
}
|
| 345 |
+
static constexpr int kIndexInFileMessages =
|
| 346 |
+
2;
|
| 347 |
+
|
| 348 |
+
friend void swap(Value& a, Value& b) {
|
| 349 |
+
a.Swap(&b);
|
| 350 |
+
}
|
| 351 |
+
inline void Swap(Value* other) {
|
| 352 |
+
if (other == this) return;
|
| 353 |
+
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
|
| 354 |
+
if (GetOwningArena() != nullptr &&
|
| 355 |
+
GetOwningArena() == other->GetOwningArena()) {
|
| 356 |
+
#else // PROTOBUF_FORCE_COPY_IN_SWAP
|
| 357 |
+
if (GetOwningArena() == other->GetOwningArena()) {
|
| 358 |
+
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
|
| 359 |
+
InternalSwap(other);
|
| 360 |
+
} else {
|
| 361 |
+
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
|
| 362 |
+
}
|
| 363 |
+
}
|
| 364 |
+
void UnsafeArenaSwap(Value* other) {
|
| 365 |
+
if (other == this) return;
|
| 366 |
+
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
|
| 367 |
+
InternalSwap(other);
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
// implements Message ----------------------------------------------
|
| 371 |
+
|
| 372 |
+
Value* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final {
|
| 373 |
+
return CreateMaybeMessage<Value>(arena);
|
| 374 |
+
}
|
| 375 |
+
using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom;
|
| 376 |
+
void CopyFrom(const Value& from);
|
| 377 |
+
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
|
| 378 |
+
void MergeFrom( const Value& from) {
|
| 379 |
+
Value::MergeImpl(*this, from);
|
| 380 |
+
}
|
| 381 |
+
private:
|
| 382 |
+
static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg);
|
| 383 |
+
public:
|
| 384 |
+
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
|
| 385 |
+
bool IsInitialized() const final;
|
| 386 |
+
|
| 387 |
+
size_t ByteSizeLong() const final;
|
| 388 |
+
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
|
| 389 |
+
uint8_t* _InternalSerialize(
|
| 390 |
+
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
|
| 391 |
+
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
|
| 392 |
+
|
| 393 |
+
private:
|
| 394 |
+
void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
|
| 395 |
+
void SharedDtor();
|
| 396 |
+
void SetCachedSize(int size) const final;
|
| 397 |
+
void InternalSwap(Value* other);
|
| 398 |
+
|
| 399 |
+
private:
|
| 400 |
+
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
|
| 401 |
+
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
|
| 402 |
+
return "google.protobuf.Value";
|
| 403 |
+
}
|
| 404 |
+
protected:
|
| 405 |
+
explicit Value(::PROTOBUF_NAMESPACE_ID::Arena* arena,
|
| 406 |
+
bool is_message_owned = false);
|
| 407 |
+
public:
|
| 408 |
+
|
| 409 |
+
static const ClassData _class_data_;
|
| 410 |
+
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final;
|
| 411 |
+
|
| 412 |
+
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
|
| 413 |
+
|
| 414 |
+
// nested types ----------------------------------------------------
|
| 415 |
+
|
| 416 |
+
// accessors -------------------------------------------------------
|
| 417 |
+
|
| 418 |
+
enum : int {
|
| 419 |
+
kNullValueFieldNumber = 1,
|
| 420 |
+
kNumberValueFieldNumber = 2,
|
| 421 |
+
kStringValueFieldNumber = 3,
|
| 422 |
+
kBoolValueFieldNumber = 4,
|
| 423 |
+
kStructValueFieldNumber = 5,
|
| 424 |
+
kListValueFieldNumber = 6,
|
| 425 |
+
};
|
| 426 |
+
// .google.protobuf.NullValue null_value = 1;
|
| 427 |
+
bool has_null_value() const;
|
| 428 |
+
private:
|
| 429 |
+
bool _internal_has_null_value() const;
|
| 430 |
+
public:
|
| 431 |
+
void clear_null_value();
|
| 432 |
+
::PROTOBUF_NAMESPACE_ID::NullValue null_value() const;
|
| 433 |
+
void set_null_value(::PROTOBUF_NAMESPACE_ID::NullValue value);
|
| 434 |
+
private:
|
| 435 |
+
::PROTOBUF_NAMESPACE_ID::NullValue _internal_null_value() const;
|
| 436 |
+
void _internal_set_null_value(::PROTOBUF_NAMESPACE_ID::NullValue value);
|
| 437 |
+
public:
|
| 438 |
+
|
| 439 |
+
// double number_value = 2;
|
| 440 |
+
bool has_number_value() const;
|
| 441 |
+
private:
|
| 442 |
+
bool _internal_has_number_value() const;
|
| 443 |
+
public:
|
| 444 |
+
void clear_number_value();
|
| 445 |
+
double number_value() const;
|
| 446 |
+
void set_number_value(double value);
|
| 447 |
+
private:
|
| 448 |
+
double _internal_number_value() const;
|
| 449 |
+
void _internal_set_number_value(double value);
|
| 450 |
+
public:
|
| 451 |
+
|
| 452 |
+
// string string_value = 3;
|
| 453 |
+
bool has_string_value() const;
|
| 454 |
+
private:
|
| 455 |
+
bool _internal_has_string_value() const;
|
| 456 |
+
public:
|
| 457 |
+
void clear_string_value();
|
| 458 |
+
const std::string& string_value() const;
|
| 459 |
+
template <typename ArgT0 = const std::string&, typename... ArgT>
|
| 460 |
+
void set_string_value(ArgT0&& arg0, ArgT... args);
|
| 461 |
+
std::string* mutable_string_value();
|
| 462 |
+
PROTOBUF_NODISCARD std::string* release_string_value();
|
| 463 |
+
void set_allocated_string_value(std::string* string_value);
|
| 464 |
+
private:
|
| 465 |
+
const std::string& _internal_string_value() const;
|
| 466 |
+
inline PROTOBUF_ALWAYS_INLINE void _internal_set_string_value(const std::string& value);
|
| 467 |
+
std::string* _internal_mutable_string_value();
|
| 468 |
+
public:
|
| 469 |
+
|
| 470 |
+
// bool bool_value = 4;
|
| 471 |
+
bool has_bool_value() const;
|
| 472 |
+
private:
|
| 473 |
+
bool _internal_has_bool_value() const;
|
| 474 |
+
public:
|
| 475 |
+
void clear_bool_value();
|
| 476 |
+
bool bool_value() const;
|
| 477 |
+
void set_bool_value(bool value);
|
| 478 |
+
private:
|
| 479 |
+
bool _internal_bool_value() const;
|
| 480 |
+
void _internal_set_bool_value(bool value);
|
| 481 |
+
public:
|
| 482 |
+
|
| 483 |
+
// .google.protobuf.Struct struct_value = 5;
|
| 484 |
+
bool has_struct_value() const;
|
| 485 |
+
private:
|
| 486 |
+
bool _internal_has_struct_value() const;
|
| 487 |
+
public:
|
| 488 |
+
void clear_struct_value();
|
| 489 |
+
const ::PROTOBUF_NAMESPACE_ID::Struct& struct_value() const;
|
| 490 |
+
PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::Struct* release_struct_value();
|
| 491 |
+
::PROTOBUF_NAMESPACE_ID::Struct* mutable_struct_value();
|
| 492 |
+
void set_allocated_struct_value(::PROTOBUF_NAMESPACE_ID::Struct* struct_value);
|
| 493 |
+
private:
|
| 494 |
+
const ::PROTOBUF_NAMESPACE_ID::Struct& _internal_struct_value() const;
|
| 495 |
+
::PROTOBUF_NAMESPACE_ID::Struct* _internal_mutable_struct_value();
|
| 496 |
+
public:
|
| 497 |
+
void unsafe_arena_set_allocated_struct_value(
|
| 498 |
+
::PROTOBUF_NAMESPACE_ID::Struct* struct_value);
|
| 499 |
+
::PROTOBUF_NAMESPACE_ID::Struct* unsafe_arena_release_struct_value();
|
| 500 |
+
|
| 501 |
+
// .google.protobuf.ListValue list_value = 6;
|
| 502 |
+
bool has_list_value() const;
|
| 503 |
+
private:
|
| 504 |
+
bool _internal_has_list_value() const;
|
| 505 |
+
public:
|
| 506 |
+
void clear_list_value();
|
| 507 |
+
const ::PROTOBUF_NAMESPACE_ID::ListValue& list_value() const;
|
| 508 |
+
PROTOBUF_NODISCARD ::PROTOBUF_NAMESPACE_ID::ListValue* release_list_value();
|
| 509 |
+
::PROTOBUF_NAMESPACE_ID::ListValue* mutable_list_value();
|
| 510 |
+
void set_allocated_list_value(::PROTOBUF_NAMESPACE_ID::ListValue* list_value);
|
| 511 |
+
private:
|
| 512 |
+
const ::PROTOBUF_NAMESPACE_ID::ListValue& _internal_list_value() const;
|
| 513 |
+
::PROTOBUF_NAMESPACE_ID::ListValue* _internal_mutable_list_value();
|
| 514 |
+
public:
|
| 515 |
+
void unsafe_arena_set_allocated_list_value(
|
| 516 |
+
::PROTOBUF_NAMESPACE_ID::ListValue* list_value);
|
| 517 |
+
::PROTOBUF_NAMESPACE_ID::ListValue* unsafe_arena_release_list_value();
|
| 518 |
+
|
| 519 |
+
void clear_kind();
|
| 520 |
+
KindCase kind_case() const;
|
| 521 |
+
// @@protoc_insertion_point(class_scope:google.protobuf.Value)
|
| 522 |
+
private:
|
| 523 |
+
class _Internal;
|
| 524 |
+
void set_has_null_value();
|
| 525 |
+
void set_has_number_value();
|
| 526 |
+
void set_has_string_value();
|
| 527 |
+
void set_has_bool_value();
|
| 528 |
+
void set_has_struct_value();
|
| 529 |
+
void set_has_list_value();
|
| 530 |
+
|
| 531 |
+
inline bool has_kind() const;
|
| 532 |
+
inline void clear_has_kind();
|
| 533 |
+
|
| 534 |
+
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
|
| 535 |
+
typedef void InternalArenaConstructable_;
|
| 536 |
+
typedef void DestructorSkippable_;
|
| 537 |
+
struct Impl_ {
|
| 538 |
+
union KindUnion {
|
| 539 |
+
constexpr KindUnion() : _constinit_{} {}
|
| 540 |
+
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized _constinit_;
|
| 541 |
+
int null_value_;
|
| 542 |
+
double number_value_;
|
| 543 |
+
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr string_value_;
|
| 544 |
+
bool bool_value_;
|
| 545 |
+
::PROTOBUF_NAMESPACE_ID::Struct* struct_value_;
|
| 546 |
+
::PROTOBUF_NAMESPACE_ID::ListValue* list_value_;
|
| 547 |
+
} kind_;
|
| 548 |
+
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
|
| 549 |
+
uint32_t _oneof_case_[1];
|
| 550 |
+
|
| 551 |
+
};
|
| 552 |
+
union { Impl_ _impl_; };
|
| 553 |
+
friend struct ::TableStruct_google_2fprotobuf_2fstruct_2eproto;
|
| 554 |
+
};
|
| 555 |
+
// -------------------------------------------------------------------
|
| 556 |
+
|
| 557 |
+
class PROTOBUF_EXPORT ListValue final :
|
| 558 |
+
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ListValue) */ {
|
| 559 |
+
public:
|
| 560 |
+
inline ListValue() : ListValue(nullptr) {}
|
| 561 |
+
~ListValue() override;
|
| 562 |
+
explicit PROTOBUF_CONSTEXPR ListValue(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
|
| 563 |
+
|
| 564 |
+
ListValue(const ListValue& from);
|
| 565 |
+
ListValue(ListValue&& from) noexcept
|
| 566 |
+
: ListValue() {
|
| 567 |
+
*this = ::std::move(from);
|
| 568 |
+
}
|
| 569 |
+
|
| 570 |
+
inline ListValue& operator=(const ListValue& from) {
|
| 571 |
+
CopyFrom(from);
|
| 572 |
+
return *this;
|
| 573 |
+
}
|
| 574 |
+
inline ListValue& operator=(ListValue&& from) noexcept {
|
| 575 |
+
if (this == &from) return *this;
|
| 576 |
+
if (GetOwningArena() == from.GetOwningArena()
|
| 577 |
+
#ifdef PROTOBUF_FORCE_COPY_IN_MOVE
|
| 578 |
+
&& GetOwningArena() != nullptr
|
| 579 |
+
#endif // !PROTOBUF_FORCE_COPY_IN_MOVE
|
| 580 |
+
) {
|
| 581 |
+
InternalSwap(&from);
|
| 582 |
+
} else {
|
| 583 |
+
CopyFrom(from);
|
| 584 |
+
}
|
| 585 |
+
return *this;
|
| 586 |
+
}
|
| 587 |
+
|
| 588 |
+
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
|
| 589 |
+
return GetDescriptor();
|
| 590 |
+
}
|
| 591 |
+
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() {
|
| 592 |
+
return default_instance().GetMetadata().descriptor;
|
| 593 |
+
}
|
| 594 |
+
static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() {
|
| 595 |
+
return default_instance().GetMetadata().reflection;
|
| 596 |
+
}
|
| 597 |
+
static const ListValue& default_instance() {
|
| 598 |
+
return *internal_default_instance();
|
| 599 |
+
}
|
| 600 |
+
static inline const ListValue* internal_default_instance() {
|
| 601 |
+
return reinterpret_cast<const ListValue*>(
|
| 602 |
+
&_ListValue_default_instance_);
|
| 603 |
+
}
|
| 604 |
+
static constexpr int kIndexInFileMessages =
|
| 605 |
+
3;
|
| 606 |
+
|
| 607 |
+
friend void swap(ListValue& a, ListValue& b) {
|
| 608 |
+
a.Swap(&b);
|
| 609 |
+
}
|
| 610 |
+
inline void Swap(ListValue* other) {
|
| 611 |
+
if (other == this) return;
|
| 612 |
+
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
|
| 613 |
+
if (GetOwningArena() != nullptr &&
|
| 614 |
+
GetOwningArena() == other->GetOwningArena()) {
|
| 615 |
+
#else // PROTOBUF_FORCE_COPY_IN_SWAP
|
| 616 |
+
if (GetOwningArena() == other->GetOwningArena()) {
|
| 617 |
+
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
|
| 618 |
+
InternalSwap(other);
|
| 619 |
+
} else {
|
| 620 |
+
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
|
| 621 |
+
}
|
| 622 |
+
}
|
| 623 |
+
void UnsafeArenaSwap(ListValue* other) {
|
| 624 |
+
if (other == this) return;
|
| 625 |
+
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
|
| 626 |
+
InternalSwap(other);
|
| 627 |
+
}
|
| 628 |
+
|
| 629 |
+
// implements Message ----------------------------------------------
|
| 630 |
+
|
| 631 |
+
ListValue* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final {
|
| 632 |
+
return CreateMaybeMessage<ListValue>(arena);
|
| 633 |
+
}
|
| 634 |
+
using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom;
|
| 635 |
+
void CopyFrom(const ListValue& from);
|
| 636 |
+
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
|
| 637 |
+
void MergeFrom( const ListValue& from) {
|
| 638 |
+
ListValue::MergeImpl(*this, from);
|
| 639 |
+
}
|
| 640 |
+
private:
|
| 641 |
+
static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg);
|
| 642 |
+
public:
|
| 643 |
+
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
|
| 644 |
+
bool IsInitialized() const final;
|
| 645 |
+
|
| 646 |
+
size_t ByteSizeLong() const final;
|
| 647 |
+
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
|
| 648 |
+
uint8_t* _InternalSerialize(
|
| 649 |
+
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
|
| 650 |
+
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
|
| 651 |
+
|
| 652 |
+
private:
|
| 653 |
+
void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned);
|
| 654 |
+
void SharedDtor();
|
| 655 |
+
void SetCachedSize(int size) const final;
|
| 656 |
+
void InternalSwap(ListValue* other);
|
| 657 |
+
|
| 658 |
+
private:
|
| 659 |
+
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
|
| 660 |
+
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
|
| 661 |
+
return "google.protobuf.ListValue";
|
| 662 |
+
}
|
| 663 |
+
protected:
|
| 664 |
+
explicit ListValue(::PROTOBUF_NAMESPACE_ID::Arena* arena,
|
| 665 |
+
bool is_message_owned = false);
|
| 666 |
+
public:
|
| 667 |
+
|
| 668 |
+
static const ClassData _class_data_;
|
| 669 |
+
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final;
|
| 670 |
+
|
| 671 |
+
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
|
| 672 |
+
|
| 673 |
+
// nested types ----------------------------------------------------
|
| 674 |
+
|
| 675 |
+
// accessors -------------------------------------------------------
|
| 676 |
+
|
| 677 |
+
enum : int {
|
| 678 |
+
kValuesFieldNumber = 1,
|
| 679 |
+
};
|
| 680 |
+
// repeated .google.protobuf.Value values = 1;
|
| 681 |
+
int values_size() const;
|
| 682 |
+
private:
|
| 683 |
+
int _internal_values_size() const;
|
| 684 |
+
public:
|
| 685 |
+
void clear_values();
|
| 686 |
+
::PROTOBUF_NAMESPACE_ID::Value* mutable_values(int index);
|
| 687 |
+
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Value >*
|
| 688 |
+
mutable_values();
|
| 689 |
+
private:
|
| 690 |
+
const ::PROTOBUF_NAMESPACE_ID::Value& _internal_values(int index) const;
|
| 691 |
+
::PROTOBUF_NAMESPACE_ID::Value* _internal_add_values();
|
| 692 |
+
public:
|
| 693 |
+
const ::PROTOBUF_NAMESPACE_ID::Value& values(int index) const;
|
| 694 |
+
::PROTOBUF_NAMESPACE_ID::Value* add_values();
|
| 695 |
+
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Value >&
|
| 696 |
+
values() const;
|
| 697 |
+
|
| 698 |
+
// @@protoc_insertion_point(class_scope:google.protobuf.ListValue)
|
| 699 |
+
private:
|
| 700 |
+
class _Internal;
|
| 701 |
+
|
| 702 |
+
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
|
| 703 |
+
typedef void InternalArenaConstructable_;
|
| 704 |
+
typedef void DestructorSkippable_;
|
| 705 |
+
struct Impl_ {
|
| 706 |
+
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Value > values_;
|
| 707 |
+
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
|
| 708 |
+
};
|
| 709 |
+
union { Impl_ _impl_; };
|
| 710 |
+
friend struct ::TableStruct_google_2fprotobuf_2fstruct_2eproto;
|
| 711 |
+
};
|
| 712 |
+
// ===================================================================
|
| 713 |
+
|
| 714 |
+
|
| 715 |
+
// ===================================================================
|
| 716 |
+
|
| 717 |
+
#ifdef __GNUC__
|
| 718 |
+
#pragma GCC diagnostic push
|
| 719 |
+
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
| 720 |
+
#endif // __GNUC__
|
| 721 |
+
// -------------------------------------------------------------------
|
| 722 |
+
|
| 723 |
+
// Struct
|
| 724 |
+
|
| 725 |
+
// map<string, .google.protobuf.Value> fields = 1;
|
| 726 |
+
inline int Struct::_internal_fields_size() const {
|
| 727 |
+
return _impl_.fields_.size();
|
| 728 |
+
}
|
| 729 |
+
inline int Struct::fields_size() const {
|
| 730 |
+
return _internal_fields_size();
|
| 731 |
+
}
|
| 732 |
+
inline void Struct::clear_fields() {
|
| 733 |
+
_impl_.fields_.Clear();
|
| 734 |
+
}
|
| 735 |
+
inline const ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::Value >&
|
| 736 |
+
Struct::_internal_fields() const {
|
| 737 |
+
return _impl_.fields_.GetMap();
|
| 738 |
+
}
|
| 739 |
+
inline const ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::Value >&
|
| 740 |
+
Struct::fields() const {
|
| 741 |
+
// @@protoc_insertion_point(field_map:google.protobuf.Struct.fields)
|
| 742 |
+
return _internal_fields();
|
| 743 |
+
}
|
| 744 |
+
inline ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::Value >*
|
| 745 |
+
Struct::_internal_mutable_fields() {
|
| 746 |
+
return _impl_.fields_.MutableMap();
|
| 747 |
+
}
|
| 748 |
+
inline ::PROTOBUF_NAMESPACE_ID::Map< std::string, ::PROTOBUF_NAMESPACE_ID::Value >*
|
| 749 |
+
Struct::mutable_fields() {
|
| 750 |
+
// @@protoc_insertion_point(field_mutable_map:google.protobuf.Struct.fields)
|
| 751 |
+
return _internal_mutable_fields();
|
| 752 |
+
}
|
| 753 |
+
|
| 754 |
+
// -------------------------------------------------------------------
|
| 755 |
+
|
| 756 |
+
// Value
|
| 757 |
+
|
| 758 |
+
// .google.protobuf.NullValue null_value = 1;
|
| 759 |
+
inline bool Value::_internal_has_null_value() const {
|
| 760 |
+
return kind_case() == kNullValue;
|
| 761 |
+
}
|
| 762 |
+
inline bool Value::has_null_value() const {
|
| 763 |
+
return _internal_has_null_value();
|
| 764 |
+
}
|
| 765 |
+
inline void Value::set_has_null_value() {
|
| 766 |
+
_impl_._oneof_case_[0] = kNullValue;
|
| 767 |
+
}
|
| 768 |
+
inline void Value::clear_null_value() {
|
| 769 |
+
if (_internal_has_null_value()) {
|
| 770 |
+
_impl_.kind_.null_value_ = 0;
|
| 771 |
+
clear_has_kind();
|
| 772 |
+
}
|
| 773 |
+
}
|
| 774 |
+
inline ::PROTOBUF_NAMESPACE_ID::NullValue Value::_internal_null_value() const {
|
| 775 |
+
if (_internal_has_null_value()) {
|
| 776 |
+
return static_cast< ::PROTOBUF_NAMESPACE_ID::NullValue >(_impl_.kind_.null_value_);
|
| 777 |
+
}
|
| 778 |
+
return static_cast< ::PROTOBUF_NAMESPACE_ID::NullValue >(0);
|
| 779 |
+
}
|
| 780 |
+
inline ::PROTOBUF_NAMESPACE_ID::NullValue Value::null_value() const {
|
| 781 |
+
// @@protoc_insertion_point(field_get:google.protobuf.Value.null_value)
|
| 782 |
+
return _internal_null_value();
|
| 783 |
+
}
|
| 784 |
+
inline void Value::_internal_set_null_value(::PROTOBUF_NAMESPACE_ID::NullValue value) {
|
| 785 |
+
if (!_internal_has_null_value()) {
|
| 786 |
+
clear_kind();
|
| 787 |
+
set_has_null_value();
|
| 788 |
+
}
|
| 789 |
+
_impl_.kind_.null_value_ = value;
|
| 790 |
+
}
|
| 791 |
+
inline void Value::set_null_value(::PROTOBUF_NAMESPACE_ID::NullValue value) {
|
| 792 |
+
_internal_set_null_value(value);
|
| 793 |
+
// @@protoc_insertion_point(field_set:google.protobuf.Value.null_value)
|
| 794 |
+
}
|
| 795 |
+
|
| 796 |
+
// double number_value = 2;
|
| 797 |
+
inline bool Value::_internal_has_number_value() const {
|
| 798 |
+
return kind_case() == kNumberValue;
|
| 799 |
+
}
|
| 800 |
+
inline bool Value::has_number_value() const {
|
| 801 |
+
return _internal_has_number_value();
|
| 802 |
+
}
|
| 803 |
+
inline void Value::set_has_number_value() {
|
| 804 |
+
_impl_._oneof_case_[0] = kNumberValue;
|
| 805 |
+
}
|
| 806 |
+
inline void Value::clear_number_value() {
|
| 807 |
+
if (_internal_has_number_value()) {
|
| 808 |
+
_impl_.kind_.number_value_ = 0;
|
| 809 |
+
clear_has_kind();
|
| 810 |
+
}
|
| 811 |
+
}
|
| 812 |
+
inline double Value::_internal_number_value() const {
|
| 813 |
+
if (_internal_has_number_value()) {
|
| 814 |
+
return _impl_.kind_.number_value_;
|
| 815 |
+
}
|
| 816 |
+
return 0;
|
| 817 |
+
}
|
| 818 |
+
inline void Value::_internal_set_number_value(double value) {
|
| 819 |
+
if (!_internal_has_number_value()) {
|
| 820 |
+
clear_kind();
|
| 821 |
+
set_has_number_value();
|
| 822 |
+
}
|
| 823 |
+
_impl_.kind_.number_value_ = value;
|
| 824 |
+
}
|
| 825 |
+
inline double Value::number_value() const {
|
| 826 |
+
// @@protoc_insertion_point(field_get:google.protobuf.Value.number_value)
|
| 827 |
+
return _internal_number_value();
|
| 828 |
+
}
|
| 829 |
+
inline void Value::set_number_value(double value) {
|
| 830 |
+
_internal_set_number_value(value);
|
| 831 |
+
// @@protoc_insertion_point(field_set:google.protobuf.Value.number_value)
|
| 832 |
+
}
|
| 833 |
+
|
| 834 |
+
// string string_value = 3;
|
| 835 |
+
inline bool Value::_internal_has_string_value() const {
|
| 836 |
+
return kind_case() == kStringValue;
|
| 837 |
+
}
|
| 838 |
+
inline bool Value::has_string_value() const {
|
| 839 |
+
return _internal_has_string_value();
|
| 840 |
+
}
|
| 841 |
+
inline void Value::set_has_string_value() {
|
| 842 |
+
_impl_._oneof_case_[0] = kStringValue;
|
| 843 |
+
}
|
| 844 |
+
inline void Value::clear_string_value() {
|
| 845 |
+
if (_internal_has_string_value()) {
|
| 846 |
+
_impl_.kind_.string_value_.Destroy();
|
| 847 |
+
clear_has_kind();
|
| 848 |
+
}
|
| 849 |
+
}
|
| 850 |
+
inline const std::string& Value::string_value() const {
|
| 851 |
+
// @@protoc_insertion_point(field_get:google.protobuf.Value.string_value)
|
| 852 |
+
return _internal_string_value();
|
| 853 |
+
}
|
| 854 |
+
template <typename ArgT0, typename... ArgT>
|
| 855 |
+
inline void Value::set_string_value(ArgT0&& arg0, ArgT... args) {
|
| 856 |
+
if (!_internal_has_string_value()) {
|
| 857 |
+
clear_kind();
|
| 858 |
+
set_has_string_value();
|
| 859 |
+
_impl_.kind_.string_value_.InitDefault();
|
| 860 |
+
}
|
| 861 |
+
_impl_.kind_.string_value_.Set( static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
|
| 862 |
+
// @@protoc_insertion_point(field_set:google.protobuf.Value.string_value)
|
| 863 |
+
}
|
| 864 |
+
inline std::string* Value::mutable_string_value() {
|
| 865 |
+
std::string* _s = _internal_mutable_string_value();
|
| 866 |
+
// @@protoc_insertion_point(field_mutable:google.protobuf.Value.string_value)
|
| 867 |
+
return _s;
|
| 868 |
+
}
|
| 869 |
+
inline const std::string& Value::_internal_string_value() const {
|
| 870 |
+
if (_internal_has_string_value()) {
|
| 871 |
+
return _impl_.kind_.string_value_.Get();
|
| 872 |
+
}
|
| 873 |
+
return ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited();
|
| 874 |
+
}
|
| 875 |
+
inline void Value::_internal_set_string_value(const std::string& value) {
|
| 876 |
+
if (!_internal_has_string_value()) {
|
| 877 |
+
clear_kind();
|
| 878 |
+
set_has_string_value();
|
| 879 |
+
_impl_.kind_.string_value_.InitDefault();
|
| 880 |
+
}
|
| 881 |
+
_impl_.kind_.string_value_.Set(value, GetArenaForAllocation());
|
| 882 |
+
}
|
| 883 |
+
inline std::string* Value::_internal_mutable_string_value() {
|
| 884 |
+
if (!_internal_has_string_value()) {
|
| 885 |
+
clear_kind();
|
| 886 |
+
set_has_string_value();
|
| 887 |
+
_impl_.kind_.string_value_.InitDefault();
|
| 888 |
+
}
|
| 889 |
+
return _impl_.kind_.string_value_.Mutable( GetArenaForAllocation());
|
| 890 |
+
}
|
| 891 |
+
inline std::string* Value::release_string_value() {
|
| 892 |
+
// @@protoc_insertion_point(field_release:google.protobuf.Value.string_value)
|
| 893 |
+
if (_internal_has_string_value()) {
|
| 894 |
+
clear_has_kind();
|
| 895 |
+
return _impl_.kind_.string_value_.Release();
|
| 896 |
+
} else {
|
| 897 |
+
return nullptr;
|
| 898 |
+
}
|
| 899 |
+
}
|
| 900 |
+
inline void Value::set_allocated_string_value(std::string* string_value) {
|
| 901 |
+
if (has_kind()) {
|
| 902 |
+
clear_kind();
|
| 903 |
+
}
|
| 904 |
+
if (string_value != nullptr) {
|
| 905 |
+
set_has_string_value();
|
| 906 |
+
_impl_.kind_.string_value_.InitAllocated(string_value, GetArenaForAllocation());
|
| 907 |
+
}
|
| 908 |
+
// @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.string_value)
|
| 909 |
+
}
|
| 910 |
+
|
| 911 |
+
// bool bool_value = 4;
|
| 912 |
+
inline bool Value::_internal_has_bool_value() const {
|
| 913 |
+
return kind_case() == kBoolValue;
|
| 914 |
+
}
|
| 915 |
+
inline bool Value::has_bool_value() const {
|
| 916 |
+
return _internal_has_bool_value();
|
| 917 |
+
}
|
| 918 |
+
inline void Value::set_has_bool_value() {
|
| 919 |
+
_impl_._oneof_case_[0] = kBoolValue;
|
| 920 |
+
}
|
| 921 |
+
inline void Value::clear_bool_value() {
|
| 922 |
+
if (_internal_has_bool_value()) {
|
| 923 |
+
_impl_.kind_.bool_value_ = false;
|
| 924 |
+
clear_has_kind();
|
| 925 |
+
}
|
| 926 |
+
}
|
| 927 |
+
inline bool Value::_internal_bool_value() const {
|
| 928 |
+
if (_internal_has_bool_value()) {
|
| 929 |
+
return _impl_.kind_.bool_value_;
|
| 930 |
+
}
|
| 931 |
+
return false;
|
| 932 |
+
}
|
| 933 |
+
inline void Value::_internal_set_bool_value(bool value) {
|
| 934 |
+
if (!_internal_has_bool_value()) {
|
| 935 |
+
clear_kind();
|
| 936 |
+
set_has_bool_value();
|
| 937 |
+
}
|
| 938 |
+
_impl_.kind_.bool_value_ = value;
|
| 939 |
+
}
|
| 940 |
+
inline bool Value::bool_value() const {
|
| 941 |
+
// @@protoc_insertion_point(field_get:google.protobuf.Value.bool_value)
|
| 942 |
+
return _internal_bool_value();
|
| 943 |
+
}
|
| 944 |
+
inline void Value::set_bool_value(bool value) {
|
| 945 |
+
_internal_set_bool_value(value);
|
| 946 |
+
// @@protoc_insertion_point(field_set:google.protobuf.Value.bool_value)
|
| 947 |
+
}
|
| 948 |
+
|
| 949 |
+
// .google.protobuf.Struct struct_value = 5;
|
| 950 |
+
inline bool Value::_internal_has_struct_value() const {
|
| 951 |
+
return kind_case() == kStructValue;
|
| 952 |
+
}
|
| 953 |
+
inline bool Value::has_struct_value() const {
|
| 954 |
+
return _internal_has_struct_value();
|
| 955 |
+
}
|
| 956 |
+
inline void Value::set_has_struct_value() {
|
| 957 |
+
_impl_._oneof_case_[0] = kStructValue;
|
| 958 |
+
}
|
| 959 |
+
inline void Value::clear_struct_value() {
|
| 960 |
+
if (_internal_has_struct_value()) {
|
| 961 |
+
if (GetArenaForAllocation() == nullptr) {
|
| 962 |
+
delete _impl_.kind_.struct_value_;
|
| 963 |
+
}
|
| 964 |
+
clear_has_kind();
|
| 965 |
+
}
|
| 966 |
+
}
|
| 967 |
+
inline ::PROTOBUF_NAMESPACE_ID::Struct* Value::release_struct_value() {
|
| 968 |
+
// @@protoc_insertion_point(field_release:google.protobuf.Value.struct_value)
|
| 969 |
+
if (_internal_has_struct_value()) {
|
| 970 |
+
clear_has_kind();
|
| 971 |
+
::PROTOBUF_NAMESPACE_ID::Struct* temp = _impl_.kind_.struct_value_;
|
| 972 |
+
if (GetArenaForAllocation() != nullptr) {
|
| 973 |
+
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
|
| 974 |
+
}
|
| 975 |
+
_impl_.kind_.struct_value_ = nullptr;
|
| 976 |
+
return temp;
|
| 977 |
+
} else {
|
| 978 |
+
return nullptr;
|
| 979 |
+
}
|
| 980 |
+
}
|
| 981 |
+
inline const ::PROTOBUF_NAMESPACE_ID::Struct& Value::_internal_struct_value() const {
|
| 982 |
+
return _internal_has_struct_value()
|
| 983 |
+
? *_impl_.kind_.struct_value_
|
| 984 |
+
: reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::Struct&>(::PROTOBUF_NAMESPACE_ID::_Struct_default_instance_);
|
| 985 |
+
}
|
| 986 |
+
inline const ::PROTOBUF_NAMESPACE_ID::Struct& Value::struct_value() const {
|
| 987 |
+
// @@protoc_insertion_point(field_get:google.protobuf.Value.struct_value)
|
| 988 |
+
return _internal_struct_value();
|
| 989 |
+
}
|
| 990 |
+
inline ::PROTOBUF_NAMESPACE_ID::Struct* Value::unsafe_arena_release_struct_value() {
|
| 991 |
+
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.struct_value)
|
| 992 |
+
if (_internal_has_struct_value()) {
|
| 993 |
+
clear_has_kind();
|
| 994 |
+
::PROTOBUF_NAMESPACE_ID::Struct* temp = _impl_.kind_.struct_value_;
|
| 995 |
+
_impl_.kind_.struct_value_ = nullptr;
|
| 996 |
+
return temp;
|
| 997 |
+
} else {
|
| 998 |
+
return nullptr;
|
| 999 |
+
}
|
| 1000 |
+
}
|
| 1001 |
+
inline void Value::unsafe_arena_set_allocated_struct_value(::PROTOBUF_NAMESPACE_ID::Struct* struct_value) {
|
| 1002 |
+
clear_kind();
|
| 1003 |
+
if (struct_value) {
|
| 1004 |
+
set_has_struct_value();
|
| 1005 |
+
_impl_.kind_.struct_value_ = struct_value;
|
| 1006 |
+
}
|
| 1007 |
+
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.struct_value)
|
| 1008 |
+
}
|
| 1009 |
+
inline ::PROTOBUF_NAMESPACE_ID::Struct* Value::_internal_mutable_struct_value() {
|
| 1010 |
+
if (!_internal_has_struct_value()) {
|
| 1011 |
+
clear_kind();
|
| 1012 |
+
set_has_struct_value();
|
| 1013 |
+
_impl_.kind_.struct_value_ = CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Struct >(GetArenaForAllocation());
|
| 1014 |
+
}
|
| 1015 |
+
return _impl_.kind_.struct_value_;
|
| 1016 |
+
}
|
| 1017 |
+
inline ::PROTOBUF_NAMESPACE_ID::Struct* Value::mutable_struct_value() {
|
| 1018 |
+
::PROTOBUF_NAMESPACE_ID::Struct* _msg = _internal_mutable_struct_value();
|
| 1019 |
+
// @@protoc_insertion_point(field_mutable:google.protobuf.Value.struct_value)
|
| 1020 |
+
return _msg;
|
| 1021 |
+
}
|
| 1022 |
+
|
| 1023 |
+
// .google.protobuf.ListValue list_value = 6;
|
| 1024 |
+
inline bool Value::_internal_has_list_value() const {
|
| 1025 |
+
return kind_case() == kListValue;
|
| 1026 |
+
}
|
| 1027 |
+
inline bool Value::has_list_value() const {
|
| 1028 |
+
return _internal_has_list_value();
|
| 1029 |
+
}
|
| 1030 |
+
inline void Value::set_has_list_value() {
|
| 1031 |
+
_impl_._oneof_case_[0] = kListValue;
|
| 1032 |
+
}
|
| 1033 |
+
inline void Value::clear_list_value() {
|
| 1034 |
+
if (_internal_has_list_value()) {
|
| 1035 |
+
if (GetArenaForAllocation() == nullptr) {
|
| 1036 |
+
delete _impl_.kind_.list_value_;
|
| 1037 |
+
}
|
| 1038 |
+
clear_has_kind();
|
| 1039 |
+
}
|
| 1040 |
+
}
|
| 1041 |
+
inline ::PROTOBUF_NAMESPACE_ID::ListValue* Value::release_list_value() {
|
| 1042 |
+
// @@protoc_insertion_point(field_release:google.protobuf.Value.list_value)
|
| 1043 |
+
if (_internal_has_list_value()) {
|
| 1044 |
+
clear_has_kind();
|
| 1045 |
+
::PROTOBUF_NAMESPACE_ID::ListValue* temp = _impl_.kind_.list_value_;
|
| 1046 |
+
if (GetArenaForAllocation() != nullptr) {
|
| 1047 |
+
temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp);
|
| 1048 |
+
}
|
| 1049 |
+
_impl_.kind_.list_value_ = nullptr;
|
| 1050 |
+
return temp;
|
| 1051 |
+
} else {
|
| 1052 |
+
return nullptr;
|
| 1053 |
+
}
|
| 1054 |
+
}
|
| 1055 |
+
inline const ::PROTOBUF_NAMESPACE_ID::ListValue& Value::_internal_list_value() const {
|
| 1056 |
+
return _internal_has_list_value()
|
| 1057 |
+
? *_impl_.kind_.list_value_
|
| 1058 |
+
: reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::ListValue&>(::PROTOBUF_NAMESPACE_ID::_ListValue_default_instance_);
|
| 1059 |
+
}
|
| 1060 |
+
inline const ::PROTOBUF_NAMESPACE_ID::ListValue& Value::list_value() const {
|
| 1061 |
+
// @@protoc_insertion_point(field_get:google.protobuf.Value.list_value)
|
| 1062 |
+
return _internal_list_value();
|
| 1063 |
+
}
|
| 1064 |
+
inline ::PROTOBUF_NAMESPACE_ID::ListValue* Value::unsafe_arena_release_list_value() {
|
| 1065 |
+
// @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Value.list_value)
|
| 1066 |
+
if (_internal_has_list_value()) {
|
| 1067 |
+
clear_has_kind();
|
| 1068 |
+
::PROTOBUF_NAMESPACE_ID::ListValue* temp = _impl_.kind_.list_value_;
|
| 1069 |
+
_impl_.kind_.list_value_ = nullptr;
|
| 1070 |
+
return temp;
|
| 1071 |
+
} else {
|
| 1072 |
+
return nullptr;
|
| 1073 |
+
}
|
| 1074 |
+
}
|
| 1075 |
+
inline void Value::unsafe_arena_set_allocated_list_value(::PROTOBUF_NAMESPACE_ID::ListValue* list_value) {
|
| 1076 |
+
clear_kind();
|
| 1077 |
+
if (list_value) {
|
| 1078 |
+
set_has_list_value();
|
| 1079 |
+
_impl_.kind_.list_value_ = list_value;
|
| 1080 |
+
}
|
| 1081 |
+
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.list_value)
|
| 1082 |
+
}
|
| 1083 |
+
inline ::PROTOBUF_NAMESPACE_ID::ListValue* Value::_internal_mutable_list_value() {
|
| 1084 |
+
if (!_internal_has_list_value()) {
|
| 1085 |
+
clear_kind();
|
| 1086 |
+
set_has_list_value();
|
| 1087 |
+
_impl_.kind_.list_value_ = CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::ListValue >(GetArenaForAllocation());
|
| 1088 |
+
}
|
| 1089 |
+
return _impl_.kind_.list_value_;
|
| 1090 |
+
}
|
| 1091 |
+
inline ::PROTOBUF_NAMESPACE_ID::ListValue* Value::mutable_list_value() {
|
| 1092 |
+
::PROTOBUF_NAMESPACE_ID::ListValue* _msg = _internal_mutable_list_value();
|
| 1093 |
+
// @@protoc_insertion_point(field_mutable:google.protobuf.Value.list_value)
|
| 1094 |
+
return _msg;
|
| 1095 |
+
}
|
| 1096 |
+
|
| 1097 |
+
inline bool Value::has_kind() const {
|
| 1098 |
+
return kind_case() != KIND_NOT_SET;
|
| 1099 |
+
}
|
| 1100 |
+
inline void Value::clear_has_kind() {
|
| 1101 |
+
_impl_._oneof_case_[0] = KIND_NOT_SET;
|
| 1102 |
+
}
|
| 1103 |
+
inline Value::KindCase Value::kind_case() const {
|
| 1104 |
+
return Value::KindCase(_impl_._oneof_case_[0]);
|
| 1105 |
+
}
|
| 1106 |
+
// -------------------------------------------------------------------
|
| 1107 |
+
|
| 1108 |
+
// ListValue
|
| 1109 |
+
|
| 1110 |
+
// repeated .google.protobuf.Value values = 1;
|
| 1111 |
+
inline int ListValue::_internal_values_size() const {
|
| 1112 |
+
return _impl_.values_.size();
|
| 1113 |
+
}
|
| 1114 |
+
inline int ListValue::values_size() const {
|
| 1115 |
+
return _internal_values_size();
|
| 1116 |
+
}
|
| 1117 |
+
inline void ListValue::clear_values() {
|
| 1118 |
+
_impl_.values_.Clear();
|
| 1119 |
+
}
|
| 1120 |
+
inline ::PROTOBUF_NAMESPACE_ID::Value* ListValue::mutable_values(int index) {
|
| 1121 |
+
// @@protoc_insertion_point(field_mutable:google.protobuf.ListValue.values)
|
| 1122 |
+
return _impl_.values_.Mutable(index);
|
| 1123 |
+
}
|
| 1124 |
+
inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Value >*
|
| 1125 |
+
ListValue::mutable_values() {
|
| 1126 |
+
// @@protoc_insertion_point(field_mutable_list:google.protobuf.ListValue.values)
|
| 1127 |
+
return &_impl_.values_;
|
| 1128 |
+
}
|
| 1129 |
+
inline const ::PROTOBUF_NAMESPACE_ID::Value& ListValue::_internal_values(int index) const {
|
| 1130 |
+
return _impl_.values_.Get(index);
|
| 1131 |
+
}
|
| 1132 |
+
inline const ::PROTOBUF_NAMESPACE_ID::Value& ListValue::values(int index) const {
|
| 1133 |
+
// @@protoc_insertion_point(field_get:google.protobuf.ListValue.values)
|
| 1134 |
+
return _internal_values(index);
|
| 1135 |
+
}
|
| 1136 |
+
inline ::PROTOBUF_NAMESPACE_ID::Value* ListValue::_internal_add_values() {
|
| 1137 |
+
return _impl_.values_.Add();
|
| 1138 |
+
}
|
| 1139 |
+
inline ::PROTOBUF_NAMESPACE_ID::Value* ListValue::add_values() {
|
| 1140 |
+
::PROTOBUF_NAMESPACE_ID::Value* _add = _internal_add_values();
|
| 1141 |
+
// @@protoc_insertion_point(field_add:google.protobuf.ListValue.values)
|
| 1142 |
+
return _add;
|
| 1143 |
+
}
|
| 1144 |
+
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< ::PROTOBUF_NAMESPACE_ID::Value >&
|
| 1145 |
+
ListValue::values() const {
|
| 1146 |
+
// @@protoc_insertion_point(field_list:google.protobuf.ListValue.values)
|
| 1147 |
+
return _impl_.values_;
|
| 1148 |
+
}
|
| 1149 |
+
|
| 1150 |
+
#ifdef __GNUC__
|
| 1151 |
+
#pragma GCC diagnostic pop
|
| 1152 |
+
#endif // __GNUC__
|
| 1153 |
+
// -------------------------------------------------------------------
|
| 1154 |
+
|
| 1155 |
+
// -------------------------------------------------------------------
|
| 1156 |
+
|
| 1157 |
+
// -------------------------------------------------------------------
|
| 1158 |
+
|
| 1159 |
+
|
| 1160 |
+
// @@protoc_insertion_point(namespace_scope)
|
| 1161 |
+
|
| 1162 |
+
PROTOBUF_NAMESPACE_CLOSE
|
| 1163 |
+
|
| 1164 |
+
PROTOBUF_NAMESPACE_OPEN
|
| 1165 |
+
|
| 1166 |
+
template <> struct is_proto_enum< ::PROTOBUF_NAMESPACE_ID::NullValue> : ::std::true_type {};
|
| 1167 |
+
template <>
|
| 1168 |
+
inline const EnumDescriptor* GetEnumDescriptor< ::PROTOBUF_NAMESPACE_ID::NullValue>() {
|
| 1169 |
+
return ::PROTOBUF_NAMESPACE_ID::NullValue_descriptor();
|
| 1170 |
+
}
|
| 1171 |
+
|
| 1172 |
+
PROTOBUF_NAMESPACE_CLOSE
|
| 1173 |
+
|
| 1174 |
+
// @@protoc_insertion_point(global_scope)
|
| 1175 |
+
|
| 1176 |
+
#include <google/protobuf/port_undef.inc>
|
| 1177 |
+
#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fstruct_2eproto
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/testing/file.h
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// Author: kenton@google.com (Kenton Varda)
|
| 32 |
+
// emulates google3/file/base/file.h
|
| 33 |
+
|
| 34 |
+
#ifndef GOOGLE_PROTOBUF_TESTING_FILE_H__
|
| 35 |
+
#define GOOGLE_PROTOBUF_TESTING_FILE_H__
|
| 36 |
+
|
| 37 |
+
#include <google/protobuf/stubs/common.h>
|
| 38 |
+
|
| 39 |
+
namespace google {
|
| 40 |
+
namespace protobuf {
|
| 41 |
+
|
| 42 |
+
const int DEFAULT_FILE_MODE = 0777;
|
| 43 |
+
|
| 44 |
+
// Protocol buffer code only uses a couple static methods of File, and only
|
| 45 |
+
// in tests.
|
| 46 |
+
class File {
|
| 47 |
+
public:
|
| 48 |
+
// Check if the file exists.
|
| 49 |
+
static bool Exists(const std::string& name);
|
| 50 |
+
|
| 51 |
+
// Read an entire file to a string. Return true if successful, false
|
| 52 |
+
// otherwise.
|
| 53 |
+
static bool ReadFileToString(const std::string& name, std::string* output,
|
| 54 |
+
bool text_mode = false);
|
| 55 |
+
|
| 56 |
+
// Same as above, but crash on failure.
|
| 57 |
+
static void ReadFileToStringOrDie(const std::string& name,
|
| 58 |
+
std::string* output);
|
| 59 |
+
|
| 60 |
+
// Create a file and write a string to it.
|
| 61 |
+
static bool WriteStringToFile(const std::string& contents,
|
| 62 |
+
const std::string& name);
|
| 63 |
+
|
| 64 |
+
// Same as above, but crash on failure.
|
| 65 |
+
static void WriteStringToFileOrDie(const std::string& contents,
|
| 66 |
+
const std::string& name);
|
| 67 |
+
|
| 68 |
+
// Create a directory.
|
| 69 |
+
static bool CreateDir(const std::string& name, int mode);
|
| 70 |
+
|
| 71 |
+
// Create a directory and all parent directories if necessary.
|
| 72 |
+
static bool RecursivelyCreateDir(const std::string& path, int mode);
|
| 73 |
+
|
| 74 |
+
// If "name" is a file, we delete it. If it is a directory, we
|
| 75 |
+
// call DeleteRecursively() for each file or directory (other than
|
| 76 |
+
// dot and double-dot) within it, and then delete the directory itself.
|
| 77 |
+
// The "dummy" parameters have a meaning in the original version of this
|
| 78 |
+
// method but they are not used anywhere in protocol buffers.
|
| 79 |
+
static void DeleteRecursively(const std::string& name, void* dummy1,
|
| 80 |
+
void* dummy2);
|
| 81 |
+
|
| 82 |
+
// Change working directory to given directory.
|
| 83 |
+
static bool ChangeWorkingDirectory(const std::string& new_working_directory);
|
| 84 |
+
|
| 85 |
+
static bool GetContents(const std::string& name, std::string* output,
|
| 86 |
+
bool /*is_default*/) {
|
| 87 |
+
return ReadFileToString(name, output);
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
static bool GetContentsAsText(const std::string& name, std::string* output,
|
| 91 |
+
bool /*is_default*/) {
|
| 92 |
+
return ReadFileToString(name, output, true);
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
static bool SetContents(const std::string& name, const std::string& contents,
|
| 96 |
+
bool /*is_default*/) {
|
| 97 |
+
return WriteStringToFile(contents, name);
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
private:
|
| 101 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(File);
|
| 102 |
+
};
|
| 103 |
+
|
| 104 |
+
} // namespace protobuf
|
| 105 |
+
} // namespace google
|
| 106 |
+
|
| 107 |
+
#endif // GOOGLE_PROTOBUF_TESTING_FILE_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/testing/googletest.h
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// Author: kenton@google.com (Kenton Varda)
|
| 32 |
+
// emulates google3/testing/base/public/googletest.h
|
| 33 |
+
|
| 34 |
+
#ifndef GOOGLE_PROTOBUF_GOOGLETEST_H__
|
| 35 |
+
#define GOOGLE_PROTOBUF_GOOGLETEST_H__
|
| 36 |
+
|
| 37 |
+
#include <map>
|
| 38 |
+
#include <vector>
|
| 39 |
+
#include <google/protobuf/stubs/common.h>
|
| 40 |
+
#include <google/protobuf/stubs/logging.h>
|
| 41 |
+
#include <gmock/gmock.h>
|
| 42 |
+
// Disable death tests if we use exceptions in CHECK().
|
| 43 |
+
#if !PROTOBUF_USE_EXCEPTIONS && defined(GTEST_HAS_DEATH_TEST) && \
|
| 44 |
+
!GTEST_OS_WINDOWS
|
| 45 |
+
#define PROTOBUF_HAS_DEATH_TEST
|
| 46 |
+
#endif
|
| 47 |
+
|
| 48 |
+
namespace google {
|
| 49 |
+
namespace protobuf {
|
| 50 |
+
|
| 51 |
+
// When running unittests, get the directory containing the source code.
|
| 52 |
+
std::string TestSourceDir();
|
| 53 |
+
|
| 54 |
+
// When running unittests, get a directory where temporary files may be
|
| 55 |
+
// placed.
|
| 56 |
+
std::string TestTempDir();
|
| 57 |
+
|
| 58 |
+
// Capture all text written to stdout or stderr.
|
| 59 |
+
void CaptureTestStdout();
|
| 60 |
+
void CaptureTestStderr();
|
| 61 |
+
|
| 62 |
+
// Stop capturing stdout or stderr and return the text captured.
|
| 63 |
+
std::string GetCapturedTestStdout();
|
| 64 |
+
std::string GetCapturedTestStderr();
|
| 65 |
+
|
| 66 |
+
// For use with ScopedMemoryLog::GetMessages(). Inside Google the LogLevel
|
| 67 |
+
// constants don't have the LOGLEVEL_ prefix, so the code that used
|
| 68 |
+
// ScopedMemoryLog refers to LOGLEVEL_ERROR as just ERROR.
|
| 69 |
+
#undef ERROR // defend against promiscuous windows.h
|
| 70 |
+
static const LogLevel ERROR = LOGLEVEL_ERROR;
|
| 71 |
+
static const LogLevel WARNING = LOGLEVEL_WARNING;
|
| 72 |
+
|
| 73 |
+
// Receives copies of all LOG(ERROR) messages while in scope. Sample usage:
|
| 74 |
+
// {
|
| 75 |
+
// ScopedMemoryLog log; // constructor registers object as a log sink
|
| 76 |
+
// SomeRoutineThatMayLogMessages();
|
| 77 |
+
// const vector<string>& warnings = log.GetMessages(ERROR);
|
| 78 |
+
// } // destructor unregisters object as a log sink
|
| 79 |
+
// This is a dummy implementation which covers only what is used by protocol
|
| 80 |
+
// buffer unit tests.
|
| 81 |
+
class ScopedMemoryLog {
|
| 82 |
+
public:
|
| 83 |
+
ScopedMemoryLog();
|
| 84 |
+
virtual ~ScopedMemoryLog();
|
| 85 |
+
|
| 86 |
+
// Fetches all messages with the given severity level.
|
| 87 |
+
const std::vector<std::string>& GetMessages(LogLevel error);
|
| 88 |
+
|
| 89 |
+
private:
|
| 90 |
+
std::map<LogLevel, std::vector<std::string> > messages_;
|
| 91 |
+
LogHandler* old_handler_;
|
| 92 |
+
|
| 93 |
+
static void HandleLog(LogLevel level, const char* filename, int line,
|
| 94 |
+
const std::string& message);
|
| 95 |
+
|
| 96 |
+
static ScopedMemoryLog* active_log_;
|
| 97 |
+
|
| 98 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ScopedMemoryLog);
|
| 99 |
+
};
|
| 100 |
+
|
| 101 |
+
} // namespace protobuf
|
| 102 |
+
} // namespace google
|
| 103 |
+
|
| 104 |
+
#endif // GOOGLE_PROTOBUF_GOOGLETEST_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/delimited_message_util.h
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// Adapted from the patch of kenton@google.com (Kenton Varda)
|
| 32 |
+
// See https://github.com/protocolbuffers/protobuf/pull/710 for details.
|
| 33 |
+
|
| 34 |
+
#ifndef GOOGLE_PROTOBUF_UTIL_DELIMITED_MESSAGE_UTIL_H__
|
| 35 |
+
#define GOOGLE_PROTOBUF_UTIL_DELIMITED_MESSAGE_UTIL_H__
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
#include <ostream>
|
| 39 |
+
|
| 40 |
+
#include <google/protobuf/message_lite.h>
|
| 41 |
+
#include <google/protobuf/io/coded_stream.h>
|
| 42 |
+
#include <google/protobuf/io/zero_copy_stream_impl.h>
|
| 43 |
+
|
| 44 |
+
// Must be included last.
|
| 45 |
+
#include <google/protobuf/port_def.inc>
|
| 46 |
+
|
| 47 |
+
namespace google {
|
| 48 |
+
namespace protobuf {
|
| 49 |
+
namespace util {
|
| 50 |
+
|
| 51 |
+
// Write a single size-delimited message from the given stream. Delimited
|
| 52 |
+
// format allows a single file or stream to contain multiple messages,
|
| 53 |
+
// whereas normally writing multiple non-delimited messages to the same
|
| 54 |
+
// stream would cause them to be merged. A delimited message is a varint
|
| 55 |
+
// encoding the message size followed by a message of exactly that size.
|
| 56 |
+
//
|
| 57 |
+
// Note that if you want to *read* a delimited message from a file descriptor
|
| 58 |
+
// or istream, you will need to construct an io::FileInputStream or
|
| 59 |
+
// io::OstreamInputStream (implementations of io::ZeroCopyStream) and use the
|
| 60 |
+
// utility function ParseDelimitedFromZeroCopyStream(). You must then
|
| 61 |
+
// continue to use the same ZeroCopyInputStream to read all further data from
|
| 62 |
+
// the stream until EOF. This is because these ZeroCopyInputStream
|
| 63 |
+
// implementations are buffered: they read a big chunk of data at a time,
|
| 64 |
+
// then parse it. As a result, they may read past the end of the delimited
|
| 65 |
+
// message. There is no way for them to push the extra data back into the
|
| 66 |
+
// underlying source, so instead you must keep using the same stream object.
|
| 67 |
+
bool PROTOBUF_EXPORT SerializeDelimitedToFileDescriptor(
|
| 68 |
+
const MessageLite& message, int file_descriptor);
|
| 69 |
+
|
| 70 |
+
bool PROTOBUF_EXPORT SerializeDelimitedToOstream(const MessageLite& message,
|
| 71 |
+
std::ostream* output);
|
| 72 |
+
|
| 73 |
+
// Read a single size-delimited message from the given stream. Delimited
|
| 74 |
+
// format allows a single file or stream to contain multiple messages,
|
| 75 |
+
// whereas normally parsing consumes the entire input. A delimited message
|
| 76 |
+
// is a varint encoding the message size followed by a message of exactly
|
| 77 |
+
// that size.
|
| 78 |
+
//
|
| 79 |
+
// If |clean_eof| is not NULL, then it will be set to indicate whether the
|
| 80 |
+
// stream ended cleanly. That is, if the stream ends without this method
|
| 81 |
+
// having read any data at all from it, then *clean_eof will be set true,
|
| 82 |
+
// otherwise it will be set false. Note that these methods return false
|
| 83 |
+
// on EOF, but they also return false on other errors, so |clean_eof| is
|
| 84 |
+
// needed to distinguish a clean end from errors.
|
| 85 |
+
bool PROTOBUF_EXPORT ParseDelimitedFromZeroCopyStream(
|
| 86 |
+
MessageLite* message, io::ZeroCopyInputStream* input, bool* clean_eof);
|
| 87 |
+
|
| 88 |
+
bool PROTOBUF_EXPORT ParseDelimitedFromCodedStream(MessageLite* message,
|
| 89 |
+
io::CodedInputStream* input,
|
| 90 |
+
bool* clean_eof);
|
| 91 |
+
|
| 92 |
+
// Write a single size-delimited message from the given stream. Delimited
|
| 93 |
+
// format allows a single file or stream to contain multiple messages,
|
| 94 |
+
// whereas normally writing multiple non-delimited messages to the same
|
| 95 |
+
// stream would cause them to be merged. A delimited message is a varint
|
| 96 |
+
// encoding the message size followed by a message of exactly that size.
|
| 97 |
+
bool PROTOBUF_EXPORT SerializeDelimitedToZeroCopyStream(
|
| 98 |
+
const MessageLite& message, io::ZeroCopyOutputStream* output);
|
| 99 |
+
|
| 100 |
+
bool PROTOBUF_EXPORT SerializeDelimitedToCodedStream(
|
| 101 |
+
const MessageLite& message, io::CodedOutputStream* output);
|
| 102 |
+
|
| 103 |
+
} // namespace util
|
| 104 |
+
} // namespace protobuf
|
| 105 |
+
} // namespace google
|
| 106 |
+
|
| 107 |
+
#include <google/protobuf/port_undef.inc>
|
| 108 |
+
|
| 109 |
+
#endif // GOOGLE_PROTOBUF_UTIL_DELIMITED_MESSAGE_UTIL_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/field_comparator.h
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// Defines classes for field comparison.
|
| 32 |
+
|
| 33 |
+
#ifndef GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__
|
| 34 |
+
#define GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
#include <cstdint>
|
| 38 |
+
#include <map>
|
| 39 |
+
#include <string>
|
| 40 |
+
#include <vector>
|
| 41 |
+
|
| 42 |
+
#include <google/protobuf/stubs/common.h>
|
| 43 |
+
|
| 44 |
+
// Must be included last.
|
| 45 |
+
#include <google/protobuf/port_def.inc>
|
| 46 |
+
|
| 47 |
+
namespace google {
|
| 48 |
+
namespace protobuf {
|
| 49 |
+
|
| 50 |
+
class Message;
|
| 51 |
+
class EnumValueDescriptor;
|
| 52 |
+
class FieldDescriptor;
|
| 53 |
+
|
| 54 |
+
namespace util {
|
| 55 |
+
|
| 56 |
+
class FieldContext;
|
| 57 |
+
class MessageDifferencer;
|
| 58 |
+
|
| 59 |
+
// Base class specifying the interface for comparing protocol buffer fields.
|
| 60 |
+
// Regular users should consider using or subclassing DefaultFieldComparator
|
| 61 |
+
// rather than this interface.
|
| 62 |
+
// Currently, this does not support comparing unknown fields.
|
| 63 |
+
class PROTOBUF_EXPORT FieldComparator {
|
| 64 |
+
public:
|
| 65 |
+
FieldComparator();
|
| 66 |
+
virtual ~FieldComparator();
|
| 67 |
+
|
| 68 |
+
enum ComparisonResult {
|
| 69 |
+
SAME, // Compared fields are equal. In case of comparing submessages,
|
| 70 |
+
// user should not recursively compare their contents.
|
| 71 |
+
DIFFERENT, // Compared fields are different. In case of comparing
|
| 72 |
+
// submessages, user should not recursively compare their
|
| 73 |
+
// contents.
|
| 74 |
+
RECURSE, // Compared submessages need to be compared recursively.
|
| 75 |
+
// FieldComparator does not specify the semantics of recursive
|
| 76 |
+
// comparison. This value should not be returned for simple
|
| 77 |
+
// values.
|
| 78 |
+
};
|
| 79 |
+
|
| 80 |
+
// Compares the values of a field in two protocol buffer messages.
|
| 81 |
+
// Returns SAME or DIFFERENT for simple values, and SAME, DIFFERENT or RECURSE
|
| 82 |
+
// for submessages. Returning RECURSE for fields not being submessages is
|
| 83 |
+
// illegal.
|
| 84 |
+
// In case the given FieldDescriptor points to a repeated field, the indices
|
| 85 |
+
// need to be valid. Otherwise they should be ignored.
|
| 86 |
+
//
|
| 87 |
+
// FieldContext contains information about the specific instances of the
|
| 88 |
+
// fields being compared, versus FieldDescriptor which only contains general
|
| 89 |
+
// type information about the fields.
|
| 90 |
+
virtual ComparisonResult Compare(const Message& message_1,
|
| 91 |
+
const Message& message_2,
|
| 92 |
+
const FieldDescriptor* field, int index_1,
|
| 93 |
+
int index_2,
|
| 94 |
+
const util::FieldContext* field_context) = 0;
|
| 95 |
+
|
| 96 |
+
private:
|
| 97 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldComparator);
|
| 98 |
+
};
|
| 99 |
+
|
| 100 |
+
// Basic implementation of FieldComparator. Supports three modes of floating
|
| 101 |
+
// point value comparison: exact, approximate using MathUtil::AlmostEqual
|
| 102 |
+
// method, and arbitrarily precise using MathUtil::WithinFractionOrMargin.
|
| 103 |
+
class PROTOBUF_EXPORT SimpleFieldComparator : public FieldComparator {
|
| 104 |
+
public:
|
| 105 |
+
enum FloatComparison {
|
| 106 |
+
EXACT, // Floats and doubles are compared exactly.
|
| 107 |
+
APPROXIMATE, // Floats and doubles are compared using the
|
| 108 |
+
// MathUtil::AlmostEqual method or
|
| 109 |
+
// MathUtil::WithinFractionOrMargin method.
|
| 110 |
+
// TODO(ksroka): Introduce third value to differentiate uses of AlmostEqual
|
| 111 |
+
// and WithinFractionOrMargin.
|
| 112 |
+
};
|
| 113 |
+
|
| 114 |
+
// Creates new comparator with float comparison set to EXACT.
|
| 115 |
+
SimpleFieldComparator();
|
| 116 |
+
|
| 117 |
+
~SimpleFieldComparator() override;
|
| 118 |
+
|
| 119 |
+
void set_float_comparison(FloatComparison float_comparison) {
|
| 120 |
+
float_comparison_ = float_comparison;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
FloatComparison float_comparison() const { return float_comparison_; }
|
| 124 |
+
|
| 125 |
+
// Set whether the FieldComparator shall treat floats or doubles that are both
|
| 126 |
+
// NaN as equal (treat_nan_as_equal = true) or as different
|
| 127 |
+
// (treat_nan_as_equal = false). Default is treating NaNs always as different.
|
| 128 |
+
void set_treat_nan_as_equal(bool treat_nan_as_equal) {
|
| 129 |
+
treat_nan_as_equal_ = treat_nan_as_equal;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
bool treat_nan_as_equal() const { return treat_nan_as_equal_; }
|
| 133 |
+
|
| 134 |
+
// Sets the fraction and margin for the float comparison of a given field.
|
| 135 |
+
// Uses MathUtil::WithinFractionOrMargin to compare the values.
|
| 136 |
+
//
|
| 137 |
+
// REQUIRES: field->cpp_type == FieldDescriptor::CPPTYPE_DOUBLE or
|
| 138 |
+
// field->cpp_type == FieldDescriptor::CPPTYPE_FLOAT
|
| 139 |
+
// REQUIRES: float_comparison_ == APPROXIMATE
|
| 140 |
+
void SetFractionAndMargin(const FieldDescriptor* field, double fraction,
|
| 141 |
+
double margin);
|
| 142 |
+
|
| 143 |
+
// Sets the fraction and margin for the float comparison of all float and
|
| 144 |
+
// double fields, unless a field has been given a specific setting via
|
| 145 |
+
// SetFractionAndMargin() above.
|
| 146 |
+
// Uses MathUtil::WithinFractionOrMargin to compare the values.
|
| 147 |
+
//
|
| 148 |
+
// REQUIRES: float_comparison_ == APPROXIMATE
|
| 149 |
+
void SetDefaultFractionAndMargin(double fraction, double margin);
|
| 150 |
+
|
| 151 |
+
protected:
|
| 152 |
+
// Returns the comparison result for the given field in two messages.
|
| 153 |
+
//
|
| 154 |
+
// This function is called directly by DefaultFieldComparator::Compare.
|
| 155 |
+
// Subclasses can call this function to compare fields they do not need to
|
| 156 |
+
// handle specially.
|
| 157 |
+
ComparisonResult SimpleCompare(const Message& message_1,
|
| 158 |
+
const Message& message_2,
|
| 159 |
+
const FieldDescriptor* field, int index_1,
|
| 160 |
+
int index_2,
|
| 161 |
+
const util::FieldContext* field_context);
|
| 162 |
+
|
| 163 |
+
// Compare using the provided message_differencer. For example, a subclass can
|
| 164 |
+
// use this method to compare some field in a certain way using the same
|
| 165 |
+
// message_differencer instance and the field context.
|
| 166 |
+
bool CompareWithDifferencer(MessageDifferencer* differencer,
|
| 167 |
+
const Message& message1, const Message& message2,
|
| 168 |
+
const util::FieldContext* field_context);
|
| 169 |
+
|
| 170 |
+
// Returns FieldComparator::SAME if boolean_result is true and
|
| 171 |
+
// FieldComparator::DIFFERENT otherwise.
|
| 172 |
+
ComparisonResult ResultFromBoolean(bool boolean_result) const;
|
| 173 |
+
|
| 174 |
+
private:
|
| 175 |
+
// Defines the tolerance for floating point comparison (fraction and margin).
|
| 176 |
+
struct Tolerance {
|
| 177 |
+
double fraction;
|
| 178 |
+
double margin;
|
| 179 |
+
Tolerance() : fraction(0.0), margin(0.0) {}
|
| 180 |
+
Tolerance(double f, double m) : fraction(f), margin(m) {}
|
| 181 |
+
};
|
| 182 |
+
|
| 183 |
+
// Defines the map to store the tolerances for floating point comparison.
|
| 184 |
+
typedef std::map<const FieldDescriptor*, Tolerance> ToleranceMap;
|
| 185 |
+
|
| 186 |
+
friend class MessageDifferencer;
|
| 187 |
+
// The following methods get executed when CompareFields is called for the
|
| 188 |
+
// basic types (instead of submessages). They return true on success. One
|
| 189 |
+
// can use ResultFromBoolean() to convert that boolean to a ComparisonResult
|
| 190 |
+
// value.
|
| 191 |
+
bool CompareBool(const FieldDescriptor& /* unused */, bool value_1,
|
| 192 |
+
bool value_2) {
|
| 193 |
+
return value_1 == value_2;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
// Uses CompareDoubleOrFloat, a helper function used by both CompareDouble and
|
| 197 |
+
// CompareFloat.
|
| 198 |
+
bool CompareDouble(const FieldDescriptor& field, double value_1,
|
| 199 |
+
double value_2);
|
| 200 |
+
|
| 201 |
+
bool CompareEnum(const FieldDescriptor& field,
|
| 202 |
+
const EnumValueDescriptor* value_1,
|
| 203 |
+
const EnumValueDescriptor* value_2);
|
| 204 |
+
|
| 205 |
+
// Uses CompareDoubleOrFloat, a helper function used by both CompareDouble and
|
| 206 |
+
// CompareFloat.
|
| 207 |
+
bool CompareFloat(const FieldDescriptor& field, float value_1, float value_2);
|
| 208 |
+
|
| 209 |
+
bool CompareInt32(const FieldDescriptor& /* unused */, int32_t value_1,
|
| 210 |
+
int32_t value_2) {
|
| 211 |
+
return value_1 == value_2;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
bool CompareInt64(const FieldDescriptor& /* unused */, int64_t value_1,
|
| 215 |
+
int64_t value_2) {
|
| 216 |
+
return value_1 == value_2;
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
bool CompareString(const FieldDescriptor& /* unused */,
|
| 220 |
+
const std::string& value_1, const std::string& value_2) {
|
| 221 |
+
return value_1 == value_2;
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
bool CompareUInt32(const FieldDescriptor& /* unused */, uint32_t value_1,
|
| 225 |
+
uint32_t value_2) {
|
| 226 |
+
return value_1 == value_2;
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
bool CompareUInt64(const FieldDescriptor& /* unused */, uint64_t value_1,
|
| 230 |
+
uint64_t value_2) {
|
| 231 |
+
return value_1 == value_2;
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
// This function is used by CompareDouble and CompareFloat to avoid code
|
| 235 |
+
// duplication. There are no checks done against types of the values passed,
|
| 236 |
+
// but it's likely to fail if passed non-numeric arguments.
|
| 237 |
+
template <typename T>
|
| 238 |
+
bool CompareDoubleOrFloat(const FieldDescriptor& field, T value_1, T value_2);
|
| 239 |
+
|
| 240 |
+
FloatComparison float_comparison_;
|
| 241 |
+
|
| 242 |
+
// If true, floats and doubles that are both NaN are considered to be
|
| 243 |
+
// equal. Otherwise, two floats or doubles that are NaN are considered to be
|
| 244 |
+
// different.
|
| 245 |
+
bool treat_nan_as_equal_;
|
| 246 |
+
|
| 247 |
+
// True iff default_tolerance_ has been explicitly set.
|
| 248 |
+
//
|
| 249 |
+
// If false, then the default tolerance for floats and doubles is that which
|
| 250 |
+
// is used by MathUtil::AlmostEquals().
|
| 251 |
+
bool has_default_tolerance_;
|
| 252 |
+
|
| 253 |
+
// Default float/double tolerance. Only meaningful if
|
| 254 |
+
// has_default_tolerance_ == true.
|
| 255 |
+
Tolerance default_tolerance_;
|
| 256 |
+
|
| 257 |
+
// Field-specific float/double tolerances, which override any default for
|
| 258 |
+
// those particular fields.
|
| 259 |
+
ToleranceMap map_tolerance_;
|
| 260 |
+
|
| 261 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SimpleFieldComparator);
|
| 262 |
+
};
|
| 263 |
+
|
| 264 |
+
// Default field comparison: use the basic implementation of FieldComparator.
|
| 265 |
+
#ifdef PROTOBUF_FUTURE_BREAKING_CHANGES
|
| 266 |
+
class PROTOBUF_EXPORT DefaultFieldComparator final
|
| 267 |
+
: public SimpleFieldComparator
|
| 268 |
+
#else // PROTOBUF_FUTURE_BREAKING_CHANGES
|
| 269 |
+
class PROTOBUF_EXPORT DefaultFieldComparator : public SimpleFieldComparator
|
| 270 |
+
#endif // PROTOBUF_FUTURE_BREAKING_CHANGES
|
| 271 |
+
{
|
| 272 |
+
public:
|
| 273 |
+
ComparisonResult Compare(const Message& message_1, const Message& message_2,
|
| 274 |
+
const FieldDescriptor* field, int index_1,
|
| 275 |
+
int index_2,
|
| 276 |
+
const util::FieldContext* field_context) override {
|
| 277 |
+
return SimpleCompare(message_1, message_2, field, index_1, index_2,
|
| 278 |
+
field_context);
|
| 279 |
+
}
|
| 280 |
+
};
|
| 281 |
+
|
| 282 |
+
} // namespace util
|
| 283 |
+
} // namespace protobuf
|
| 284 |
+
} // namespace google
|
| 285 |
+
|
| 286 |
+
#include <google/protobuf/port_undef.inc>
|
| 287 |
+
|
| 288 |
+
#endif // GOOGLE_PROTOBUF_UTIL_FIELD_COMP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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// Defines utilities for the FieldMask well known type.
|
| 32 |
+
|
| 33 |
+
#ifndef GOOGLE_PROTOBUF_UTIL_FIELD_MASK_UTIL_H__
|
| 34 |
+
#define GOOGLE_PROTOBUF_UTIL_FIELD_MASK_UTIL_H__
|
| 35 |
+
|
| 36 |
+
#include <cstdint>
|
| 37 |
+
#include <string>
|
| 38 |
+
|
| 39 |
+
#include <google/protobuf/field_mask.pb.h>
|
| 40 |
+
#include <google/protobuf/stubs/strutil.h>
|
| 41 |
+
#include <google/protobuf/descriptor.h>
|
| 42 |
+
|
| 43 |
+
// Must be included last.
|
| 44 |
+
#include <google/protobuf/port_def.inc>
|
| 45 |
+
|
| 46 |
+
namespace google {
|
| 47 |
+
namespace protobuf {
|
| 48 |
+
namespace util {
|
| 49 |
+
|
| 50 |
+
class PROTOBUF_EXPORT FieldMaskUtil {
|
| 51 |
+
typedef google::protobuf::FieldMask FieldMask;
|
| 52 |
+
|
| 53 |
+
public:
|
| 54 |
+
// Converts FieldMask to/from string, formatted by separating each path
|
| 55 |
+
// with a comma (e.g., "foo_bar,baz.quz").
|
| 56 |
+
static std::string ToString(const FieldMask& mask);
|
| 57 |
+
static void FromString(StringPiece str, FieldMask* out);
|
| 58 |
+
|
| 59 |
+
// Populates the FieldMask with the paths corresponding to the fields with the
|
| 60 |
+
// given numbers, after checking that all field numbers are valid.
|
| 61 |
+
template <typename T>
|
| 62 |
+
static void FromFieldNumbers(const std::vector<int64_t>& field_numbers,
|
| 63 |
+
FieldMask* out) {
|
| 64 |
+
for (const auto field_number : field_numbers) {
|
| 65 |
+
const FieldDescriptor* field_desc =
|
| 66 |
+
T::descriptor()->FindFieldByNumber(field_number);
|
| 67 |
+
GOOGLE_CHECK(field_desc != nullptr)
|
| 68 |
+
<< "Invalid field number for " << T::descriptor()->full_name() << ": "
|
| 69 |
+
<< field_number;
|
| 70 |
+
AddPathToFieldMask<T>(field_desc->lowercase_name(), out);
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
// Converts FieldMask to/from string, formatted according to proto3 JSON
|
| 75 |
+
// spec for FieldMask (e.g., "fooBar,baz.quz"). If the field name is not
|
| 76 |
+
// style conforming (i.e., not snake_case when converted to string, or not
|
| 77 |
+
// camelCase when converted from string), the conversion will fail.
|
| 78 |
+
static bool ToJsonString(const FieldMask& mask, std::string* out);
|
| 79 |
+
static bool FromJsonString(StringPiece str, FieldMask* out);
|
| 80 |
+
|
| 81 |
+
// Get the descriptors of the fields which the given path from the message
|
| 82 |
+
// descriptor traverses, if field_descriptors is not null.
|
| 83 |
+
// Return false if the path is not valid, and the content of field_descriptors
|
| 84 |
+
// is unspecified.
|
| 85 |
+
static bool GetFieldDescriptors(
|
| 86 |
+
const Descriptor* descriptor, StringPiece path,
|
| 87 |
+
std::vector<const FieldDescriptor*>* field_descriptors);
|
| 88 |
+
|
| 89 |
+
// Checks whether the given path is valid for type T.
|
| 90 |
+
template <typename T>
|
| 91 |
+
static bool IsValidPath(StringPiece path) {
|
| 92 |
+
return GetFieldDescriptors(T::descriptor(), path, nullptr);
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
// Checks whether the given FieldMask is valid for type T.
|
| 96 |
+
template <typename T>
|
| 97 |
+
static bool IsValidFieldMask(const FieldMask& mask) {
|
| 98 |
+
for (int i = 0; i < mask.paths_size(); ++i) {
|
| 99 |
+
if (!GetFieldDescriptors(T::descriptor(), mask.paths(i), nullptr)) {
|
| 100 |
+
return false;
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
+
return true;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
// Adds a path to FieldMask after checking whether the given path is valid.
|
| 107 |
+
// This method check-fails if the path is not a valid path for type T.
|
| 108 |
+
template <typename T>
|
| 109 |
+
static void AddPathToFieldMask(StringPiece path, FieldMask* mask) {
|
| 110 |
+
GOOGLE_CHECK(IsValidPath<T>(path)) << path;
|
| 111 |
+
mask->add_paths(std::string(path));
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
// Creates a FieldMask with all fields of type T. This FieldMask only
|
| 115 |
+
// contains fields of T but not any sub-message fields.
|
| 116 |
+
template <typename T>
|
| 117 |
+
static FieldMask GetFieldMaskForAllFields() {
|
| 118 |
+
FieldMask out;
|
| 119 |
+
GetFieldMaskForAllFields(T::descriptor(), &out);
|
| 120 |
+
return out;
|
| 121 |
+
}
|
| 122 |
+
template <typename T>
|
| 123 |
+
PROTOBUF_DEPRECATED_MSG("Use *out = GetFieldMaskForAllFields() instead")
|
| 124 |
+
static void GetFieldMaskForAllFields(FieldMask* out) {
|
| 125 |
+
GetFieldMaskForAllFields(T::descriptor(), out);
|
| 126 |
+
}
|
| 127 |
+
// This flavor takes the protobuf type descriptor as an argument.
|
| 128 |
+
// Useful when the type is not known at compile time.
|
| 129 |
+
static void GetFieldMaskForAllFields(const Descriptor* descriptor,
|
| 130 |
+
FieldMask* out);
|
| 131 |
+
|
| 132 |
+
// Converts a FieldMask to the canonical form. It will:
|
| 133 |
+
// 1. Remove paths that are covered by another path. For example,
|
| 134 |
+
// "foo.bar" is covered by "foo" and will be removed if "foo"
|
| 135 |
+
// is also in the FieldMask.
|
| 136 |
+
// 2. Sort all paths in alphabetical order.
|
| 137 |
+
static void ToCanonicalForm(const FieldMask& mask, FieldMask* out);
|
| 138 |
+
|
| 139 |
+
// Creates an union of two FieldMasks.
|
| 140 |
+
static void Union(const FieldMask& mask1, const FieldMask& mask2,
|
| 141 |
+
FieldMask* out);
|
| 142 |
+
|
| 143 |
+
// Creates an intersection of two FieldMasks.
|
| 144 |
+
static void Intersect(const FieldMask& mask1, const FieldMask& mask2,
|
| 145 |
+
FieldMask* out);
|
| 146 |
+
|
| 147 |
+
// Subtracts mask2 from mask1 base of type T.
|
| 148 |
+
template <typename T>
|
| 149 |
+
static void Subtract(const FieldMask& mask1, const FieldMask& mask2,
|
| 150 |
+
FieldMask* out) {
|
| 151 |
+
Subtract(T::descriptor(), mask1, mask2, out);
|
| 152 |
+
}
|
| 153 |
+
// This flavor takes the protobuf type descriptor as an argument.
|
| 154 |
+
// Useful when the type is not known at compile time.
|
| 155 |
+
static void Subtract(const Descriptor* descriptor, const FieldMask& mask1,
|
| 156 |
+
const FieldMask& mask2, FieldMask* out);
|
| 157 |
+
|
| 158 |
+
// Returns true if path is covered by the given FieldMask. Note that path
|
| 159 |
+
// "foo.bar" covers all paths like "foo.bar.baz", "foo.bar.quz.x", etc.
|
| 160 |
+
// Also note that parent paths are not covered by explicit child path, i.e.
|
| 161 |
+
// "foo.bar" does NOT cover "foo", even if "bar" is the only child.
|
| 162 |
+
static bool IsPathInFieldMask(StringPiece path, const FieldMask& mask);
|
| 163 |
+
|
| 164 |
+
class MergeOptions;
|
| 165 |
+
// Merges fields specified in a FieldMask into another message.
|
| 166 |
+
static void MergeMessageTo(const Message& source, const FieldMask& mask,
|
| 167 |
+
const MergeOptions& options, Message* destination);
|
| 168 |
+
|
| 169 |
+
class TrimOptions;
|
| 170 |
+
// Removes from 'message' any field that is not represented in the given
|
| 171 |
+
// FieldMask. If the FieldMask is empty, does nothing.
|
| 172 |
+
// Returns true if the message is modified.
|
| 173 |
+
static bool TrimMessage(const FieldMask& mask, Message* message);
|
| 174 |
+
|
| 175 |
+
// Removes from 'message' any field that is not represented in the given
|
| 176 |
+
// FieldMask with customized TrimOptions.
|
| 177 |
+
// If the FieldMask is empty, does nothing.
|
| 178 |
+
// Returns true if the message is modified.
|
| 179 |
+
static bool TrimMessage(const FieldMask& mask, Message* message,
|
| 180 |
+
const TrimOptions& options);
|
| 181 |
+
|
| 182 |
+
private:
|
| 183 |
+
friend class SnakeCaseCamelCaseTest;
|
| 184 |
+
// Converts a field name from snake_case to camelCase:
|
| 185 |
+
// 1. Every character after "_" will be converted to uppercase.
|
| 186 |
+
// 2. All "_"s are removed.
|
| 187 |
+
// The conversion will fail if:
|
| 188 |
+
// 1. The field name contains uppercase letters.
|
| 189 |
+
// 2. Any character after a "_" is not a lowercase letter.
|
| 190 |
+
// If the conversion succeeds, it's guaranteed that the resulted
|
| 191 |
+
// camelCase name will yield the original snake_case name when
|
| 192 |
+
// converted using CamelCaseToSnakeCase().
|
| 193 |
+
//
|
| 194 |
+
// Note that the input can contain characters not allowed in C identifiers.
|
| 195 |
+
// For example, "foo_bar,baz_quz" will be converted to "fooBar,bazQuz"
|
| 196 |
+
// successfully.
|
| 197 |
+
static bool SnakeCaseToCamelCase(StringPiece input,
|
| 198 |
+
std::string* output);
|
| 199 |
+
// Converts a field name from camelCase to snake_case:
|
| 200 |
+
// 1. Every uppercase letter is converted to lowercase with an additional
|
| 201 |
+
// preceding "_".
|
| 202 |
+
// The conversion will fail if:
|
| 203 |
+
// 1. The field name contains "_"s.
|
| 204 |
+
// If the conversion succeeds, it's guaranteed that the resulted
|
| 205 |
+
// snake_case name will yield the original camelCase name when
|
| 206 |
+
// converted using SnakeCaseToCamelCase().
|
| 207 |
+
//
|
| 208 |
+
// Note that the input can contain characters not allowed in C identifiers.
|
| 209 |
+
// For example, "fooBar,bazQuz" will be converted to "foo_bar,baz_quz"
|
| 210 |
+
// successfully.
|
| 211 |
+
static bool CamelCaseToSnakeCase(StringPiece input,
|
| 212 |
+
std::string* output);
|
| 213 |
+
};
|
| 214 |
+
|
| 215 |
+
class PROTOBUF_EXPORT FieldMaskUtil::MergeOptions {
|
| 216 |
+
public:
|
| 217 |
+
MergeOptions()
|
| 218 |
+
: replace_message_fields_(false), replace_repeated_fields_(false) {}
|
| 219 |
+
// When merging message fields, the default behavior is to merge the
|
| 220 |
+
// content of two message fields together. If you instead want to use
|
| 221 |
+
// the field from the source message to replace the corresponding field
|
| 222 |
+
// in the destination message, set this flag to true. When this flag is set,
|
| 223 |
+
// specified submessage fields that are missing in source will be cleared in
|
| 224 |
+
// destination.
|
| 225 |
+
void set_replace_message_fields(bool value) {
|
| 226 |
+
replace_message_fields_ = value;
|
| 227 |
+
}
|
| 228 |
+
bool replace_message_fields() const { return replace_message_fields_; }
|
| 229 |
+
// The default merging behavior will append entries from the source
|
| 230 |
+
// repeated field to the destination repeated field. If you only want
|
| 231 |
+
// to keep the entries from the source repeated field, set this flag
|
| 232 |
+
// to true.
|
| 233 |
+
void set_replace_repeated_fields(bool value) {
|
| 234 |
+
replace_repeated_fields_ = value;
|
| 235 |
+
}
|
| 236 |
+
bool replace_repeated_fields() const { return replace_repeated_fields_; }
|
| 237 |
+
|
| 238 |
+
private:
|
| 239 |
+
bool replace_message_fields_;
|
| 240 |
+
bool replace_repeated_fields_;
|
| 241 |
+
};
|
| 242 |
+
|
| 243 |
+
class PROTOBUF_EXPORT FieldMaskUtil::TrimOptions {
|
| 244 |
+
public:
|
| 245 |
+
TrimOptions() : keep_required_fields_(false) {}
|
| 246 |
+
// When trimming message fields, the default behavior is to trim required
|
| 247 |
+
// fields of the present message if they are not specified in the field mask.
|
| 248 |
+
// If you instead want to keep required fields of the present message even
|
| 249 |
+
// when they are not specified in the field mask, set this flag to true.
|
| 250 |
+
void set_keep_required_fields(bool value) { keep_required_fields_ = value; }
|
| 251 |
+
bool keep_required_fields() const { return keep_required_fields_; }
|
| 252 |
+
|
| 253 |
+
private:
|
| 254 |
+
bool keep_required_fields_;
|
| 255 |
+
};
|
| 256 |
+
|
| 257 |
+
} // namespace util
|
| 258 |
+
} // namespace protobuf
|
| 259 |
+
} // namespace google
|
| 260 |
+
|
| 261 |
+
#include <google/protobuf/port_undef.inc>
|
| 262 |
+
|
| 263 |
+
#endif // GOOGLE_PROTOBUF_UTIL_FIELD_MASK_UTIL_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/constants.h
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_CONSTANTS_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_UTIL_INTERNAL_CONSTANTS_H__
|
| 33 |
+
|
| 34 |
+
#include <cstdint>
|
| 35 |
+
|
| 36 |
+
#include <google/protobuf/stubs/common.h>
|
| 37 |
+
|
| 38 |
+
// This file contains constants used by //net/proto2/util/converter.
|
| 39 |
+
|
| 40 |
+
namespace google {
|
| 41 |
+
namespace protobuf {
|
| 42 |
+
namespace util {
|
| 43 |
+
namespace converter {
|
| 44 |
+
// Prefix for type URLs.
|
| 45 |
+
const char kTypeServiceBaseUrl[] = "type.googleapis.com";
|
| 46 |
+
|
| 47 |
+
// Format string for RFC3339 timestamp formatting.
|
| 48 |
+
const char kRfc3339TimeFormat[] = "%E4Y-%m-%dT%H:%M:%S";
|
| 49 |
+
|
| 50 |
+
// Same as above, but the year value is not zero-padded i.e. this accepts
|
| 51 |
+
// timestamps like "1-01-0001T23:59:59Z" instead of "0001-01-0001T23:59:59Z".
|
| 52 |
+
const char kRfc3339TimeFormatNoPadding[] = "%Y-%m-%dT%H:%M:%S";
|
| 53 |
+
|
| 54 |
+
// Minimum seconds allowed in a google.protobuf.Timestamp value.
|
| 55 |
+
const int64_t kTimestampMinSeconds = -62135596800LL;
|
| 56 |
+
|
| 57 |
+
// Maximum seconds allowed in a google.protobuf.Timestamp value.
|
| 58 |
+
const int64_t kTimestampMaxSeconds = 253402300799LL;
|
| 59 |
+
|
| 60 |
+
// Minimum seconds allowed in a google.protobuf.Duration value.
|
| 61 |
+
const int64_t kDurationMinSeconds = -315576000000LL;
|
| 62 |
+
|
| 63 |
+
// Maximum seconds allowed in a google.protobuf.Duration value.
|
| 64 |
+
const int64_t kDurationMaxSeconds = 315576000000LL;
|
| 65 |
+
|
| 66 |
+
// Nano seconds in a second.
|
| 67 |
+
const int32_t kNanosPerSecond = 1000000000;
|
| 68 |
+
|
| 69 |
+
// Type url representing NULL values in google.protobuf.Struct type.
|
| 70 |
+
const char kStructNullValueTypeUrl[] =
|
| 71 |
+
"type.googleapis.com/google.protobuf.NullValue";
|
| 72 |
+
|
| 73 |
+
// Type string for google.protobuf.Struct
|
| 74 |
+
const char kStructType[] = "google.protobuf.Struct";
|
| 75 |
+
|
| 76 |
+
// Type string for struct.proto's google.protobuf.Value value type.
|
| 77 |
+
const char kStructValueType[] = "google.protobuf.Value";
|
| 78 |
+
|
| 79 |
+
// Type string for struct.proto's google.protobuf.ListValue value type.
|
| 80 |
+
const char kStructListValueType[] = "google.protobuf.ListValue";
|
| 81 |
+
|
| 82 |
+
// Type string for google.protobuf.Timestamp
|
| 83 |
+
const char kTimestampType[] = "google.protobuf.Timestamp";
|
| 84 |
+
|
| 85 |
+
// Type string for google.protobuf.Duration
|
| 86 |
+
const char kDurationType[] = "google.protobuf.Duration";
|
| 87 |
+
|
| 88 |
+
// Type URL for struct value type google.protobuf.Value
|
| 89 |
+
const char kStructValueTypeUrl[] = "type.googleapis.com/google.protobuf.Value";
|
| 90 |
+
|
| 91 |
+
// Type string for google.protobuf.Any
|
| 92 |
+
const char kAnyType[] = "google.protobuf.Any";
|
| 93 |
+
|
| 94 |
+
// The protobuf option name of jspb.message_id;
|
| 95 |
+
const char kOptionJspbMessageId[] = "jspb.message_id";
|
| 96 |
+
|
| 97 |
+
} // namespace converter
|
| 98 |
+
} // namespace util
|
| 99 |
+
} // namespace protobuf
|
| 100 |
+
} // namespace google
|
| 101 |
+
#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_CONSTANTS_H__
|
videochat2/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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_DATAPIECE_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_UTIL_INTERNAL_DATAPIECE_H__
|
| 33 |
+
|
| 34 |
+
#include <cstdint>
|
| 35 |
+
#include <string>
|
| 36 |
+
|
| 37 |
+
#include <google/protobuf/stubs/common.h>
|
| 38 |
+
#include <google/protobuf/stubs/logging.h>
|
| 39 |
+
#include <google/protobuf/type.pb.h>
|
| 40 |
+
#include <google/protobuf/stubs/statusor.h>
|
| 41 |
+
#include <google/protobuf/stubs/strutil.h>
|
| 42 |
+
|
| 43 |
+
// Must be included last.
|
| 44 |
+
#include <google/protobuf/port_def.inc>
|
| 45 |
+
|
| 46 |
+
namespace google {
|
| 47 |
+
namespace protobuf {
|
| 48 |
+
namespace util {
|
| 49 |
+
namespace converter {
|
| 50 |
+
class ProtoWriter;
|
| 51 |
+
|
| 52 |
+
// Container for a single piece of data together with its data type.
|
| 53 |
+
//
|
| 54 |
+
// For primitive types (int32, int64, uint32, uint64, double, float, bool),
|
| 55 |
+
// the data is stored by value.
|
| 56 |
+
//
|
| 57 |
+
// For string, a StringPiece is stored. For Cord, a pointer to Cord is stored.
|
| 58 |
+
// Just like StringPiece, the DataPiece class does not own the storage for
|
| 59 |
+
// the actual string or Cord, so it is the user's responsibility to guarantee
|
| 60 |
+
// that the underlying storage is still valid when the DataPiece is accessed.
|
| 61 |
+
class PROTOBUF_EXPORT DataPiece {
|
| 62 |
+
public:
|
| 63 |
+
// Identifies data type of the value.
|
| 64 |
+
// These are the types supported by DataPiece.
|
| 65 |
+
enum Type {
|
| 66 |
+
TYPE_INT32 = 1,
|
| 67 |
+
TYPE_INT64 = 2,
|
| 68 |
+
TYPE_UINT32 = 3,
|
| 69 |
+
TYPE_UINT64 = 4,
|
| 70 |
+
TYPE_DOUBLE = 5,
|
| 71 |
+
TYPE_FLOAT = 6,
|
| 72 |
+
TYPE_BOOL = 7,
|
| 73 |
+
TYPE_ENUM = 8,
|
| 74 |
+
TYPE_STRING = 9,
|
| 75 |
+
TYPE_BYTES = 10,
|
| 76 |
+
TYPE_NULL = 11, // explicit NULL type
|
| 77 |
+
};
|
| 78 |
+
|
| 79 |
+
// Constructors and Destructor
|
| 80 |
+
explicit DataPiece(const int32_t value)
|
| 81 |
+
: type_(TYPE_INT32), i32_(value), use_strict_base64_decoding_(false) {}
|
| 82 |
+
explicit DataPiece(const int64_t value)
|
| 83 |
+
: type_(TYPE_INT64), i64_(value), use_strict_base64_decoding_(false) {}
|
| 84 |
+
explicit DataPiece(const uint32_t value)
|
| 85 |
+
: type_(TYPE_UINT32), u32_(value), use_strict_base64_decoding_(false) {}
|
| 86 |
+
explicit DataPiece(const uint64_t value)
|
| 87 |
+
: type_(TYPE_UINT64), u64_(value), use_strict_base64_decoding_(false) {}
|
| 88 |
+
explicit DataPiece(const double value)
|
| 89 |
+
: type_(TYPE_DOUBLE),
|
| 90 |
+
double_(value),
|
| 91 |
+
use_strict_base64_decoding_(false) {}
|
| 92 |
+
explicit DataPiece(const float value)
|
| 93 |
+
: type_(TYPE_FLOAT), float_(value), use_strict_base64_decoding_(false) {}
|
| 94 |
+
explicit DataPiece(const bool value)
|
| 95 |
+
: type_(TYPE_BOOL), bool_(value), use_strict_base64_decoding_(false) {}
|
| 96 |
+
DataPiece(StringPiece value, bool use_strict_base64_decoding)
|
| 97 |
+
: type_(TYPE_STRING),
|
| 98 |
+
str_(value),
|
| 99 |
+
use_strict_base64_decoding_(use_strict_base64_decoding) {}
|
| 100 |
+
// Constructor for bytes. The second parameter is not used.
|
| 101 |
+
DataPiece(StringPiece value, bool /*dummy*/, bool use_strict_base64_decoding)
|
| 102 |
+
: type_(TYPE_BYTES),
|
| 103 |
+
str_(value),
|
| 104 |
+
use_strict_base64_decoding_(use_strict_base64_decoding) {}
|
| 105 |
+
|
| 106 |
+
DataPiece(const DataPiece& r) : type_(r.type_) { InternalCopy(r); }
|
| 107 |
+
|
| 108 |
+
DataPiece& operator=(const DataPiece& x) {
|
| 109 |
+
InternalCopy(x);
|
| 110 |
+
return *this;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
static DataPiece NullData() { return DataPiece(TYPE_NULL, 0); }
|
| 114 |
+
|
| 115 |
+
virtual ~DataPiece() {
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
// Accessors
|
| 119 |
+
Type type() const { return type_; }
|
| 120 |
+
|
| 121 |
+
bool use_strict_base64_decoding() { return use_strict_base64_decoding_; }
|
| 122 |
+
|
| 123 |
+
StringPiece str() const {
|
| 124 |
+
GOOGLE_LOG_IF(DFATAL, type_ != TYPE_STRING) << "Not a string type.";
|
| 125 |
+
return str_;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
// Parses, casts or converts the value stored in the DataPiece into an int32.
|
| 130 |
+
util::StatusOr<int32_t> ToInt32() const;
|
| 131 |
+
|
| 132 |
+
// Parses, casts or converts the value stored in the DataPiece into a uint32.
|
| 133 |
+
util::StatusOr<uint32_t> ToUint32() const;
|
| 134 |
+
|
| 135 |
+
// Parses, casts or converts the value stored in the DataPiece into an int64.
|
| 136 |
+
util::StatusOr<int64_t> ToInt64() const;
|
| 137 |
+
|
| 138 |
+
// Parses, casts or converts the value stored in the DataPiece into a uint64.
|
| 139 |
+
util::StatusOr<uint64_t> ToUint64() const;
|
| 140 |
+
|
| 141 |
+
// Parses, casts or converts the value stored in the DataPiece into a double.
|
| 142 |
+
util::StatusOr<double> ToDouble() const;
|
| 143 |
+
|
| 144 |
+
// Parses, casts or converts the value stored in the DataPiece into a float.
|
| 145 |
+
util::StatusOr<float> ToFloat() const;
|
| 146 |
+
|
| 147 |
+
// Parses, casts or converts the value stored in the DataPiece into a bool.
|
| 148 |
+
util::StatusOr<bool> ToBool() const;
|
| 149 |
+
|
| 150 |
+
// Parses, casts or converts the value stored in the DataPiece into a string.
|
| 151 |
+
util::StatusOr<std::string> ToString() const;
|
| 152 |
+
|
| 153 |
+
// Tries to convert the value contained in this datapiece to string. If the
|
| 154 |
+
// conversion fails, it returns the default_string.
|
| 155 |
+
std::string ValueAsStringOrDefault(StringPiece default_string) const;
|
| 156 |
+
|
| 157 |
+
util::StatusOr<std::string> ToBytes() const;
|
| 158 |
+
|
| 159 |
+
private:
|
| 160 |
+
friend class ProtoWriter;
|
| 161 |
+
|
| 162 |
+
// Disallow implicit constructor.
|
| 163 |
+
DataPiece();
|
| 164 |
+
|
| 165 |
+
// Helper to create NULL or ENUM types.
|
| 166 |
+
DataPiece(Type type, int32_t val)
|
| 167 |
+
: type_(type), i32_(val), use_strict_base64_decoding_(false) {}
|
| 168 |
+
|
| 169 |
+
// Same as the ToEnum() method above but with additional flag to ignore
|
| 170 |
+
// unknown enum values.
|
| 171 |
+
util::StatusOr<int> ToEnum(const google::protobuf::Enum* enum_type,
|
| 172 |
+
bool use_lower_camel_for_enums,
|
| 173 |
+
bool case_insensitive_enum_parsing,
|
| 174 |
+
bool ignore_unknown_enum_values,
|
| 175 |
+
bool* is_unknown_enum_value) const;
|
| 176 |
+
|
| 177 |
+
// For numeric conversion between
|
| 178 |
+
// int32, int64, uint32, uint64, double, float and bool
|
| 179 |
+
template <typename To>
|
| 180 |
+
util::StatusOr<To> GenericConvert() const;
|
| 181 |
+
|
| 182 |
+
// For conversion from string to
|
| 183 |
+
// int32, int64, uint32, uint64, double, float and bool
|
| 184 |
+
template <typename To>
|
| 185 |
+
util::StatusOr<To> StringToNumber(bool (*func)(StringPiece, To*)) const;
|
| 186 |
+
|
| 187 |
+
// Decodes a base64 string. Returns true on success.
|
| 188 |
+
bool DecodeBase64(StringPiece src, std::string* dest) const;
|
| 189 |
+
|
| 190 |
+
// Helper function to initialize this DataPiece with 'other'.
|
| 191 |
+
void InternalCopy(const DataPiece& other);
|
| 192 |
+
|
| 193 |
+
// Data type for this piece of data.
|
| 194 |
+
Type type_;
|
| 195 |
+
|
| 196 |
+
// Stored piece of data.
|
| 197 |
+
union {
|
| 198 |
+
int32_t i32_;
|
| 199 |
+
int64_t i64_;
|
| 200 |
+
uint32_t u32_;
|
| 201 |
+
uint64_t u64_;
|
| 202 |
+
double double_;
|
| 203 |
+
float float_;
|
| 204 |
+
bool bool_;
|
| 205 |
+
StringPiece str_;
|
| 206 |
+
};
|
| 207 |
+
|
| 208 |
+
// Uses a stricter version of base64 decoding for byte fields.
|
| 209 |
+
bool use_strict_base64_decoding_;
|
| 210 |
+
};
|
| 211 |
+
|
| 212 |
+
} // namespace converter
|
| 213 |
+
} // namespace util
|
| 214 |
+
} // namespace protobuf
|
| 215 |
+
} // namespace google
|
| 216 |
+
|
| 217 |
+
#include <google/protobuf/port_undef.inc>
|
| 218 |
+
|
| 219 |
+
#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_DATAPIECE_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/default_value_objectwriter.h
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_DEFAULT_VALUE_OBJECTWRITER_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_UTIL_INTERNAL_DEFAULT_VALUE_OBJECTWRITER_H__
|
| 33 |
+
|
| 34 |
+
#include <cstdint>
|
| 35 |
+
#include <functional>
|
| 36 |
+
#include <memory>
|
| 37 |
+
#include <stack>
|
| 38 |
+
#include <vector>
|
| 39 |
+
|
| 40 |
+
#include <google/protobuf/stubs/common.h>
|
| 41 |
+
#include <google/protobuf/stubs/strutil.h>
|
| 42 |
+
#include <google/protobuf/util/internal/datapiece.h>
|
| 43 |
+
#include <google/protobuf/util/internal/object_writer.h>
|
| 44 |
+
#include <google/protobuf/util/internal/type_info.h>
|
| 45 |
+
#include <google/protobuf/util/internal/utility.h>
|
| 46 |
+
#include <google/protobuf/util/type_resolver.h>
|
| 47 |
+
|
| 48 |
+
// Must be included last.
|
| 49 |
+
#include <google/protobuf/port_def.inc>
|
| 50 |
+
|
| 51 |
+
namespace google {
|
| 52 |
+
namespace protobuf {
|
| 53 |
+
namespace util {
|
| 54 |
+
namespace converter {
|
| 55 |
+
|
| 56 |
+
// An ObjectWriter that renders non-repeated primitive fields of proto messages
|
| 57 |
+
// with their default values. DefaultValueObjectWriter holds objects, lists and
|
| 58 |
+
// fields it receives in a tree structure and writes them out to another
|
| 59 |
+
// ObjectWriter when EndObject() is called on the root object. It also writes
|
| 60 |
+
// out all non-repeated primitive fields that haven't been explicitly rendered
|
| 61 |
+
// with their default values (0 for numbers, "" for strings, etc).
|
| 62 |
+
class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
|
| 63 |
+
public:
|
| 64 |
+
// A Callback function to check whether a field needs to be scrubbed.
|
| 65 |
+
//
|
| 66 |
+
// Returns true if the field should not be present in the output. Returns
|
| 67 |
+
// false otherwise.
|
| 68 |
+
//
|
| 69 |
+
// The 'path' parameter is a vector of path to the field from root. For
|
| 70 |
+
// example: if a nested field "a.b.c" (b is the parent message field of c and
|
| 71 |
+
// a is the parent message field of b), then the vector should contain { "a",
|
| 72 |
+
// "b", "c" }.
|
| 73 |
+
//
|
| 74 |
+
// The Field* should point to the google::protobuf::Field of "c".
|
| 75 |
+
typedef std::function<bool(
|
| 76 |
+
const std::vector<std::string>& /*path of the field*/,
|
| 77 |
+
const google::protobuf::Field* /*field*/)>
|
| 78 |
+
FieldScrubCallBack;
|
| 79 |
+
|
| 80 |
+
DefaultValueObjectWriter(TypeResolver* type_resolver,
|
| 81 |
+
const google::protobuf::Type& type,
|
| 82 |
+
ObjectWriter* ow);
|
| 83 |
+
|
| 84 |
+
~DefaultValueObjectWriter() override;
|
| 85 |
+
|
| 86 |
+
// ObjectWriter methods.
|
| 87 |
+
DefaultValueObjectWriter* StartObject(StringPiece name) override;
|
| 88 |
+
|
| 89 |
+
DefaultValueObjectWriter* EndObject() override;
|
| 90 |
+
|
| 91 |
+
DefaultValueObjectWriter* StartList(StringPiece name) override;
|
| 92 |
+
|
| 93 |
+
DefaultValueObjectWriter* EndList() override;
|
| 94 |
+
|
| 95 |
+
DefaultValueObjectWriter* RenderBool(StringPiece name,
|
| 96 |
+
bool value) override;
|
| 97 |
+
|
| 98 |
+
DefaultValueObjectWriter* RenderInt32(StringPiece name,
|
| 99 |
+
int32_t value) override;
|
| 100 |
+
|
| 101 |
+
DefaultValueObjectWriter* RenderUint32(StringPiece name,
|
| 102 |
+
uint32_t value) override;
|
| 103 |
+
|
| 104 |
+
DefaultValueObjectWriter* RenderInt64(StringPiece name,
|
| 105 |
+
int64_t value) override;
|
| 106 |
+
|
| 107 |
+
DefaultValueObjectWriter* RenderUint64(StringPiece name,
|
| 108 |
+
uint64_t value) override;
|
| 109 |
+
|
| 110 |
+
DefaultValueObjectWriter* RenderDouble(StringPiece name,
|
| 111 |
+
double value) override;
|
| 112 |
+
|
| 113 |
+
DefaultValueObjectWriter* RenderFloat(StringPiece name,
|
| 114 |
+
float value) override;
|
| 115 |
+
|
| 116 |
+
DefaultValueObjectWriter* RenderString(StringPiece name,
|
| 117 |
+
StringPiece value) override;
|
| 118 |
+
DefaultValueObjectWriter* RenderBytes(StringPiece name,
|
| 119 |
+
StringPiece value) override;
|
| 120 |
+
|
| 121 |
+
DefaultValueObjectWriter* RenderNull(StringPiece name) override;
|
| 122 |
+
|
| 123 |
+
// Register the callback for scrubbing of fields.
|
| 124 |
+
void RegisterFieldScrubCallBack(FieldScrubCallBack field_scrub_callback);
|
| 125 |
+
|
| 126 |
+
// If set to true, empty lists are suppressed from output when default values
|
| 127 |
+
// are written.
|
| 128 |
+
void set_suppress_empty_list(bool value) { suppress_empty_list_ = value; }
|
| 129 |
+
|
| 130 |
+
// If set to true, original proto field names are used
|
| 131 |
+
void set_preserve_proto_field_names(bool value) {
|
| 132 |
+
preserve_proto_field_names_ = value;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
// If set to true, enums are rendered as ints from output when default values
|
| 136 |
+
// are written.
|
| 137 |
+
void set_print_enums_as_ints(bool value) { use_ints_for_enums_ = value; }
|
| 138 |
+
|
| 139 |
+
protected:
|
| 140 |
+
enum NodeKind {
|
| 141 |
+
PRIMITIVE = 0,
|
| 142 |
+
OBJECT = 1,
|
| 143 |
+
LIST = 2,
|
| 144 |
+
MAP = 3,
|
| 145 |
+
};
|
| 146 |
+
|
| 147 |
+
// "Node" represents a node in the tree that holds the input of
|
| 148 |
+
// DefaultValueObjectWriter.
|
| 149 |
+
class PROTOBUF_EXPORT Node {
|
| 150 |
+
public:
|
| 151 |
+
Node(const std::string& name, const google::protobuf::Type* type,
|
| 152 |
+
NodeKind kind, const DataPiece& data, bool is_placeholder,
|
| 153 |
+
const std::vector<std::string>& path, bool suppress_empty_list,
|
| 154 |
+
bool preserve_proto_field_names, bool use_ints_for_enums,
|
| 155 |
+
FieldScrubCallBack field_scrub_callback);
|
| 156 |
+
virtual ~Node() {
|
| 157 |
+
for (int i = 0; i < children_.size(); ++i) {
|
| 158 |
+
delete children_[i];
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
// Adds a child to this node. Takes ownership of this child.
|
| 163 |
+
void AddChild(Node* child) { children_.push_back(child); }
|
| 164 |
+
|
| 165 |
+
// Finds the child given its name.
|
| 166 |
+
Node* FindChild(StringPiece name);
|
| 167 |
+
|
| 168 |
+
// Populates children of this Node based on its type. If there are already
|
| 169 |
+
// children created, they will be merged to the result. Caller should pass
|
| 170 |
+
// in TypeInfo for looking up types of the children.
|
| 171 |
+
virtual void PopulateChildren(const TypeInfo* typeinfo);
|
| 172 |
+
|
| 173 |
+
// If this node is a leaf (has data), writes the current node to the
|
| 174 |
+
// ObjectWriter; if not, then recursively writes the children to the
|
| 175 |
+
// ObjectWriter.
|
| 176 |
+
virtual void WriteTo(ObjectWriter* ow);
|
| 177 |
+
|
| 178 |
+
// Accessors
|
| 179 |
+
const std::string& name() const { return name_; }
|
| 180 |
+
|
| 181 |
+
const std::vector<std::string>& path() const { return path_; }
|
| 182 |
+
|
| 183 |
+
const google::protobuf::Type* type() const { return type_; }
|
| 184 |
+
|
| 185 |
+
void set_type(const google::protobuf::Type* type) { type_ = type; }
|
| 186 |
+
|
| 187 |
+
NodeKind kind() const { return kind_; }
|
| 188 |
+
|
| 189 |
+
int number_of_children() const { return children_.size(); }
|
| 190 |
+
|
| 191 |
+
void set_data(const DataPiece& data) { data_ = data; }
|
| 192 |
+
|
| 193 |
+
bool is_any() const { return is_any_; }
|
| 194 |
+
|
| 195 |
+
void set_is_any(bool is_any) { is_any_ = is_any; }
|
| 196 |
+
|
| 197 |
+
void set_is_placeholder(bool is_placeholder) {
|
| 198 |
+
is_placeholder_ = is_placeholder;
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
protected:
|
| 202 |
+
// Returns the Value Type of a map given the Type of the map entry and a
|
| 203 |
+
// TypeInfo instance.
|
| 204 |
+
const google::protobuf::Type* GetMapValueType(
|
| 205 |
+
const google::protobuf::Type& found_type, const TypeInfo* typeinfo);
|
| 206 |
+
|
| 207 |
+
// Calls WriteTo() on every child in children_.
|
| 208 |
+
void WriteChildren(ObjectWriter* ow);
|
| 209 |
+
|
| 210 |
+
// The name of this node.
|
| 211 |
+
std::string name_;
|
| 212 |
+
// google::protobuf::Type of this node. Owned by TypeInfo.
|
| 213 |
+
const google::protobuf::Type* type_;
|
| 214 |
+
// The kind of this node.
|
| 215 |
+
NodeKind kind_;
|
| 216 |
+
// Whether this is a node for "Any".
|
| 217 |
+
bool is_any_;
|
| 218 |
+
// The data of this node when it is a leaf node.
|
| 219 |
+
DataPiece data_;
|
| 220 |
+
// Children of this node.
|
| 221 |
+
std::vector<Node*> children_;
|
| 222 |
+
// Whether this node is a placeholder for an object or list automatically
|
| 223 |
+
// generated when creating the parent node. Should be set to false after
|
| 224 |
+
// the parent node's StartObject()/StartList() method is called with this
|
| 225 |
+
// node's name.
|
| 226 |
+
bool is_placeholder_;
|
| 227 |
+
|
| 228 |
+
// Path of the field of this node
|
| 229 |
+
std::vector<std::string> path_;
|
| 230 |
+
|
| 231 |
+
// Whether to suppress empty list output.
|
| 232 |
+
bool suppress_empty_list_;
|
| 233 |
+
|
| 234 |
+
// Whether to preserve original proto field names
|
| 235 |
+
bool preserve_proto_field_names_;
|
| 236 |
+
|
| 237 |
+
// Whether to always print enums as ints
|
| 238 |
+
bool use_ints_for_enums_;
|
| 239 |
+
|
| 240 |
+
// Function for determining whether a field needs to be scrubbed or not.
|
| 241 |
+
FieldScrubCallBack field_scrub_callback_;
|
| 242 |
+
|
| 243 |
+
private:
|
| 244 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Node);
|
| 245 |
+
};
|
| 246 |
+
|
| 247 |
+
// Creates a new Node and returns it. Caller owns memory of returned object.
|
| 248 |
+
virtual Node* CreateNewNode(const std::string& name,
|
| 249 |
+
const google::protobuf::Type* type, NodeKind kind,
|
| 250 |
+
const DataPiece& data, bool is_placeholder,
|
| 251 |
+
const std::vector<std::string>& path,
|
| 252 |
+
bool suppress_empty_list,
|
| 253 |
+
bool preserve_proto_field_names,
|
| 254 |
+
bool use_ints_for_enums,
|
| 255 |
+
FieldScrubCallBack field_scrub_callback);
|
| 256 |
+
|
| 257 |
+
// Creates a DataPiece containing the default value of the type of the field.
|
| 258 |
+
static DataPiece CreateDefaultDataPieceForField(
|
| 259 |
+
const google::protobuf::Field& field, const TypeInfo* typeinfo) {
|
| 260 |
+
return CreateDefaultDataPieceForField(field, typeinfo, false);
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
// Same as the above but with a flag to use ints instead of enum names.
|
| 264 |
+
static DataPiece CreateDefaultDataPieceForField(
|
| 265 |
+
const google::protobuf::Field& field, const TypeInfo* typeinfo,
|
| 266 |
+
bool use_ints_for_enums);
|
| 267 |
+
|
| 268 |
+
protected:
|
| 269 |
+
// Returns a pointer to current Node in tree.
|
| 270 |
+
Node* current() { return current_; }
|
| 271 |
+
|
| 272 |
+
private:
|
| 273 |
+
// Populates children of "node" if it is an "any" Node and its real type has
|
| 274 |
+
// been given.
|
| 275 |
+
void MaybePopulateChildrenOfAny(Node* node);
|
| 276 |
+
|
| 277 |
+
// Writes the root_ node to ow_ and resets the root_ and current_ pointer to
|
| 278 |
+
// nullptr.
|
| 279 |
+
void WriteRoot();
|
| 280 |
+
|
| 281 |
+
// Adds or replaces the data_ of a primitive child node.
|
| 282 |
+
void RenderDataPiece(StringPiece name, const DataPiece& data);
|
| 283 |
+
|
| 284 |
+
// Returns the default enum value as a DataPiece, or the first enum value if
|
| 285 |
+
// there is no default. For proto3, where we cannot specify an explicit
|
| 286 |
+
// default, a zero value will always be returned.
|
| 287 |
+
static DataPiece FindEnumDefault(const google::protobuf::Field& field,
|
| 288 |
+
const TypeInfo* typeinfo,
|
| 289 |
+
bool use_ints_for_enums);
|
| 290 |
+
|
| 291 |
+
// Type information for all the types used in the descriptor. Used to find
|
| 292 |
+
// google::protobuf::Type of nested messages/enums.
|
| 293 |
+
const TypeInfo* typeinfo_;
|
| 294 |
+
// Whether the TypeInfo object is owned by this class.
|
| 295 |
+
bool own_typeinfo_;
|
| 296 |
+
// google::protobuf::Type of the root message type.
|
| 297 |
+
const google::protobuf::Type& type_;
|
| 298 |
+
// Holds copies of strings passed to RenderString.
|
| 299 |
+
std::vector<std::unique_ptr<std::string>> string_values_;
|
| 300 |
+
|
| 301 |
+
// The current Node. Owned by its parents.
|
| 302 |
+
Node* current_;
|
| 303 |
+
// The root Node.
|
| 304 |
+
std::unique_ptr<Node> root_;
|
| 305 |
+
// The stack to hold the path of Nodes from current_ to root_;
|
| 306 |
+
std::stack<Node*> stack_;
|
| 307 |
+
|
| 308 |
+
// Whether to suppress output of empty lists.
|
| 309 |
+
bool suppress_empty_list_;
|
| 310 |
+
|
| 311 |
+
// Whether to preserve original proto field names
|
| 312 |
+
bool preserve_proto_field_names_;
|
| 313 |
+
|
| 314 |
+
// Whether to always print enums as ints
|
| 315 |
+
bool use_ints_for_enums_;
|
| 316 |
+
|
| 317 |
+
// Function for determining whether a field needs to be scrubbed or not.
|
| 318 |
+
FieldScrubCallBack field_scrub_callback_;
|
| 319 |
+
|
| 320 |
+
ObjectWriter* ow_;
|
| 321 |
+
|
| 322 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DefaultValueObjectWriter);
|
| 323 |
+
};
|
| 324 |
+
|
| 325 |
+
} // namespace converter
|
| 326 |
+
} // namespace util
|
| 327 |
+
} // namespace protobuf
|
| 328 |
+
} // namespace google
|
| 329 |
+
|
| 330 |
+
#include <google/protobuf/port_undef.inc>
|
| 331 |
+
|
| 332 |
+
#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_DEFAULT_VALUE_OBJECTWRITER_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/error_listener.h
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_ERROR_LISTENER_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_UTIL_INTERNAL_ERROR_LISTENER_H__
|
| 33 |
+
|
| 34 |
+
#include <algorithm>
|
| 35 |
+
#include <memory>
|
| 36 |
+
#include <string>
|
| 37 |
+
#include <vector>
|
| 38 |
+
|
| 39 |
+
#include <google/protobuf/stubs/callback.h>
|
| 40 |
+
#include <google/protobuf/stubs/common.h>
|
| 41 |
+
#include <google/protobuf/stubs/logging.h>
|
| 42 |
+
#include <google/protobuf/stubs/strutil.h>
|
| 43 |
+
#include <google/protobuf/util/internal/location_tracker.h>
|
| 44 |
+
|
| 45 |
+
// Must be included last.
|
| 46 |
+
#include <google/protobuf/port_def.inc>
|
| 47 |
+
|
| 48 |
+
namespace google {
|
| 49 |
+
namespace protobuf {
|
| 50 |
+
namespace util {
|
| 51 |
+
namespace converter {
|
| 52 |
+
|
| 53 |
+
// Interface for error listener.
|
| 54 |
+
class PROTOBUF_EXPORT ErrorListener {
|
| 55 |
+
public:
|
| 56 |
+
virtual ~ErrorListener() {}
|
| 57 |
+
|
| 58 |
+
// Reports an invalid name at the given location.
|
| 59 |
+
virtual void InvalidName(const LocationTrackerInterface& loc,
|
| 60 |
+
StringPiece invalid_name,
|
| 61 |
+
StringPiece message) = 0;
|
| 62 |
+
|
| 63 |
+
// Reports an invalid value for a field.
|
| 64 |
+
virtual void InvalidValue(const LocationTrackerInterface& loc,
|
| 65 |
+
StringPiece type_name,
|
| 66 |
+
StringPiece value) = 0;
|
| 67 |
+
|
| 68 |
+
// Reports a missing required field.
|
| 69 |
+
virtual void MissingField(const LocationTrackerInterface& loc,
|
| 70 |
+
StringPiece missing_name) = 0;
|
| 71 |
+
|
| 72 |
+
protected:
|
| 73 |
+
ErrorListener() {}
|
| 74 |
+
|
| 75 |
+
private:
|
| 76 |
+
// Do not add any data members to this class.
|
| 77 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ErrorListener);
|
| 78 |
+
};
|
| 79 |
+
|
| 80 |
+
// An error listener that ignores all errors.
|
| 81 |
+
class PROTOBUF_EXPORT NoopErrorListener : public ErrorListener {
|
| 82 |
+
public:
|
| 83 |
+
NoopErrorListener() {}
|
| 84 |
+
~NoopErrorListener() override {}
|
| 85 |
+
|
| 86 |
+
void InvalidName(const LocationTrackerInterface& /*loc*/,
|
| 87 |
+
StringPiece /* invalid_name */,
|
| 88 |
+
StringPiece /* message */) override {}
|
| 89 |
+
|
| 90 |
+
void InvalidValue(const LocationTrackerInterface& /*loc*/,
|
| 91 |
+
StringPiece /* type_name */,
|
| 92 |
+
StringPiece /* value */) override {}
|
| 93 |
+
|
| 94 |
+
void MissingField(const LocationTrackerInterface& /* loc */,
|
| 95 |
+
StringPiece /* missing_name */) override {}
|
| 96 |
+
|
| 97 |
+
private:
|
| 98 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(NoopErrorListener);
|
| 99 |
+
};
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
} // namespace converter
|
| 103 |
+
} // namespace util
|
| 104 |
+
} // namespace protobuf
|
| 105 |
+
} // namespace google
|
| 106 |
+
|
| 107 |
+
#include <google/protobuf/port_undef.inc>
|
| 108 |
+
|
| 109 |
+
#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_ERROR_LISTENER_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/expecting_objectwriter.h
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_EXPECTING_OBJECTWRITER_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_UTIL_INTERNAL_EXPECTING_OBJECTWRITER_H__
|
| 33 |
+
|
| 34 |
+
// An implementation of ObjectWriter that automatically sets the
|
| 35 |
+
// gmock expectations for the response to a method. Every method
|
| 36 |
+
// returns the object itself for chaining.
|
| 37 |
+
//
|
| 38 |
+
// Usage:
|
| 39 |
+
// // Setup
|
| 40 |
+
// MockObjectWriter mock;
|
| 41 |
+
// ExpectingObjectWriter ow(&mock);
|
| 42 |
+
//
|
| 43 |
+
// // Set expectation
|
| 44 |
+
// ow.StartObject("")
|
| 45 |
+
// ->RenderString("key", "value")
|
| 46 |
+
// ->EndObject();
|
| 47 |
+
//
|
| 48 |
+
// // Actual testing
|
| 49 |
+
// mock.StartObject(StringPiece())
|
| 50 |
+
// ->RenderString("key", "value")
|
| 51 |
+
// ->EndObject();
|
| 52 |
+
|
| 53 |
+
#include <cstdint>
|
| 54 |
+
|
| 55 |
+
#include <google/protobuf/stubs/common.h>
|
| 56 |
+
#include <gmock/gmock.h>
|
| 57 |
+
#include <google/protobuf/stubs/strutil.h>
|
| 58 |
+
#include <google/protobuf/util/internal/object_writer.h>
|
| 59 |
+
|
| 60 |
+
namespace google {
|
| 61 |
+
namespace protobuf {
|
| 62 |
+
namespace util {
|
| 63 |
+
namespace converter {
|
| 64 |
+
|
| 65 |
+
using testing::Eq;
|
| 66 |
+
using testing::IsEmpty;
|
| 67 |
+
using testing::NanSensitiveDoubleEq;
|
| 68 |
+
using testing::NanSensitiveFloatEq;
|
| 69 |
+
using testing::Return;
|
| 70 |
+
using testing::StrEq;
|
| 71 |
+
using testing::TypedEq;
|
| 72 |
+
|
| 73 |
+
class MockObjectWriter : public ObjectWriter {
|
| 74 |
+
public:
|
| 75 |
+
MockObjectWriter() {}
|
| 76 |
+
|
| 77 |
+
MOCK_METHOD(ObjectWriter*, StartObject, (StringPiece), (override));
|
| 78 |
+
MOCK_METHOD(ObjectWriter*, EndObject, (), (override));
|
| 79 |
+
MOCK_METHOD(ObjectWriter*, StartList, (StringPiece), (override));
|
| 80 |
+
MOCK_METHOD(ObjectWriter*, EndList, (), (override));
|
| 81 |
+
MOCK_METHOD(ObjectWriter*, RenderBool, (StringPiece, bool), (override));
|
| 82 |
+
MOCK_METHOD(ObjectWriter*, RenderInt32, (StringPiece, int32_t),
|
| 83 |
+
(override));
|
| 84 |
+
MOCK_METHOD(ObjectWriter*, RenderUint32, (StringPiece, uint32_t),
|
| 85 |
+
(override));
|
| 86 |
+
MOCK_METHOD(ObjectWriter*, RenderInt64, (StringPiece, int64_t),
|
| 87 |
+
(override));
|
| 88 |
+
MOCK_METHOD(ObjectWriter*, RenderUint64, (StringPiece, uint64_t),
|
| 89 |
+
(override));
|
| 90 |
+
MOCK_METHOD(ObjectWriter*, RenderDouble, (StringPiece, double),
|
| 91 |
+
(override));
|
| 92 |
+
MOCK_METHOD(ObjectWriter*, RenderFloat, (StringPiece, float),
|
| 93 |
+
(override));
|
| 94 |
+
MOCK_METHOD(ObjectWriter*, RenderString,
|
| 95 |
+
(StringPiece, StringPiece), (override));
|
| 96 |
+
MOCK_METHOD(ObjectWriter*, RenderBytes, (StringPiece, StringPiece),
|
| 97 |
+
(override));
|
| 98 |
+
MOCK_METHOD(ObjectWriter*, RenderNull, (StringPiece), (override));
|
| 99 |
+
};
|
| 100 |
+
|
| 101 |
+
class ExpectingObjectWriter : public ObjectWriter {
|
| 102 |
+
public:
|
| 103 |
+
explicit ExpectingObjectWriter(MockObjectWriter* mock) : mock_(mock) {}
|
| 104 |
+
|
| 105 |
+
ObjectWriter* StartObject(StringPiece name) override {
|
| 106 |
+
(name.empty() ? EXPECT_CALL(*mock_, StartObject(IsEmpty()))
|
| 107 |
+
: EXPECT_CALL(*mock_, StartObject(Eq(std::string(name)))))
|
| 108 |
+
.WillOnce(Return(mock_))
|
| 109 |
+
.RetiresOnSaturation();
|
| 110 |
+
return this;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
ObjectWriter* EndObject() override {
|
| 114 |
+
EXPECT_CALL(*mock_, EndObject())
|
| 115 |
+
.WillOnce(Return(mock_))
|
| 116 |
+
.RetiresOnSaturation();
|
| 117 |
+
return this;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
ObjectWriter* StartList(StringPiece name) override {
|
| 121 |
+
(name.empty() ? EXPECT_CALL(*mock_, StartList(IsEmpty()))
|
| 122 |
+
: EXPECT_CALL(*mock_, StartList(Eq(std::string(name)))))
|
| 123 |
+
.WillOnce(Return(mock_))
|
| 124 |
+
.RetiresOnSaturation();
|
| 125 |
+
return this;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
ObjectWriter* EndList() override {
|
| 129 |
+
EXPECT_CALL(*mock_, EndList())
|
| 130 |
+
.WillOnce(Return(mock_))
|
| 131 |
+
.RetiresOnSaturation();
|
| 132 |
+
return this;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
ObjectWriter* RenderBool(StringPiece name, bool value) override {
|
| 136 |
+
(name.empty()
|
| 137 |
+
? EXPECT_CALL(*mock_, RenderBool(IsEmpty(), TypedEq<bool>(value)))
|
| 138 |
+
: EXPECT_CALL(*mock_,
|
| 139 |
+
RenderBool(Eq(std::string(name)), TypedEq<bool>(value))))
|
| 140 |
+
.WillOnce(Return(mock_))
|
| 141 |
+
.RetiresOnSaturation();
|
| 142 |
+
return this;
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
ObjectWriter* RenderInt32(StringPiece name, int32_t value) override {
|
| 146 |
+
(name.empty()
|
| 147 |
+
? EXPECT_CALL(*mock_, RenderInt32(IsEmpty(), TypedEq<int32_t>(value)))
|
| 148 |
+
: EXPECT_CALL(*mock_, RenderInt32(Eq(std::string(name)),
|
| 149 |
+
TypedEq<int32_t>(value))))
|
| 150 |
+
.WillOnce(Return(mock_))
|
| 151 |
+
.RetiresOnSaturation();
|
| 152 |
+
return this;
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
ObjectWriter* RenderUint32(StringPiece name, uint32_t value) override {
|
| 156 |
+
(name.empty() ? EXPECT_CALL(*mock_, RenderUint32(IsEmpty(),
|
| 157 |
+
TypedEq<uint32_t>(value)))
|
| 158 |
+
: EXPECT_CALL(*mock_, RenderUint32(Eq(std::string(name)),
|
| 159 |
+
TypedEq<uint32_t>(value))))
|
| 160 |
+
.WillOnce(Return(mock_))
|
| 161 |
+
.RetiresOnSaturation();
|
| 162 |
+
return this;
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
ObjectWriter* RenderInt64(StringPiece name, int64_t value) override {
|
| 166 |
+
(name.empty()
|
| 167 |
+
? EXPECT_CALL(*mock_, RenderInt64(IsEmpty(), TypedEq<int64_t>(value)))
|
| 168 |
+
: EXPECT_CALL(*mock_, RenderInt64(Eq(std::string(name)),
|
| 169 |
+
TypedEq<int64_t>(value))))
|
| 170 |
+
.WillOnce(Return(mock_))
|
| 171 |
+
.RetiresOnSaturation();
|
| 172 |
+
return this;
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
ObjectWriter* RenderUint64(StringPiece name, uint64_t value) override {
|
| 176 |
+
(name.empty() ? EXPECT_CALL(*mock_, RenderUint64(IsEmpty(),
|
| 177 |
+
TypedEq<uint64_t>(value)))
|
| 178 |
+
: EXPECT_CALL(*mock_, RenderUint64(Eq(std::string(name)),
|
| 179 |
+
TypedEq<uint64_t>(value))))
|
| 180 |
+
.WillOnce(Return(mock_))
|
| 181 |
+
.RetiresOnSaturation();
|
| 182 |
+
return this;
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
ObjectWriter* RenderDouble(StringPiece name, double value) override {
|
| 186 |
+
(name.empty()
|
| 187 |
+
? EXPECT_CALL(*mock_,
|
| 188 |
+
RenderDouble(IsEmpty(), NanSensitiveDoubleEq(value)))
|
| 189 |
+
: EXPECT_CALL(*mock_, RenderDouble(Eq(std::string(name)),
|
| 190 |
+
NanSensitiveDoubleEq(value))))
|
| 191 |
+
.WillOnce(Return(mock_))
|
| 192 |
+
.RetiresOnSaturation();
|
| 193 |
+
return this;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
ObjectWriter* RenderFloat(StringPiece name, float value) override {
|
| 197 |
+
(name.empty()
|
| 198 |
+
? EXPECT_CALL(*mock_,
|
| 199 |
+
RenderFloat(IsEmpty(), NanSensitiveFloatEq(value)))
|
| 200 |
+
: EXPECT_CALL(*mock_, RenderFloat(Eq(std::string(name)),
|
| 201 |
+
NanSensitiveFloatEq(value))))
|
| 202 |
+
.WillOnce(Return(mock_))
|
| 203 |
+
.RetiresOnSaturation();
|
| 204 |
+
return this;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
ObjectWriter* RenderString(StringPiece name,
|
| 208 |
+
StringPiece value) override {
|
| 209 |
+
(name.empty() ? EXPECT_CALL(*mock_, RenderString(IsEmpty(),
|
| 210 |
+
TypedEq<StringPiece>(
|
| 211 |
+
std::string(value))))
|
| 212 |
+
: EXPECT_CALL(*mock_, RenderString(Eq(std::string(name)),
|
| 213 |
+
TypedEq<StringPiece>(
|
| 214 |
+
std::string(value)))))
|
| 215 |
+
.WillOnce(Return(mock_))
|
| 216 |
+
.RetiresOnSaturation();
|
| 217 |
+
return this;
|
| 218 |
+
}
|
| 219 |
+
virtual ObjectWriter* RenderBytes(StringPiece name, StringPiece value) {
|
| 220 |
+
(name.empty()
|
| 221 |
+
? EXPECT_CALL(*mock_, RenderBytes(IsEmpty(), TypedEq<StringPiece>(
|
| 222 |
+
value.ToString())))
|
| 223 |
+
: EXPECT_CALL(*mock_,
|
| 224 |
+
RenderBytes(Eq(std::string(name)),
|
| 225 |
+
TypedEq<StringPiece>(value.ToString()))))
|
| 226 |
+
.WillOnce(Return(mock_))
|
| 227 |
+
.RetiresOnSaturation();
|
| 228 |
+
return this;
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
ObjectWriter* RenderNull(StringPiece name) override {
|
| 232 |
+
(name.empty() ? EXPECT_CALL(*mock_, RenderNull(IsEmpty()))
|
| 233 |
+
: EXPECT_CALL(*mock_, RenderNull(Eq(std::string(name))))
|
| 234 |
+
.WillOnce(Return(mock_))
|
| 235 |
+
.RetiresOnSaturation());
|
| 236 |
+
return this;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
private:
|
| 240 |
+
MockObjectWriter* mock_;
|
| 241 |
+
|
| 242 |
+
GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(ExpectingObjectWriter);
|
| 243 |
+
};
|
| 244 |
+
|
| 245 |
+
} // namespace converter
|
| 246 |
+
} // namespace util
|
| 247 |
+
} // namespace protobuf
|
| 248 |
+
} // namespace google
|
| 249 |
+
|
| 250 |
+
#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_EXPECTING_OBJECTWRITER_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/field_mask_utility.h
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
// FieldMask related utility methods.
|
| 32 |
+
|
| 33 |
+
#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_FIELD_MASK_UTILITY_H__
|
| 34 |
+
#define GOOGLE_PROTOBUF_UTIL_INTERNAL_FIELD_MASK_UTILITY_H__
|
| 35 |
+
|
| 36 |
+
#include <functional>
|
| 37 |
+
#include <stack>
|
| 38 |
+
|
| 39 |
+
#include <google/protobuf/stubs/callback.h>
|
| 40 |
+
#include <google/protobuf/stubs/common.h>
|
| 41 |
+
#include <google/protobuf/stubs/status.h>
|
| 42 |
+
#include <google/protobuf/stubs/strutil.h>
|
| 43 |
+
#include <google/protobuf/stubs/status.h>
|
| 44 |
+
|
| 45 |
+
namespace google {
|
| 46 |
+
namespace protobuf {
|
| 47 |
+
namespace util {
|
| 48 |
+
namespace converter {
|
| 49 |
+
|
| 50 |
+
typedef std::function<std::string(StringPiece)> ConverterCallback;
|
| 51 |
+
typedef std::function<util::Status(StringPiece)> PathSinkCallback;
|
| 52 |
+
|
| 53 |
+
// Applies a 'converter' to each segment of a FieldMask path and returns the
|
| 54 |
+
// result. Quoted strings in the 'path' are copied to the output as-is without
|
| 55 |
+
// converting their content. Escaping is supported within quoted strings.
|
| 56 |
+
// For example, "ab\"_c" will be returned as "ab\"_c" without any changes.
|
| 57 |
+
std::string ConvertFieldMaskPath(const StringPiece path,
|
| 58 |
+
ConverterCallback converter);
|
| 59 |
+
|
| 60 |
+
// Decodes a compact list of FieldMasks. For example, "a.b,a.c.d,a.c.e" will be
|
| 61 |
+
// decoded into a list of field paths - "a.b", "a.c.d", "a.c.e". And the results
|
| 62 |
+
// will be sent to 'path_sink', i.e. 'path_sink' will be called once per
|
| 63 |
+
// resulting path.
|
| 64 |
+
// Note that we also support Apiary style FieldMask form. The above example in
|
| 65 |
+
// the Apiary style will look like "a.b,a.c(d,e)".
|
| 66 |
+
util::Status DecodeCompactFieldMaskPaths(StringPiece paths,
|
| 67 |
+
PathSinkCallback path_sink);
|
| 68 |
+
|
| 69 |
+
} // namespace converter
|
| 70 |
+
} // namespace util
|
| 71 |
+
} // namespace protobuf
|
| 72 |
+
} // namespace google
|
| 73 |
+
|
| 74 |
+
#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_FIELD_MASK_UTILITY_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/json_escaping.h
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_ESCAPING_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_ESCAPING_H__
|
| 33 |
+
|
| 34 |
+
#include <cstdint>
|
| 35 |
+
|
| 36 |
+
#include <google/protobuf/stubs/common.h>
|
| 37 |
+
#include <google/protobuf/stubs/bytestream.h>
|
| 38 |
+
|
| 39 |
+
namespace google {
|
| 40 |
+
namespace protobuf {
|
| 41 |
+
namespace util {
|
| 42 |
+
namespace converter {
|
| 43 |
+
|
| 44 |
+
class JsonEscaping {
|
| 45 |
+
public:
|
| 46 |
+
// The minimum value of a unicode high-surrogate code unit in the utf-16
|
| 47 |
+
// encoding. A high-surrogate is also known as a leading-surrogate.
|
| 48 |
+
// See http://www.unicode.org/glossary/#high_surrogate_code_unit
|
| 49 |
+
static constexpr uint16_t kMinHighSurrogate = 0xd800;
|
| 50 |
+
|
| 51 |
+
// The maximum value of a unicide high-surrogate code unit in the utf-16
|
| 52 |
+
// encoding. A high-surrogate is also known as a leading-surrogate.
|
| 53 |
+
// See http://www.unicode.org/glossary/#high_surrogate_code_unit
|
| 54 |
+
static constexpr uint16_t kMaxHighSurrogate = 0xdbff;
|
| 55 |
+
|
| 56 |
+
// The minimum value of a unicode low-surrogate code unit in the utf-16
|
| 57 |
+
// encoding. A low-surrogate is also known as a trailing-surrogate.
|
| 58 |
+
// See http://www.unicode.org/glossary/#low_surrogate_code_unit
|
| 59 |
+
static constexpr uint16_t kMinLowSurrogate = 0xdc00;
|
| 60 |
+
|
| 61 |
+
// The maximum value of a unicode low-surrogate code unit in the utf-16
|
| 62 |
+
// encoding. A low-surrogate is also known as a trailing surrogate.
|
| 63 |
+
// See http://www.unicode.org/glossary/#low_surrogate_code_unit
|
| 64 |
+
static constexpr uint16_t kMaxLowSurrogate = 0xdfff;
|
| 65 |
+
|
| 66 |
+
// The minimum value of a unicode supplementary code point.
|
| 67 |
+
// See http://www.unicode.org/glossary/#supplementary_code_point
|
| 68 |
+
static constexpr uint32_t kMinSupplementaryCodePoint = 0x010000;
|
| 69 |
+
|
| 70 |
+
// The minimum value of a unicode code point.
|
| 71 |
+
// See http://www.unicode.org/glossary/#code_point
|
| 72 |
+
static constexpr uint32_t kMinCodePoint = 0x000000;
|
| 73 |
+
|
| 74 |
+
// The maximum value of a unicode code point.
|
| 75 |
+
// See http://www.unicode.org/glossary/#code_point
|
| 76 |
+
static constexpr uint32_t kMaxCodePoint = 0x10ffff;
|
| 77 |
+
|
| 78 |
+
JsonEscaping() {}
|
| 79 |
+
virtual ~JsonEscaping() {}
|
| 80 |
+
|
| 81 |
+
// Escape the given ByteSource to the given ByteSink.
|
| 82 |
+
static void Escape(strings::ByteSource* input, strings::ByteSink* output);
|
| 83 |
+
|
| 84 |
+
// Escape the given ByteSource to the given ByteSink.
|
| 85 |
+
// This is optimized for the case where the string is all printable 7-bit
|
| 86 |
+
// ASCII and does not contain a few other characters (such as quotes).
|
| 87 |
+
static void Escape(StringPiece input, strings::ByteSink* output);
|
| 88 |
+
|
| 89 |
+
private:
|
| 90 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(JsonEscaping);
|
| 91 |
+
};
|
| 92 |
+
|
| 93 |
+
} // namespace converter
|
| 94 |
+
} // namespace util
|
| 95 |
+
} // namespace protobuf
|
| 96 |
+
} // namespace google
|
| 97 |
+
|
| 98 |
+
#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_ESCAPING_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/json_objectwriter.h
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_OBJECTWRITER_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_OBJECTWRITER_H__
|
| 33 |
+
|
| 34 |
+
#include <cstdint>
|
| 35 |
+
#include <memory>
|
| 36 |
+
#include <string>
|
| 37 |
+
|
| 38 |
+
#include <google/protobuf/io/coded_stream.h>
|
| 39 |
+
#include <google/protobuf/stubs/bytestream.h>
|
| 40 |
+
#include <google/protobuf/util/internal/structured_objectwriter.h>
|
| 41 |
+
|
| 42 |
+
// clang-format off
|
| 43 |
+
#include <google/protobuf/port_def.inc>
|
| 44 |
+
// clang-format on
|
| 45 |
+
|
| 46 |
+
namespace google {
|
| 47 |
+
namespace protobuf {
|
| 48 |
+
namespace util {
|
| 49 |
+
namespace converter {
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
// An ObjectWriter implementation that outputs JSON. This ObjectWriter
|
| 53 |
+
// supports writing a compact form or a pretty printed form.
|
| 54 |
+
//
|
| 55 |
+
// Sample usage:
|
| 56 |
+
// string output;
|
| 57 |
+
// StringOutputStream* str_stream = new StringOutputStream(&output);
|
| 58 |
+
// CodedOutputStream* out_stream = new CodedOutputStream(str_stream);
|
| 59 |
+
// JsonObjectWriter* ow = new JsonObjectWriter(" ", out_stream);
|
| 60 |
+
// ow->StartObject("")
|
| 61 |
+
// ->RenderString("name", "value")
|
| 62 |
+
// ->RenderString("emptystring", string())
|
| 63 |
+
// ->StartObject("nested")
|
| 64 |
+
// ->RenderInt64("light", 299792458);
|
| 65 |
+
// ->RenderDouble("pi", 3.141592653589793);
|
| 66 |
+
// ->EndObject()
|
| 67 |
+
// ->StartList("empty")
|
| 68 |
+
// ->EndList()
|
| 69 |
+
// ->EndObject();
|
| 70 |
+
//
|
| 71 |
+
// And then the output string would become:
|
| 72 |
+
// {
|
| 73 |
+
// "name": "value",
|
| 74 |
+
// "emptystring": "",
|
| 75 |
+
// "nested": {
|
| 76 |
+
// "light": "299792458",
|
| 77 |
+
// "pi": 3.141592653589793
|
| 78 |
+
// },
|
| 79 |
+
// "empty": []
|
| 80 |
+
// }
|
| 81 |
+
//
|
| 82 |
+
// JsonObjectWriter does not validate if calls actually result in valid JSON.
|
| 83 |
+
// For example, passing an empty name when one would be required won't result
|
| 84 |
+
// in an error, just an invalid output.
|
| 85 |
+
//
|
| 86 |
+
// Note that all int64 and uint64 are rendered as strings instead of numbers.
|
| 87 |
+
// This is because JavaScript parses numbers as 64-bit float thus int64 and
|
| 88 |
+
// uint64 would lose precision if rendered as numbers.
|
| 89 |
+
//
|
| 90 |
+
// JsonObjectWriter is thread-unsafe.
|
| 91 |
+
class PROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
|
| 92 |
+
public:
|
| 93 |
+
JsonObjectWriter(StringPiece indent_string, io::CodedOutputStream* out)
|
| 94 |
+
: element_(new Element(/*parent=*/nullptr, /*is_json_object=*/false)),
|
| 95 |
+
stream_(out),
|
| 96 |
+
sink_(out),
|
| 97 |
+
indent_string_(indent_string),
|
| 98 |
+
indent_char_('\0'),
|
| 99 |
+
indent_count_(0),
|
| 100 |
+
use_websafe_base64_for_bytes_(false) {
|
| 101 |
+
// See if we have a trivial sequence of indent characters.
|
| 102 |
+
if (!indent_string.empty()) {
|
| 103 |
+
indent_char_ = indent_string[0];
|
| 104 |
+
indent_count_ = indent_string.length();
|
| 105 |
+
for (int i = 1; i < indent_string.length(); i++) {
|
| 106 |
+
if (indent_char_ != indent_string_[i]) {
|
| 107 |
+
indent_char_ = '\0';
|
| 108 |
+
indent_count_ = 0;
|
| 109 |
+
break;
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
~JsonObjectWriter() override;
|
| 115 |
+
|
| 116 |
+
// ObjectWriter methods.
|
| 117 |
+
JsonObjectWriter* StartObject(StringPiece name) override;
|
| 118 |
+
JsonObjectWriter* EndObject() override;
|
| 119 |
+
JsonObjectWriter* StartList(StringPiece name) override;
|
| 120 |
+
JsonObjectWriter* EndList() override;
|
| 121 |
+
JsonObjectWriter* RenderBool(StringPiece name, bool value) override;
|
| 122 |
+
JsonObjectWriter* RenderInt32(StringPiece name, int32_t value) override;
|
| 123 |
+
JsonObjectWriter* RenderUint32(StringPiece name,
|
| 124 |
+
uint32_t value) override;
|
| 125 |
+
JsonObjectWriter* RenderInt64(StringPiece name, int64_t value) override;
|
| 126 |
+
JsonObjectWriter* RenderUint64(StringPiece name,
|
| 127 |
+
uint64_t value) override;
|
| 128 |
+
JsonObjectWriter* RenderDouble(StringPiece name, double value) override;
|
| 129 |
+
JsonObjectWriter* RenderFloat(StringPiece name, float value) override;
|
| 130 |
+
JsonObjectWriter* RenderString(StringPiece name,
|
| 131 |
+
StringPiece value) override;
|
| 132 |
+
JsonObjectWriter* RenderBytes(StringPiece name, StringPiece value) override;
|
| 133 |
+
JsonObjectWriter* RenderNull(StringPiece name) override;
|
| 134 |
+
virtual JsonObjectWriter* RenderNullAsEmpty(StringPiece name);
|
| 135 |
+
|
| 136 |
+
void set_use_websafe_base64_for_bytes(bool value) {
|
| 137 |
+
use_websafe_base64_for_bytes_ = value;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
protected:
|
| 141 |
+
class PROTOBUF_EXPORT Element : public BaseElement {
|
| 142 |
+
public:
|
| 143 |
+
Element(Element* parent, bool is_json_object)
|
| 144 |
+
: BaseElement(parent),
|
| 145 |
+
is_first_(true),
|
| 146 |
+
is_json_object_(is_json_object) {}
|
| 147 |
+
|
| 148 |
+
// Called before each field of the Element is to be processed.
|
| 149 |
+
// Returns true if this is the first call (processing the first field).
|
| 150 |
+
bool is_first() {
|
| 151 |
+
if (is_first_) {
|
| 152 |
+
is_first_ = false;
|
| 153 |
+
return true;
|
| 154 |
+
}
|
| 155 |
+
return false;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
// Whether we are currently rendering inside a JSON object (i.e., between
|
| 159 |
+
// StartObject() and EndObject()).
|
| 160 |
+
bool is_json_object() const { return is_json_object_; }
|
| 161 |
+
|
| 162 |
+
private:
|
| 163 |
+
bool is_first_;
|
| 164 |
+
bool is_json_object_;
|
| 165 |
+
|
| 166 |
+
GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(Element);
|
| 167 |
+
};
|
| 168 |
+
|
| 169 |
+
Element* element() override { return element_.get(); }
|
| 170 |
+
|
| 171 |
+
private:
|
| 172 |
+
class PROTOBUF_EXPORT ByteSinkWrapper : public strings::ByteSink {
|
| 173 |
+
public:
|
| 174 |
+
explicit ByteSinkWrapper(io::CodedOutputStream* stream) : stream_(stream) {}
|
| 175 |
+
~ByteSinkWrapper() override {}
|
| 176 |
+
|
| 177 |
+
// ByteSink methods.
|
| 178 |
+
void Append(const char* bytes, size_t n) override {
|
| 179 |
+
stream_->WriteRaw(bytes, n);
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
private:
|
| 183 |
+
io::CodedOutputStream* stream_;
|
| 184 |
+
|
| 185 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ByteSinkWrapper);
|
| 186 |
+
};
|
| 187 |
+
|
| 188 |
+
// Renders a simple value as a string. By default all non-string Render
|
| 189 |
+
// methods convert their argument to a string and call this method. This
|
| 190 |
+
// method can then be used to render the simple value without escaping it.
|
| 191 |
+
JsonObjectWriter* RenderSimple(StringPiece name,
|
| 192 |
+
StringPiece value) {
|
| 193 |
+
WritePrefix(name);
|
| 194 |
+
WriteRawString(value);
|
| 195 |
+
return this;
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
// Pushes a new JSON array element to the stack.
|
| 199 |
+
void PushArray() {
|
| 200 |
+
element_.reset(new Element(element_.release(), /*is_json_object=*/false));
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
// Pushes a new JSON object element to the stack.
|
| 204 |
+
void PushObject() {
|
| 205 |
+
element_.reset(new Element(element_.release(), /*is_json_object=*/true));
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
// Pops an element off of the stack and deletes the popped element.
|
| 209 |
+
void Pop() {
|
| 210 |
+
bool needs_newline = !element_->is_first();
|
| 211 |
+
element_.reset(element_->pop<Element>());
|
| 212 |
+
if (needs_newline) NewLine();
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
// If pretty printing is enabled, this will write a newline to the output,
|
| 216 |
+
// followed by optional indentation. Otherwise this method is a noop.
|
| 217 |
+
void NewLine() {
|
| 218 |
+
if (!indent_string_.empty()) {
|
| 219 |
+
size_t len = sizeof('\n') + (indent_string_.size() * element()->level());
|
| 220 |
+
|
| 221 |
+
// Take the slow-path if we don't have sufficient characters remaining in
|
| 222 |
+
// our buffer or we have a non-trivial indent string which would prevent
|
| 223 |
+
// us from using memset.
|
| 224 |
+
uint8_t* out = nullptr;
|
| 225 |
+
if (indent_count_ > 0) {
|
| 226 |
+
out = stream_->GetDirectBufferForNBytesAndAdvance(len);
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
if (out != nullptr) {
|
| 230 |
+
out[0] = '\n';
|
| 231 |
+
memset(&out[1], indent_char_, len - 1);
|
| 232 |
+
} else {
|
| 233 |
+
// Slow path, no contiguous output buffer available.
|
| 234 |
+
WriteChar('\n');
|
| 235 |
+
for (int i = 0; i < element()->level(); i++) {
|
| 236 |
+
stream_->WriteRaw(indent_string_.c_str(), indent_string_.length());
|
| 237 |
+
}
|
| 238 |
+
}
|
| 239 |
+
}
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
// Writes a prefix. This will write out any pretty printing and
|
| 243 |
+
// commas that are required, followed by the name and a ':' if
|
| 244 |
+
// the name is not null.
|
| 245 |
+
void WritePrefix(StringPiece name);
|
| 246 |
+
|
| 247 |
+
// Writes an individual character to the output.
|
| 248 |
+
void WriteChar(const char c) { stream_->WriteRaw(&c, sizeof(c)); }
|
| 249 |
+
|
| 250 |
+
// Writes a string to the output.
|
| 251 |
+
void WriteRawString(StringPiece s) {
|
| 252 |
+
stream_->WriteRaw(s.data(), s.length());
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
std::unique_ptr<Element> element_;
|
| 256 |
+
io::CodedOutputStream* stream_;
|
| 257 |
+
ByteSinkWrapper sink_;
|
| 258 |
+
const std::string indent_string_;
|
| 259 |
+
|
| 260 |
+
// For the common case of indent being a single character repeated.
|
| 261 |
+
char indent_char_;
|
| 262 |
+
int indent_count_;
|
| 263 |
+
|
| 264 |
+
// Whether to use regular or websafe base64 encoding for byte fields. Defaults
|
| 265 |
+
// to regular base64 encoding.
|
| 266 |
+
bool use_websafe_base64_for_bytes_;
|
| 267 |
+
|
| 268 |
+
GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(JsonObjectWriter);
|
| 269 |
+
};
|
| 270 |
+
|
| 271 |
+
} // namespace converter
|
| 272 |
+
} // namespace util
|
| 273 |
+
} // namespace protobuf
|
| 274 |
+
} // namespace google
|
| 275 |
+
|
| 276 |
+
#include <google/protobuf/port_undef.inc>
|
| 277 |
+
|
| 278 |
+
#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_OBJECTWRITER_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/json_stream_parser.h
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_STREAM_PARSER_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_STREAM_PARSER_H__
|
| 33 |
+
|
| 34 |
+
#include <cstdint>
|
| 35 |
+
#include <stack>
|
| 36 |
+
#include <string>
|
| 37 |
+
|
| 38 |
+
#include <google/protobuf/stubs/common.h>
|
| 39 |
+
#include <google/protobuf/stubs/status.h>
|
| 40 |
+
#include <google/protobuf/stubs/strutil.h>
|
| 41 |
+
#include <google/protobuf/stubs/status.h>
|
| 42 |
+
|
| 43 |
+
// Must be included last.
|
| 44 |
+
#include <google/protobuf/port_def.inc>
|
| 45 |
+
|
| 46 |
+
namespace google {
|
| 47 |
+
namespace protobuf {
|
| 48 |
+
namespace util {
|
| 49 |
+
namespace converter {
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
class ObjectWriter;
|
| 53 |
+
|
| 54 |
+
// A JSON parser that can parse a stream of JSON chunks rather than needing the
|
| 55 |
+
// entire JSON string up front. It is a modified version of the parser in
|
| 56 |
+
// //net/proto/json/json-parser.h that has been changed in the following ways:
|
| 57 |
+
// - Changed from recursion to an explicit stack to allow resumption
|
| 58 |
+
// - Added support for int64 and uint64 numbers
|
| 59 |
+
// - Removed support for octal and decimal escapes
|
| 60 |
+
// - Removed support for numeric keys
|
| 61 |
+
// - Removed support for functions (javascript)
|
| 62 |
+
// - Removed some lax-comma support (but kept trailing comma support)
|
| 63 |
+
// - Writes directly to an ObjectWriter rather than using subclassing
|
| 64 |
+
//
|
| 65 |
+
// Here is an example usage:
|
| 66 |
+
// JsonStreamParser parser(ow_.get());
|
| 67 |
+
// util::Status result = parser.Parse(chunk1);
|
| 68 |
+
// result.Update(parser.Parse(chunk2));
|
| 69 |
+
// result.Update(parser.FinishParse());
|
| 70 |
+
// GOOGLE_DCHECK(result.ok()) << "Failed to parse JSON";
|
| 71 |
+
//
|
| 72 |
+
// This parser is thread-compatible as long as only one thread is calling a
|
| 73 |
+
// Parse() method at a time.
|
| 74 |
+
class PROTOBUF_EXPORT JsonStreamParser {
|
| 75 |
+
public:
|
| 76 |
+
// Creates a JsonStreamParser that will write to the given ObjectWriter.
|
| 77 |
+
explicit JsonStreamParser(ObjectWriter* ow);
|
| 78 |
+
virtual ~JsonStreamParser();
|
| 79 |
+
|
| 80 |
+
// Parses a UTF-8 encoded JSON string from a StringPiece. If the returned
|
| 81 |
+
// status is non-ok, the status might contain a payload ParseErrorType with
|
| 82 |
+
// type_url kParseErrorTypeUrl and a payload containing string snippet of the
|
| 83 |
+
// error with type_url kParseErrorSnippetUrl.
|
| 84 |
+
util::Status Parse(StringPiece json);
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
// Finish parsing the JSON string. If the returned status is non-ok, the
|
| 88 |
+
// status might contain a payload ParseErrorType with type_url
|
| 89 |
+
// kParseErrorTypeUrl and a payload containing string snippet of the error
|
| 90 |
+
// with type_url kParseErrorSnippetUrl.
|
| 91 |
+
util::Status FinishParse();
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
// Sets the max recursion depth of JSON message to be deserialized. JSON
|
| 95 |
+
// messages over this depth will fail to be deserialized.
|
| 96 |
+
// Default value is 100.
|
| 97 |
+
void set_max_recursion_depth(int max_depth) {
|
| 98 |
+
max_recursion_depth_ = max_depth;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
// Denotes the cause of error.
|
| 102 |
+
enum ParseErrorType {
|
| 103 |
+
UNKNOWN_PARSE_ERROR,
|
| 104 |
+
OCTAL_OR_HEX_ARE_NOT_VALID_JSON_VALUES,
|
| 105 |
+
EXPECTED_COLON,
|
| 106 |
+
EXPECTED_COMMA_OR_BRACKET,
|
| 107 |
+
EXPECTED_VALUE,
|
| 108 |
+
EXPECTED_COMMA_OR_BRACES,
|
| 109 |
+
EXPECTED_OBJECT_KEY_OR_BRACES,
|
| 110 |
+
EXPECTED_VALUE_OR_BRACKET,
|
| 111 |
+
INVALID_KEY_OR_VARIABLE_NAME,
|
| 112 |
+
NON_UTF_8,
|
| 113 |
+
PARSING_TERMINATED_BEFORE_END_OF_INPUT,
|
| 114 |
+
UNEXPECTED_TOKEN,
|
| 115 |
+
EXPECTED_CLOSING_QUOTE,
|
| 116 |
+
ILLEGAL_HEX_STRING,
|
| 117 |
+
INVALID_ESCAPE_SEQUENCE,
|
| 118 |
+
MISSING_LOW_SURROGATE,
|
| 119 |
+
INVALID_LOW_SURROGATE,
|
| 120 |
+
INVALID_UNICODE,
|
| 121 |
+
UNABLE_TO_PARSE_NUMBER,
|
| 122 |
+
NUMBER_EXCEEDS_RANGE_DOUBLE
|
| 123 |
+
};
|
| 124 |
+
|
| 125 |
+
private:
|
| 126 |
+
friend class JsonStreamParserTest;
|
| 127 |
+
// Return the current recursion depth.
|
| 128 |
+
int recursion_depth() { return recursion_depth_; }
|
| 129 |
+
|
| 130 |
+
enum TokenType {
|
| 131 |
+
BEGIN_STRING, // " or '
|
| 132 |
+
BEGIN_NUMBER, // - or digit
|
| 133 |
+
BEGIN_TRUE, // true
|
| 134 |
+
BEGIN_FALSE, // false
|
| 135 |
+
BEGIN_NULL, // null
|
| 136 |
+
BEGIN_OBJECT, // {
|
| 137 |
+
END_OBJECT, // }
|
| 138 |
+
BEGIN_ARRAY, // [
|
| 139 |
+
END_ARRAY, // ]
|
| 140 |
+
ENTRY_SEPARATOR, // :
|
| 141 |
+
VALUE_SEPARATOR, // ,
|
| 142 |
+
BEGIN_KEY, // letter, _, $ or digit. Must begin with non-digit
|
| 143 |
+
UNKNOWN // Unknown token or we ran out of the stream.
|
| 144 |
+
};
|
| 145 |
+
|
| 146 |
+
enum ParseType {
|
| 147 |
+
VALUE, // Expects a {, [, true, false, null, string or number
|
| 148 |
+
OBJ_MID, // Expects a ',' or }
|
| 149 |
+
ENTRY, // Expects a key or }
|
| 150 |
+
ENTRY_MID, // Expects a :
|
| 151 |
+
ARRAY_VALUE, // Expects a value or ]
|
| 152 |
+
ARRAY_MID // Expects a ',' or ]
|
| 153 |
+
};
|
| 154 |
+
|
| 155 |
+
// Holds the result of parsing a number
|
| 156 |
+
struct NumberResult {
|
| 157 |
+
enum Type { DOUBLE, INT, UINT };
|
| 158 |
+
Type type;
|
| 159 |
+
union {
|
| 160 |
+
double double_val;
|
| 161 |
+
int64_t int_val;
|
| 162 |
+
uint64_t uint_val;
|
| 163 |
+
};
|
| 164 |
+
};
|
| 165 |
+
|
| 166 |
+
// Parses a single chunk of JSON, returning an error if the JSON was invalid.
|
| 167 |
+
util::Status ParseChunk(StringPiece chunk);
|
| 168 |
+
|
| 169 |
+
// Runs the parser based on stack_ and p_, until the stack is empty or p_ runs
|
| 170 |
+
// out of data. If we unexpectedly run out of p_ we push the latest back onto
|
| 171 |
+
// the stack and return.
|
| 172 |
+
util::Status RunParser();
|
| 173 |
+
|
| 174 |
+
// Parses a value from p_ and writes it to ow_.
|
| 175 |
+
// A value may be an object, array, true, false, null, string or number.
|
| 176 |
+
util::Status ParseValue(TokenType type);
|
| 177 |
+
|
| 178 |
+
// Parses a string and writes it out to the ow_.
|
| 179 |
+
util::Status ParseString();
|
| 180 |
+
|
| 181 |
+
// Parses a string, storing the result in parsed_.
|
| 182 |
+
util::Status ParseStringHelper();
|
| 183 |
+
|
| 184 |
+
// This function parses unicode escape sequences in strings. It returns an
|
| 185 |
+
// error when there's a parsing error, either the size is not the expected
|
| 186 |
+
// size or a character is not a hex digit. When it returns str will contain
|
| 187 |
+
// what has been successfully parsed so far.
|
| 188 |
+
util::Status ParseUnicodeEscape();
|
| 189 |
+
|
| 190 |
+
// Expects p_ to point to a JSON number, writes the number to the writer using
|
| 191 |
+
// the appropriate Render method based on the type of number.
|
| 192 |
+
util::Status ParseNumber();
|
| 193 |
+
|
| 194 |
+
// Parse a number into a NumberResult, reporting an error if no number could
|
| 195 |
+
// be parsed. This method will try to parse into a uint64, int64, or double
|
| 196 |
+
// based on whether the number was positive or negative or had a decimal
|
| 197 |
+
// component.
|
| 198 |
+
util::Status ParseNumberHelper(NumberResult* result);
|
| 199 |
+
|
| 200 |
+
// Parse a number as double into a NumberResult.
|
| 201 |
+
util::Status ParseDoubleHelper(const std::string& number,
|
| 202 |
+
NumberResult* result);
|
| 203 |
+
|
| 204 |
+
// Handles a { during parsing of a value.
|
| 205 |
+
util::Status HandleBeginObject();
|
| 206 |
+
|
| 207 |
+
// Parses from the ENTRY state.
|
| 208 |
+
util::Status ParseEntry(TokenType type);
|
| 209 |
+
|
| 210 |
+
// Parses from the ENTRY_MID state.
|
| 211 |
+
util::Status ParseEntryMid(TokenType type);
|
| 212 |
+
|
| 213 |
+
// Parses from the OBJ_MID state.
|
| 214 |
+
util::Status ParseObjectMid(TokenType type);
|
| 215 |
+
|
| 216 |
+
// Handles a [ during parsing of a value.
|
| 217 |
+
util::Status HandleBeginArray();
|
| 218 |
+
|
| 219 |
+
// Parses from the ARRAY_VALUE state.
|
| 220 |
+
util::Status ParseArrayValue(TokenType type);
|
| 221 |
+
|
| 222 |
+
// Parses from the ARRAY_MID state.
|
| 223 |
+
util::Status ParseArrayMid(TokenType type);
|
| 224 |
+
|
| 225 |
+
// Expects p_ to point to an unquoted literal
|
| 226 |
+
util::Status ParseTrue();
|
| 227 |
+
util::Status ParseFalse();
|
| 228 |
+
util::Status ParseNull();
|
| 229 |
+
util::Status ParseEmptyNull();
|
| 230 |
+
|
| 231 |
+
// Whether an empty-null is allowed in the current state.
|
| 232 |
+
bool IsEmptyNullAllowed(TokenType type);
|
| 233 |
+
|
| 234 |
+
// Whether the whole input is all whitespaces.
|
| 235 |
+
bool IsInputAllWhiteSpaces(TokenType type);
|
| 236 |
+
|
| 237 |
+
// Report a failure as a util::Status.
|
| 238 |
+
util::Status ReportFailure(StringPiece message,
|
| 239 |
+
ParseErrorType parse_code);
|
| 240 |
+
|
| 241 |
+
// Report a failure due to an UNKNOWN token type. We check if we hit the
|
| 242 |
+
// end of the stream and if we're finishing or not to detect what type of
|
| 243 |
+
// status to return in this case.
|
| 244 |
+
util::Status ReportUnknown(StringPiece message,
|
| 245 |
+
ParseErrorType parse_code);
|
| 246 |
+
|
| 247 |
+
// Helper function to check recursion depth and increment it. It will return
|
| 248 |
+
// OkStatus() if the current depth is allowed. Otherwise an error is returned.
|
| 249 |
+
// key is used for error reporting.
|
| 250 |
+
util::Status IncrementRecursionDepth(StringPiece key) const;
|
| 251 |
+
|
| 252 |
+
// Advance p_ past all whitespace or until the end of the string.
|
| 253 |
+
void SkipWhitespace();
|
| 254 |
+
|
| 255 |
+
// Advance p_ one UTF-8 character
|
| 256 |
+
void Advance();
|
| 257 |
+
|
| 258 |
+
// Expects p_ to point to the beginning of a key.
|
| 259 |
+
util::Status ParseKey();
|
| 260 |
+
|
| 261 |
+
// Return the type of the next token at p_.
|
| 262 |
+
TokenType GetNextTokenType();
|
| 263 |
+
|
| 264 |
+
// The object writer to write parse events to.
|
| 265 |
+
ObjectWriter* ow_;
|
| 266 |
+
|
| 267 |
+
// The stack of parsing we still need to do. When the stack runs empty we will
|
| 268 |
+
// have parsed a single value from the root (e.g. an object or list).
|
| 269 |
+
std::stack<ParseType> stack_;
|
| 270 |
+
|
| 271 |
+
// Contains any leftover text from a previous chunk that we weren't able to
|
| 272 |
+
// fully parse, for example the start of a key or number.
|
| 273 |
+
std::string leftover_;
|
| 274 |
+
|
| 275 |
+
// The current chunk of JSON being parsed. Primarily used for providing
|
| 276 |
+
// context during error reporting.
|
| 277 |
+
StringPiece json_;
|
| 278 |
+
|
| 279 |
+
// A pointer within the current JSON being parsed, used to track location.
|
| 280 |
+
StringPiece p_;
|
| 281 |
+
|
| 282 |
+
// Stores the last key read, as we separate parsing of keys and values.
|
| 283 |
+
StringPiece key_;
|
| 284 |
+
|
| 285 |
+
// Storage for key_ if we need to keep ownership, for example between chunks
|
| 286 |
+
// or if the key was unescaped from a JSON string.
|
| 287 |
+
std::string key_storage_;
|
| 288 |
+
|
| 289 |
+
// True during the FinishParse() call, so we know that any errors are fatal.
|
| 290 |
+
// For example an unterminated string will normally result in cancelling and
|
| 291 |
+
// trying during the next chunk, but during FinishParse() it is an error.
|
| 292 |
+
bool finishing_;
|
| 293 |
+
|
| 294 |
+
// Whether non whitespace tokens have been seen during parsing.
|
| 295 |
+
// It is used to handle the case of a pure whitespace stream input.
|
| 296 |
+
bool seen_non_whitespace_;
|
| 297 |
+
|
| 298 |
+
// The JsonStreamParser requires a root element by default and it will raise
|
| 299 |
+
// error if the root element is missing. If `allow_no_root_element_` is true,
|
| 300 |
+
// the JsonStreamParser can also handle this case.
|
| 301 |
+
bool allow_no_root_element_;
|
| 302 |
+
|
| 303 |
+
// String we parsed during a call to ParseStringHelper().
|
| 304 |
+
StringPiece parsed_;
|
| 305 |
+
|
| 306 |
+
// Storage for the string we parsed. This may be empty if the string was able
|
| 307 |
+
// to be parsed directly from the input.
|
| 308 |
+
std::string parsed_storage_;
|
| 309 |
+
|
| 310 |
+
// The character that opened the string, either ' or ".
|
| 311 |
+
// A value of 0 indicates that string parsing is not in process.
|
| 312 |
+
char string_open_;
|
| 313 |
+
|
| 314 |
+
// Storage for the chunk that are being parsed in ParseChunk().
|
| 315 |
+
std::string chunk_storage_;
|
| 316 |
+
|
| 317 |
+
// Whether to allow non UTF-8 encoded input and replace invalid code points.
|
| 318 |
+
bool coerce_to_utf8_;
|
| 319 |
+
|
| 320 |
+
// Replacement character for invalid UTF-8 code points.
|
| 321 |
+
std::string utf8_replacement_character_;
|
| 322 |
+
|
| 323 |
+
// Whether allows empty string represented null array value or object entry
|
| 324 |
+
// value.
|
| 325 |
+
bool allow_empty_null_;
|
| 326 |
+
|
| 327 |
+
// Whether unquoted object keys can contain embedded non-alphanumeric
|
| 328 |
+
// characters when this is unambiguous for parsing.
|
| 329 |
+
bool allow_permissive_key_naming_;
|
| 330 |
+
|
| 331 |
+
// Whether allows out-of-range floating point numbers or reject them.
|
| 332 |
+
bool loose_float_number_conversion_;
|
| 333 |
+
|
| 334 |
+
// Tracks current recursion depth.
|
| 335 |
+
mutable int recursion_depth_;
|
| 336 |
+
|
| 337 |
+
// Maximum allowed recursion depth.
|
| 338 |
+
int max_recursion_depth_;
|
| 339 |
+
|
| 340 |
+
GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(JsonStreamParser);
|
| 341 |
+
};
|
| 342 |
+
|
| 343 |
+
} // namespace converter
|
| 344 |
+
} // namespace util
|
| 345 |
+
} // namespace protobuf
|
| 346 |
+
} // namespace google
|
| 347 |
+
|
| 348 |
+
#include <google/protobuf/port_undef.inc>
|
| 349 |
+
|
| 350 |
+
#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_JSON_STREAM_PARSER_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/location_tracker.h
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_LOCATION_TRACKER_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_UTIL_INTERNAL_LOCATION_TRACKER_H__
|
| 33 |
+
|
| 34 |
+
#include <string>
|
| 35 |
+
|
| 36 |
+
#include <google/protobuf/stubs/common.h>
|
| 37 |
+
|
| 38 |
+
// Must be included last.
|
| 39 |
+
#include <google/protobuf/port_def.inc>
|
| 40 |
+
|
| 41 |
+
namespace google {
|
| 42 |
+
namespace protobuf {
|
| 43 |
+
namespace util {
|
| 44 |
+
namespace converter {
|
| 45 |
+
|
| 46 |
+
// LocationTrackerInterface is an interface for classes that track
|
| 47 |
+
// the location information for the purpose of error reporting.
|
| 48 |
+
class PROTOBUF_EXPORT LocationTrackerInterface {
|
| 49 |
+
public:
|
| 50 |
+
virtual ~LocationTrackerInterface() {}
|
| 51 |
+
|
| 52 |
+
// Returns the object location as human readable string.
|
| 53 |
+
virtual std::string ToString() const = 0;
|
| 54 |
+
|
| 55 |
+
protected:
|
| 56 |
+
LocationTrackerInterface() {}
|
| 57 |
+
|
| 58 |
+
private:
|
| 59 |
+
// Please do not add any data members to this class.
|
| 60 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LocationTrackerInterface);
|
| 61 |
+
};
|
| 62 |
+
|
| 63 |
+
} // namespace converter
|
| 64 |
+
} // namespace util
|
| 65 |
+
} // namespace protobuf
|
| 66 |
+
} // namespace google
|
| 67 |
+
|
| 68 |
+
#include <google/protobuf/port_undef.inc>
|
| 69 |
+
|
| 70 |
+
#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_LOCATION_TRACKER_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/mock_error_listener.h
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_MOCK_ERROR_LISTENER_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_UTIL_INTERNAL_MOCK_ERROR_LISTENER_H__
|
| 33 |
+
|
| 34 |
+
#include <gmock/gmock.h>
|
| 35 |
+
#include <google/protobuf/stubs/strutil.h>
|
| 36 |
+
#include <google/protobuf/util/internal/error_listener.h>
|
| 37 |
+
#include <google/protobuf/util/internal/location_tracker.h>
|
| 38 |
+
|
| 39 |
+
namespace google {
|
| 40 |
+
namespace protobuf {
|
| 41 |
+
namespace util {
|
| 42 |
+
namespace converter {
|
| 43 |
+
|
| 44 |
+
class MockErrorListener : public ErrorListener {
|
| 45 |
+
public:
|
| 46 |
+
MockErrorListener() {}
|
| 47 |
+
~MockErrorListener() override {}
|
| 48 |
+
|
| 49 |
+
MOCK_METHOD(void, InvalidName,
|
| 50 |
+
(const LocationTrackerInterface& loc,
|
| 51 |
+
StringPiece unknown_name, StringPiece message),
|
| 52 |
+
(override));
|
| 53 |
+
MOCK_METHOD(void, InvalidValue,
|
| 54 |
+
(const LocationTrackerInterface& loc, StringPiece type_name,
|
| 55 |
+
StringPiece value),
|
| 56 |
+
(override));
|
| 57 |
+
MOCK_METHOD(void, MissingField,
|
| 58 |
+
(const LocationTrackerInterface& loc,
|
| 59 |
+
StringPiece missing_name),
|
| 60 |
+
(override));
|
| 61 |
+
};
|
| 62 |
+
|
| 63 |
+
} // namespace converter
|
| 64 |
+
} // namespace util
|
| 65 |
+
} // namespace protobuf
|
| 66 |
+
} // namespace google
|
| 67 |
+
|
| 68 |
+
#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_MOCK_ERROR_LISTENER_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/object_location_tracker.h
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_LOCATION_TRACKER_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_LOCATION_TRACKER_H__
|
| 33 |
+
|
| 34 |
+
#include <string>
|
| 35 |
+
|
| 36 |
+
#include <google/protobuf/stubs/common.h>
|
| 37 |
+
#include <google/protobuf/util/internal/location_tracker.h>
|
| 38 |
+
|
| 39 |
+
namespace google {
|
| 40 |
+
namespace protobuf {
|
| 41 |
+
namespace util {
|
| 42 |
+
namespace converter {
|
| 43 |
+
|
| 44 |
+
// An empty concrete implementation of LocationTrackerInterface.
|
| 45 |
+
class ObjectLocationTracker : public LocationTrackerInterface {
|
| 46 |
+
public:
|
| 47 |
+
// Creates an empty location tracker.
|
| 48 |
+
ObjectLocationTracker() {}
|
| 49 |
+
|
| 50 |
+
~ObjectLocationTracker() override {}
|
| 51 |
+
|
| 52 |
+
// Returns empty because nothing is tracked.
|
| 53 |
+
std::string ToString() const override { return ""; }
|
| 54 |
+
|
| 55 |
+
private:
|
| 56 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectLocationTracker);
|
| 57 |
+
};
|
| 58 |
+
|
| 59 |
+
} // namespace converter
|
| 60 |
+
} // namespace util
|
| 61 |
+
} // namespace protobuf
|
| 62 |
+
} // namespace google
|
| 63 |
+
|
| 64 |
+
#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_LOCATION_TRACKER_H__
|
videochat2/lib/python3.10/site-packages/tensorflow/include/google/protobuf/util/internal/object_source.h
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Protocol Buffers - Google's data interchange format
|
| 2 |
+
// Copyright 2008 Google Inc. All rights reserved.
|
| 3 |
+
// https://developers.google.com/protocol-buffers/
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
// * Redistributions in binary form must reproduce the above
|
| 12 |
+
// copyright notice, this list of conditions and the following disclaimer
|
| 13 |
+
// in the documentation and/or other materials provided with the
|
| 14 |
+
// distribution.
|
| 15 |
+
// * Neither the name of Google Inc. nor the names of its
|
| 16 |
+
// contributors may be used to endorse or promote products derived from
|
| 17 |
+
// this software without specific prior written permission.
|
| 18 |
+
//
|
| 19 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 20 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 21 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 22 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 23 |
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 24 |
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 25 |
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 26 |
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 27 |
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 28 |
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 30 |
+
|
| 31 |
+
#ifndef GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_SOURCE_H__
|
| 32 |
+
#define GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_SOURCE_H__
|
| 33 |
+
|
| 34 |
+
#include <google/protobuf/stubs/common.h>
|
| 35 |
+
#include <google/protobuf/stubs/status.h>
|
| 36 |
+
#include <google/protobuf/stubs/strutil.h>
|
| 37 |
+
#include <google/protobuf/stubs/status.h>
|
| 38 |
+
|
| 39 |
+
// Must be included last.
|
| 40 |
+
#include <google/protobuf/port_def.inc>
|
| 41 |
+
|
| 42 |
+
namespace google {
|
| 43 |
+
namespace protobuf {
|
| 44 |
+
namespace util {
|
| 45 |
+
namespace converter {
|
| 46 |
+
|
| 47 |
+
class ObjectWriter;
|
| 48 |
+
|
| 49 |
+
// An ObjectSource is anything that can write to an ObjectWriter.
|
| 50 |
+
// Implementation of this interface typically provide constructors or
|
| 51 |
+
// factory methods to create an instance based on some source data, for
|
| 52 |
+
// example, a character stream, or protobuf.
|
| 53 |
+
//
|
| 54 |
+
// Derived classes could be thread-unsafe.
|
| 55 |
+
class PROTOBUF_EXPORT ObjectSource {
|
| 56 |
+
public:
|
| 57 |
+
virtual ~ObjectSource() {}
|
| 58 |
+
|
| 59 |
+
// Writes to the ObjectWriter
|
| 60 |
+
virtual util::Status WriteTo(ObjectWriter* ow) const {
|
| 61 |
+
return NamedWriteTo("", ow);
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
// Writes to the ObjectWriter with a custom name for the message.
|
| 65 |
+
// This is useful when you chain ObjectSource together by embedding one
|
| 66 |
+
// within another.
|
| 67 |
+
virtual util::Status NamedWriteTo(StringPiece name,
|
| 68 |
+
ObjectWriter* ow) const = 0;
|
| 69 |
+
|
| 70 |
+
protected:
|
| 71 |
+
ObjectSource() {}
|
| 72 |
+
|
| 73 |
+
private:
|
| 74 |
+
// Do not add any data members to this class.
|
| 75 |
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectSource);
|
| 76 |
+
};
|
| 77 |
+
|
| 78 |
+
} // namespace converter
|
| 79 |
+
} // namespace util
|
| 80 |
+
} // namespace protobuf
|
| 81 |
+
} // namespace google
|
| 82 |
+
|
| 83 |
+
#include <google/protobuf/port_undef.inc>
|
| 84 |
+
|
| 85 |
+
#endif // GOOGLE_PROTOBUF_UTIL_INTERNAL_OBJECT_SOURCE_H__
|