From 3ac5b6aa85b5d1526b22518045c756b4027e6d7c Mon Sep 17 00:00:00 2001 From: David Reiss Date: Tue, 17 Feb 2009 20:28:10 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@745235 13f79535-47bb-0310-9956-ffa450edef68 --- compiler/cpp/Makefile.am | 3 +- compiler/cpp/src/generate/t_xsd_generator.cc | 71 +++++++++++++++++- compiler/cpp/src/generate/t_xsd_generator.h | 78 -------------------- 3 files changed, 71 insertions(+), 81 deletions(-) delete mode 100644 compiler/cpp/src/generate/t_xsd_generator.h diff --git a/compiler/cpp/Makefile.am b/compiler/cpp/Makefile.am index 6b21c675..fe2a2d70 100644 --- a/compiler/cpp/Makefile.am +++ b/compiler/cpp/Makefile.am @@ -36,8 +36,7 @@ thrift_SOURCES = src/thrifty.yy \ 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 diff --git a/compiler/cpp/src/generate/t_xsd_generator.cc b/compiler/cpp/src/generate/t_xsd_generator.cc index 6b02038f..10c1556a 100644 --- a/compiler/cpp/src/generate/t_xsd_generator.cc +++ b/compiler/cpp/src/generate/t_xsd_generator.cc @@ -4,13 +4,82 @@ // See accompanying file LICENSE or visit the Thrift site at: // http://developers.facebook.com/thrift/ +#include +#include +#include + #include #include #include -#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 + */ +class t_xsd_generator : public t_generator { + public: + t_xsd_generator( + t_program* program, + const std::map& 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()); diff --git a/compiler/cpp/src/generate/t_xsd_generator.h b/compiler/cpp/src/generate/t_xsd_generator.h deleted file mode 100644 index d2e4e4bd..00000000 --- a/compiler/cpp/src/generate/t_xsd_generator.h +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2006- Facebook -// Distributed under the Thrift Software License -// -// See accompanying file LICENSE or visit the Thrift site at: -// http://developers.facebook.com/thrift/ - -#ifndef T_XSD_GENERATOR_H -#define T_XSD_GENERATOR_H - -#include -#include -#include -#include "t_generator.h" - -/** - * XSD generator, creates an XSD for the base types etc. - * - * @author Mark Slee - */ -class t_xsd_generator : public t_generator { - public: - t_xsd_generator( - t_program* program, - const std::map& 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_; - -}; - -#endif -- 2.17.1