aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/stubs
diff options
context:
space:
mode:
authorGravatar Feng Xiao <xfxyjwf@gmail.com>2015-06-15 21:42:57 -0700
committerGravatar Feng Xiao <xfxyjwf@gmail.com>2015-06-17 11:19:46 -0700
commit818c5eee08840355d70d2f3bdf1a2f17986a5e70 (patch)
treee6db0b1344385f8c48820c58d7297f653bff39f7 /src/google/protobuf/stubs
parente96ff30120a3834f7d1e31e43e591bf7cfbd731f (diff)
Fix broken builds.
Diffstat (limited to 'src/google/protobuf/stubs')
-rw-r--r--src/google/protobuf/stubs/bytestream.h18
-rw-r--r--src/google/protobuf/stubs/common.cc13
-rw-r--r--src/google/protobuf/stubs/common.h8
-rw-r--r--src/google/protobuf/stubs/mathlimits.h8
-rw-r--r--src/google/protobuf/stubs/status.cc2
-rw-r--r--src/google/protobuf/stubs/status.h4
-rw-r--r--src/google/protobuf/stubs/statusor.h2
-rw-r--r--src/google/protobuf/stubs/stringpiece.h5
-rw-r--r--src/google/protobuf/stubs/strutil_unittest.cc7
-rw-r--r--src/google/protobuf/stubs/time.cc2
-rw-r--r--src/google/protobuf/stubs/time.h10
11 files changed, 52 insertions, 27 deletions
diff --git a/src/google/protobuf/stubs/bytestream.h b/src/google/protobuf/stubs/bytestream.h
index c9c9a76e..de8e0204 100644
--- a/src/google/protobuf/stubs/bytestream.h
+++ b/src/google/protobuf/stubs/bytestream.h
@@ -74,7 +74,7 @@ namespace strings {
// sink->Append(my_data.data(), my_data.size());
// sink->Flush();
//
-class ByteSink {
+class LIBPROTOBUF_EXPORT ByteSink {
public:
ByteSink() {}
virtual ~ByteSink() {}
@@ -103,7 +103,7 @@ class ByteSink {
// source->Skip(data.length());
// }
//
-class ByteSource {
+class LIBPROTOBUF_EXPORT ByteSource {
public:
ByteSource() {}
virtual ~ByteSource() {}
@@ -159,7 +159,7 @@ class ByteSource {
// sink.Append("hi", 2); // OK
// sink.Append(data, 100); // WOOPS! Overflows buf[10].
//
-class UncheckedArrayByteSink : public ByteSink {
+class LIBPROTOBUF_EXPORT UncheckedArrayByteSink : public ByteSink {
public:
explicit UncheckedArrayByteSink(char* dest) : dest_(dest) {}
virtual void Append(const char* data, size_t n);
@@ -187,7 +187,7 @@ class UncheckedArrayByteSink : public ByteSink {
// sink.Append("hi", 2); // OK
// sink.Append(data, 100); // Will only write 8 more bytes
//
-class CheckedArrayByteSink : public ByteSink {
+class LIBPROTOBUF_EXPORT CheckedArrayByteSink : public ByteSink {
public:
CheckedArrayByteSink(char* outbuf, size_t capacity);
virtual void Append(const char* bytes, size_t n);
@@ -223,7 +223,7 @@ class CheckedArrayByteSink : public ByteSink {
// const char* buf = sink.GetBuffer(); // Ownership transferred
// delete[] buf;
//
-class GrowingArrayByteSink : public strings::ByteSink {
+class LIBPROTOBUF_EXPORT GrowingArrayByteSink : public strings::ByteSink {
public:
explicit GrowingArrayByteSink(size_t estimated_size);
virtual ~GrowingArrayByteSink();
@@ -253,7 +253,7 @@ class GrowingArrayByteSink : public strings::ByteSink {
// sink.Append("World", 5);
// assert(dest == "Hello World");
//
-class StringByteSink : public ByteSink {
+class LIBPROTOBUF_EXPORT StringByteSink : public ByteSink {
public:
explicit StringByteSink(string* dest) : dest_(dest) {}
virtual void Append(const char* data, size_t n);
@@ -270,7 +270,7 @@ class StringByteSink : public ByteSink {
// NullByteSink sink;
// sink.Append(data, data.size()); // All data ignored.
//
-class NullByteSink : public ByteSink {
+class LIBPROTOBUF_EXPORT NullByteSink : public ByteSink {
public:
NullByteSink() {}
virtual void Append(const char *data, size_t n) {}
@@ -292,7 +292,7 @@ class NullByteSink : public ByteSink {
// assert(source.Available() == 5);
// assert(source.Peek() == "Hello");
//
-class ArrayByteSource : public ByteSource {
+class LIBPROTOBUF_EXPORT ArrayByteSource : public ByteSource {
public:
explicit ArrayByteSource(StringPiece s) : input_(s) {}
@@ -323,7 +323,7 @@ class ArrayByteSource : public ByteSource {
// assert(limit.Available() == 5);
// assert(limit.Peek() == "Hello");
//
-class LimitByteSource : public ByteSource {
+class LIBPROTOBUF_EXPORT LimitByteSource : public ByteSource {
public:
// Returns at most "limit" bytes from "source".
LimitByteSource(ByteSource* source, size_t limit);
diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc
index b895d915..5173ba5d 100644
--- a/src/google/protobuf/stubs/common.cc
+++ b/src/google/protobuf/stubs/common.cc
@@ -34,6 +34,7 @@
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/stubs/status.h>
#include <google/protobuf/stubs/stringpiece.h>
+#include <google/protobuf/stubs/strutil.h>
#include <stdio.h>
#include <errno.h>
#include <vector>
@@ -155,6 +156,16 @@ LogMessage& LogMessage::operator<<(const StringPiece& value) {
return *this;
}
+LogMessage& LogMessage::operator<<(long long value) {
+ message_ += SimpleItoa(value);
+ return *this;
+}
+
+LogMessage& LogMessage::operator<<(unsigned long long value) {
+ message_ += SimpleItoa(value);
+ return *this;
+}
+
LogMessage& LogMessage::operator<<(
const ::google::protobuf::util::Status& status) {
message_ += status.ToString();
@@ -180,7 +191,7 @@ LogMessage& LogMessage::operator<<(
DECLARE_STREAM_OPERATOR(char , "%c" )
DECLARE_STREAM_OPERATOR(int , "%d" )
-DECLARE_STREAM_OPERATOR(uint , "%u" )
+DECLARE_STREAM_OPERATOR(unsigned int , "%u" )
DECLARE_STREAM_OPERATOR(long , "%ld")
DECLARE_STREAM_OPERATOR(unsigned long, "%lu")
DECLARE_STREAM_OPERATOR(double , "%g" )
diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h
index 34d79f48..c3620146 100644
--- a/src/google/protobuf/stubs/common.h
+++ b/src/google/protobuf/stubs/common.h
@@ -50,8 +50,8 @@
#undef PROTOBUF_LITTLE_ENDIAN
#ifdef _MSC_VER
- #if defined(_M_IX86) && \
- !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)
+ // Assuming windows is always little-endian.
+ #if !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)
#define PROTOBUF_LITTLE_ENDIAN 1
#endif
#if _MSC_VER >= 1300
@@ -703,9 +703,11 @@ class LIBPROTOBUF_EXPORT LogMessage {
LogMessage& operator<<(const char* value);
LogMessage& operator<<(char value);
LogMessage& operator<<(int value);
- LogMessage& operator<<(uint value);
+ LogMessage& operator<<(unsigned int value);
LogMessage& operator<<(long value);
LogMessage& operator<<(unsigned long value);
+ LogMessage& operator<<(long long value);
+ LogMessage& operator<<(unsigned long long value);
LogMessage& operator<<(double value);
LogMessage& operator<<(void* value);
LogMessage& operator<<(const StringPiece& value);
diff --git a/src/google/protobuf/stubs/mathlimits.h b/src/google/protobuf/stubs/mathlimits.h
index 39957d69..d9846940 100644
--- a/src/google/protobuf/stubs/mathlimits.h
+++ b/src/google/protobuf/stubs/mathlimits.h
@@ -53,6 +53,8 @@
#include <cfloat>
+#include <google/protobuf/stubs/common.h>
+
// ========================================================================= //
// Useful integer and floating point limits and type traits.
@@ -162,7 +164,7 @@ template<typename T> struct MathLimits {
#define DECL_SIGNED_INT_LIMITS(IntType, UnsignedIntType) \
template<> \
-struct MathLimits<IntType> { \
+struct LIBPROTOBUF_EXPORT MathLimits<IntType> { \
typedef IntType Type; \
typedef UnsignedIntType UnsignedType; \
static const bool kIsSigned = true; \
@@ -182,7 +184,7 @@ struct MathLimits<IntType> { \
#define DECL_UNSIGNED_INT_LIMITS(IntType) \
template<> \
-struct MathLimits<IntType> { \
+struct LIBPROTOBUF_EXPORT MathLimits<IntType> { \
typedef IntType Type; \
typedef IntType UnsignedType; \
static const bool kIsSigned = false; \
@@ -241,7 +243,7 @@ DECL_UNSIGNED_INT_LIMITS(unsigned long long int)
// the global objects construction time.
#define DECL_FP_LIMITS(FP_Type, PREFIX) \
template<> \
-struct MathLimits<FP_Type> { \
+struct LIBPROTOBUF_EXPORT MathLimits<FP_Type> { \
typedef FP_Type Type; \
typedef FP_Type UnsignedType; \
static const bool kIsSigned = true; \
diff --git a/src/google/protobuf/stubs/status.cc b/src/google/protobuf/stubs/status.cc
index 9a68fad4..7314c563 100644
--- a/src/google/protobuf/stubs/status.cc
+++ b/src/google/protobuf/stubs/status.cc
@@ -29,8 +29,10 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <google/protobuf/stubs/status.h>
+#include <ostream>
#include <stdint.h>
#include <stdio.h>
+#include <string>
#include <utility>
namespace google {
diff --git a/src/google/protobuf/stubs/status.h b/src/google/protobuf/stubs/status.h
index 34d6cf12..614ab994 100644
--- a/src/google/protobuf/stubs/status.h
+++ b/src/google/protobuf/stubs/status.h
@@ -62,7 +62,7 @@ enum Code {
};
} // namespace error
-class Status {
+class LIBPROTOBUF_EXPORT Status {
public:
// Creates a "successful" status.
Status();
@@ -106,7 +106,7 @@ class Status {
};
// Prints a human-readable representation of 'x' to 'os'.
-ostream& operator<<(ostream& os, const Status& x);
+LIBPROTOBUF_EXPORT ostream& operator<<(ostream& os, const Status& x);
#define EXPECT_OK(value) EXPECT_TRUE((value).ok())
diff --git a/src/google/protobuf/stubs/statusor.h b/src/google/protobuf/stubs/statusor.h
index 9495107e..a9d2b374 100644
--- a/src/google/protobuf/stubs/statusor.h
+++ b/src/google/protobuf/stubs/statusor.h
@@ -162,7 +162,7 @@ class StatusOr {
namespace internal {
-class StatusOrHelper {
+class LIBPROTOBUF_EXPORT StatusOrHelper {
public:
// Move type-agnostic error handling to the .cc.
static void Crash(const util::Status& status);
diff --git a/src/google/protobuf/stubs/stringpiece.h b/src/google/protobuf/stubs/stringpiece.h
index 5d4d5fe4..353a60d3 100644
--- a/src/google/protobuf/stubs/stringpiece.h
+++ b/src/google/protobuf/stubs/stringpiece.h
@@ -174,7 +174,7 @@ typedef string::difference_type stringpiece_ssize_type;
#define STRINGPIECE_CHECK_SIZE 0
#endif
-class StringPiece {
+class LIBPROTOBUF_EXPORT StringPiece {
private:
const char* ptr_;
stringpiece_ssize_type length_;
@@ -183,6 +183,9 @@ class StringPiece {
// sizeof(stringpiece_ssize_type) may be smaller than sizeof(size_t).
static stringpiece_ssize_type CheckedSsizeTFromSizeT(size_t size) {
#if STRINGPIECE_CHECK_SIZE > 0
+#ifdef max
+#undef max
+#endif
if (size > static_cast<size_t>(
std::numeric_limits<stringpiece_ssize_type>::max())) {
// Some people grep for this message in logs
diff --git a/src/google/protobuf/stubs/strutil_unittest.cc b/src/google/protobuf/stubs/strutil_unittest.cc
index 3e849324..5d62fc4a 100644
--- a/src/google/protobuf/stubs/strutil_unittest.cc
+++ b/src/google/protobuf/stubs/strutil_unittest.cc
@@ -38,6 +38,10 @@
#include <google/protobuf/testing/googletest.h>
#include <gtest/gtest.h>
+#ifdef _WIN32
+#define snprintf _snprintf
+#endif
+
namespace google {
namespace protobuf {
namespace {
@@ -461,7 +465,7 @@ TEST(Base64, EscapeAndUnescape) {
encode_length);
// Is it the expected encoded value?
- EXPECT_STREQ(encode_buffer, base64_tests[i].cyphertext);
+ ASSERT_STREQ(encode_buffer, base64_tests[i].cyphertext);
// If we encode it into a buffer of exactly the right length...
memset(encode_buffer, 0, sizeof(encode_buffer));
@@ -774,7 +778,6 @@ TEST(Base64, EscapeAndUnescape) {
// Now try the long strings, this tests the streaming
for (int i = 0; i < sizeof(base64_strings) / sizeof(base64_strings[0]);
++i) {
-
const unsigned char* unsigned_plaintext =
reinterpret_cast<const unsigned char*>(base64_strings[i].plaintext);
int plain_length = strlen(base64_strings[i].plaintext);
diff --git a/src/google/protobuf/stubs/time.cc b/src/google/protobuf/stubs/time.cc
index 73b99af6..3319a244 100644
--- a/src/google/protobuf/stubs/time.cc
+++ b/src/google/protobuf/stubs/time.cc
@@ -1,5 +1,7 @@
#include <google/protobuf/stubs/time.h>
+#include <ctime>
+
#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/stubs/strutil.h>
diff --git a/src/google/protobuf/stubs/time.h b/src/google/protobuf/stubs/time.h
index 0f641dc9..20a6b56d 100644
--- a/src/google/protobuf/stubs/time.h
+++ b/src/google/protobuf/stubs/time.h
@@ -49,12 +49,12 @@ struct DateTime {
// negative to represent time before 1970-01-01) to DateTime. Returns false
// if the timestamp is not in the range between 0001-01-01T00:00:00 and
// 9999-12-31T23:59:59.
-bool SecondsToDateTime(int64 seconds, DateTime* time);
+bool LIBPROTOBUF_EXPORT SecondsToDateTime(int64 seconds, DateTime* time);
// Converts DateTime to a timestamp (seconds since 1970-01-01T00:00:00).
// Returns false if the DateTime is not valid or is not in the valid range.
-bool DateTimeToSeconds(const DateTime& time, int64* seconds);
+bool LIBPROTOBUF_EXPORT DateTimeToSeconds(const DateTime& time, int64* seconds);
-void GetCurrentTime(int64* seconds, int32* nanos);
+void LIBPROTOBUF_EXPORT GetCurrentTime(int64* seconds, int32* nanos);
// Formats a time string in RFC3339 fromat.
//
@@ -63,10 +63,10 @@ void GetCurrentTime(int64* seconds, int32* nanos);
// value.
//
// Note that "nanos" must in the range of [0, 999999999].
-string FormatTime(int64 seconds, int32 nanos);
+string LIBPROTOBUF_EXPORT FormatTime(int64 seconds, int32 nanos);
// Parses a time string. This method accepts RFC3339 date/time string with UTC
// offset. For example, "2015-05-20T13:29:35.120-08:00".
-bool ParseTime(const string& vaule, int64* seconds, int32* nanos);
+bool LIBPROTOBUF_EXPORT ParseTime(const string& vaule, int64* seconds, int32* nanos);
} // namespace internal
} // namespace protobuf