r1317@opsdev009 (orig r70384): mcslee | 2007-11-16 16:32:36 -0800
[amiethrift.git] / compiler / cpp / src / generate / t_xsd_generator.h
blob31d9f60ab5767d663e64d88f99e085313845fb32
1 // Copyright (c) 2006- Facebook
2 // Distributed under the Thrift Software License
3 //
4 // See accompanying file LICENSE or visit the Thrift site at:
5 // http://developers.facebook.com/thrift/
7 #ifndef T_XSD_GENERATOR_H
8 #define T_XSD_GENERATOR_H
10 #include <fstream>
11 #include <iostream>
12 #include <sstream>
13 #include "t_generator.h"
15 /**
16 * XSD generator, creates an XSD for the base types etc.
18 * @author Mark Slee <mcslee@facebook.com>
20 class t_xsd_generator : public t_generator {
21 public:
22 t_xsd_generator(t_program* program) :
23 t_generator(program) {
24 out_dir_base_ = "gen-xsd";
27 virtual ~t_xsd_generator() {}
29 /**
30 * Init and close methods
33 void init_generator();
34 void close_generator();
36 /**
37 * Program-level generation functions
40 void generate_typedef(t_typedef* ttypedef);
41 void generate_enum(t_enum* tenum) {}
43 void generate_service(t_service* tservice);
44 void generate_struct(t_struct* tstruct);
46 private:
48 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);
50 std::string ns(std::string in, std::string ns) {
51 return ns + ":" + in;
54 std::string xsd(std::string in) {
55 return ns(in, "xsd");
58 std::string type_name(t_type* ttype);
59 std::string base_type_name(t_base_type::t_base tbase);
61 /**
62 * Output xsd/php file
64 std::ofstream f_xsd_;
65 std::ofstream f_php_;
67 /**
68 * Output string stream
70 std::ostringstream s_xsd_types_;
74 #endif