39 #ifndef GOOGLE_PROTOBUF_MESSAGE_LITE_H__
40 #define GOOGLE_PROTOBUF_MESSAGE_LITE_H__
43 #include <google/protobuf/stubs/common.h>
44 #include <google/protobuf/stubs/logging.h>
45 #include <google/protobuf/stubs/once.h>
47 #include <google/protobuf/stubs/port.h>
54 class CodedInputStream;
55 class CodedOutputStream;
56 class ZeroCopyInputStream;
57 class ZeroCopyOutputStream;
61 class RepeatedPtrFieldBase;
73 inline int ToCachedSize(
size_t size) {
return static_cast<int>(size); }
82 return static_cast<unsigned int>(size);
89 GOOGLE_DCHECK_LE(size,
static_cast<size_t>(INT_MAX));
90 return static_cast<int>(size);
106 template <
typename T>
117 constexpr
const T&
get()
const {
return reinterpret_cast<const T&
>(union_); }
123 char space[
sizeof(T)];
124 int64 align_to_int64;
172 virtual string GetTypeName()
const = 0;
187 virtual ::google::protobuf::Arena*
GetArena()
const {
return NULL; }
205 virtual void Clear() = 0;
208 virtual bool IsInitialized()
const = 0;
213 virtual string InitializationErrorString()
const;
217 virtual void CheckTypeAndMergeFrom(
const MessageLite& other) = 0;
229 bool ParseFromCodedStream(io::CodedInputStream* input);
232 bool ParsePartialFromCodedStream(io::CodedInputStream* input);
235 bool ParseFromZeroCopyStream(io::ZeroCopyInputStream* input);
238 bool ParsePartialFromZeroCopyStream(io::ZeroCopyInputStream* input);
242 bool ParseFromBoundedZeroCopyStream(io::ZeroCopyInputStream* input,
int size);
245 bool ParsePartialFromBoundedZeroCopyStream(io::ZeroCopyInputStream* input,
252 bool ParseFromString(
const string& data);
255 bool ParsePartialFromString(
const string& data);
257 bool ParseFromArray(
const void* data,
int size);
260 bool ParsePartialFromArray(
const void* data,
int size);
274 bool MergeFromCodedStream(io::CodedInputStream* input);
281 virtual bool MergePartialFromCodedStream(io::CodedInputStream* input) = 0;
291 bool SerializeToCodedStream(io::CodedOutputStream* output)
const;
293 bool SerializePartialToCodedStream(io::CodedOutputStream* output)
const;
296 bool SerializeToZeroCopyStream(io::ZeroCopyOutputStream* output)
const;
298 bool SerializePartialToZeroCopyStream(io::ZeroCopyOutputStream* output)
const;
301 bool SerializeToString(
string* output)
const;
303 bool SerializePartialToString(
string* output)
const;
306 bool SerializeToArray(
void* data,
int size)
const;
308 bool SerializePartialToArray(
void* data,
int size)
const;
316 string SerializeAsString()
const;
318 string SerializePartialAsString()
const;
322 bool AppendToString(
string* output)
const;
324 bool AppendPartialToString(
string* output)
const;
334 PROTOBUF_RUNTIME_DEPRECATED(
"Please use ByteSizeLong() instead")
342 virtual void SerializeWithCachedSizes(
343 io::CodedOutputStream* output)
const;
355 virtual uint8* SerializeWithCachedSizesToArray(uint8* target)
const;
368 virtual int GetCachedSize()
const = 0;
370 virtual uint8* InternalSerializeWithCachedSizesToArray(
bool deterministic,
371 uint8* target)
const;
378 template <
typename T>
379 static ::google::protobuf::internal::RepeatedPtrFieldBase*
CastToBase(
383 template <
typename T>
384 static const ::google::protobuf::internal::RepeatedPtrFieldBase&
CastToBase(
385 const ::google::protobuf::RepeatedPtrField<T>& repeated) {
389 template <
typename T>
391 return Arena::CreateMaybeMessage<T>(arena);
396 virtual const void* InternalGetTable()
const {
return NULL; }
398 friend class internal::WireFormatLite;
400 friend class internal::WeakFieldMap;
424 #endif // GOOGLE_PROTOBUF_MESSAGE_LITE_H__