source: CMT/v1r25/source/cmt_fragment.h

Last change on this file was 561, checked in by rybkin, 13 years ago

See C.L. 444

  • Property svn:eol-style set to native
File size: 4.5 KB
Line 
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
15class Variable
16{
17public:
18
19  typedef cmt_vector<Variable> VariableVector;
20
21  static Variable* find (VariableVector& vector, 
22                         const cmt_string& name);
23
24public:
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
45private:
46  cmt_string m_macro_braces;
47  cmt_string m_macro_pars;
48};
49
50class Fragment
51{
52public:
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                   const cmt_string& path);
65  //                   Use* use);
66  static void show (const cmt_string& name);
67  static void show_all ();
68  static void clear_all ();
69  static bool copy (FILE* out, const cmt_string& name, int variables, ...);
70  static bool copy (cmt_string& out, const cmt_string& name, int variables, ...);
71  static bool copy (FILE* out, const cmt_string& name, 
72                    const Variable::VariableVector& vector, int variables, ...);
73  static bool copy (cmt_string& out, const cmt_string& name, 
74                    const Variable::VariableVector& vector, int variables, ...);
75
76  static FragmentVector& fragments ();
77
78public:
79  Fragment ();
80  Fragment (const cmt_string& fragment_name);
81  ~Fragment ();
82  void clear ();
83  int print (PrintMode mode = Csh, ostream& out = cout); // Csh is default for ArgParser::mode
84  //  int print ();
85  bool locate ();
86
87  bool copy (FILE* out, int variables, ...);
88  bool copy (cmt_string& out, int variables, ...);
89  bool copy (FILE* out, int variables, va_list ids);
90  bool copy (cmt_string& out, int variables, va_list ids);
91  bool wincopy (FILE* out, int variables, va_list ids);
92  bool wincopy (cmt_string& out, int variables, va_list ids);
93
94  bool copy (FILE* out, const Variable::VariableVector& vector, int variables, ...);
95  bool copy (cmt_string& out, const Variable::VariableVector& vector, int variables, ...);
96  bool copy (FILE* out, const Variable::VariableVector& vector, int variables, va_list ids);
97  bool copy (cmt_string& out, const Variable::VariableVector& vector, int variables, va_list ids);
98  bool wincopy (FILE* out, const Variable::VariableVector& vector, int variables, va_list ids);
99  bool wincopy (cmt_string& out, const Variable::VariableVector& vector, int variables, va_list ids);
100
101  cmt_string name;
102  cmt_string suffix;
103  cmt_string header;
104  cmt_string trailer;
105  bool need_dependencies;
106  cmt_string path;
107  UseRef use;
108};
109
110class FragmentHandle
111{
112public:
113  FragmentHandle ();
114  FragmentHandle (const cmt_string name);
115
116  FragmentHandle& operator = (const FragmentHandle& other);
117  void reset ();
118  void set (const cmt_string name);
119  cmt_string& name ();
120  cmt_string& suffix ();
121  cmt_string& header ();
122  cmt_string& trailer ();
123  bool need_dependencies ();
124
125  bool copy (FILE* out, int variables, ...);
126  bool copy (cmt_string& out, int variables, ...);
127  bool wincopy (FILE* out, int variables, ...);
128  bool wincopy (cmt_string& out, int variables, ...);
129
130  bool copy (FILE* out, const Variable::VariableVector& vector, int variables, ...);
131  bool copy (cmt_string& out, const Variable::VariableVector& vector, int variables, ...);
132  bool wincopy (FILE* out, const Variable::VariableVector& vector, int variables, ...);
133  bool wincopy (cmt_string& out, const Variable::VariableVector& vector, int variables, ...);
134
135private:
136  bool setup ();
137
138  Fragment* _fragment;
139  cmt_string _name;
140  bool _initialized;
141};
142
143#endif
Note: See TracBrowser for help on using the repository browser.