Go to the documentation of this file.
35 #include <google/protobuf/wire_format_lite.h>
42 #include <google/protobuf/stubs/logging.h>
43 #include <google/protobuf/stubs/common.h>
44 #include <google/protobuf/stubs/stringprintf.h>
45 #include <google/protobuf/io/coded_stream.h>
46 #include <google/protobuf/io/zero_copy_stream.h>
47 #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
50 #include <google/protobuf/port_def.inc>
56 #if !defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)
68 io::CodedOutputStream::StaticVarintSize32<
70 io::CodedOutputStream::StaticVarintSize32<
72 io::CodedOutputStream::StaticVarintSize32<
74 io::CodedOutputStream::StaticVarintSize32<
79 static_cast<CppType
>(0),
130 if (!
input->ReadVarint64(&
value))
return false;
135 if (!
input->ReadLittleEndian64(&
value))
return false;
145 if (!
input->IncrementRecursionDepth())
return false;
147 input->DecrementRecursionDepth();
149 if (!
input->LastTagWas(
161 if (!
input->ReadLittleEndian32(&
value))
return false;
177 if (!
input->ReadVarint64(&
value))
return false;
184 if (!
input->ReadLittleEndian64(&
value))
return false;
202 if (!
input->IncrementRecursionDepth())
return false;
204 input->DecrementRecursionDepth();
206 if (!
input->LastTagWas(
218 if (!
input->ReadLittleEndian32(&
value))
return false;
302 while (
input->BytesUntilLimit() > 0) {
304 if (!ReadPrimitive<int, WireFormatLite::TYPE_ENUM>(
input, &
value)) {
307 if (is_valid ==
nullptr || is_valid(
value)) {
312 unknown_fields_stream->WriteVarint32(
tag);
313 unknown_fields_stream->WriteVarint32(
value);
316 input->PopLimit(limit);
320 #if !defined(PROTOBUF_LITTLE_ENDIAN)
352 #endif // !defined(PROTOBUF_LITTLE_ENDIAN)
354 template <
typename CType>
356 #if defined(PROTOBUF_LITTLE_ENDIAN)
357 output->WriteRaw(
reinterpret_cast<const char*
>(
a),
n *
sizeof(
a[0]));
359 const int kAtATime = 128;
361 for (
int i = 0;
i <
n;
i += kAtATime) {
364 for (
int j = 0; j < to_do; j++) {
365 EncodeFixedSizeValue(
a[
i + j],
ptr);
375 WriteArray<float>(a, n,
output);
380 WriteArray<double>(a, n,
output);
385 WriteArray<uint32_t>(a, n,
output);
390 WriteArray<uint64_t>(a, n,
output);
395 WriteArray<int32_t>(a, n,
output);
400 WriteArray<int64_t>(a, n,
output);
405 WriteArray<bool>(a, n,
output);
574 bool emit_stacktrace) {
576 (void)emit_stacktrace;
578 if (field_name !=
nullptr) {
581 GOOGLE_LOG(
ERROR) <<
"String field" << quoted_field_name <<
" contains invalid "
582 <<
"UTF-8 data when " << operation_str <<
" a protocol "
583 <<
"buffer. Use the 'bytes' type if you intend to send raw "
584 <<
"bytes. " << stacktrace;
588 const char* field_name) {
590 const char* operation_str =
nullptr;
593 operation_str =
"parsing";
596 operation_str =
"serializing";
608 template <
bool ZigZag,
bool SignExtended,
typename T>
610 static_assert(
sizeof(
T) == 4,
"This routine only works for 32 bit integers");
614 "Cannot ZigZag encode unsigned types");
618 "Cannot SignExtended unsigned types");
619 static_assert(!(SignExtended && ZigZag),
620 "Cannot SignExtended and ZigZag on the same type");
623 for (
int i = 0;
i <
n;
i++) {
627 }
else if (SignExtended) {
635 if (
x > 0x3FFF)
sum++;
636 if (
x > 0x1FFFFF)
sum++;
637 if (
x > 0xFFFFFFF)
sum++;
639 if (SignExtended)
sum += msb_sum * 5;
643 template <
bool ZigZag,
typename T>
645 static_assert(
sizeof(
T) == 8,
"This routine only works for 64 bit integers");
648 "Cannot ZigZag encode unsigned types");
650 for (
int i = 0;
i <
n;
i++) {
662 if (
x > 0x3FFF)
sum++;
663 if (
x > 0x1FFFFF)
sum++;
664 if (
x > 0xFFFFFFF)
sum++;
673 #if defined(__SSE__) && defined(__clang__)
675 return VarintSize<false, true>(
value.data(),
value.size());
679 return VarintSize<false, false>(
value.data(),
value.size());
683 return VarintSize<true, false>(
value.data(),
value.size());
688 return VarintSize<false, true>(
value.data(),
value.size());
691 #else // !(defined(__SSE4_1__) && defined(__clang__))
695 const int n =
value.size();
696 for (
int i = 0;
i <
n;
i++) {
704 const int n =
value.size();
705 for (
int i = 0;
i <
n;
i++) {
713 const int n =
value.size();
714 for (
int i = 0;
i <
n;
i++) {
722 const int n =
value.size();
723 for (
int i = 0;
i <
n;
i++) {
735 #define USE_SSE_FOR_64_BIT_INTEGER_ARRAYS 0
736 #if USE_SSE_FOR_64_BIT_INTEGER_ARRAYS
738 return VarintSize64<false>(
value.data(),
value.size());
742 return VarintSize64<false>(
value.data(),
value.size());
746 return VarintSize64<true>(
value.data(),
value.size());
753 const int n =
value.size();
754 for (
int i = 0;
i <
n;
i++) {
762 const int n =
value.size();
763 for (
int i = 0;
i <
n;
i++) {
771 const int n =
value.size();
772 for (
int i = 0;
i <
n;
i++) {
784 #include <google/protobuf/port_undef.inc>
const Descriptor::ReservedRange value
static size_t VarintSize(const T *data, const int n)
void WriteVarint64(uint64 value)
double sum(const T &container, F functor)
#define T(upbtypeconst, upbtype, ctype, default_value)
static size_t VarintSize64(const T *data, const int n)
static void * tag(intptr_t t)
const PROTOBUF_EXPORT std::string & GetEmptyStringAlreadyInited()
GRPC_CUSTOM_MESSAGELITE MessageLite
unsigned __int64 uint64_t
GRPC_CUSTOM_CODEDINPUTSTREAM CodedInputStream
string StringPrintf(const char *format,...)
static PROTOBUF_ALWAYS_INLINE bool ReadBytesToString(io::CodedInputStream *input, std::string *value)
virtual void SkipUnknownEnum(int field_number, int value)
GRPC_CUSTOM_CODEDOUTPUTSTREAM CodedOutputStream
static const LogLevel ERROR
void PrintUTF8ErrorLog(const char *field_name, const char *operation_str, bool emit_stacktrace)
constexpr size_t kInt32MaxSize
virtual bool SkipMessage(io::CodedInputStream *input)
bool SkipMessage(io::CodedInputStream *input) override
virtual bool SkipField(io::CodedInputStream *input, uint32 tag)
bool SkipField(io::CodedInputStream *input, uint32 tag) override
PROTOBUF_EXPORT bool IsStructurallyValidUTF8(const char *buf, int len)
static void WriteArray(const CType *a, int n, io::CodedOutputStream *output)
std::array< int64_t, Size > values
void SkipUnknownEnum(int field_number, int value) override
#define GOOGLE_LOG(LEVEL)
void WriteVarint32(uint32 value)
#define GOOGLE_CHECK_LE(A, B)
io::CodedOutputStream * unknown_fields_
grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:53