aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/util
diff options
context:
space:
mode:
authorGravatar Bo Yang <teboring@google.com>2015-08-23 10:45:14 -0700
committerGravatar Bo Yang <teboring@google.com>2015-08-25 17:58:48 -0700
commitff7bdad231d037802fd457ee4fd65e0291d366d7 (patch)
tree12f437b32201cdbbfade6d63193e15483640716d /src/google/protobuf/util
parent839b180dbae98adf6caa54d0fb87b8d0a43081dc (diff)
Fix bugs on windows
Diffstat (limited to 'src/google/protobuf/util')
-rw-r--r--src/google/protobuf/util/internal/datapiece.h14
-rw-r--r--src/google/protobuf/util/internal/default_value_objectwriter.h2
-rw-r--r--src/google/protobuf/util/internal/json_objectwriter.cc9
-rw-r--r--src/google/protobuf/util/internal/type_info.h2
-rw-r--r--src/google/protobuf/util/internal/utility.cc2
-rw-r--r--src/google/protobuf/util/json_util.h4
-rw-r--r--src/google/protobuf/util/time_util.h31
-rw-r--r--src/google/protobuf/util/type_resolver_util.h2
8 files changed, 40 insertions, 26 deletions
diff --git a/src/google/protobuf/util/internal/datapiece.h b/src/google/protobuf/util/internal/datapiece.h
index 30947252..2ab3fa88 100644
--- a/src/google/protobuf/util/internal/datapiece.h
+++ b/src/google/protobuf/util/internal/datapiece.h
@@ -193,13 +193,13 @@ class LIBPROTOBUF_EXPORT DataPiece {
// Stored piece of data.
union {
- const int32 i32_;
- const int64 i64_;
- const uint32 u32_;
- const uint64 u64_;
- const double double_;
- const float float_;
- const bool bool_;
+ int32 i32_;
+ int64 i64_;
+ uint32 u32_;
+ uint64 u64_;
+ double double_;
+ float float_;
+ bool bool_;
StringPiecePod str_;
};
};
diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.h b/src/google/protobuf/util/internal/default_value_objectwriter.h
index 2468c8d9..d4547601 100644
--- a/src/google/protobuf/util/internal/default_value_objectwriter.h
+++ b/src/google/protobuf/util/internal/default_value_objectwriter.h
@@ -57,7 +57,7 @@ namespace converter {
// ObjectWriter when EndObject() is called on the root object. It also writes
// out all non-repeated primitive fields that haven't been explicitly rendered
// with their default values (0 for numbers, "" for strings, etc).
-class DefaultValueObjectWriter : public ObjectWriter {
+class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
public:
DefaultValueObjectWriter(TypeResolver* type_resolver,
const google::protobuf::Type& type,
diff --git a/src/google/protobuf/util/internal/json_objectwriter.cc b/src/google/protobuf/util/internal/json_objectwriter.cc
index d88a81f9..f81e3306 100644
--- a/src/google/protobuf/util/internal/json_objectwriter.cc
+++ b/src/google/protobuf/util/internal/json_objectwriter.cc
@@ -37,6 +37,7 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/util/internal/utility.h>
#include <google/protobuf/util/internal/json_escaping.h>
+#include <google/protobuf/stubs/mathlimits.h>
#include <google/protobuf/stubs/strutil.h>
namespace google {
@@ -115,7 +116,9 @@ JsonObjectWriter* JsonObjectWriter::RenderUint64(StringPiece name,
JsonObjectWriter* JsonObjectWriter::RenderDouble(StringPiece name,
double value) {
- if (isfinite(value)) return RenderSimple(name, SimpleDtoa(value));
+ if (google::protobuf::MathLimits<double>::IsFinite(value)) {
+ return RenderSimple(name, SimpleDtoa(value));
+ }
// Render quoted with NaN/Infinity-aware DoubleAsString.
return RenderString(name, DoubleAsString(value));
@@ -123,7 +126,9 @@ JsonObjectWriter* JsonObjectWriter::RenderDouble(StringPiece name,
JsonObjectWriter* JsonObjectWriter::RenderFloat(StringPiece name,
float value) {
- if (isfinite(value)) return RenderSimple(name, SimpleFtoa(value));
+ if (google::protobuf::MathLimits<float>::IsFinite(value)) {
+ return RenderSimple(name, SimpleFtoa(value));
+ }
// Render quoted with NaN/Infinity-aware FloatAsString.
return RenderString(name, FloatAsString(value));
diff --git a/src/google/protobuf/util/internal/type_info.h b/src/google/protobuf/util/internal/type_info.h
index e394e8cf..d8133176 100644
--- a/src/google/protobuf/util/internal/type_info.h
+++ b/src/google/protobuf/util/internal/type_info.h
@@ -44,7 +44,7 @@ namespace util {
namespace converter {
// Internal helper class for type resolving. Note that this class is not
// thread-safe and should only be accessed in one thread.
-class TypeInfo {
+class LIBPROTOBUF_EXPORT TypeInfo {
public:
TypeInfo() {}
virtual ~TypeInfo() {}
diff --git a/src/google/protobuf/util/internal/utility.cc b/src/google/protobuf/util/internal/utility.cc
index 2d63de00..d4ac6f77 100644
--- a/src/google/protobuf/util/internal/utility.cc
+++ b/src/google/protobuf/util/internal/utility.cc
@@ -311,7 +311,7 @@ string DoubleAsString(double value) {
}
string FloatAsString(float value) {
- if (isfinite(value)) return SimpleFtoa(value);
+ if (google::protobuf::MathLimits<float>::IsFinite(value)) return SimpleFtoa(value);
return DoubleAsString(value);
}
diff --git a/src/google/protobuf/util/json_util.h b/src/google/protobuf/util/json_util.h
index 614564cc..1718bfb5 100644
--- a/src/google/protobuf/util/json_util.h
+++ b/src/google/protobuf/util/json_util.h
@@ -80,7 +80,7 @@ inline util::Status BinaryToJsonStream(
JsonOptions());
}
-util::Status BinaryToJsonString(
+LIBPROTOBUF_EXPORT util::Status BinaryToJsonString(
TypeResolver* resolver,
const string& type_url,
const string& binary_input,
@@ -107,7 +107,7 @@ util::Status JsonToBinaryStream(
io::ZeroCopyInputStream* json_input,
io::ZeroCopyOutputStream* binary_output);
-util::Status JsonToBinaryString(
+LIBPROTOBUF_EXPORT util::Status JsonToBinaryString(
TypeResolver* resolver,
const string& type_url,
const string& json_input,
diff --git a/src/google/protobuf/util/time_util.h b/src/google/protobuf/util/time_util.h
index 11268157..58dbf8e6 100644
--- a/src/google/protobuf/util/time_util.h
+++ b/src/google/protobuf/util/time_util.h
@@ -31,13 +31,17 @@
#ifndef GOOGLE_PROTOBUF_UTIL_TIME_UTIL_H__
#define GOOGLE_PROTOBUF_UTIL_TIME_UTIL_H__
-#include <sys/time.h>
-
#include <ctime>
#include <ostream>
#include <string>
+#ifdef _MSC_VER
+#include <winsock2.h>
+#else
+#include <sys/time.h>
+#endif
#include <google/protobuf/duration.pb.h>
+#include <google/protobuf/stubs/port.h>
#include <google/protobuf/timestamp.pb.h>
namespace google {
@@ -85,6 +89,9 @@ class LIBPROTOBUF_EXPORT TimeUtil {
static string ToString(const Duration& duration);
static bool FromString(const string& value, Duration* timestamp);
+#ifdef GetCurrentTime
+#undef GetCurrentTime // Visual Studio has macro GetCurrentTime
+#endif
// Gets the current UTC time.
static Timestamp GetCurrentTime();
// Returns the Time representing "1970-01-01 00:00:00".
@@ -153,12 +160,12 @@ namespace protobuf {
// Overloaded operators for Duration.
//
// Assignment operators.
-Duration& operator+=(Duration& d1, const Duration& d2); // NOLINT
-Duration& operator-=(Duration& d1, const Duration& d2); // NOLINT
-Duration& operator*=(Duration& d, int64 r); // NOLINT
-Duration& operator*=(Duration& d, double r); // NOLINT
-Duration& operator/=(Duration& d, int64 r); // NOLINT
-Duration& operator/=(Duration& d, double r); // NOLINT
+LIBPROTOBUF_EXPORT Duration& operator+=(Duration& d1, const Duration& d2); // NOLINT
+LIBPROTOBUF_EXPORT Duration& operator-=(Duration& d1, const Duration& d2); // NOLINT
+LIBPROTOBUF_EXPORT Duration& operator*=(Duration& d, int64 r); // NOLINT
+LIBPROTOBUF_EXPORT Duration& operator*=(Duration& d, double r); // NOLINT
+LIBPROTOBUF_EXPORT Duration& operator/=(Duration& d, int64 r); // NOLINT
+LIBPROTOBUF_EXPORT Duration& operator/=(Duration& d, double r); // NOLINT
// Overload for other integer types.
template <typename T>
Duration& operator*=(Duration& d, T r) { // NOLINT
@@ -170,7 +177,7 @@ Duration& operator/=(Duration& d, T r) { // NOLINT
int64 x = r;
return d /= x;
}
-Duration& operator%=(Duration& d1, const Duration& d2); // NOLINT
+LIBPROTOBUF_EXPORT Duration& operator%=(Duration& d1, const Duration& d2); // NOLINT
// Relational operators.
inline bool operator<(const Duration& d1, const Duration& d2) {
if (d1.seconds() == d2.seconds()) {
@@ -221,7 +228,7 @@ template<typename T>
inline Duration operator/(Duration d, T r) {
return d /= r;
}
-int64 operator/(const Duration& d1, const Duration& d2);
+LIBPROTOBUF_EXPORT int64 operator/(const Duration& d1, const Duration& d2);
inline Duration operator%(const Duration& d1, const Duration& d2) {
Duration result = d1;
@@ -236,7 +243,9 @@ inline ostream& operator<<(ostream& out, const Duration& d) {
// Overloaded operators for Timestamp
//
// Assignement operators.
+LIBPROTOBUF_EXPORT
Timestamp& operator+=(Timestamp& t, const Duration& d); // NOLINT
+LIBPROTOBUF_EXPORT
Timestamp& operator-=(Timestamp& t, const Duration& d); // NOLINT
// Relational operators.
inline bool operator<(const Timestamp& t1, const Timestamp& t2) {
@@ -273,7 +282,7 @@ inline Timestamp operator-(const Timestamp& t, const Duration& d) {
Timestamp result = t;
return result -= d;
}
-Duration operator-(const Timestamp& t1, const Timestamp& t2);
+LIBPROTOBUF_EXPORT Duration operator-(const Timestamp& t1, const Timestamp& t2);
inline ostream& operator<<(ostream& out, const Timestamp& t) {
out << google::protobuf::util::TimeUtil::ToString(t);
diff --git a/src/google/protobuf/util/type_resolver_util.h b/src/google/protobuf/util/type_resolver_util.h
index 00cf9c13..c0ef3c1a 100644
--- a/src/google/protobuf/util/type_resolver_util.h
+++ b/src/google/protobuf/util/type_resolver_util.h
@@ -42,7 +42,7 @@ class TypeResolver;
// Creates a TypeResolver that serves type information in the given descriptor
// pool. Caller takes ownership of the returned TypeResolver.
-TypeResolver* NewTypeResolverForDescriptorPool(
+LIBPROTOBUF_EXPORT TypeResolver* NewTypeResolverForDescriptorPool(
const string& url_prefix, const DescriptorPool* pool);
} // namespace util