Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

define.h

Go to the documentation of this file.
00001 #ifndef define_h
00002 #define define_h
00003 
00004 #include "tag.h"
00005 #include "strings.h"
00006 #include "file.h"
00007 
00009 class DefineOpen : private Tag
00010 {
00011 public:
00012   enum Type
00013     {
00014       SIMPLE_TAG,
00015       OPEN_CLOSE_TAG
00016     };
00017   
00018   struct Parameter
00019   {
00020     enum Type
00021       {
00022         STRING,
00023         TYPE
00024       };
00025 
00026     std::string value;
00027     std::string default_value;
00028     bool has_default;
00029     Type type;
00030 
00031     Parameter() {}
00032 
00033     Parameter( std::string v, Type t ) : 
00034       value( v ), type( t ), has_default(false) {}
00035 
00036     Parameter( std::string v, Type t, std::string default_value ) : 
00037       value( v ), type( t ), default_value( default_value ), has_default(true) {}
00038 
00039   };
00040 
00041   typedef std::list<Parameter> parameter_list;
00042   typedef parameter_list::iterator parameter_list_it;
00043 
00044 private:
00045 
00046   struct Par : public Parameter
00047   {
00048     int number;
00049 
00050     Par() {}
00051 
00052     Par( int n, std::string& v, Type t ) 
00053       : Parameter( v, t ),
00054         number( n )
00055     {}
00056 
00057     Par( int n, std::string& v, Type t, std::string default_value ) 
00058       : Parameter( v, t, default_value ),
00059         number( n )
00060     {}
00061   };
00062 
00063   typedef std::list<Par> par_list;
00064   typedef par_list::iterator par_list_it;
00065 
00066   struct DPAR {
00067     int number;
00068     std::string value;
00069   };
00070 
00071   typedef std::list<DPAR> dpar_list;
00072   typedef dpar_list::iterator dpar_list_it;
00073 
00074 
00075 private:
00076 
00077   std::string name;
00078   mutable parameter_list parameters;
00079   std::string init_class;
00080   std::string function;
00081   std::string interpreter;
00082   Type type;
00083   bool nested;
00084 
00085   int level;
00086 
00087   bool real_tag; 
00088 
00089 public:
00090   DefineOpen( Line& line );
00091   DefineOpen() : Tag() {}
00092 
00093   bool operator!() const { return !is_valid_tag; }
00094   bool is_valid() const { return is_valid_tag; }
00095   
00096   std::string get_name() const { return name; }
00097 
00098   parameter_list get_parameters() const { return parameters; }
00099 
00100   std::string get_init_class() const { return init_class; }
00101 
00102   std::string get_function() const { return function; }
00103 
00104   std::string get_interpreter() const { return interpreter; }
00105 
00106   Type get_type() const { return type; }
00107 
00108   int get_level() const { return level; }
00109 
00110   Line get_line() const { return Tag::get_line(); }
00111 
00113   /*** on error it returns an empty string 
00114        usally it should return something like this:
00115        "foobar( "hello", 12.3 );"
00116   */
00117   std::string get_command( Tag& user_tag ) const;
00118 
00119   bool is_nested() const { return nested; }
00120 
00121   bool get_real_tag() const { return real_tag; }
00122 
00123 private:
00124   bool extract_type( std::string type );
00125   void extract_parameters();
00126   static bool par_comp( Par& a, Par& b) { return a.number < b.number; }
00127   static bool dpar_comp( DPAR& a, DPAR& b ) { return a.number < b.number; }
00128 
00129 public:
00130   friend bool operator!=( const DPAR& d, const int n );
00131 };
00132 
00133 class DefineClose : private Tag
00134 {
00135 public:
00136   DefineClose( Line& line );
00137 
00138   bool operator!() const { return !is_valid_tag; }
00139   bool is_valid() const { return is_valid_tag; }
00140 };
00141 
00142 inline bool operator==( const DefineOpen& defo, DefineOpen::Type type )
00143 {
00144   return defo.get_type() == type;
00145 }
00146 
00147 
00148 class Interpreter;
00149 
00151 /*** The File will be given to the function as it's first argument */
00152 bool define_call( DefineOpen def, Interpreter* ip, File arg, Tag user_tag );
00153 
00154 inline bool operator!=( const DefineOpen::DPAR& d, const int n )
00155 { return d.number != n; }
00156 
00157 #endif

Generated on Tue Nov 20 02:19:52 2001 for Leo<HTML> by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001