You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by dr...@apache.org on 2009/02/17 21:28:10 UTC
svn commit: r745235 - in /incubator/thrift/trunk/compiler/cpp: Makefile.am
src/generate/t_xsd_generator.cc src/generate/t_xsd_generator.h
Author: dreiss
Date: Tue Feb 17 20:28:10 2009
New Revision: 745235
URL: http://svn.apache.org/viewvc?rev=745235&view=rev
Log:
Remove t_xsd_generator.h.
t_xsd_generator.h is no longer included anywhere, because
the XSD generator uses the new dynamic generator framework.
Therefore, we can collapse the class definition into the .cc file.
Removed:
incubator/thrift/trunk/compiler/cpp/src/generate/t_xsd_generator.h
Modified:
incubator/thrift/trunk/compiler/cpp/Makefile.am
incubator/thrift/trunk/compiler/cpp/src/generate/t_xsd_generator.cc
Modified: incubator/thrift/trunk/compiler/cpp/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/Makefile.am?rev=745235&r1=745234&r2=745235&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/Makefile.am (original)
+++ incubator/thrift/trunk/compiler/cpp/Makefile.am Tue Feb 17 20:28:10 2009
@@ -36,8 +36,7 @@
src/parse/t_const_value.h \
src/generate/t_generator.h \
src/generate/t_oop_generator.h \
- src/generate/t_php_generator.h \
- src/generate/t_xsd_generator.h
+ src/generate/t_php_generator.h
if THRIFT_GEN_cpp
thrift_SOURCES += src/generate/t_cpp_generator.cc
Modified: incubator/thrift/trunk/compiler/cpp/src/generate/t_xsd_generator.cc
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_xsd_generator.cc?rev=745235&r1=745234&r2=745235&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/generate/t_xsd_generator.cc (original)
+++ incubator/thrift/trunk/compiler/cpp/src/generate/t_xsd_generator.cc Tue Feb 17 20:28:10 2009
@@ -4,13 +4,82 @@
// See accompanying file LICENSE or visit the Thrift site at:
// http://developers.facebook.com/thrift/
+#include <fstream>
+#include <iostream>
+#include <sstream>
+
#include <stdlib.h>
#include <sys/stat.h>
#include <sstream>
-#include "t_xsd_generator.h"
+#include "t_generator.h"
#include "platform.h"
using namespace std;
+
+/**
+ * XSD generator, creates an XSD for the base types etc.
+ *
+ * @author Mark Slee <mc...@facebook.com>
+ */
+class t_xsd_generator : public t_generator {
+ public:
+ t_xsd_generator(
+ t_program* program,
+ const std::map<std::string, std::string>& parsed_options,
+ const std::string& option_string)
+ : t_generator(program)
+ {
+ out_dir_base_ = "gen-xsd";
+ }
+
+ virtual ~t_xsd_generator() {}
+
+ /**
+ * Init and close methods
+ */
+
+ void init_generator();
+ void close_generator();
+
+ /**
+ * Program-level generation functions
+ */
+
+ void generate_typedef(t_typedef* ttypedef);
+ void generate_enum(t_enum* tenum) {}
+
+ void generate_service(t_service* tservice);
+ void generate_struct(t_struct* tstruct);
+
+ private:
+
+ void generate_element(std::ostream& out, std::string name, t_type* ttype, t_struct* attrs=NULL, bool optional=false, bool nillable=false, bool list_element=false);
+
+ std::string ns(std::string in, std::string ns) {
+ return ns + ":" + in;
+ }
+
+ std::string xsd(std::string in) {
+ return ns(in, "xsd");
+ }
+
+ std::string type_name(t_type* ttype);
+ std::string base_type_name(t_base_type::t_base tbase);
+
+ /**
+ * Output xsd/php file
+ */
+ std::ofstream f_xsd_;
+ std::ofstream f_php_;
+
+ /**
+ * Output string stream
+ */
+ std::ostringstream s_xsd_types_;
+
+};
+
+
void t_xsd_generator::init_generator() {
// Make output directory
MKDIR(get_out_dir().c_str());