Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

cmt_fragment.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------
00002 // Copyright Christian Arnault LAL-Orsay CNRS
00003 // arnault@lal.in2p3.fr
00004 // See the complete license in cmt_license.txt "http://www.cecill.info". 
00005 //-----------------------------------------------------------
00006 
00007 #ifndef __cmt_fragment_h__
00008 #define __cmt_fragment_h__
00009 
00010 #include <stdarg.h>
00011 
00012 #include "cmt_parser.h"
00013 #include "cmt_system.h"
00014 
00015 class Variable
00016 {
00017 public:
00018 
00019   typedef cmt_vector<Variable> VariableVector;
00020 
00021   static Variable* find (VariableVector& vector, 
00022                          const cmt_string& name);
00023 
00024 public:
00025 
00026   Variable ();
00027   Variable (const cmt_string& n);
00028 
00029   const cmt_string& macro_braces () const;
00030   const cmt_string& macro_pars () const;
00031 
00032   void set (const cmt_string& new_name,
00033             const cmt_string& new_value = "");
00034 
00035   Variable& operator = (const Variable& other);
00036   Variable& operator = (const cmt_string& v);
00037   void operator += (const cmt_string& v);
00038   cmt_string operator + (const cmt_string& v) const;
00039   operator const cmt_string& () const;
00040   bool operator == (const cmt_string& v) const;
00041   bool operator != (const cmt_string& v) const;
00042   cmt_string name;
00043   cmt_string value;
00044 
00045 private:
00046   cmt_string m_macro_braces;
00047   cmt_string m_macro_pars;
00048 };
00049 
00050 class Fragment
00051 {
00052 public:
00053   typedef cmt_vector<Fragment> FragmentVector;
00054 
00055   static void action (const CmtSystem::cmt_string_vector& words,
00056                       Use* use);
00057   static Fragment* find (const cmt_string& name);
00058   static void add (const cmt_string& name,
00059                    const cmt_string& suffix,
00060                    const cmt_string& header,
00061                    const cmt_string& trailer,
00062                    bool need_dependencies,
00063                    Use* use);
00064   static void show (const cmt_string& name);
00065   static void show_all ();
00066   static void clear_all ();
00067   static bool copy (FILE* out, const cmt_string& name, int variables, ...);
00068   static bool copy (cmt_string& out, const cmt_string& name, int variables, ...);
00069   static bool copy (FILE* out, const cmt_string& name, 
00070                     const Variable::VariableVector& vector, int variables, ...);
00071   static bool copy (cmt_string& out, const cmt_string& name, 
00072                     const Variable::VariableVector& vector, int variables, ...);
00073 
00074   static FragmentVector& fragments ();
00075 
00076 public:
00077   Fragment ();
00078   Fragment (const cmt_string& fragment_name);
00079   ~Fragment ();
00080   void clear ();
00081   int print ();
00082   bool locate ();
00083 
00084   bool copy (FILE* out, int variables, ...);
00085   bool copy (cmt_string& out, int variables, ...);
00086   bool copy (FILE* out, int variables, va_list ids);
00087   bool copy (cmt_string& out, int variables, va_list ids);
00088   bool wincopy (FILE* out, int variables, va_list ids);
00089   bool wincopy (cmt_string& out, int variables, va_list ids);
00090 
00091   bool copy (FILE* out, const Variable::VariableVector& vector, int variables, ...);
00092   bool copy (cmt_string& out, const Variable::VariableVector& vector, int variables, ...);
00093   bool copy (FILE* out, const Variable::VariableVector& vector, int variables, va_list ids);
00094   bool copy (cmt_string& out, const Variable::VariableVector& vector, int variables, va_list ids);
00095   bool wincopy (FILE* out, const Variable::VariableVector& vector, int variables, va_list ids);
00096   bool wincopy (cmt_string& out, const Variable::VariableVector& vector, int variables, va_list ids);
00097 
00098   cmt_string name;
00099   cmt_string suffix;
00100   cmt_string header;
00101   cmt_string trailer;
00102   bool need_dependencies;
00103   cmt_string path;
00104   UseRef use;
00105 };
00106 
00107 class FragmentHandle
00108 {
00109 public:
00110   FragmentHandle ();
00111   FragmentHandle (const cmt_string name);
00112 
00113   FragmentHandle& operator = (const FragmentHandle& other);
00114   void reset ();
00115   void set (const cmt_string name);
00116   cmt_string& name ();
00117   cmt_string& suffix ();
00118   cmt_string& header ();
00119   cmt_string& trailer ();
00120   bool need_dependencies ();
00121 
00122   bool copy (FILE* out, int variables, ...);
00123   bool copy (cmt_string& out, int variables, ...);
00124   bool wincopy (FILE* out, int variables, ...);
00125   bool wincopy (cmt_string& out, int variables, ...);
00126 
00127   bool copy (FILE* out, const Variable::VariableVector& vector, int variables, ...);
00128   bool copy (cmt_string& out, const Variable::VariableVector& vector, int variables, ...);
00129   bool wincopy (FILE* out, const Variable::VariableVector& vector, int variables, ...);
00130   bool wincopy (cmt_string& out, const Variable::VariableVector& vector, int variables, ...);
00131 
00132 private:
00133   bool setup ();
00134 
00135   Fragment* _fragment;
00136   cmt_string _name;
00137   bool _initialized;
00138 };
00139 
00140 #endif

Generated on Mon May 2 10:25:04 2005 for CMT by doxygen 1.3.5