diff options
Diffstat (limited to 'src/google/protobuf/util/internal/datapiece.h')
-rw-r--r-- | src/google/protobuf/util/internal/datapiece.h | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/google/protobuf/util/internal/datapiece.h b/src/google/protobuf/util/internal/datapiece.h index 95b133da..074fde69 100644 --- a/src/google/protobuf/util/internal/datapiece.h +++ b/src/google/protobuf/util/internal/datapiece.h @@ -37,16 +37,17 @@ #include <google/protobuf/stubs/stringpiece.h> #include <google/protobuf/stubs/statusor.h> - namespace google { namespace protobuf { class Enum; } // namespace protobuf +} // namespace google - +namespace google { namespace protobuf { namespace util { namespace converter { +class ProtoWriter; // Container for a single piece of data together with its data type. // @@ -164,10 +165,13 @@ class LIBPROTOBUF_EXPORT DataPiece { // If the value is not a string, attempts to convert to a 32-bit integer. // If none of these succeeds, returns a conversion error status. util::StatusOr<int> ToEnum(const google::protobuf::Enum* enum_type, - bool use_lower_camel_for_enums, - bool ignore_unknown_enum_values) const; + bool use_lower_camel_for_enums) const { + return ToEnum(enum_type, use_lower_camel_for_enums, false, nullptr); + } private: + friend class ProtoWriter; + // Disallow implicit constructor. DataPiece(); @@ -175,6 +179,13 @@ class LIBPROTOBUF_EXPORT DataPiece { DataPiece(Type type, int32 val) : type_(type), i32_(val), use_strict_base64_decoding_(false) {} + // Same as the ToEnum() method above but with additional flag to ignore + // unknown enum values. + util::StatusOr<int> ToEnum(const google::protobuf::Enum* enum_type, + bool use_lower_camel_for_enums, + bool ignore_unknown_enum_values, + bool* is_unknown_enum_value) const; + // For numeric conversion between // int32, int64, uint32, uint64, double, float and bool template <typename To> @@ -183,7 +194,8 @@ class LIBPROTOBUF_EXPORT DataPiece { // For conversion from string to // int32, int64, uint32, uint64, double, float and bool template <typename To> - util::StatusOr<To> StringToNumber(bool (*func)(StringPiece, To*)) const; + util::StatusOr<To> StringToNumber(bool (*func)(StringPiece, + To*)) const; // Decodes a base64 string. Returns true on success. bool DecodeBase64(StringPiece src, string* dest) const; @@ -215,6 +227,6 @@ class LIBPROTOBUF_EXPORT DataPiece { } // namespace converter } // namespace util } // namespace protobuf - } // namespace google + #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_DATAPIECE_H__ |