Thrift: Generate structural fingerprints for thrift structs.
Summary:
We are going to write a dense protocol soon that eliminates some metadata.
To prevent version conflicts, we want each structure to have a
structural fingerprint that will change whenever the struct changes
in a way that will affect the dense protocol.
This change computes those fingerprints and puts them in
the generated C++ code.
Reviewed By: aditya, mcslee
Test Plan:
Recompiled thrift.
Thrifted DebugProtoTest with old and new compilers.
Compared output.
Also ran thrift with those "cout"s uncommented,
examined the fingerprint material,
and verified the hashes.
Revert Plan: ok
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665227 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/parse/t_field.h b/compiler/cpp/src/parse/t_field.h
index a4a2cc7..25c50a5 100644
--- a/compiler/cpp/src/parse/t_field.h
+++ b/compiler/cpp/src/parse/t_field.h
@@ -8,6 +8,7 @@
#define T_FIELD_H
#include <string>
+#include <boost/lexical_cast.hpp>
// Forward declare for xsd_attrs
class t_struct;
@@ -112,6 +113,14 @@
has_doc_ = true;
}
+ // This is not the same function as t_type::get_fingerprint_material,
+ // but it does the same thing.
+ std::string get_fingerprint_material() const {
+ return boost::lexical_cast<std::string>(key_) + ":" +
+ (req_ == OPTIONAL ? "opt-" : "") +
+ type_->get_fingerprint_material();
+ }
+
private:
t_type* type_;
std::string name_;