adding documentation syntax to thrift
see DocTest.thrift for examples.
todo: integrate parsed documentation into code generation
review: marc k, mcslee
test plan: DocTest.thrift
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664970 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/parse/t_enum_value.h b/compiler/cpp/src/parse/t_enum_value.h
index 65e61cb..66be3b3 100644
--- a/compiler/cpp/src/parse/t_enum_value.h
+++ b/compiler/cpp/src/parse/t_enum_value.h
@@ -2,6 +2,7 @@
#define T_ENUM_VALUE_H
#include <string>
+#include "t_doc.h"
/**
* A constant. These are used inside of enum definitions. Constants are just
@@ -10,7 +11,7 @@
*
* @author Mark Slee <mcslee@facebook.com>
*/
-class t_enum_value {
+class t_enum_value : public t_doc {
public:
t_enum_value(std::string name) :
name_(name),
diff --git a/compiler/cpp/src/parse/t_field.h b/compiler/cpp/src/parse/t_field.h
index 058b9fb..03d4ba7 100644
--- a/compiler/cpp/src/parse/t_field.h
+++ b/compiler/cpp/src/parse/t_field.h
@@ -55,14 +55,30 @@
return value_;
}
+ const std::string& get_doc() const {
+ return doc_;
+ }
+
+ bool has_doc() {
+ return has_doc_;
+ }
+
+ void set_doc(const std::string& doc) {
+ doc_ = doc;
+ has_doc_ = true;
+ }
+
private:
t_type* type_;
std::string name_;
int32_t key_;
t_const_value* value_;
-
+
bool xsd_optional_;
+ std::string doc_;
+ bool has_doc_;
+
};
#endif
diff --git a/compiler/cpp/src/parse/t_function.h b/compiler/cpp/src/parse/t_function.h
index 6f06abe..e75c659 100644
--- a/compiler/cpp/src/parse/t_function.h
+++ b/compiler/cpp/src/parse/t_function.h
@@ -4,6 +4,7 @@
#include <string>
#include "t_type.h"
#include "t_struct.h"
+#include "t_doc.h"
/**
* Representation of a function. Key parts are return type, function name,
@@ -12,7 +13,7 @@
*
* @author Mark Slee <mcslee@facebook.com>
*/
-class t_function {
+class t_function : public t_doc {
public:
t_function(t_type* returntype,
std::string name,
diff --git a/compiler/cpp/src/parse/t_program.h b/compiler/cpp/src/parse/t_program.h
index 7f7af44..610867a 100644
--- a/compiler/cpp/src/parse/t_program.h
+++ b/compiler/cpp/src/parse/t_program.h
@@ -18,6 +18,7 @@
#include "t_list.h"
#include "t_map.h"
#include "t_set.h"
+//#include "t_doc.h"
/**
* Top level class representing an entire thrift program. A program consists
diff --git a/compiler/cpp/src/parse/t_type.h b/compiler/cpp/src/parse/t_type.h
index da062b5..f6aa7ab 100644
--- a/compiler/cpp/src/parse/t_type.h
+++ b/compiler/cpp/src/parse/t_type.h
@@ -2,6 +2,7 @@
#define T_TYPE_H
#include <string>
+#include "t_doc.h"
class t_program;
@@ -14,7 +15,7 @@
*
* @author Mark Slee <mcslee@facebook.com>
*/
-class t_type {
+class t_type : public t_doc {
public:
virtual ~t_type() {}
@@ -55,9 +56,10 @@
t_type(std::string name) :
name_(name) {}
-
+
t_program* program_;
std::string name_;
+
};
#endif