iRoCS Toolbox  1.1.0
PrettyOptionPrinter.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * Copyright (C) 2004-2015 Olaf Ronneberger, Florian Pigorsch, Jörg Mechnich,
4  * Thorsten Falk
5  *
6  * Image Analysis Lab, University of Freiburg, Germany
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  **************************************************************************/
23 
24 /**************************************************************************
25 ** Title:
26 ** $RCSfile$
27 ** $Revision: 538 $$Name$
28 ** $Date: 2004-09-13 12:04:04 +0200 (Mon, 13 Sep 2004) $
29 ** Copyright: GPL $Author: ronneber $
30 ** Description:
31 **
32 **
33 **
34 **-------------------------------------------------------------------------
35 **
36 ** $Log$
37 ** Revision 1.3 2004/09/13 10:04:04 ronneber
38 ** - documentation update
39 **
40 ** Revision 1.2 2004/09/08 14:33:53 ronneber
41 ** - adapted to new ParamInfo class
42 **
43 ** Revision 1.1 2004/08/26 08:36:59 ronneber
44 ** initital import
45 **
46 **
47 **
48 **************************************************************************/
49 
50 #ifndef PRETTYOPTIONPRINTER_HH
51 #define PRETTYOPTIONPRINTER_HH
52 
53 #ifdef HAVE_CONFIG_H
54 #include <config.hh>
55 #endif
56 
57 #include <iostream>
58 #include <map>
59 #include "HelpExtractor.hh"
60 #include "ParamInfo.hh"
61 #include "SVMError.hh"
62 
63 namespace svt
64 {
65  /*======================================================================*/
74  /*======================================================================*/
76  {
77  public:
78 
79  PrettyOptionPrinter( std::ostream& os, int indentColumn = 30)
80  : _indentColumn( indentColumn),
81  _itemIndent( 4),
82  _minAlterIndent( 12),
83  _os(os)
84  {}
85 
86 
87  /*======================================================================*/
94  /*======================================================================*/
95  void printOption( const ParamInfo& param);
96 
97 
98  /*======================================================================*/
105  /*======================================================================*/
106  void printOptions( std::string header,
107  const std::vector<ParamInfo>& params);
108 
109 
110 
111  /*======================================================================*/
119  /*======================================================================*/
120  void printDefListParagraph( const std::string& item,
121  const std::string& description);
122 
123 
124 
125  void printHeader( const std::string& header)
126  {
127  _os << header << "\n";
128  }
129 
130 
131 
132  void printSubHeader( const std::string& header)
133  {
134  _os << "\n"
135  << header << "\n"
136  << std::string( header.size(), '-') << "\n";
137  }
138 
139 
140 
141  /*======================================================================*/
151  /*======================================================================*/
152  int indentColumn() const
153  {
154  return _indentColumn;
155  }
156 
157  void setIndentColumn( int column)
158  {
159  _indentColumn = column;
160  }
161 
162 #if 0
163  template< typename LIST>
164  void printTypeHelp( std::string key) const
165  {
166  std::map<std::string, std::string> nameDescriptionMap;
167 
168  HelpExtractor<LIST>::getNamesDescriptions( nameDescriptionMap);
169  for( std::map<std::string,std::string>::const_iterator p =
170  nameDescriptionMap.begin();
171  p != nameDescriptionMap.end(); ++p)
172  {
173  printOption( key + " " + p->first, p->second);
174  }
175  }
176 #endif
177  private:
178  int _indentColumn;
179  int _itemIndent;
180  int _minAlterIndent;
181  std::ostream& _os;
182 
183  };
184 
185 }
186 
187 
188 
189 #endif
void printDefListParagraph(const std::string &item, const std::string &description)
print one paragraph of a definition list.
static void getNamesDescriptions(ParamInfo &help)
recursive extract name() and description() for TList items
int indentColumn() const
get / set start column for pretty printing of command line options
void printOptions(std::string header, const std::vector< ParamInfo > &params)
print subHeader and all options contained in the vector.
void printOption(const ParamInfo &param)
pretty print command line option.
PrettyOptionPrinter(std::ostream &os, int indentColumn=30)
void printHeader(const std::string &header)
The PrettyOptionPrinter class contains mehtods for pretty printing of commandline options...
void printSubHeader(const std::string &header)
The ParamInfo class contains informations about one parameter like key, help text, guiHints etc.
Definition: ParamInfo.hh:82