[1] | 1 | //----------------------------------------------------------- |
---|
| 2 | // Copyright Christian Arnault LAL-Orsay CNRS |
---|
| 3 | // arnault@lal.in2p3.fr |
---|
| 4 | // See the complete license in cmt_license.txt "http://www.cecill.info". |
---|
| 5 | //----------------------------------------------------------- |
---|
| 6 | |
---|
| 7 | #ifndef __cmt_fragment_h__ |
---|
| 8 | #define __cmt_fragment_h__ |
---|
| 9 | |
---|
| 10 | #include <stdarg.h> |
---|
| 11 | |
---|
| 12 | #include "cmt_parser.h" |
---|
| 13 | #include "cmt_system.h" |
---|
| 14 | |
---|
| 15 | class Variable |
---|
| 16 | { |
---|
| 17 | public: |
---|
| 18 | |
---|
| 19 | typedef cmt_vector<Variable> VariableVector; |
---|
| 20 | |
---|
| 21 | static Variable* find (VariableVector& vector, |
---|
| 22 | const cmt_string& name); |
---|
| 23 | |
---|
| 24 | public: |
---|
| 25 | |
---|
| 26 | Variable (); |
---|
| 27 | Variable (const cmt_string& n); |
---|
| 28 | |
---|
| 29 | const cmt_string& macro_braces () const; |
---|
| 30 | const cmt_string& macro_pars () const; |
---|
| 31 | |
---|
| 32 | void set (const cmt_string& new_name, |
---|
| 33 | const cmt_string& new_value = ""); |
---|
| 34 | |
---|
| 35 | Variable& operator = (const Variable& other); |
---|
| 36 | Variable& operator = (const cmt_string& v); |
---|
| 37 | void operator += (const cmt_string& v); |
---|
| 38 | cmt_string operator + (const cmt_string& v) const; |
---|
| 39 | operator const cmt_string& () const; |
---|
| 40 | bool operator == (const cmt_string& v) const; |
---|
| 41 | bool operator != (const cmt_string& v) const; |
---|
| 42 | cmt_string name; |
---|
| 43 | cmt_string value; |
---|
| 44 | |
---|
| 45 | private: |
---|
| 46 | cmt_string m_macro_braces; |
---|
| 47 | cmt_string m_macro_pars; |
---|
| 48 | }; |
---|
| 49 | |
---|
| 50 | class Fragment |
---|
| 51 | { |
---|
| 52 | public: |
---|
| 53 | typedef cmt_vector<Fragment> FragmentVector; |
---|
| 54 | |
---|
| 55 | static void action (const CmtSystem::cmt_string_vector& words, |
---|
| 56 | Use* use); |
---|
| 57 | static Fragment* find (const cmt_string& name); |
---|
| 58 | static void add (const cmt_string& name, |
---|
| 59 | const cmt_string& suffix, |
---|
| 60 | const cmt_string& header, |
---|
| 61 | const cmt_string& trailer, |
---|
| 62 | bool need_dependencies, |
---|
| 63 | Use* use); |
---|
| 64 | static void show (const cmt_string& name); |
---|
| 65 | static void show_all (); |
---|
| 66 | static void clear_all (); |
---|
| 67 | static bool copy (FILE* out, const cmt_string& name, int variables, ...); |
---|
| 68 | static bool copy (cmt_string& out, const cmt_string& name, int variables, ...); |
---|
| 69 | static bool copy (FILE* out, const cmt_string& name, |
---|
| 70 | const Variable::VariableVector& vector, int variables, ...); |
---|
| 71 | static bool copy (cmt_string& out, const cmt_string& name, |
---|
| 72 | const Variable::VariableVector& vector, int variables, ...); |
---|
| 73 | |
---|
| 74 | static FragmentVector& fragments (); |
---|
| 75 | |
---|
| 76 | public: |
---|
| 77 | Fragment (); |
---|
| 78 | Fragment (const cmt_string& fragment_name); |
---|
| 79 | ~Fragment (); |
---|
| 80 | void clear (); |
---|
| 81 | int print (); |
---|
| 82 | bool locate (); |
---|
| 83 | |
---|
| 84 | bool copy (FILE* out, int variables, ...); |
---|
| 85 | bool copy (cmt_string& out, int variables, ...); |
---|
| 86 | bool copy (FILE* out, int variables, va_list ids); |
---|
| 87 | bool copy (cmt_string& out, int variables, va_list ids); |
---|
| 88 | bool wincopy (FILE* out, int variables, va_list ids); |
---|
| 89 | bool wincopy (cmt_string& out, int variables, va_list ids); |
---|
| 90 | |
---|
| 91 | bool copy (FILE* out, const Variable::VariableVector& vector, int variables, ...); |
---|
| 92 | bool copy (cmt_string& out, const Variable::VariableVector& vector, int variables, ...); |
---|
| 93 | bool copy (FILE* out, const Variable::VariableVector& vector, int variables, va_list ids); |
---|
| 94 | bool copy (cmt_string& out, const Variable::VariableVector& vector, int variables, va_list ids); |
---|
| 95 | bool wincopy (FILE* out, const Variable::VariableVector& vector, int variables, va_list ids); |
---|
| 96 | bool wincopy (cmt_string& out, const Variable::VariableVector& vector, int variables, va_list ids); |
---|
| 97 | |
---|
| 98 | cmt_string name; |
---|
| 99 | cmt_string suffix; |
---|
| 100 | cmt_string header; |
---|
| 101 | cmt_string trailer; |
---|
| 102 | bool need_dependencies; |
---|
| 103 | cmt_string path; |
---|
| 104 | UseRef use; |
---|
| 105 | }; |
---|
| 106 | |
---|
| 107 | class FragmentHandle |
---|
| 108 | { |
---|
| 109 | public: |
---|
| 110 | FragmentHandle (); |
---|
| 111 | FragmentHandle (const cmt_string name); |
---|
| 112 | |
---|
| 113 | FragmentHandle& operator = (const FragmentHandle& other); |
---|
| 114 | void reset (); |
---|
| 115 | void set (const cmt_string name); |
---|
| 116 | cmt_string& name (); |
---|
| 117 | cmt_string& suffix (); |
---|
| 118 | cmt_string& header (); |
---|
| 119 | cmt_string& trailer (); |
---|
| 120 | bool need_dependencies (); |
---|
| 121 | |
---|
| 122 | bool copy (FILE* out, int variables, ...); |
---|
| 123 | bool copy (cmt_string& out, int variables, ...); |
---|
| 124 | bool wincopy (FILE* out, int variables, ...); |
---|
| 125 | bool wincopy (cmt_string& out, int variables, ...); |
---|
| 126 | |
---|
| 127 | bool copy (FILE* out, const Variable::VariableVector& vector, int variables, ...); |
---|
| 128 | bool copy (cmt_string& out, const Variable::VariableVector& vector, int variables, ...); |
---|
| 129 | bool wincopy (FILE* out, const Variable::VariableVector& vector, int variables, ...); |
---|
| 130 | bool wincopy (cmt_string& out, const Variable::VariableVector& vector, int variables, ...); |
---|
| 131 | |
---|
| 132 | private: |
---|
| 133 | bool setup (); |
---|
| 134 | |
---|
| 135 | Fragment* _fragment; |
---|
| 136 | cmt_string _name; |
---|
| 137 | bool _initialized; |
---|
| 138 | }; |
---|
| 139 | |
---|
| 140 | #endif |
---|