/usr/include/relion-1.4/src/args.h is in librelion-dev-common 1.4+dfsg-3ubuntu1.
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 | /***************************************************************************
*
* Author: "Sjors H.W. Scheres"
* MRC Laboratory of Molecular Biology
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This complete copyright notice must be included in any revised version of the
* source code. Additional authorship citations may be added, but existing
* author citations must be preserved.
***************************************************************************/
/***************************************************************************
*
* Authors: Carlos Oscar S. Sorzano (coss@cnb.csic.es)
*
* Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* All comments concerning this program package may be sent to the
* e-mail address 'xmipp@cnb.csic.es'
***************************************************************************/
#ifndef ARGS_H
#define ARGS_H
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
//ROB
#include <string.h>
#include "src/funcs.h"
#include "src/matrix1d.h"
template <typename T> class Matrix1D;
/** @defgroup Arguments Functions for parsing the command line
*
* These functions help you to manage the command line parameters
*/
/** Get parameters from the command line.
* @ingroup CommandLineFunctions
*
* This function assumes that the command line is structured in such a way that
* for each parameter a block like "-param <param_value>" is defined. The label
* "param" can be substituted by any other one you like. If the parameter is
* optional then this function allows you to define a default value. If no
* default value is supplied and the parameter is not specified in the command
* line, then an exception is thrown. You may change the default exception.
*
* You may also indicate that in case of error no exception is raised and force
* the program to abort (use the exit variable).
*
* @code
* m_param = textToFloat(getParameter(argc, argv, "-m"));
*
* // Get compulsory parameter "-m"
* m_param = textToFloat(getParameter(argc, argv, "-m","2.65"));
*
* // Optional parameter, if no parameter is given it takes 2.65 by default
* m_param = textToFloat(getParameter(argc, argv, "-m", NULL, 6001, "-m parameter not \
* found. I'm going out", TRUE);
*
* // Compulsory parameter, if not found give an special error message and exit
* // the program
*
* @endcode
*/
std::string getParameter(int argc,
char** argv,
std::string param,
std::string option = "NULL");
/** Get boolean parameters from the command line.
* @ingroup CommandLineFunctions
*
* This function assumes that the command line is structured in such a way that
* for each parameter a block like "-param" is defined. The label "param" can be
* substituted by any other one you like. It might be used to look for a boolean
* parameter, for instance:
*
* -verbose means that verbose functionality is set (TRUE)
*
* @code
* verbose = checkParameter(argc, argv, "-verbose"));
*
* // checks if "-verbose" was supplied in the command line. If -verbose was
* // supplied the function returns TRUE (1), otherwise returns FALSE (0)
* @endcode
*/
bool checkParameter(int argc, char** argv, std::string param);
class IOParser
{
private:
std::vector<std::string> options;
std::vector<std::string> usages;
std::vector<bool> optionals;
std::vector<std::string> defaultvalues;
std::vector<int> section_numbers;
std::vector<std::string> section_names;
std::vector<std::string> error_messages;
std::vector<std::string> warning_messages;
int current_section;
// The original command line
int argc;
char** argv;
public:
/** Constructor */
IOParser();
/** Copy constructor */
IOParser(const IOParser &in);
/**Assignment operator */
IOParser& operator= (const IOParser &in);
/** Destructor */
~IOParser();
/** Copy everything from input to this */
void copy(const IOParser &in);
/** Clear object */
void clear();
/** Store pointer to command line */
void setCommandLine(int _argc, char** _argv);
/** Check whether option exists in the stored options */
bool optionExists(std::string option);
/** Add a section to the parser, and set the current section to the newly created one, returns number of current section */
int addSection(std::string name);
/** Set the current section to this number */
void setSection(int number);
/** Get the current section to this number */
int getSection()
{
return current_section;
}
/** Add an option to the object list */
void addOption(std::string option, std::string usage, std::string defaultvalue = "NULL");
/** Get the value from the command line, and adds option to the list if it did not yet exist */
std::string getOption(std::string option, std::string usage, std::string defaultvalue = "NULL");
/** Returns true if option was given and false if not, and adds option to the list if it did not yet exist */
bool checkOption(std::string option, std::string usage, std::string defaultvalue = "false");
/** Checks the whole command line and reports an error if it contains an undefined option */
bool commandLineContainsUndefinedOption();
/** Write the stored command line to outstream */
void writeCommandLine(std::ostream &outstream);
/** Returns true is there were any error messages (and prints them if verb>0 */
bool checkForErrors(int verb = 1);
/** Check the whole command line for invalid arguments, if found add to the error messages */
void checkForUnknownArguments();
/** Write one line of the usage to outstream */
void writeUsageOneLine(int i, std::ostream &out);
/** Write one section of the usage to outstream */
void writeUsageOneSection(int section, std::ostream &out);
/** Write the usage for all options to outstream */
void writeUsage(std::ostream &outstream);
};
#endif
|