]> Creatis software - clitk.git/blob - utilities/gengetopt/skels/free_string.h
auto generate dicom file UIDs when new series/study is specified
[clitk.git] / utilities / gengetopt / skels / free_string.h
1 /*
2  * File automatically generated by
3  * gengen 1.2 by Lorenzo Bettini 
4  * http://www.gnu.org/software/gengen
5  */
6
7 #ifndef FREE_STRING_GEN_CLASS_H
8 #define FREE_STRING_GEN_CLASS_H
9
10 #include <string>
11 #include <iostream>
12
13 using std::string;
14 using std::ostream;
15
16 class free_string_gen_class
17 {
18  protected:
19   bool has_string_type;
20   string opt_var;
21   string structure;
22
23  public:
24   free_string_gen_class() :
25     has_string_type (false)
26   {
27   }
28   
29   free_string_gen_class(bool _has_string_type, const string &_opt_var, const string &_structure) :
30     has_string_type (_has_string_type), opt_var (_opt_var), structure (_structure)
31   {
32   }
33
34   static void
35   generate_string(const string &s, ostream &stream, unsigned int indent)
36   {
37     if (!indent || s.find('\n') == string::npos)
38       {
39         stream << s;
40         return;
41       }
42
43     string::size_type pos;
44     string::size_type start = 0;
45     string ind (indent, ' ');
46     while ( (pos=s.find('\n', start)) != string::npos)
47       {
48         stream << s.substr (start, (pos+1)-start);
49         start = pos+1;
50         if (start+1 <= s.size ())
51           stream << ind;
52       }
53     if (start+1 <= s.size ())
54       stream << s.substr (start);
55   }
56
57   void set_has_string_type(bool _has_string_type)
58   {
59     has_string_type = _has_string_type;
60   }
61
62   void set_opt_var(const string &_opt_var)
63   {
64     opt_var = _opt_var;
65   }
66
67   void set_structure(const string &_structure)
68   {
69     structure = _structure;
70   }
71
72   void generate_free_string(ostream &stream, unsigned int indent = 0);
73   
74 };
75
76 #endif // FREE_STRING_GEN_CLASS_H