Update thrift compiler for new syntax, generate new form of C++ code
Reviewed By: wayne, he loves less warnings
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664840 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/parse/t_scope.h b/compiler/cpp/src/parse/t_scope.h
new file mode 100644
index 0000000..504393b
--- /dev/null
+++ b/compiler/cpp/src/parse/t_scope.h
@@ -0,0 +1,57 @@
+#ifndef T_SCOPE_H
+#define T_SCOPE_H
+
+#include <map>
+#include <string>
+
+#include "t_type.h"
+#include "t_service.h"
+
+/**
+ * This represents a variable scope used for looking up predefined types and
+ * services. Typically, a scope is associated with a t_program. Scopes are not
+ * used to determine code generation, but rather to resolve identifiers at
+ * parse time.
+ *
+ * @author Mark Slee <mcslee@facebook.com>
+ */
+class t_scope {
+ public:
+ t_scope() {}
+
+ void add_type(std::string name, t_type* type) {
+ types_[name] = type;
+ }
+
+ t_type* get_type(std::string name) {
+ return types_[name];
+ }
+
+ void add_service(std::string name, t_service* service) {
+ services_[name] = service;
+ }
+
+ t_service* get_service(std::string name) {
+ return services_[name];
+ }
+
+ void print() {
+ std::map<std::string, t_type*>::iterator iter;
+ for (iter = types_.begin(); iter != types_.end(); ++iter) {
+ printf("%s => %s\n",
+ iter->first.c_str(),
+ iter->second->get_name().c_str());
+ }
+ }
+
+ private:
+
+ // Map of names to types
+ std::map<std::string, t_type*> types_;
+
+ // Map of names to services
+ std::map<std::string, t_service*> services_;
+
+};
+
+#endif