source: CMT/v1r25-branch/source/cmt_fragment.h

Last change on this file was 664, checked in by rybkin, 10 years ago

merge -r 646:663 HEAD

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