Thrift: Merging external patch.
Summary:
Merging a patch from Andy Lutomirsky.
- Allow fields to be marked "required" or "optional" (only affects C++).
- Thrift structs now have operator ==.
Reviewed By: mcslee
Test Plan: test/OptionalRequiredTest.cpp
Revert Plan: ok
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665202 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/parse/t_field.h b/compiler/cpp/src/parse/t_field.h
index d342bff..a4a2cc7 100644
--- a/compiler/cpp/src/parse/t_field.h
+++ b/compiler/cpp/src/parse/t_field.h
@@ -33,6 +33,7 @@
type_(type),
name_(name),
key_(key),
+ req_(OPT_IN_REQ_OUT),
value_(NULL),
xsd_optional_(false),
xsd_nillable_(false),
@@ -52,6 +53,20 @@
return key_;
}
+ enum e_req {
+ REQUIRED,
+ OPTIONAL,
+ OPT_IN_REQ_OUT
+ };
+
+ void set_req(e_req req) {
+ req_ = req;
+ }
+
+ e_req get_req() const {
+ return req_;
+ }
+
void set_value(t_const_value* value) {
value_ = value;
}
@@ -101,6 +116,7 @@
t_type* type_;
std::string name_;
int32_t key_;
+ e_req req_;
t_const_value* value_;
bool xsd_optional_;