Qualia  0.2
CmdLine.h
Go to the documentation of this file.
1 // Copyright (C) 2003--2004 Ronan Collobert (collober@idiap.ch)
2 //
3 // This file is part of Torch 3.1.
4 //
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
9 // are met:
10 // 1. Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 // 2. Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 // 3. The name of the author may not be used to endorse or promote products
16 // derived from this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 
29 #ifndef CMD_LINE_INC
30 #define CMD_LINE_INC
31 
32 #include <qualia/core/common.h>
35 
53 class CmdLine
54 {
55  public:
56  char *program_name;
57  bool write_log;
61  char *text_info;
62 
67 
68  char **argv;
69  int argc;
70 
71  // -----
72 
74  CmdLine();
75 
80  int read(int argc_, char **argv_);
81 
86  void help();
87 
88  //-----
89 
105 
106  void addICmdOption(const char *name, int *ptr, int init_value, const char *help="", bool save_it=false);
108  void addBCmdOption(const char *name, bool *ptr, bool init_value, const char *help="", bool save_it=false);
110  void addRCmdOption(const char *name, real *ptr, real init_value, const char *help="", bool save_it=false);
112  void addSCmdOption(const char *name, char **ptr, const char *init_value, const char *help="", bool save_it=false);
113 
121 
122  void addICmdArg(const char *name, int *ptr, const char *help="", bool save_it=false);
124  void addBCmdArg(const char *name, bool *ptr, const char *help="", bool save_it=false);
126  void addRCmdArg(const char *name, real *ptr, const char *help="", bool save_it=false);
128  void addSCmdArg(const char *name, char **ptr, const char *help="", bool save_it=false);
129 
131  void addText(const char *text);
132 
134  void info(const char *text);
135 
141  void addMasterSwitch(const char *text);
142 
146  void setWorkingDirectory(const char* dirname);
147 
151  char *getPath(const char *filename);
152 
156  DiskXFile *getXFile(const char *filename);
157 
159  virtual void load(DiskXFile *file);
160 
162  virtual void save(DiskXFile *file);
163 
164  //-----
165 
169  void addCmdOption(CmdOption *option);
170 
174  void writeLog(DiskXFile *file, bool write_associated_files);
175 
176  virtual ~CmdLine();
177 };
178 
179 #endif