#include <google/protobuf/io/coded_stream.h>
#include <limits.h>
#include <algorithm>
#include <cstring>
#include <utility>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
#include <google/protobuf/stubs/stl_util.h>
#include <google/protobuf/port_def.inc>
namespace google {
namespace protobuf {
namespace io {
namespace {
static const int kMaxVarintBytes = …;
static const int kMaxVarint32Bytes = …;
inline bool NextNonEmpty(ZeroCopyInputStream* input, const void** data,
int* size) { … }
}
CodedInputStream::~CodedInputStream() { … }
int CodedInputStream::default_recursion_limit_ = …;
void CodedInputStream::BackUpInputToCurrentPosition() { … }
inline void CodedInputStream::RecomputeBufferLimits() { … }
CodedInputStream::Limit CodedInputStream::PushLimit(int byte_limit) { … }
void CodedInputStream::PopLimit(Limit limit) { … }
std::pair<CodedInputStream::Limit, int>
CodedInputStream::IncrementRecursionDepthAndPushLimit(int byte_limit) { … }
CodedInputStream::Limit CodedInputStream::ReadLengthAndPushLimit() { … }
bool CodedInputStream::DecrementRecursionDepthAndPopLimit(Limit limit) { … }
bool CodedInputStream::CheckEntireMessageConsumedAndPopLimit(Limit limit) { … }
int CodedInputStream::BytesUntilLimit() const { … }
void CodedInputStream::SetTotalBytesLimit(int total_bytes_limit) { … }
int CodedInputStream::BytesUntilTotalBytesLimit() const { … }
void CodedInputStream::PrintTotalBytesLimitError() { … }
bool CodedInputStream::SkipFallback(int count, int original_buffer_size) { … }
bool CodedInputStream::GetDirectBufferPointer(const void** data, int* size) { … }
bool CodedInputStream::ReadRaw(void* buffer, int size) { … }
bool CodedInputStream::ReadString(std::string* buffer, int size) { … }
bool CodedInputStream::ReadStringFallback(std::string* buffer, int size) { … }
bool CodedInputStream::ReadLittleEndian32Fallback(uint32_t* value) { … }
bool CodedInputStream::ReadLittleEndian64Fallback(uint64_t* value) { … }
namespace {
template <size_t N>
const uint8_t* DecodeVarint64KnownSize(const uint8_t* buffer, uint64_t* value) { … }
PROTOBUF_ALWAYS_INLINE
::std::pair<bool, const uint8_t*> ReadVarint32FromArray(uint32_t first_byte,
const uint8_t* buffer,
uint32_t* value);
inline ::std::pair<bool, const uint8_t*> ReadVarint32FromArray(
uint32_t first_byte, const uint8_t* buffer, uint32_t* value) { … }
PROTOBUF_ALWAYS_INLINE::std::pair<bool, const uint8_t*> ReadVarint64FromArray(
const uint8_t* buffer, uint64_t* value);
inline ::std::pair<bool, const uint8_t*> ReadVarint64FromArray(
const uint8_t* buffer, uint64_t* value) { … }
}
bool CodedInputStream::ReadVarint32Slow(uint32_t* value) { … }
int64_t CodedInputStream::ReadVarint32Fallback(uint32_t first_byte_or_zero) { … }
int CodedInputStream::ReadVarintSizeAsIntSlow() { … }
int CodedInputStream::ReadVarintSizeAsIntFallback() { … }
uint32_t CodedInputStream::ReadTagSlow() { … }
uint32_t CodedInputStream::ReadTagFallback(uint32_t first_byte_or_zero) { … }
bool CodedInputStream::ReadVarint64Slow(uint64_t* value) { … }
std::pair<uint64_t, bool> CodedInputStream::ReadVarint64Fallback() { … }
bool CodedInputStream::Refresh() { … }
void EpsCopyOutputStream::EnableAliasing(bool enabled) { … }
int64_t EpsCopyOutputStream::ByteCount(uint8_t* ptr) const { … }
int EpsCopyOutputStream::Flush(uint8_t* ptr) { … }
uint8_t* EpsCopyOutputStream::Trim(uint8_t* ptr) { … }
uint8_t* EpsCopyOutputStream::FlushAndResetBuffer(uint8_t* ptr) { … }
bool EpsCopyOutputStream::Skip(int count, uint8_t** pp) { … }
bool EpsCopyOutputStream::GetDirectBufferPointer(void** data, int* size,
uint8_t** pp) { … }
uint8_t* EpsCopyOutputStream::GetDirectBufferForNBytesAndAdvance(int size,
uint8_t** pp) { … }
uint8_t* EpsCopyOutputStream::Next() { … }
uint8_t* EpsCopyOutputStream::EnsureSpaceFallback(uint8_t* ptr) { … }
uint8_t* EpsCopyOutputStream::WriteRawFallback(const void* data, int size,
uint8_t* ptr) { … }
uint8_t* EpsCopyOutputStream::WriteAliasedRaw(const void* data, int size,
uint8_t* ptr) { … }
#ifndef PROTOBUF_LITTLE_ENDIAN
uint8_t* EpsCopyOutputStream::WriteRawLittleEndian32(const void* data, int size,
uint8_t* ptr) {
auto p = static_cast<const uint8_t*>(data);
auto end = p + size;
while (end - p >= kSlopBytes) {
ptr = EnsureSpace(ptr);
uint32_t buffer[4];
static_assert(sizeof(buffer) == kSlopBytes, "Buffer must be kSlopBytes");
std::memcpy(buffer, p, kSlopBytes);
p += kSlopBytes;
for (auto x : buffer)
ptr = CodedOutputStream::WriteLittleEndian32ToArray(x, ptr);
}
while (p < end) {
ptr = EnsureSpace(ptr);
uint32_t buffer;
std::memcpy(&buffer, p, 4);
p += 4;
ptr = CodedOutputStream::WriteLittleEndian32ToArray(buffer, ptr);
}
return ptr;
}
uint8_t* EpsCopyOutputStream::WriteRawLittleEndian64(const void* data, int size,
uint8_t* ptr) {
auto p = static_cast<const uint8_t*>(data);
auto end = p + size;
while (end - p >= kSlopBytes) {
ptr = EnsureSpace(ptr);
uint64_t buffer[2];
static_assert(sizeof(buffer) == kSlopBytes, "Buffer must be kSlopBytes");
std::memcpy(buffer, p, kSlopBytes);
p += kSlopBytes;
for (auto x : buffer)
ptr = CodedOutputStream::WriteLittleEndian64ToArray(x, ptr);
}
while (p < end) {
ptr = EnsureSpace(ptr);
uint64_t buffer;
std::memcpy(&buffer, p, 8);
p += 8;
ptr = CodedOutputStream::WriteLittleEndian64ToArray(buffer, ptr);
}
return ptr;
}
#endif
uint8_t* EpsCopyOutputStream::WriteStringMaybeAliasedOutline(uint32_t num,
const std::string& s,
uint8_t* ptr) { … }
uint8_t* EpsCopyOutputStream::WriteStringOutline(uint32_t num, const std::string& s,
uint8_t* ptr) { … }
std::atomic<bool> CodedOutputStream::default_serialization_deterministic_{ … };
CodedOutputStream::~CodedOutputStream() { … }
uint8_t* CodedOutputStream::WriteStringWithSizeToArray(const std::string& str,
uint8_t* target) { … }
uint8_t* CodedOutputStream::WriteVarint32ToArrayOutOfLineHelper(uint32_t value,
uint8_t* target) { … }
}
}
}
#include <google/protobuf/port_undef.inc>