Go to the documentation of this file.
109 #ifndef GOOGLE_PROTOBUF_IO_CODED_STREAM_H__
110 #define GOOGLE_PROTOBUF_IO_CODED_STREAM_H__
119 #if !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)
120 #define PROTOBUF_LITTLE_ENDIAN 1
122 #if _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)
125 #pragma runtime_checks("c", off)
128 #include <sys/param.h>
129 #if ((defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \
130 (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN)) && \
131 !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)
132 #define PROTOBUF_LITTLE_ENDIAN 1
140 #include <google/protobuf/port_def.inc>
146 class MessageFactory;
147 class ZeroCopyCodedInputStream;
151 class EpsCopyByteStream;
157 class CodedInputStream;
158 class CodedOutputStream;
161 class ZeroCopyInputStream;
162 class ZeroCopyOutputStream;
192 inline bool IsFlat()
const;
205 bool GetDirectBufferPointer(
const void**
data,
int*
size);
209 PROTOBUF_ALWAYS_INLINE
210 void GetDirectBufferPointerInline(
const void**
data,
int*
size);
217 PROTOBUF_ALWAYS_INLINE
218 bool InternalReadRawInline(
void*
buffer,
int size);
224 PROTOBUF_ALWAYS_INLINE
258 bool ReadVarintSizeAsInt(
int*
value);
269 return last_tag_ = ReadTagNoLastTag();
272 PROTOBUF_ALWAYS_INLINE
uint32 ReadTagNoLastTag();
282 PROTOBUF_ALWAYS_INLINE
284 std::pair<uint32, bool> result = ReadTagWithCutoffNoLastTag(cutoff);
285 last_tag_ = result.first;
289 PROTOBUF_ALWAYS_INLINE
290 std::pair<uint32, bool> ReadTagWithCutoffNoLastTag(
uint32 cutoff);
299 PROTOBUF_ALWAYS_INLINE
bool ExpectTag(
uint32 expected);
308 PROTOBUF_ALWAYS_INLINE
328 bool LastTagWas(
uint32 expected);
337 bool ConsumedEntireMessage();
363 Limit PushLimit(
int byte_limit);
367 void PopLimit(
Limit limit);
371 int BytesUntilLimit()
const;
374 int CurrentPosition()
const;
393 void SetTotalBytesLimit(
int total_bytes_limit);
395 PROTOBUF_DEPRECATED_MSG(
396 "Please use the single parameter version of SetTotalBytesLimit(). The "
397 "second parameter is ignored.")
398 void SetTotalBytesLimit(
int total_bytes_limit,
int) {
399 SetTotalBytesLimit(total_bytes_limit);
404 int BytesUntilTotalBytesLimit()
const;
413 void SetRecursionLimit(
int limit);
420 bool IncrementRecursionDepth();
423 void DecrementRecursionDepth();
428 void UnsafeDecrementRecursionDepth();
435 std::pair<CodedInputStream::Limit, int> IncrementRecursionDepthAndPushLimit(
439 Limit ReadLengthAndPushLimit();
448 bool DecrementRecursionDepthAndPopLimit(Limit limit);
455 bool CheckEntireMessageConsumedAndPopLimit(Limit limit);
590 bool SkipFallback(
int count,
int original_buffer_size);
593 void Advance(
int amount);
596 void BackUpInputToCurrentPosition();
600 void RecomputeBufferLimits();
603 void PrintTotalBytesLimitError();
620 int64 ReadVarint32Fallback(
uint32 first_byte_or_zero);
621 int ReadVarintSizeAsIntFallback();
622 std::pair<uint64, bool> ReadVarint64Fallback();
625 int ReadVarintSizeAsIntSlow();
637 int BufferSize()
const;
639 static const int kDefaultTotalBytesLimit = INT_MAX;
643 friend class google::protobuf::ZeroCopyCodedInputStream;
644 friend class google::protobuf::internal::EpsCopyByteStream;
726 bool GetDirectBufferPointer(
void**
data,
int*
size);
735 inline uint8* GetDirectBufferForNBytesAndAdvance(
int size);
741 void WriteRawMaybeAliased(
const void*
data,
int size);
767 void EnableAliasing(
bool enabled);
802 PROTOBUF_ALWAYS_INLINE
811 static size_t VarintSize32SignExtended(
int32 value);
814 template <u
int32 Value>
819 : (
Value < (1 << 14))
821 : (
Value < (1 << 21)) ? 3 : (
Value < (1 << 28)) ? 4 : 5;
825 inline int ByteCount()
const;
856 is_serialization_deterministic_ =
value;
863 return is_serialization_deterministic_;
867 return default_serialization_deterministic_.load(
868 std::memory_order_relaxed) != 0;
884 void Advance(
int amount);
892 void WriteAliasedRaw(
const void*
buffer,
int size);
908 default_serialization_deterministic_.store(
true, std::memory_order_relaxed);
958 #if defined(PROTOBUF_LITTLE_ENDIAN)
960 return buffer +
sizeof(*value);
966 return buffer +
sizeof(*value);
972 #if defined(PROTOBUF_LITTLE_ENDIAN)
974 return buffer +
sizeof(*value);
985 return buffer +
sizeof(*value);
990 #if defined(PROTOBUF_LITTLE_ENDIAN)
991 if (PROTOBUF_PREDICT_TRUE(
BufferSize() >=
static_cast<int>(
sizeof(*
value)))) {
1003 #if defined(PROTOBUF_LITTLE_ENDIAN)
1004 if (PROTOBUF_PREDICT_TRUE(
BufferSize() >=
static_cast<int>(
sizeof(*
value)))) {
1033 uint32 first_byte_or_zero = 0;
1038 first_byte_or_zero =
buffer_[0];
1040 const uint32 kMax1ByteVarint = 0x7f;
1043 return std::make_pair(tag, cutoff >= kMax1ByteVarint || tag <= cutoff);
1050 const uint32 kMax2ByteVarint = (0x7f << 7) + 0x7f;
1059 bool at_or_below_cutoff = cutoff >= kMax2ByteVarint || tag <= cutoff;
1060 return std::make_pair(tag, at_or_below_cutoff);
1065 return std::make_pair(tag,
static_cast<uint32>(tag - 1) < cutoff);
1077 if (expected < (1 << 7)) {
1085 }
else if (expected < (1 << 14)) {
1086 if (PROTOBUF_PREDICT_TRUE(
BufferSize() >= 2) &&
1102 if (expected < (1 << 7)) {
1103 if (
buffer[0] == expected) {
1106 }
else if (expected < (1 << 14)) {
1107 if (
buffer[0] ==
static_cast<uint8>(expected | 0x80) &&
1151 while (
value >= 0x80) {
1162 while (
value >= 0x80) {
1182 #if defined(PROTOBUF_LITTLE_ENDIAN)
1195 #if defined(PROTOBUF_LITTLE_ENDIAN)
1252 return static_cast<size_t>((log2value * 9 + 73) / 64);
1262 return static_cast<size_t>((log2value * 9 + 73) / 64);
1343 total_bytes_read_(0),
1346 legitimate_message_end_(
false),
1347 aliasing_enabled_(
false),
1349 buffer_size_after_limit_(0),
1350 total_bytes_limit_(kDefaultTotalBytesLimit),
1351 recursion_budget_(default_recursion_limit_),
1352 recursion_limit_(default_recursion_limit_),
1353 extension_pool_(
NULL),
1354 extension_factory_(
NULL) {
1363 total_bytes_read_(
size),
1366 legitimate_message_end_(
false),
1367 aliasing_enabled_(
false),
1368 current_limit_(
size),
1369 buffer_size_after_limit_(0),
1370 total_bytes_limit_(kDefaultTotalBytesLimit),
1371 recursion_budget_(default_recursion_limit_),
1372 recursion_limit_(default_recursion_limit_),
1373 extension_pool_(
NULL),
1374 extension_factory_(
NULL) {
1382 if (
count < 0)
return false;
1384 const int original_buffer_size =
BufferSize();
1386 if (
count <= original_buffer_size) {
1399 #if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)
1400 #pragma runtime_checks("c", restore)
1401 #endif // _MSC_VER && !defined(__INTEL_COMPILER)
1403 #include <google/protobuf/port_undef.inc>
1405 #endif // GOOGLE_PROTOBUF_IO_CODED_STREAM_H__
void WriteRawMaybeAliased(const void *data, int size)
static uint8 * WriteLittleEndian32ToArray(uint32 value, uint8 *target)
void WriteRaw(const void *buffer, int size)
const Descriptor::ReservedRange value
void WriteAliasedRaw(const void *buffer, int size)
static void SetDefaultSerializationDeterministic()
#define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName)
ZeroCopyOutputStream * output_
std::unique_ptr< io::Tokenizer > input_
void WriteVarint32SlowPath(uint32 value)
void WriteVarint64(uint64 value)
static size_t VarintSize64(uint64 value)
void WriteString(const std::string &str)
static bool IsDefaultSerializationDeterministic()
GLsizei const GLchar *const * string
void SetSerializationDeterministic(bool value)
bool is_serialization_deterministic_
void MapTestForceDeterministic()
static uint32 Log2FloorNonZero(uint32 n)
static uint8 * WriteVarint32SignExtendedToArray(int32 value, uint8 *target)
static uint8 * WriteVarint32ToArray(uint32 value, uint8 *target)
void WriteVarint32SignExtended(int32 value)
static size_t VarintSize64(const T *data, const int n)
GLenum GLenum GLsizei const GLuint GLboolean enabled
static size_t VarintSize32(uint32 value)
static size_t VarintSize32SignExtended(int32 value)
static uint8 * WriteVarint64ToArray(uint64 value, uint8 *target)
static uint32 Log2FloorNonZero64(uint64 n)
void WriteVarint64SlowPath(uint64 value)
InternalDescriptorPool * pool
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
void WriteTag(uint32 value)
static const int32 kint32max
static uint8 * WriteLittleEndian64ToArray(uint64 value, uint8 *target)
static std::atomic< bool > default_serialization_deterministic_
bool IsSerializationDeterministic() const
def Skip(lines, pos, regex)
uint8 * GetDirectBufferForNBytesAndAdvance(int size)
static PROTOBUF_ALWAYS_INLINE uint8 * WriteTagToArray(uint32 value, uint8 *target)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
static uint8 buffer_[kBufferSize]
GLsizei const GLfloat * value
const upb_json_parsermethod const upb_symtab upb_sink * output
void WriteVarint32(uint32 value)
std::pair< const char *, uint32 > ReadTagFallback(const char *p, uint32 res)
static uint8 * WriteStringToArray(const std::string &str, uint8 *target)
static uint8 * WriteRawToArray(const void *buffer, int size, uint8 *target)
libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:48