aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/io')
-rw-r--r--src/google/protobuf/io/coded_stream.cc86
-rw-r--r--src/google/protobuf/io/coded_stream.h72
-rw-r--r--src/google/protobuf/io/coded_stream_inl.h2
-rw-r--r--src/google/protobuf/io/coded_stream_unittest.cc4
-rw-r--r--src/google/protobuf/io/gzip_stream.h11
-rw-r--r--src/google/protobuf/io/printer.h44
-rw-r--r--src/google/protobuf/io/tokenizer.h42
-rw-r--r--src/google/protobuf/io/zero_copy_stream.h8
-rw-r--r--src/google/protobuf/io/zero_copy_stream_impl.h25
-rw-r--r--src/google/protobuf/io/zero_copy_stream_impl_lite.h28
10 files changed, 181 insertions, 141 deletions
diff --git a/src/google/protobuf/io/coded_stream.cc b/src/google/protobuf/io/coded_stream.cc
index 311668ce..547c5c64 100644
--- a/src/google/protobuf/io/coded_stream.cc
+++ b/src/google/protobuf/io/coded_stream.cc
@@ -123,7 +123,7 @@ CodedInputStream::Limit CodedInputStream::PushLimit(int byte_limit) {
// security: byte_limit is possibly evil, so check for negative values
// and overflow. Also check that the new requested limit is before the
// previous limit; otherwise we continue to enforce the previous limit.
- if (GOOGLE_PREDICT_TRUE(byte_limit >= 0 &&
+ if (PROTOBUF_PREDICT_TRUE(byte_limit >= 0 &&
byte_limit <= INT_MAX - current_position &&
byte_limit < current_limit_ - current_position)) {
current_limit_ = current_position + byte_limit;
@@ -314,11 +314,25 @@ bool CodedInputStream::ReadLittleEndian64Fallback(uint64* value) {
namespace {
+// Decodes varint64 with known size, N, and returns next pointer. Knowing N at
+// compile time, compiler can generate optimal code. For example, instead of
+// subtracting 0x80 at each iteration, it subtracts properly shifted mask once.
+template <size_t N>
+const uint8* DecodeVarint64KnownSize(const uint8* buffer, uint64* value) {
+ GOOGLE_DCHECK_GT(N, 0);
+ uint64 result = static_cast<uint64>(buffer[N - 1]) << (7 * (N - 1));
+ for (int i = 0, offset = 0; i < N - 1; i++, offset += 7) {
+ result += static_cast<uint64>(buffer[i] - 0x80) << offset;
+ }
+ *value = result;
+ return buffer + N;
+}
+
// Read a varint from the given buffer, write it to *value, and return a pair.
// The first part of the pair is true iff the read was successful. The second
// part is buffer + (number of bytes read). This function is always inlined,
// so returning a pair is costless.
-GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
+PROTOBUF_ALWAYS_INLINE
::std::pair<bool, const uint8*> ReadVarint32FromArray(
uint32 first_byte, const uint8* buffer,
uint32* value);
@@ -356,47 +370,39 @@ inline ::std::pair<bool, const uint8*> ReadVarint32FromArray(
return std::make_pair(true, ptr);
}
-GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE::std::pair<bool, const uint8*>
-ReadVarint64FromArray(const uint8* buffer, uint64* value);
+PROTOBUF_ALWAYS_INLINE::std::pair<bool, const uint8*> ReadVarint64FromArray(
+ const uint8* buffer, uint64* value);
inline ::std::pair<bool, const uint8*> ReadVarint64FromArray(
const uint8* buffer, uint64* value) {
- const uint8* ptr = buffer;
- uint32 b;
-
- // Splitting into 32-bit pieces gives better performance on 32-bit
- // processors.
- uint32 part0 = 0, part1 = 0, part2 = 0;
-
- b = *(ptr++); part0 = b ; if (!(b & 0x80)) goto done;
- part0 -= 0x80;
- b = *(ptr++); part0 += b << 7; if (!(b & 0x80)) goto done;
- part0 -= 0x80 << 7;
- b = *(ptr++); part0 += b << 14; if (!(b & 0x80)) goto done;
- part0 -= 0x80 << 14;
- b = *(ptr++); part0 += b << 21; if (!(b & 0x80)) goto done;
- part0 -= 0x80 << 21;
- b = *(ptr++); part1 = b ; if (!(b & 0x80)) goto done;
- part1 -= 0x80;
- b = *(ptr++); part1 += b << 7; if (!(b & 0x80)) goto done;
- part1 -= 0x80 << 7;
- b = *(ptr++); part1 += b << 14; if (!(b & 0x80)) goto done;
- part1 -= 0x80 << 14;
- b = *(ptr++); part1 += b << 21; if (!(b & 0x80)) goto done;
- part1 -= 0x80 << 21;
- b = *(ptr++); part2 = b ; if (!(b & 0x80)) goto done;
- part2 -= 0x80;
- b = *(ptr++); part2 += b << 7; if (!(b & 0x80)) goto done;
- // "part2 -= 0x80 << 7" is irrelevant because (0x80 << 7) << 56 is 0.
-
- // We have overrun the maximum size of a varint (10 bytes). Assume
- // the data is corrupt.
- return std::make_pair(false, ptr);
+ // Assumes varint64 is at least 2 bytes.
+ GOOGLE_DCHECK_GE(buffer[0], 128);
+
+ const uint8* next;
+ if (buffer[1] < 128) {
+ next = DecodeVarint64KnownSize<2>(buffer, value);
+ } else if (buffer[2] < 128) {
+ next = DecodeVarint64KnownSize<3>(buffer, value);
+ } else if (buffer[3] < 128) {
+ next = DecodeVarint64KnownSize<4>(buffer, value);
+ } else if (buffer[4] < 128) {
+ next = DecodeVarint64KnownSize<5>(buffer, value);
+ } else if (buffer[5] < 128) {
+ next = DecodeVarint64KnownSize<6>(buffer, value);
+ } else if (buffer[6] < 128) {
+ next = DecodeVarint64KnownSize<7>(buffer, value);
+ } else if (buffer[7] < 128) {
+ next = DecodeVarint64KnownSize<8>(buffer, value);
+ } else if (buffer[8] < 128) {
+ next = DecodeVarint64KnownSize<9>(buffer, value);
+ } else if (buffer[9] < 128) {
+ next = DecodeVarint64KnownSize<10>(buffer, value);
+ } else {
+ // We have overrun the maximum size of a varint (10 bytes). Assume
+ // the data is corrupt.
+ return std::make_pair(false, buffer + 11);
+ }
- done:
- *value = (static_cast<uint64>(part0)) |
- (static_cast<uint64>(part1) << 28) |
- (static_cast<uint64>(part2) << 56);
- return std::make_pair(true, ptr);
+ return std::make_pair(true, next);
}
} // namespace
diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h
index 71a4f5fb..63631d1f 100644
--- a/src/google/protobuf/io/coded_stream.h
+++ b/src/google/protobuf/io/coded_stream.h
@@ -161,6 +161,13 @@ class CodedOutputStream;
class ZeroCopyInputStream; // zero_copy_stream.h
class ZeroCopyOutputStream; // zero_copy_stream.h
+template <typename T>
+T UnalignedLoad(const void* p) {
+ T res;
+ memcpy(&res, p, sizeof(T));
+ return res;
+}
+
// Class which reads and decodes binary data which is composed of varint-
// encoded integers and fixed-width pieces. Wraps a ZeroCopyInputStream.
// Most users will not need to deal with CodedInputStream.
@@ -168,7 +175,7 @@ class ZeroCopyOutputStream; // zero_copy_stream.h
// Most methods of CodedInputStream that return a bool return false if an
// underlying I/O error occurs or if the data is malformed. Once such a
// failure occurs, the CodedInputStream is broken and is no longer useful.
-class LIBPROTOBUF_EXPORT CodedInputStream {
+class PROTOBUF_EXPORT CodedInputStream {
public:
// Create a CodedInputStream that reads from the given ZeroCopyInputStream.
explicit CodedInputStream(ZeroCopyInputStream* input);
@@ -204,7 +211,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// Like GetDirectBufferPointer, but this method is inlined, and does not
// attempt to Refresh() if the buffer is currently empty.
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
+ PROTOBUF_ALWAYS_INLINE
void GetDirectBufferPointerInline(const void** data, int* size);
// Read raw bytes, copying them into the given buffer.
@@ -212,15 +219,15 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// Like the above, with inlined optimizations. This should only be used
// by the protobuf implementation.
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
+ PROTOBUF_ALWAYS_INLINE
bool InternalReadRawInline(void* buffer, int size);
// Like ReadRaw, but reads into a string.
- bool ReadString(string* buffer, int size);
+ bool ReadString(std::string* buffer, int size);
// Like the above, with inlined optimizations. This should only be used
// by the protobuf implementation.
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
- bool InternalReadStringInline(string* buffer, int size);
+ PROTOBUF_ALWAYS_INLINE
+ bool InternalReadStringInline(std::string* buffer, int size);
// Read a 32-bit little-endian integer.
@@ -263,11 +270,11 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// Always inline because this is only called in one place per parse loop
// but it is called for every iteration of said loop, so it should be fast.
// GCC doesn't want to inline this by default.
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTag() {
+ PROTOBUF_ALWAYS_INLINE uint32 ReadTag() {
return last_tag_ = ReadTagNoLastTag();
}
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTagNoLastTag();
+ PROTOBUF_ALWAYS_INLINE uint32 ReadTagNoLastTag();
// This usually a faster alternative to ReadTag() when cutoff is a manifest
// constant. It does particularly well for cutoff >= 127. The first part
@@ -277,14 +284,14 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// above cutoff or is 0. (There's intentional wiggle room when tag is 0,
// because that can arise in several ways, and for best performance we want
// to avoid an extra "is tag == 0?" check here.)
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
+ PROTOBUF_ALWAYS_INLINE
std::pair<uint32, bool> ReadTagWithCutoff(uint32 cutoff) {
std::pair<uint32, bool> result = ReadTagWithCutoffNoLastTag(cutoff);
last_tag_ = result.first;
return result;
}
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
+ PROTOBUF_ALWAYS_INLINE
std::pair<uint32, bool> ReadTagWithCutoffNoLastTag(uint32 cutoff);
// Usually returns true if calling ReadVarint32() now would produce the given
@@ -294,7 +301,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// parameter.
// Always inline because this collapses to a small number of instructions
// when given a constant parameter, but GCC doesn't want to inline by default.
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE bool ExpectTag(uint32 expected);
+ PROTOBUF_ALWAYS_INLINE bool ExpectTag(uint32 expected);
// Like above, except this reads from the specified buffer. The caller is
// responsible for ensuring that the buffer is large enough to read a varint
@@ -303,7 +310,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
//
// Returns a pointer beyond the expected tag if it was found, or NULL if it
// was not.
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
+ PROTOBUF_ALWAYS_INLINE
static const uint8* ExpectTagFromArray(const uint8* buffer, uint32 expected);
// Usually returns true if no more bytes can be read. Always returns false
@@ -390,7 +397,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// This is unrelated to PushLimit()/PopLimit().
void SetTotalBytesLimit(int total_bytes_limit);
- GOOGLE_PROTOBUF_DEPRECATED_MSG(
+ PROTOBUF_DEPRECATED_MSG(
"Please use the single parameter version of SetTotalBytesLimit(). The "
"second parameter is ignored.")
void SetTotalBytesLimit(int total_bytes_limit, int) {
@@ -409,6 +416,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// Sets the maximum recursion depth. The default is 100.
void SetRecursionLimit(int limit);
+ int RecursionBudget() { return recursion_budget_; }
// Increments the current recursion depth. Returns true if the depth is
@@ -627,7 +635,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// stream.
uint32 ReadTagFallback(uint32 first_byte_or_zero);
uint32 ReadTagSlow();
- bool ReadStringFallback(string* buffer, int size);
+ bool ReadStringFallback(std::string* buffer, int size);
// Return the size of the buffer.
int BufferSize() const;
@@ -683,7 +691,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// }
//
// delete coded_output;
-class LIBPROTOBUF_EXPORT CodedOutputStream {
+class PROTOBUF_EXPORT CodedOutputStream {
public:
// Create an CodedOutputStream that writes to the given ZeroCopyOutputStream.
explicit CodedOutputStream(ZeroCopyOutputStream* output);
@@ -737,11 +745,11 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
static uint8* WriteRawToArray(const void* buffer, int size, uint8* target);
// Equivalent to WriteRaw(str.data(), str.size()).
- void WriteString(const string& str);
+ void WriteString(const std::string& str);
// Like WriteString() but writing directly to the target array.
- static uint8* WriteStringToArray(const string& str, uint8* target);
+ static uint8* WriteStringToArray(const std::string& str, uint8* target);
// Write the varint-encoded size of str followed by str.
- static uint8* WriteStringWithSizeToArray(const string& str, uint8* target);
+ static uint8* WriteStringWithSizeToArray(const std::string& str, uint8* target);
// Instructs the CodedOutputStream to allow the underlying
@@ -788,7 +796,7 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
// but GCC by default doesn't want to inline this.
void WriteTag(uint32 value);
// Like WriteTag() but writing directly to the target array.
- GOOGLE_PROTOBUF_ATTRIBUTE_ALWAYS_INLINE
+ PROTOBUF_ALWAYS_INLINE
static uint8* WriteTagToArray(uint32 value, uint8* target);
// Returns the number of bytes needed to encode the given value as a varint.
@@ -908,7 +916,7 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
inline bool CodedInputStream::ReadVarint32(uint32* value) {
uint32 v = 0;
- if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_)) {
+ if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_)) {
v = *buffer_;
if (v < 0x80) {
*value = v;
@@ -922,7 +930,7 @@ inline bool CodedInputStream::ReadVarint32(uint32* value) {
}
inline bool CodedInputStream::ReadVarint64(uint64* value) {
- if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_) && *buffer_ < 0x80) {
+ if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_) && *buffer_ < 0x80) {
*value = *buffer_;
Advance(1);
return true;
@@ -933,7 +941,7 @@ inline bool CodedInputStream::ReadVarint64(uint64* value) {
}
inline bool CodedInputStream::ReadVarintSizeAsInt(int* value) {
- if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_)) {
+ if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_)) {
int v = *buffer_;
if (v < 0x80) {
*value = v;
@@ -984,7 +992,7 @@ inline const uint8* CodedInputStream::ReadLittleEndian64FromArray(
inline bool CodedInputStream::ReadLittleEndian32(uint32* value) {
#if defined(PROTOBUF_LITTLE_ENDIAN)
- if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
+ if (PROTOBUF_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
buffer_ = ReadLittleEndian32FromArray(buffer_, value);
return true;
} else {
@@ -997,7 +1005,7 @@ inline bool CodedInputStream::ReadLittleEndian32(uint32* value) {
inline bool CodedInputStream::ReadLittleEndian64(uint64* value) {
#if defined(PROTOBUF_LITTLE_ENDIAN)
- if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
+ if (PROTOBUF_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
buffer_ = ReadLittleEndian64FromArray(buffer_, value);
return true;
} else {
@@ -1010,7 +1018,7 @@ inline bool CodedInputStream::ReadLittleEndian64(uint64* value) {
inline uint32 CodedInputStream::ReadTagNoLastTag() {
uint32 v = 0;
- if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_)) {
+ if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_)) {
v = *buffer_;
if (v < 0x80) {
Advance(1);
@@ -1027,7 +1035,7 @@ inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoffNoLastTag(
// constant, and things like "cutoff >= kMax1ByteVarint" to be evaluated at
// compile time.
uint32 first_byte_or_zero = 0;
- if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_)) {
+ if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_)) {
// Hot case: buffer_ non_empty, buffer_[0] in [1, 128).
// TODO(gpike): Is it worth rearranging this? E.g., if the number of fields
// is large enough then is it better to check for the two-byte case first?
@@ -1041,8 +1049,8 @@ inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoffNoLastTag(
// Other hot case: cutoff >= 0x80, buffer_ has at least two bytes available,
// and tag is two bytes. The latter is tested by bitwise-and-not of the
// first byte and the second byte.
- if (cutoff >= 0x80 && GOOGLE_PREDICT_TRUE(buffer_ + 1 < buffer_end_) &&
- GOOGLE_PREDICT_TRUE((buffer_[0] & ~buffer_[1]) >= 0x80)) {
+ if (cutoff >= 0x80 && PROTOBUF_PREDICT_TRUE(buffer_ + 1 < buffer_end_) &&
+ PROTOBUF_PREDICT_TRUE((buffer_[0] & ~buffer_[1]) >= 0x80)) {
const uint32 kMax2ByteVarint = (0x7f << 7) + 0x7f;
uint32 tag = (1u << 7) * buffer_[1] + (buffer_[0] - 0x80);
Advance(2);
@@ -1071,14 +1079,14 @@ inline bool CodedInputStream::ConsumedEntireMessage() {
inline bool CodedInputStream::ExpectTag(uint32 expected) {
if (expected < (1 << 7)) {
- if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_) && buffer_[0] == expected) {
+ if (PROTOBUF_PREDICT_TRUE(buffer_ < buffer_end_) && buffer_[0] == expected) {
Advance(1);
return true;
} else {
return false;
}
} else if (expected < (1 << 14)) {
- if (GOOGLE_PREDICT_TRUE(BufferSize() >= 2) &&
+ if (PROTOBUF_PREDICT_TRUE(BufferSize() >= 2) &&
buffer_[0] == static_cast<uint8>(expected | 0x80) &&
buffer_[1] == static_cast<uint8>(expected >> 7)) {
Advance(2);
@@ -1269,7 +1277,7 @@ inline size_t CodedOutputStream::VarintSize32SignExtended(int32 value) {
}
}
-inline void CodedOutputStream::WriteString(const string& str) {
+inline void CodedOutputStream::WriteString(const std::string& str) {
WriteRaw(str.data(), static_cast<int>(str.size()));
}
@@ -1283,7 +1291,7 @@ inline void CodedOutputStream::WriteRawMaybeAliased(
}
inline uint8* CodedOutputStream::WriteStringToArray(
- const string& str, uint8* target) {
+ const std::string& str, uint8* target) {
return WriteRawToArray(str.data(), static_cast<int>(str.size()), target);
}
diff --git a/src/google/protobuf/io/coded_stream_inl.h b/src/google/protobuf/io/coded_stream_inl.h
index d95b06e0..df66282a 100644
--- a/src/google/protobuf/io/coded_stream_inl.h
+++ b/src/google/protobuf/io/coded_stream_inl.h
@@ -47,7 +47,7 @@ namespace google {
namespace protobuf {
namespace io {
-inline bool CodedInputStream::InternalReadStringInline(string* buffer,
+inline bool CodedInputStream::InternalReadStringInline(std::string* buffer,
int size) {
if (size < 0) return false; // security: size is often user-supplied
diff --git a/src/google/protobuf/io/coded_stream_unittest.cc b/src/google/protobuf/io/coded_stream_unittest.cc
index bcda8c81..52cc7c33 100644
--- a/src/google/protobuf/io/coded_stream_unittest.cc
+++ b/src/google/protobuf/io/coded_stream_unittest.cc
@@ -49,10 +49,12 @@
#include <gtest/gtest.h>
#include <google/protobuf/stubs/casts.h>
+#include <google/protobuf/port_def.inc>
+
// This declares an unsigned long long integer literal in a portable way.
// (The original macro is way too big and ruins my formatting.)
#undef ULL
-#define ULL(x) GOOGLE_ULONGLONG(x)
+#define ULL(x) PROTOBUF_ULONGLONG(x)
namespace google {
diff --git a/src/google/protobuf/io/gzip_stream.h b/src/google/protobuf/io/gzip_stream.h
index ba1475c7..b8eadfab 100644
--- a/src/google/protobuf/io/gzip_stream.h
+++ b/src/google/protobuf/io/gzip_stream.h
@@ -48,12 +48,14 @@
#include <google/protobuf/port.h>
#include <zlib.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace io {
// A ZeroCopyInputStream that reads compressed data through zlib
-class LIBPROTOBUF_EXPORT GzipInputStream : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT GzipInputStream : public ZeroCopyInputStream {
public:
// Format key for constructor
enum Format {
@@ -107,8 +109,7 @@ class LIBPROTOBUF_EXPORT GzipInputStream : public ZeroCopyInputStream {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GzipInputStream);
};
-
-class LIBPROTOBUF_EXPORT GzipOutputStream : public ZeroCopyOutputStream {
+class PROTOBUF_EXPORT GzipOutputStream : public ZeroCopyOutputStream {
public:
// Format key for constructor
enum Format {
@@ -119,7 +120,7 @@ class LIBPROTOBUF_EXPORT GzipOutputStream : public ZeroCopyOutputStream {
ZLIB = 2,
};
- struct LIBPROTOBUF_EXPORT Options {
+ struct PROTOBUF_EXPORT Options {
// Defaults to GZIP.
Format format;
@@ -207,4 +208,6 @@ class LIBPROTOBUF_EXPORT GzipOutputStream : public ZeroCopyOutputStream {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_IO_GZIP_STREAM_H__
diff --git a/src/google/protobuf/io/printer.h b/src/google/protobuf/io/printer.h
index 236aed43..ce693e54 100644
--- a/src/google/protobuf/io/printer.h
+++ b/src/google/protobuf/io/printer.h
@@ -42,6 +42,8 @@
#include <vector>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace io {
@@ -49,15 +51,15 @@ namespace io {
class ZeroCopyOutputStream; // zero_copy_stream.h
// Records annotations about a Printer's output.
-class LIBPROTOBUF_EXPORT AnnotationCollector {
+class PROTOBUF_EXPORT AnnotationCollector {
public:
// Annotation is a ofset range and a payload pair.
- typedef std::pair<std::pair<size_t, size_t>, string> Annotation;
+ typedef std::pair<std::pair<size_t, size_t>, std::string> Annotation;
// Records that the bytes in file_path beginning with begin_offset and ending
// before end_offset are associated with the SourceCodeInfo-style path.
virtual void AddAnnotation(size_t begin_offset, size_t end_offset,
- const string& file_path,
+ const std::string& file_path,
const std::vector<int>& path) = 0;
// TODO(gerbens) I don't see why we need virtuals here. Just a vector of
@@ -80,7 +82,7 @@ class AnnotationProtoCollector : public AnnotationCollector {
// Override for AnnotationCollector::AddAnnotation.
virtual void AddAnnotation(size_t begin_offset, size_t end_offset,
- const string& file_path,
+ const std::string& file_path,
const std::vector<int>& path) {
typename AnnotationProto::Annotation* annotation =
annotation_proto_->add_annotation();
@@ -176,7 +178,7 @@ class AnnotationProtoCollector : public AnnotationCollector {
// This code associates the span covering "call(bar,bar)" in the output with the
// call_ descriptor.
-class LIBPROTOBUF_EXPORT Printer {
+class PROTOBUF_EXPORT Printer {
public:
// Create a printer that writes text to the given output stream. Use the
// given character as the delimiter for variables.
@@ -217,7 +219,7 @@ class LIBPROTOBUF_EXPORT Printer {
// Link a subsitution variable emitted by the last call to Print to the file
// with path file_name.
- void Annotate(const char* varname, const string& file_name) {
+ void Annotate(const char* varname, const std::string& file_name) {
Annotate(varname, varname, file_name);
}
@@ -226,7 +228,7 @@ class LIBPROTOBUF_EXPORT Printer {
// at begin_varname's value and ends after the last character of the value
// substituted for end_varname.
void Annotate(const char* begin_varname, const char* end_varname,
- const string& file_name) {
+ const std::string& file_name) {
if (annotation_collector_ == NULL) {
// Annotations aren't turned on for this Printer.
return;
@@ -240,12 +242,12 @@ class LIBPROTOBUF_EXPORT Printer {
// substituted are identified by their names surrounded by delimiter
// characters (as given to the constructor). The variable bindings are
// defined by the given map.
- void Print(const std::map<string, string>& variables, const char* text);
+ void Print(const std::map<std::string, std::string>& variables, const char* text);
// Like the first Print(), except the substitutions are given as parameters.
template <typename... Args>
void Print(const char* text, const Args&... args) {
- std::map<string, string> vars;
+ std::map<std::string, std::string> vars;
PrintInternal(&vars, text, args...);
}
@@ -260,7 +262,7 @@ class LIBPROTOBUF_EXPORT Printer {
// Write a string to the output buffer.
// This method does not look for newlines to add indentation.
- void PrintRaw(const string& data);
+ void PrintRaw(const std::string& data);
// Write a zero-delimited string to output buffer.
// This method does not look for newlines to add indentation.
@@ -275,8 +277,8 @@ class LIBPROTOBUF_EXPORT Printer {
// formatting text using named variables (eq. "$foo$) from a lookup map (vars)
// and variables directly supplied by arguments (eq "$1$" meaning first
// argument which is the zero index element of args).
- void FormatInternal(const std::vector<string>& args,
- const std::map<string, string>& vars, const char* format);
+ void FormatInternal(const std::vector<std::string>& args,
+ const std::map<std::string, std::string>& vars, const char* format);
// True if any write to the underlying stream failed. (We don't just
// crash in this case because this is an I/O failure, not a programming
@@ -291,16 +293,16 @@ class LIBPROTOBUF_EXPORT Printer {
// substituted for end_varname. Note that begin_varname and end_varname
// may refer to the same variable.
void Annotate(const char* begin_varname, const char* end_varname,
- const string& file_path, const std::vector<int>& path);
+ const std::string& file_path, const std::vector<int>& path);
// Base case
- void PrintInternal(std::map<string, string>* vars, const char* text) {
+ void PrintInternal(std::map<std::string, std::string>* vars, const char* text) {
Print(*vars, text);
}
template <typename... Args>
- void PrintInternal(std::map<string, string>* vars, const char* text,
- const char* key, const string& value,
+ void PrintInternal(std::map<std::string, std::string>* vars, const char* text,
+ const char* key, const std::string& value,
const Args&... args) {
(*vars)[key] = value;
PrintInternal(vars, text, args...);
@@ -323,7 +325,7 @@ class LIBPROTOBUF_EXPORT Printer {
inline void IndentIfAtStart();
const char* WriteVariable(
- const std::vector<string>& args, const std::map<string, string>& vars,
+ const std::vector<std::string>& args, const std::map<std::string, std::string>& vars,
const char* format, int* arg_index,
std::vector<AnnotationCollector::Annotation>* annotations);
@@ -337,7 +339,7 @@ class LIBPROTOBUF_EXPORT Printer {
// used to calculate annotation ranges in the substitutions_ map below.
size_t offset_;
- string indent_;
+ std::string indent_;
bool at_start_of_line_;
bool failed_;
@@ -348,12 +350,12 @@ class LIBPROTOBUF_EXPORT Printer {
// start offset is the beginning of the substitution; the end offset is the
// last byte of the substitution plus one (such that (end - start) is the
// length of the substituted string).
- std::map<string, std::pair<size_t, size_t> > substitutions_;
+ std::map<std::string, std::pair<size_t, size_t> > substitutions_;
// Keeps track of the keys in substitutions_ that need to be updated when
// indents are inserted. These are keys that refer to the beginning of the
// current line.
- std::vector<string> line_start_variables_;
+ std::vector<std::string> line_start_variables_;
// Returns true and sets range to the substitution range in the output for
// varname if varname was used once in the last call to Print. If varname
@@ -373,4 +375,6 @@ class LIBPROTOBUF_EXPORT Printer {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_IO_PRINTER_H__
diff --git a/src/google/protobuf/io/tokenizer.h b/src/google/protobuf/io/tokenizer.h
index 59b67729..f6c3d273 100644
--- a/src/google/protobuf/io/tokenizer.h
+++ b/src/google/protobuf/io/tokenizer.h
@@ -42,6 +42,8 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace io {
@@ -61,7 +63,7 @@ typedef int ColumnNumber;
// Abstract interface for an object which collects the errors that occur
// during parsing. A typical implementation might simply print the errors
// to stdout.
-class LIBPROTOBUF_EXPORT ErrorCollector {
+class PROTOBUF_EXPORT ErrorCollector {
public:
inline ErrorCollector() {}
virtual ~ErrorCollector();
@@ -70,13 +72,13 @@ class LIBPROTOBUF_EXPORT ErrorCollector {
// column numbers. The numbers are zero-based, so you may want to add
// 1 to each before printing them.
virtual void AddError(int line, ColumnNumber column,
- const string& message) = 0;
+ const std::string& message) = 0;
// Indicates that there was a warning in the input at the given line and
// column numbers. The numbers are zero-based, so you may want to add
// 1 to each before printing them.
virtual void AddWarning(int line, ColumnNumber column,
- const string& message) { }
+ const std::string& message) { }
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ErrorCollector);
@@ -88,7 +90,7 @@ class LIBPROTOBUF_EXPORT ErrorCollector {
// precise descriptions. Whitespace and comments are skipped. By default,
// C- and C++-style comments are recognized, but other styles can be used by
// calling set_comment_style().
-class LIBPROTOBUF_EXPORT Tokenizer {
+class PROTOBUF_EXPORT Tokenizer {
public:
// Construct a Tokenizer that reads and tokenizes text from the given
// input stream and writes errors to the given error_collector.
@@ -124,7 +126,7 @@ class LIBPROTOBUF_EXPORT Tokenizer {
// Structure representing a token read from the token stream.
struct Token {
TokenType type;
- string text; // The exact text of the token as it appeared in
+ std::string text; // The exact text of the token as it appeared in
// the input. e.g. tokens of TYPE_STRING will still
// be escaped and in quotes.
@@ -190,31 +192,31 @@ class LIBPROTOBUF_EXPORT Tokenizer {
// /* Block comment attached to
// * grault. */
// optional int32 grault = 6;
- bool NextWithComments(string* prev_trailing_comments,
- std::vector<string>* detached_comments,
- string* next_leading_comments);
+ bool NextWithComments(std::string* prev_trailing_comments,
+ std::vector<std::string>* detached_comments,
+ std::string* next_leading_comments);
// Parse helpers ---------------------------------------------------
// Parses a TYPE_FLOAT token. This never fails, so long as the text actually
// comes from a TYPE_FLOAT token parsed by Tokenizer. If it doesn't, the
// result is undefined (possibly an assert failure).
- static double ParseFloat(const string& text);
+ static double ParseFloat(const std::string& text);
// Parses a TYPE_STRING token. This never fails, so long as the text actually
// comes from a TYPE_STRING token parsed by Tokenizer. If it doesn't, the
// result is undefined (possibly an assert failure).
- static void ParseString(const string& text, string* output);
+ static void ParseString(const std::string& text, std::string* output);
// Identical to ParseString, but appends to output.
- static void ParseStringAppend(const string& text, string* output);
+ static void ParseStringAppend(const std::string& text, std::string* output);
// Parses a TYPE_INTEGER token. Returns false if the result would be
// greater than max_value. Otherwise, returns true and sets *output to the
// result. If the text is not from a Token of type TYPE_INTEGER originally
// parsed by a Tokenizer, the result is undefined (possibly an assert
// failure).
- static bool ParseInteger(const string& text, uint64 max_value,
+ static bool ParseInteger(const std::string& text, uint64 max_value,
uint64* output);
// Options ---------------------------------------------------------
@@ -250,7 +252,7 @@ class LIBPROTOBUF_EXPORT Tokenizer {
}
// External helper: validate an identifier.
- static bool IsIdentifier(const string& text);
+ static bool IsIdentifier(const std::string& text);
// -----------------------------------------------------------------
private:
@@ -276,7 +278,7 @@ class LIBPROTOBUF_EXPORT Tokenizer {
// Call RecordTo(&str) to start recording and StopRecording() to stop.
// E.g. StartToken() calls RecordTo(&current_.text). record_start_ is the
// position within the current buffer where recording started.
- string* record_target_;
+ std::string* record_target_;
int record_start_;
// Options.
@@ -299,7 +301,7 @@ class LIBPROTOBUF_EXPORT Tokenizer {
// Read a new buffer from the input.
void Refresh();
- inline void RecordTo(string* target);
+ inline void RecordTo(std::string* target);
inline void StopRecording();
// Called when the current character is the first character of a new
@@ -311,7 +313,7 @@ class LIBPROTOBUF_EXPORT Tokenizer {
inline void EndToken();
// Convenience method to add an error at the current line and column.
- void AddError(const string& message) {
+ void AddError(const std::string& message) {
error_collector_->AddError(line_, column_, message);
}
@@ -334,9 +336,9 @@ class LIBPROTOBUF_EXPORT Tokenizer {
TokenType ConsumeNumber(bool started_with_zero, bool started_with_dot);
// Consume the rest of a line.
- void ConsumeLineComment(string* content);
+ void ConsumeLineComment(std::string* content);
// Consume until "*/".
- void ConsumeBlockComment(string* content);
+ void ConsumeBlockComment(std::string* content);
enum NextCommentStatus {
// Started a line comment.
@@ -399,7 +401,7 @@ inline const Tokenizer::Token& Tokenizer::previous() {
return previous_;
}
-inline void Tokenizer::ParseString(const string& text, string* output) {
+inline void Tokenizer::ParseString(const std::string& text, std::string* output) {
output->clear();
ParseStringAppend(text, output);
}
@@ -408,4 +410,6 @@ inline void Tokenizer::ParseString(const string& text, string* output) {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_IO_TOKENIZER_H__
diff --git a/src/google/protobuf/io/zero_copy_stream.h b/src/google/protobuf/io/zero_copy_stream.h
index f532d759..de2374b5 100644
--- a/src/google/protobuf/io/zero_copy_stream.h
+++ b/src/google/protobuf/io/zero_copy_stream.h
@@ -110,6 +110,8 @@
#include <string>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -121,7 +123,7 @@ class ZeroCopyOutputStream;
// Abstract interface similar to an input stream but designed to minimize
// copying.
-class LIBPROTOBUF_EXPORT ZeroCopyInputStream {
+class PROTOBUF_EXPORT ZeroCopyInputStream {
public:
ZeroCopyInputStream() {}
virtual ~ZeroCopyInputStream() {}
@@ -178,7 +180,7 @@ class LIBPROTOBUF_EXPORT ZeroCopyInputStream {
// Abstract interface similar to an output stream but designed to minimize
// copying.
-class LIBPROTOBUF_EXPORT ZeroCopyOutputStream {
+class PROTOBUF_EXPORT ZeroCopyOutputStream {
public:
ZeroCopyOutputStream() {}
virtual ~ZeroCopyOutputStream() {}
@@ -245,4 +247,6 @@ class LIBPROTOBUF_EXPORT ZeroCopyOutputStream {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_H__
diff --git a/src/google/protobuf/io/zero_copy_stream_impl.h b/src/google/protobuf/io/zero_copy_stream_impl.h
index 206fd0d4..46062a85 100644
--- a/src/google/protobuf/io/zero_copy_stream_impl.h
+++ b/src/google/protobuf/io/zero_copy_stream_impl.h
@@ -47,6 +47,8 @@
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace io {
@@ -60,7 +62,7 @@ namespace io {
// The latter will introduce an extra layer of buffering, harming performance.
// Also, it's conceivable that FileInputStream could someday be enhanced
// to use zero-copy file descriptors on OSs which support them.
-class LIBPROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream {
public:
// Creates a stream that reads from the given Unix file descriptor.
// If a block_size is given, it specifies the number of bytes that
@@ -93,7 +95,7 @@ class LIBPROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream {
int64 ByteCount() const override;
private:
- class LIBPROTOBUF_EXPORT CopyingFileInputStream : public CopyingInputStream {
+ class PROTOBUF_EXPORT CopyingFileInputStream : public CopyingInputStream {
public:
CopyingFileInputStream(int file_descriptor);
~CopyingFileInputStream() override;
@@ -137,7 +139,7 @@ class LIBPROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream {
// harming performance. Also, it's conceivable that FileOutputStream could
// someday be enhanced to use zero-copy file descriptors on OSs which
// support them.
-class LIBPROTOBUF_EXPORT FileOutputStream : public ZeroCopyOutputStream {
+class PROTOBUF_EXPORT FileOutputStream : public ZeroCopyOutputStream {
public:
// Creates a stream that writes to the given Unix file descriptor.
// If a block_size is given, it specifies the size of the buffers
@@ -175,7 +177,7 @@ class LIBPROTOBUF_EXPORT FileOutputStream : public ZeroCopyOutputStream {
int64 ByteCount() const override;
private:
- class LIBPROTOBUF_EXPORT CopyingFileOutputStream : public CopyingOutputStream {
+ class PROTOBUF_EXPORT CopyingFileOutputStream : public CopyingOutputStream {
public:
CopyingFileOutputStream(int file_descriptor);
~CopyingFileOutputStream() override;
@@ -211,7 +213,7 @@ class LIBPROTOBUF_EXPORT FileOutputStream : public ZeroCopyOutputStream {
//
// Note that for reading files (or anything represented by a file descriptor),
// FileInputStream is more efficient.
-class LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream {
public:
// Creates a stream that reads from the given C++ istream.
// If a block_size is given, it specifies the number of bytes that
@@ -226,7 +228,7 @@ class LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream {
int64 ByteCount() const override;
private:
- class LIBPROTOBUF_EXPORT CopyingIstreamInputStream : public CopyingInputStream {
+ class PROTOBUF_EXPORT CopyingIstreamInputStream : public CopyingInputStream {
public:
CopyingIstreamInputStream(std::istream* input);
~CopyingIstreamInputStream() override;
@@ -254,7 +256,7 @@ class LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream {
//
// Note that for writing files (or anything represented by a file descriptor),
// FileOutputStream is more efficient.
-class LIBPROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream {
+class PROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream {
public:
// Creates a stream that writes to the given C++ ostream.
// If a block_size is given, it specifies the size of the buffers
@@ -269,7 +271,8 @@ class LIBPROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream {
int64 ByteCount() const override;
private:
- class LIBPROTOBUF_EXPORT CopyingOstreamOutputStream : public CopyingOutputStream {
+ class PROTOBUF_EXPORT CopyingOstreamOutputStream
+ : public CopyingOutputStream {
public:
CopyingOstreamOutputStream(std::ostream* output);
~CopyingOstreamOutputStream() override;
@@ -299,7 +302,7 @@ class LIBPROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream {
// ConcatenatingInputStream may do odd things. It is suggested that you do
// not use ConcatenatingInputStream on streams that might produce read errors
// other than end-of-stream.
-class LIBPROTOBUF_EXPORT ConcatenatingInputStream : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT ConcatenatingInputStream : public ZeroCopyInputStream {
public:
// All streams passed in as well as the array itself must remain valid
// until the ConcatenatingInputStream is destroyed.
@@ -327,7 +330,7 @@ class LIBPROTOBUF_EXPORT ConcatenatingInputStream : public ZeroCopyInputStream {
// A ZeroCopyInputStream which wraps some other stream and limits it to
// a particular byte count.
-class LIBPROTOBUF_EXPORT LimitingInputStream : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT LimitingInputStream : public ZeroCopyInputStream {
public:
LimitingInputStream(ZeroCopyInputStream* input, int64 limit);
~LimitingInputStream() override;
@@ -353,4 +356,6 @@ class LIBPROTOBUF_EXPORT LimitingInputStream : public ZeroCopyInputStream {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_H__
diff --git a/src/google/protobuf/io/zero_copy_stream_impl_lite.h b/src/google/protobuf/io/zero_copy_stream_impl_lite.h
index da4ef455..07d18849 100644
--- a/src/google/protobuf/io/zero_copy_stream_impl_lite.h
+++ b/src/google/protobuf/io/zero_copy_stream_impl_lite.h
@@ -53,6 +53,8 @@
#include <google/protobuf/stubs/stl_util.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
namespace io {
@@ -60,7 +62,7 @@ namespace io {
// ===================================================================
// A ZeroCopyInputStream backed by an in-memory array of bytes.
-class LIBPROTOBUF_EXPORT ArrayInputStream : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT ArrayInputStream : public ZeroCopyInputStream {
public:
// Create an InputStream that returns the bytes pointed to by "data".
// "data" remains the property of the caller but must remain valid until
@@ -94,7 +96,7 @@ class LIBPROTOBUF_EXPORT ArrayInputStream : public ZeroCopyInputStream {
// ===================================================================
// A ZeroCopyOutputStream backed by an in-memory array of bytes.
-class LIBPROTOBUF_EXPORT ArrayOutputStream : public ZeroCopyOutputStream {
+class PROTOBUF_EXPORT ArrayOutputStream : public ZeroCopyOutputStream {
public:
// Create an OutputStream that writes to the bytes pointed to by "data".
// "data" remains the property of the caller but must remain valid until
@@ -126,7 +128,7 @@ class LIBPROTOBUF_EXPORT ArrayOutputStream : public ZeroCopyOutputStream {
// ===================================================================
// A ZeroCopyOutputStream which appends bytes to a string.
-class LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream {
+class PROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream {
public:
// Create a StringOutputStream which appends bytes to the given string.
// The string remains property of the caller, but it is mutated in arbitrary
@@ -137,7 +139,7 @@ class LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream {
// Hint: If you call target->reserve(n) before creating the stream,
// the first call to Next() will return at least n bytes of buffer
// space.
- explicit StringOutputStream(string* target);
+ explicit StringOutputStream(std::string* target);
~StringOutputStream() override = default;
// implements ZeroCopyOutputStream ---------------------------------
@@ -146,12 +148,12 @@ class LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream {
int64 ByteCount() const override;
protected:
- void SetString(string* target);
+ void SetString(std::string* target);
private:
static const int kMinimumSize = 16;
- string* target_;
+ std::string* target_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringOutputStream);
};
@@ -173,7 +175,7 @@ class LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream {
// CopyingInputStream implementations should avoid buffering if possible.
// CopyingInputStreamAdaptor does its own buffering and will read data
// in large blocks.
-class LIBPROTOBUF_EXPORT CopyingInputStream {
+class PROTOBUF_EXPORT CopyingInputStream {
public:
virtual ~CopyingInputStream() {}
@@ -199,7 +201,7 @@ class LIBPROTOBUF_EXPORT CopyingInputStream {
// If you want to read from file descriptors or C++ istreams, this is
// already implemented for you: use FileInputStream or IstreamInputStream
// respectively.
-class LIBPROTOBUF_EXPORT CopyingInputStreamAdaptor : public ZeroCopyInputStream {
+class PROTOBUF_EXPORT CopyingInputStreamAdaptor : public ZeroCopyInputStream {
public:
// Creates a stream that reads from the given CopyingInputStream.
// If a block_size is given, it specifies the number of bytes that
@@ -267,7 +269,7 @@ class LIBPROTOBUF_EXPORT CopyingInputStreamAdaptor : public ZeroCopyInputStream
// CopyingOutputStream implementations should avoid buffering if possible.
// CopyingOutputStreamAdaptor does its own buffering and will write data
// in large blocks.
-class LIBPROTOBUF_EXPORT CopyingOutputStream {
+class PROTOBUF_EXPORT CopyingOutputStream {
public:
virtual ~CopyingOutputStream() {}
@@ -283,7 +285,7 @@ class LIBPROTOBUF_EXPORT CopyingOutputStream {
// If you want to write to file descriptors or C++ ostreams, this is
// already implemented for you: use FileOutputStream or OstreamOutputStream
// respectively.
-class LIBPROTOBUF_EXPORT CopyingOutputStreamAdaptor : public ZeroCopyOutputStream {
+class PROTOBUF_EXPORT CopyingOutputStreamAdaptor : public ZeroCopyOutputStream {
public:
// Creates a stream that writes to the given Unix file descriptor.
// If a block_size is given, it specifies the size of the buffers
@@ -356,7 +358,7 @@ class LIBPROTOBUF_EXPORT CopyingOutputStreamAdaptor : public ZeroCopyOutputStrea
// Return a pointer to mutable characters underlying the given string. The
// return value is valid until the next time the string is resized. We
// trust the caller to treat the return value as an array of length s->size().
-inline char* mutable_string_data(string* s) {
+inline char* mutable_string_data(std::string* s) {
#ifdef LANG_CXX11
// This should be simpler & faster than string_as_array() because the latter
// is guaranteed to return NULL when *s is empty, so it has to check for that.
@@ -370,7 +372,7 @@ inline char* mutable_string_data(string* s) {
// ({ char* p = mutable_string_data(s); make_pair(p, p != NULL); })
// Sometimes it's faster: in some scenarios p cannot be NULL, and then the
// code can avoid that check.
-inline std::pair<char*, bool> as_string_data(string* s) {
+inline std::pair<char*, bool> as_string_data(std::string* s) {
char *p = mutable_string_data(s);
#ifdef LANG_CXX11
return std::make_pair(p, true);
@@ -383,4 +385,6 @@ inline std::pair<char*, bool> as_string_data(string* s) {
} // namespace protobuf
} // namespace google
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__