Infrastructure for a language-neutral namespace declaration.
Altered the once-deprecated "namespace" directive in .thrift files
to take two identifiers: the language and the namespace.
They are stored in a map inside of the program object.
Future changes will convert specific generators to use this map
and deprecate the old language-specific tokens.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665512 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/parse/t_program.h b/compiler/cpp/src/parse/t_program.h
index 7b369d6..d788e2b 100644
--- a/compiler/cpp/src/parse/t_program.h
+++ b/compiler/cpp/src/parse/t_program.h
@@ -145,6 +145,19 @@
}
}
+ // Language neutral namespace / packaging
+ void set_namespace(std::string language, std::string name_space) {
+ namespaces_[language] = name_space;
+ }
+
+ std::string get_namespace(std::string language) const {
+ std::map<std::string, std::string>::const_iterator iter = namespaces_.find(language);
+ if (iter == namespaces_.end()) {
+ return std::string();
+ }
+ return iter->second;
+ }
+
// Language specific namespace / packaging
void set_cpp_namespace(std::string cpp_namespace) {
@@ -275,6 +288,9 @@
std::vector<t_struct*> xceptions_;
std::vector<t_service*> services_;
+ // Dynamic namespaces
+ std::map<std::string, std::string> namespaces_;
+
// C++ namespace
std::string cpp_namespace_;