/usr/include/torch/CmdOption.h is in libtorch3-dev 3.1-2.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | // Copyright (C) 2003--2004 Ronan Collobert (collober@idiap.ch)
//
// This file is part of Torch 3.1.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. The name of the author may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CMD_OPTION_INC
#define CMD_OPTION_INC
#include "Object.h"
namespace Torch {
/** This class defines an option for the command line.
If you need special command line arguments/options,
you have to create a new children of this class.
@author Ronan Collobert (collober@idiap.ch)
@see CmdLine
*/
class CmdOption : public Object
{
private:
// Special flags.
bool is_option;
bool is_argument;
bool is_text;
bool is_master_switch;
public:
/// Name of the option.
char *name;
/// Type name of the option.
char *type_name;
/** An help string.
Cannot be NULL.
*/
char *help;
/** True is the option has to be saved
when saving the command line.
*/
bool save;
/** True is the option has been setted after
reading the command-line.
*/
bool is_setted;
//////////////////////
///
CmdOption(const char *name_, const char *type_name_, const char *help_="", bool save_=false);
/// Initialize the value of the option.
virtual void initValue();
/// If #is_setted# is true, print the current value, else the init value.
virtual void printValue(XFile *file_);
/** Read the option on the command line.
argv_ and argc_ have to point of the next
option after that.
*/
virtual void read(int *argc_, char ***argv_);
/* Return true if the option is on the command line.
Decrements argc_ and increment argv_ if true.
*/
bool isCurrent(int *argc_, char ***argv_);
/** Returns true if it's an optional argument.
If #set_# is true, set it to an optional argument.
*/
bool isOption(bool set_=false);
/** Returns true if it's a required argument.
If #set_# is true, set it to a required argument.
*/
bool isArgument(bool set_=false);
/** Returns true if it's just text to be displayed in the command line.
If #set_# is true, set it to text mode.
*/
bool isText(bool set_=false);
/** Returns true if it's a master switch.
If #set_# is true, set it to a master switch.
*/
bool isMasterSwitch(bool set_=false);
~CmdOption();
};
/** This class defines a integer command-line option.
@author Ronan Collobert (collober@idiap.ch)
@see CmdLine
*/
class IntCmdOption : public CmdOption
{
public:
int *ptr;
int init_value;
///
IntCmdOption(const char *name_, int *ptr_, int init_value_, const char *help_="", bool save_=false);
virtual void initValue();
virtual void printValue(XFile *file_);
virtual void read(int *argc_, char ***argv_);
virtual void loadXFile(XFile *file);
virtual void saveXFile(XFile *file);
~IntCmdOption();
};
/** This class defines a real command-line option.
@author Ronan Collobert (collober@idiap.ch)
@see CmdLine
*/
class RealCmdOption : public CmdOption
{
public:
real *ptr;
real init_value;
///
RealCmdOption(const char *name_, real *ptr_, real init_value_, const char *help_="", bool save_=false);
virtual void initValue();
virtual void printValue(XFile *file_);
virtual void read(int *argc_, char ***argv_);
virtual void loadXFile(XFile *file);
virtual void saveXFile(XFile *file);
~RealCmdOption();
};
/** This class defines a bool command-line option.
@author Ronan Collobert (collober@idiap.ch)
@see CmdLine
*/
class BoolCmdOption : public CmdOption
{
public:
bool *ptr;
bool init_value;
///
BoolCmdOption(const char *name_, bool *ptr_, bool init_value_, const char *help_="", bool save_=false);
virtual void initValue();
virtual void read(int *argc_, char ***argv_);
virtual void loadXFile(XFile *file);
virtual void saveXFile(XFile *file);
~BoolCmdOption();
};
/** This class defines a string command-line option.
@author Ronan Collobert (collober@idiap.ch)
@see CmdLine
*/
class StringCmdOption : public CmdOption
{
public:
char **ptr;
char *init_value;
///
StringCmdOption(const char *name_, char **ptr_, const char *init_value_, const char *help_="", bool save_=false);
virtual void initValue();
virtual void printValue(XFile *file_);
virtual void read(int *argc_, char ***argv_);
virtual void loadXFile(XFile *file);
virtual void saveXFile(XFile *file);
~StringCmdOption();
};
}
#endif
|