mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-07-16 05:05:09 -04:00
More Linux work. This has Render, Animate and Genome building and running on Linux.
This commit is contained in:
@ -3,70 +3,70 @@
|
||||
@version 3.6
|
||||
|
||||
@brief A cross-platform command line library which can parse almost any
|
||||
of the standard command line formats in use today. It is designed
|
||||
explicitly to be portable to any platform and has been tested on Windows
|
||||
of the standard command line formats in use today. It is designed
|
||||
explicitly to be portable to any platform and has been tested on Windows
|
||||
and Linux. See CSimpleOptTempl for the class definition.
|
||||
|
||||
@section features FEATURES
|
||||
- MIT Licence allows free use in all software (including GPL
|
||||
- MIT Licence allows free use in all software (including GPL
|
||||
and commercial)
|
||||
- multi-platform (Windows 95/98/ME/NT/2K/XP, Linux, Unix)
|
||||
- supports all lengths of option names:
|
||||
<table width="60%">
|
||||
<tr><td width="30%"> -
|
||||
<tr><td width="30%"> -
|
||||
<td>switch character only (e.g. use stdin for input)
|
||||
<tr><td> -o
|
||||
<tr><td> -o
|
||||
<td>short (single character)
|
||||
<tr><td> -long
|
||||
<tr><td> -long
|
||||
<td>long (multiple character, single switch character)
|
||||
<tr><td> --longer
|
||||
<tr><td> --longer
|
||||
<td>long (multiple character, multiple switch characters)
|
||||
</table>
|
||||
- supports all types of arguments for options:
|
||||
<table width="60%">
|
||||
<tr><td width="30%"> --option
|
||||
<tr><td width="30%"> --option
|
||||
<td>short/long option flag (no argument)
|
||||
<tr><td> --option ARG
|
||||
<tr><td> --option ARG
|
||||
<td>short/long option with separate required argument
|
||||
<tr><td> --option=ARG
|
||||
<tr><td> --option=ARG
|
||||
<td>short/long option with combined required argument
|
||||
<tr><td> --option[=ARG]
|
||||
<tr><td> --option[=ARG]
|
||||
<td>short/long option with combined optional argument
|
||||
<tr><td> -oARG
|
||||
<tr><td> -oARG
|
||||
<td>short option with combined required argument
|
||||
<tr><td> -o[ARG]
|
||||
<tr><td> -o[ARG]
|
||||
<td>short option with combined optional argument
|
||||
</table>
|
||||
- supports options with multiple or variable numbers of arguments:
|
||||
<table width="60%">
|
||||
<tr><td width="30%"> --multi ARG1 ARG2
|
||||
<tr><td width="30%"> --multi ARG1 ARG2
|
||||
<td>Multiple arguments
|
||||
<tr><td> --multi N ARG-1 ARG-2 ... ARG-N
|
||||
<tr><td> --multi N ARG-1 ARG-2 ... ARG-N
|
||||
<td>Variable number of arguments
|
||||
</table>
|
||||
- supports case-insensitive option matching on short, long and/or
|
||||
- supports case-insensitive option matching on short, long and/or
|
||||
word arguments.
|
||||
- supports options which do not use a switch character. i.e. a special
|
||||
word which is construed as an option.
|
||||
e.g. "foo.exe open /directory/file.txt"
|
||||
- supports clumping of multiple short options (no arguments) in a string
|
||||
- supports options which do not use a switch character. i.e. a special
|
||||
word which is construed as an option.
|
||||
e.g. "foo.exe open /directory/file.txt"
|
||||
- supports clumping of multiple short options (no arguments) in a string
|
||||
e.g. "foo.exe -abcdef file1" <==> "foo.exe -a -b -c -d -e -f file1"
|
||||
- automatic recognition of a single slash as equivalent to a single
|
||||
- automatic recognition of a single slash as equivalent to a single
|
||||
hyphen on Windows, e.g. "/f FILE" is equivalent to "-f FILE".
|
||||
- file arguments can appear anywhere in the argument list:
|
||||
"foo.exe file1.txt -a ARG file2.txt --flag file3.txt file4.txt"
|
||||
files will be returned to the application in the same order they were
|
||||
files will be returned to the application in the same order they were
|
||||
supplied on the command line
|
||||
- short-circuit option matching: "--man" will match "--mandate"
|
||||
invalid options can be handled while continuing to parse the command
|
||||
invalid options can be handled while continuing to parse the command
|
||||
line valid options list can be changed dynamically during command line
|
||||
processing, i.e. accept different options depending on an option
|
||||
processing, i.e. accept different options depending on an option
|
||||
supplied earlier in the command line.
|
||||
- implemented with only a single C++ header file
|
||||
- optionally use no C runtime or OS functions
|
||||
- char, wchar_t and Windows TCHAR in the same program
|
||||
- complete working examples included
|
||||
- compiles cleanly at warning level 4 (Windows/VC.NET 2003), warning
|
||||
- compiles cleanly at warning level 4 (Windows/VC.NET 2003), warning
|
||||
level 3 (Windows/VC6) and -Wall (Linux/gcc)
|
||||
|
||||
@section usage USAGE
|
||||
@ -89,19 +89,19 @@
|
||||
</pre>
|
||||
Note that all options must start with a hyphen even if the slash will
|
||||
be accepted. This is because the slash character is automatically
|
||||
converted into a hyphen to test against the list of options.
|
||||
For example, the following line matches both "-?" and "/?"
|
||||
converted into a hyphen to test against the list of options.
|
||||
For example, the following line matches both "-?" and "/?"
|
||||
(on Windows).
|
||||
<pre>
|
||||
{ OPT_HELP, _T("-?"), SO_NONE }, // "-?"
|
||||
</pre>
|
||||
<li> Instantiate a CSimpleOpt object supplying argc, argv and the option
|
||||
<li> Instantiate a CSimpleOpt object supplying argc, argv and the option
|
||||
table
|
||||
<pre>
|
||||
@link CSimpleOptTempl CSimpleOpt @endlink args(argc, argv, g_rgOptions);
|
||||
</pre>
|
||||
<li> Process the arguments by calling Next() until it returns false.
|
||||
On each call, first check for an error by calling LastError(), then
|
||||
<li> Process the arguments by calling Next() until it returns false.
|
||||
On each call, first check for an error by calling LastError(), then
|
||||
either handle the error or process the argument.
|
||||
<pre>
|
||||
while (args.Next()) {
|
||||
@ -142,12 +142,12 @@ ShowFiles(args.FileCount(), args.Files());
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
</pre>
|
||||
*/
|
||||
@ -165,24 +165,24 @@ ShowFiles(args.FileCount(), args.Files());
|
||||
A cross-platform library providing a simple method to parse almost any of
|
||||
the standard command-line formats in use today.
|
||||
|
||||
See the @link SimpleOpt.h SimpleOpt @endlink documentation for full
|
||||
See the @link SimpleOpt.h SimpleOpt @endlink documentation for full
|
||||
details.
|
||||
|
||||
@section SimpleGlob SimpleGlob
|
||||
|
||||
A cross-platform file globbing library providing the ability to
|
||||
expand wildcards in command-line arguments to a list of all matching
|
||||
expand wildcards in command-line arguments to a list of all matching
|
||||
files.
|
||||
|
||||
See the @link SimpleGlob.h SimpleGlob @endlink documentation for full
|
||||
See the @link SimpleGlob.h SimpleGlob @endlink documentation for full
|
||||
details.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_SimpleOpt
|
||||
#define INCLUDED_SimpleOpt
|
||||
|
||||
// Default the max arguments to a fixed value. If you want to be able to
|
||||
// handle any number of arguments, then predefine this to 0 and it will
|
||||
// Default the max arguments to a fixed value. If you want to be able to
|
||||
// handle any number of arguments, then predefine this to 0 and it will
|
||||
// use an internal dynamically allocated buffer instead.
|
||||
#ifdef SO_MAX_ARGS
|
||||
# define SO_STATICBUF SO_MAX_ARGS
|
||||
@ -196,101 +196,101 @@ ShowFiles(args.FileCount(), args.Files());
|
||||
typedef enum _ESOError
|
||||
{
|
||||
//! No error
|
||||
SO_SUCCESS = 0,
|
||||
SO_SUCCESS = 0,
|
||||
|
||||
/*! It looks like an option (it starts with a switch character), but
|
||||
/*! It looks like an option (it starts with a switch character), but
|
||||
it isn't registered in the option table. */
|
||||
SO_OPT_INVALID = -1,
|
||||
SO_OPT_INVALID = -1,
|
||||
|
||||
/*! Multiple options matched the supplied option text.
|
||||
/*! Multiple options matched the supplied option text.
|
||||
Only returned when NOT using SO_O_EXACT. */
|
||||
SO_OPT_MULTIPLE = -2,
|
||||
SO_OPT_MULTIPLE = -2,
|
||||
|
||||
/*! Option doesn't take an argument, but a combined argument was
|
||||
/*! Option doesn't take an argument, but a combined argument was
|
||||
supplied. */
|
||||
SO_ARG_INVALID = -3,
|
||||
SO_ARG_INVALID = -3,
|
||||
|
||||
/*! SO_REQ_CMB style-argument was supplied to a SO_REQ_SEP option
|
||||
Only returned when using SO_O_PEDANTIC. */
|
||||
SO_ARG_INVALID_TYPE = -4,
|
||||
SO_ARG_INVALID_TYPE = -4,
|
||||
|
||||
//! Required argument was not supplied
|
||||
SO_ARG_MISSING = -5,
|
||||
SO_ARG_MISSING = -5,
|
||||
|
||||
/*! Option argument looks like another option.
|
||||
/*! Option argument looks like another option.
|
||||
Only returned when NOT using SO_O_NOERR. */
|
||||
SO_ARG_INVALID_DATA = -6
|
||||
SO_ARG_INVALID_DATA = -6
|
||||
} ESOError;
|
||||
|
||||
//! Option flags
|
||||
enum _ESOFlags
|
||||
{
|
||||
/*! Disallow partial matching of option names */
|
||||
SO_O_EXACT = 0x0001,
|
||||
SO_O_EXACT = 0x0001,
|
||||
|
||||
/*! Disallow use of slash as an option marker on Windows.
|
||||
/*! Disallow use of slash as an option marker on Windows.
|
||||
Un*x only ever recognizes a hyphen. */
|
||||
SO_O_NOSLASH = 0x0002,
|
||||
SO_O_NOSLASH = 0x0002,
|
||||
|
||||
/*! Permit arguments on single letter options with no equals sign.
|
||||
/*! Permit arguments on single letter options with no equals sign.
|
||||
e.g. -oARG or -o[ARG] */
|
||||
SO_O_SHORTARG = 0x0004,
|
||||
SO_O_SHORTARG = 0x0004,
|
||||
|
||||
/*! Permit single character options to be clumped into a single
|
||||
/*! Permit single character options to be clumped into a single
|
||||
option string. e.g. "-a -b -c" <==> "-abc" */
|
||||
SO_O_CLUMP = 0x0008,
|
||||
SO_O_CLUMP = 0x0008,
|
||||
|
||||
/*! Process the entire argv array for options, including the
|
||||
/*! Process the entire argv array for options, including the
|
||||
argv[0] entry. */
|
||||
SO_O_USEALL = 0x0010,
|
||||
SO_O_USEALL = 0x0010,
|
||||
|
||||
/*! Do not generate an error for invalid options. errors for missing
|
||||
arguments will still be generated. invalid options will be
|
||||
treated as files. invalid options in clumps will be silently
|
||||
/*! Do not generate an error for invalid options. errors for missing
|
||||
arguments will still be generated. invalid options will be
|
||||
treated as files. invalid options in clumps will be silently
|
||||
ignored. */
|
||||
SO_O_NOERR = 0x0020,
|
||||
SO_O_NOERR = 0x0020,
|
||||
|
||||
/*! Validate argument type pedantically. Return an error when a
|
||||
separated argument "-opt arg" is supplied by the user as a
|
||||
combined argument "-opt=arg". By default this is not considered
|
||||
/*! Validate argument type pedantically. Return an error when a
|
||||
separated argument "-opt arg" is supplied by the user as a
|
||||
combined argument "-opt=arg". By default this is not considered
|
||||
an error. */
|
||||
SO_O_PEDANTIC = 0x0040,
|
||||
SO_O_PEDANTIC = 0x0040,
|
||||
|
||||
/*! Case-insensitive comparisons for short arguments */
|
||||
SO_O_ICASE_SHORT = 0x0100,
|
||||
SO_O_ICASE_SHORT = 0x0100,
|
||||
|
||||
/*! Case-insensitive comparisons for long arguments */
|
||||
SO_O_ICASE_LONG = 0x0200,
|
||||
SO_O_ICASE_LONG = 0x0200,
|
||||
|
||||
/*! Case-insensitive comparisons for word arguments
|
||||
/*! Case-insensitive comparisons for word arguments
|
||||
i.e. arguments without any hyphens at the start. */
|
||||
SO_O_ICASE_WORD = 0x0400,
|
||||
SO_O_ICASE_WORD = 0x0400,
|
||||
|
||||
/*! Case-insensitive comparisons for all arg types */
|
||||
SO_O_ICASE = 0x0700
|
||||
SO_O_ICASE = 0x0700
|
||||
};
|
||||
|
||||
/*! Types of arguments that options may have. Note that some of the _ESOFlags
|
||||
are not compatible with all argument types. SO_O_SHORTARG requires that
|
||||
relevant options use either SO_REQ_CMB or SO_OPT. SO_O_CLUMP requires
|
||||
relevant options use either SO_REQ_CMB or SO_OPT. SO_O_CLUMP requires
|
||||
that relevant options use only SO_NONE.
|
||||
*/
|
||||
typedef enum _ESOArgType {
|
||||
/*! No argument. Just the option flags.
|
||||
e.g. -o --opt */
|
||||
SO_NONE,
|
||||
SO_NONE,
|
||||
|
||||
/*! Required separate argument.
|
||||
/*! Required separate argument.
|
||||
e.g. -o ARG --opt ARG */
|
||||
SO_REQ_SEP,
|
||||
SO_REQ_SEP,
|
||||
|
||||
/*! Required combined argument.
|
||||
/*! Required combined argument.
|
||||
e.g. -oARG -o=ARG --opt=ARG */
|
||||
SO_REQ_CMB,
|
||||
SO_REQ_CMB,
|
||||
|
||||
/*! Optional combined argument.
|
||||
/*! Optional combined argument.
|
||||
e.g. -o[ARG] -o[=ARG] --opt[=ARG] */
|
||||
SO_OPT,
|
||||
SO_OPT,
|
||||
|
||||
/*! Multiple separate arguments. The actual number of arguments is
|
||||
determined programatically at the time the argument is processed.
|
||||
@ -299,7 +299,7 @@ typedef enum _ESOArgType {
|
||||
} ESOArgType;
|
||||
|
||||
//! this option definition must be the last entry in the table
|
||||
#define SO_END_OF_OPTIONS { -1, NULL, SO_NONE }
|
||||
#define SO_END_OF_OPTIONS { -1, nullptr, SO_NONE }
|
||||
|
||||
#ifdef _DEBUG
|
||||
# ifdef _MSC_VER
|
||||
@ -328,7 +328,7 @@ public:
|
||||
//SOption()//Added for compatibility with fractal flames.
|
||||
//{
|
||||
// nId = 0;
|
||||
// pszArg = NULL;
|
||||
// pszArg = nullptr;
|
||||
// nArgType = SO_NONE;
|
||||
//}
|
||||
|
||||
@ -340,34 +340,34 @@ public:
|
||||
//}
|
||||
|
||||
/*! ID to return for this flag. Optional but must be >= 0 */
|
||||
int nId;
|
||||
int nId;
|
||||
|
||||
/*! arg string to search for, e.g. "open", "-", "-f", "--file"
|
||||
/*! arg string to search for, e.g. "open", "-", "-f", "--file"
|
||||
Note that on Windows the slash option marker will be converted
|
||||
to a hyphen so that "-f" will also match "/f". */
|
||||
const SOCHAR * pszArg;
|
||||
|
||||
/*! type of argument accepted by this option */
|
||||
ESOArgType nArgType;
|
||||
ESOArgType nArgType;
|
||||
};
|
||||
|
||||
/*! @brief Initialize the class. Init() must be called later. */
|
||||
CSimpleOptTempl()
|
||||
: m_rgShuffleBuf(NULL)
|
||||
{
|
||||
Init(0, NULL, NULL, 0);
|
||||
CSimpleOptTempl()
|
||||
: m_rgShuffleBuf(nullptr)
|
||||
{
|
||||
Init(0, nullptr, nullptr, 0);
|
||||
}
|
||||
|
||||
/*! @brief Initialize the class in preparation for use. */
|
||||
CSimpleOptTempl(
|
||||
int argc,
|
||||
SOCHAR * argv[],
|
||||
const SOption * a_rgOptions,
|
||||
int argc,
|
||||
SOCHAR * argv[],
|
||||
const SOption * a_rgOptions,
|
||||
int a_nFlags = 0
|
||||
)
|
||||
: m_rgShuffleBuf(NULL)
|
||||
{
|
||||
Init(argc, argv, a_rgOptions, a_nFlags);
|
||||
)
|
||||
: m_rgShuffleBuf(nullptr)
|
||||
{
|
||||
Init(argc, argv, a_rgOptions, a_nFlags);
|
||||
}
|
||||
|
||||
#ifndef SO_MAX_ARGS
|
||||
@ -389,17 +389,17 @@ public:
|
||||
@param a_argc Argument array size
|
||||
@param a_argv Argument array
|
||||
@param a_rgOptions Valid option array
|
||||
@param a_nFlags Optional flags to modify the processing of
|
||||
@param a_nFlags Optional flags to modify the processing of
|
||||
the arguments
|
||||
|
||||
@return true Successful
|
||||
@return true Successful
|
||||
@return false if SO_MAX_ARGC > 0: Too many arguments
|
||||
if SO_MAX_ARGC == 0: Memory allocation failure
|
||||
*/
|
||||
bool Init(
|
||||
int a_argc,
|
||||
SOCHAR * a_argv[],
|
||||
const SOption * a_rgOptions,
|
||||
int a_argc,
|
||||
SOCHAR * a_argv[],
|
||||
const SOption * a_rgOptions,
|
||||
int a_nFlags = 0
|
||||
);
|
||||
|
||||
@ -407,8 +407,8 @@ public:
|
||||
|
||||
@param a_rgOptions Valid option array
|
||||
*/
|
||||
inline void SetOptions(const SOption * a_rgOptions) {
|
||||
m_rgOptions = a_rgOptions;
|
||||
inline void SetOptions(const SOption * a_rgOptions) {
|
||||
m_rgOptions = a_rgOptions;
|
||||
}
|
||||
|
||||
/*! @brief Change the current flags during option parsing.
|
||||
@ -421,16 +421,16 @@ public:
|
||||
inline void SetFlags(int a_nFlags) { m_nFlags = a_nFlags; }
|
||||
|
||||
/*! @brief Query if a particular flag is set */
|
||||
inline bool HasFlag(int a_nFlag) const {
|
||||
return (m_nFlags & a_nFlag) == a_nFlag;
|
||||
inline bool HasFlag(int a_nFlag) const {
|
||||
return (m_nFlags & a_nFlag) == a_nFlag;
|
||||
}
|
||||
|
||||
/*! @brief Advance to the next option if available.
|
||||
|
||||
When all options have been processed it will return false. When true
|
||||
has been returned, you must check for an invalid or unrecognized
|
||||
option using the LastError() method. This will be return an error
|
||||
value other than SO_SUCCESS on an error. All standard data
|
||||
option using the LastError() method. This will be return an error
|
||||
value other than SO_SUCCESS on an error. All standard data
|
||||
(e.g. OptionText(), OptionArg(), OptionId(), etc) will be available
|
||||
depending on the error.
|
||||
|
||||
@ -450,7 +450,7 @@ public:
|
||||
|
||||
/*! @brief Return the last error that occurred.
|
||||
|
||||
This function must always be called before processing the current
|
||||
This function must always be called before processing the current
|
||||
option. This function is available only when Next() has returned true.
|
||||
*/
|
||||
inline ESOError LastError() const { return m_nLastError; }
|
||||
@ -462,7 +462,7 @@ public:
|
||||
*/
|
||||
inline int OptionId() const { return m_nOptionId; }
|
||||
|
||||
/*! @brief Return the pszArg from the options array for the current
|
||||
/*! @brief Return the pszArg from the options array for the current
|
||||
option.
|
||||
|
||||
This function is available only when Next() has returned true.
|
||||
@ -471,7 +471,7 @@ public:
|
||||
|
||||
/*! @brief Return the argument for the current option where one exists.
|
||||
|
||||
If there is no argument for the option, this will return NULL.
|
||||
If there is no argument for the option, this will return nullptr.
|
||||
This function is available only when Next() has returned true.
|
||||
*/
|
||||
inline SOCHAR * OptionArg() const { return m_pszOptionArg; }
|
||||
@ -483,7 +483,7 @@ public:
|
||||
each time returning the desired number of arguments. Previously
|
||||
returned argument pointers are remain valid.
|
||||
|
||||
If an error occurs during processing, NULL will be returned and
|
||||
If an error occurs during processing, nullptr will be returned and
|
||||
the error will be available via LastError().
|
||||
|
||||
@param n Number of arguments to return.
|
||||
@ -523,7 +523,7 @@ private:
|
||||
// Find the '=' character within a string.
|
||||
inline SOCHAR * FindEquals(SOCHAR *s) const {
|
||||
while (*s && *s != (SOCHAR)'=') ++s;
|
||||
return *s ? s : NULL;
|
||||
return *s ? s : nullptr;
|
||||
}
|
||||
bool IsEqual(SOCHAR a_cLeft, SOCHAR a_cRight, int a_nArgType) const;
|
||||
|
||||
@ -537,11 +537,11 @@ private:
|
||||
}
|
||||
|
||||
private:
|
||||
const SOption * m_rgOptions; //!< pointer to options table
|
||||
int m_nFlags; //!< flags
|
||||
const SOption * m_rgOptions; //!< pointer to options table
|
||||
int m_nFlags; //!< flags
|
||||
int m_nOptionIdx; //!< current argv option index
|
||||
int m_nOptionId; //!< id of current option (-1 = invalid)
|
||||
int m_nNextOption; //!< index of next option
|
||||
int m_nNextOption; //!< index of next option
|
||||
int m_nLastArg; //!< last argument, after this are files
|
||||
int m_argc; //!< argc to process
|
||||
SOCHAR ** m_argv; //!< argv
|
||||
@ -573,13 +573,13 @@ CSimpleOptTempl<SOCHAR>::Init(
|
||||
m_nLastError = SO_SUCCESS;
|
||||
m_nOptionIdx = 0;
|
||||
m_nOptionId = -1;
|
||||
m_pszOptionText = NULL;
|
||||
m_pszOptionArg = NULL;
|
||||
m_pszOptionText = nullptr;
|
||||
m_pszOptionArg = nullptr;
|
||||
m_nNextOption = (a_nFlags & SO_O_USEALL) ? 0 : 1;
|
||||
m_szShort[0] = (SOCHAR)'-';
|
||||
m_szShort[2] = (SOCHAR)'\0';
|
||||
m_nFlags = a_nFlags;
|
||||
m_pszClump = NULL;
|
||||
m_pszClump = nullptr;
|
||||
|
||||
#ifdef SO_MAX_ARGS
|
||||
if (m_argc > SO_MAX_ARGS) {
|
||||
@ -627,13 +627,13 @@ CSimpleOptTempl<SOCHAR>::Next()
|
||||
}
|
||||
}
|
||||
SO_ASSERT(!m_pszClump || !*m_pszClump);
|
||||
m_pszClump = NULL;
|
||||
m_pszClump = nullptr;
|
||||
|
||||
// init for the next option
|
||||
m_nOptionIdx = m_nNextOption;
|
||||
m_nOptionId = -1;
|
||||
m_pszOptionText = NULL;
|
||||
m_pszOptionArg = NULL;
|
||||
m_pszOptionText = nullptr;
|
||||
m_pszOptionArg = nullptr;
|
||||
m_nLastError = SO_SUCCESS;
|
||||
|
||||
// find the next option
|
||||
@ -642,7 +642,7 @@ CSimpleOptTempl<SOCHAR>::Next()
|
||||
int nOptIdx = m_nOptionIdx;
|
||||
while (nTableIdx < 0 && nOptIdx < m_nLastArg) {
|
||||
SOCHAR * pszArg = m_argv[nOptIdx];
|
||||
m_pszOptionArg = NULL;
|
||||
m_pszOptionArg = nullptr;
|
||||
|
||||
// find this option in the options table
|
||||
cFirst = PrepareArg(pszArg);
|
||||
@ -698,7 +698,7 @@ CSimpleOptTempl<SOCHAR>::Next()
|
||||
m_pszOptionText = pszArg;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
pszArg[0] = cFirst;
|
||||
++nOptIdx;
|
||||
if (m_pszOptionArg) {
|
||||
@ -736,7 +736,7 @@ CSimpleOptTempl<SOCHAR>::Next()
|
||||
|
||||
case SO_REQ_SEP:
|
||||
if (m_pszOptionArg) {
|
||||
// they wanted separate args, but we got a combined one,
|
||||
// they wanted separate args, but we got a combined one,
|
||||
// unless we are pedantic, just accept it.
|
||||
if (HasFlag(SO_O_PEDANTIC)) {
|
||||
m_nLastError = SO_ARG_INVALID_TYPE;
|
||||
@ -759,6 +759,8 @@ CSimpleOptTempl<SOCHAR>::Next()
|
||||
// nothing to do. Caller must now check for valid arguments
|
||||
// using GetMultiArg()
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -769,9 +771,9 @@ CSimpleOptTempl<SOCHAR>::Next()
|
||||
|
||||
// we need to return the separate arg if required, just re-use the
|
||||
// multi-arg code because it all does the same thing
|
||||
if ( nArgType == SO_REQ_SEP
|
||||
&& !m_pszOptionArg
|
||||
&& m_nLastError == SO_SUCCESS)
|
||||
if ( nArgType == SO_REQ_SEP
|
||||
&& !m_pszOptionArg
|
||||
&& m_nLastError == SO_SUCCESS)
|
||||
{
|
||||
SOCHAR ** ppArgs = MultiArg(1);
|
||||
if (ppArgs) {
|
||||
@ -821,8 +823,8 @@ CSimpleOptTempl<SOCHAR>::NextClumped()
|
||||
// prepare for the next clumped option
|
||||
m_szShort[1] = *m_pszClump++;
|
||||
m_nOptionId = -1;
|
||||
m_pszOptionText = NULL;
|
||||
m_pszOptionArg = NULL;
|
||||
m_pszOptionText = nullptr;
|
||||
m_pszOptionArg = nullptr;
|
||||
m_nLastError = SO_SUCCESS;
|
||||
|
||||
// lookup this option, ensure that we are using exact matching
|
||||
@ -950,7 +952,7 @@ CSimpleOptTempl<SOCHAR>::CalcMatch(
|
||||
|
||||
// match and skip leading hyphens
|
||||
while (*a_pszSource == (SOCHAR)'-' && *a_pszSource == *a_pszTest) {
|
||||
++a_pszSource;
|
||||
++a_pszSource;
|
||||
++a_pszTest;
|
||||
}
|
||||
if (*a_pszSource == (SOCHAR)'-' || *a_pszTest == (SOCHAR)'-') {
|
||||
@ -960,8 +962,8 @@ CSimpleOptTempl<SOCHAR>::CalcMatch(
|
||||
// find matching number of characters in the strings
|
||||
int nLen = 0;
|
||||
while (*a_pszSource && IsEqual(*a_pszSource, *a_pszTest, nArgType)) {
|
||||
++a_pszSource;
|
||||
++a_pszTest;
|
||||
++a_pszSource;
|
||||
++a_pszTest;
|
||||
++nLen;
|
||||
}
|
||||
|
||||
@ -1014,7 +1016,7 @@ CSimpleOptTempl<SOCHAR>::MultiArg(
|
||||
// ensure we have enough arguments
|
||||
if (m_nNextOption + a_nCount > m_nLastArg) {
|
||||
m_nLastError = SO_ARG_MISSING;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// our argument array
|
||||
@ -1028,7 +1030,7 @@ CSimpleOptTempl<SOCHAR>::MultiArg(
|
||||
if (rgpszArg[n][0] == (SOCHAR)'-') {
|
||||
rgpszArg[n][0] = ch;
|
||||
m_nLastError = SO_ARG_INVALID_DATA;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
rgpszArg[n][0] = ch;
|
||||
}
|
||||
@ -1045,18 +1047,18 @@ CSimpleOptTempl<SOCHAR>::MultiArg(
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/*! @brief ASCII/MBCS version of CSimpleOpt */
|
||||
typedef CSimpleOptTempl<char> CSimpleOptA;
|
||||
typedef CSimpleOptTempl<char> CSimpleOptA;
|
||||
|
||||
/*! @brief wchar_t version of CSimpleOpt */
|
||||
typedef CSimpleOptTempl<wchar_t> CSimpleOptW;
|
||||
typedef CSimpleOptTempl<wchar_t> CSimpleOptW;
|
||||
|
||||
#if defined(_UNICODE)
|
||||
/*! @brief TCHAR version dependent on if _UNICODE is defined */
|
||||
# define CSimpleOpt CSimpleOptW
|
||||
# define CSimpleOpt CSimpleOptW
|
||||
# define CharT wchar_t
|
||||
#else
|
||||
/*! @brief TCHAR version dependent on if _UNICODE is defined */
|
||||
# define CSimpleOpt CSimpleOptA
|
||||
# define CSimpleOpt CSimpleOptA
|
||||
# define CharT char
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user