PCL
Argument Parsing Routines and Utilities

Namespaces

 pcl::ArgumentItemMode
 Non-parametric argument parsing modes.
 
 pcl::ArgumentOption
 Working options affecting how non-parametric arguments are interpreted.
 

Classes

class  pcl::Argument
 A command-line argument. More...
 
class  argument_item_mode
 Represents an ArgumentItemMode enumerated value. More...
 
class  ArgumentList
 A dynamic array of command-line arguments. More...
 
class  ArgumentOptions
 A combination of ArgumentOption flags. More...
 

Functions

ArgumentList PCL_FUNC pcl::ExtractArguments (const StringList &argv, argument_item_mode mode=ArgumentItemMode::Ignore, ArgumentOptions options=ArgumentOptions())
 
String PCL_FUNC pcl::RecursiveDirSearchArgument ()
 
String PCL_FUNC pcl::ReplaceEnvironmentVariables (const String &s)
 
StringList PCL_FUNC pcl::SearchDirectory (const String &filePath, bool recursive=false)
 
void PCL_FUNC pcl::SetRecursiveDirSearchArgument (const String &id)
 

Detailed Description

Function Documentation

◆ ExtractArguments()

ArgumentList PCL_FUNC pcl::ExtractArguments ( const StringList argv,
argument_item_mode  mode = ArgumentItemMode::Ignore,
ArgumentOptions  options = ArgumentOptions() 
)

Extracts a sequence of command-line arguments of the form:

[<arg_list>] [<item_list>]

where:

<item_list> Is a sequence <item> [<item_list>]

<item> Is a non-parametric (or "item") argument. If file parsing is active (see the mode parameter below), each item will be parsed as a file path specification. If view parsing is active, items will be considered as view identifiers. In both cases, each item may include wildcards to define a search pattern, which will be automatically expanded into a sequence of actual file paths or view identifiers.

<arg_list> Is a sequence <arg> [<arg_list>]

<arg> Is a parametric argument (see the documentation for the Argument class for a complete description).

Parameters
argvThe list of input argument tokens that will be parsed.

modeIndicates how non-parametric items will be handled by this function. mode must have one of the following values:

ArgumentItemMode::Ignore. Non-parametric arguments will not be parsed and will be passed unchanged.
ArgumentItemMode::AsFiles. Each non-parametric argument is interpreted as a file path specification. Note that neither validity of file paths nor the existence of actual files are verified.
ArgumentItemMode::AsViews. Each non-parametric argument is interpreted and parsed as a view identifier specification. Note that only validity of view identifiers is verified, not the existence of actual views with such identifiers.
ArgumentItemMode::NoItems. This mode disallows non-parametric arguments. An exception is thrown if a non-parametric item is found in the input sequence of argv elements.


optionsThis is an OR'ed combination of flags from the ArgumentOption enumeration:

ArgumentItemMode::AllowWildcards. If this flag is included, each file argument containing wildcards ('*' and '?' characters) will originate a search for all files matching the specified wildcard pattern. If view arguments are being considered, each wildcard item will be expanded into a list of matching view identifiers.
ArgumentItemMode::NoPreviews. This flag prevents the inclusion of preview identifiers in the output arguments set. If a preview specification (imageId->previewId) is found and this flag is active, an exception is thrown.
ArgumentItemMode::RecursiveDirSearch. This flag only makes sense along with the ArgumentItemMode::AsFiles mode. If used, this flag will originate recursive directory searches for all file path specifications containing wildcards. Note that the behavior of this flag can be altered by the RecursiveSearchArgs flag (see below).

ArgumentItemMode::RecursiveSearchArgs. This flag only makes sense along with the ArgumentItemMode::AsFiles mode and the RecursiveDirSearch flag (see above). If used, recursive directory searches will be controlled by a special toggle argument. All instances of this argument will be processed automatically by the routine and will not be included in the output arguments list. By default, this argument is –r[+|-], but it can be changed by calling the SetRecursiveDirSearchArgument() static function.

Example of wild path argument specifications with recursive search through the standard –r toggle argument:

*.cpp –r *.h *.png –r- *.exe

In the example above, *.h and *.png will be searched recursively through the entire directory tree rooted at the current directory, but *.cpp and *.exe files will only be searched for in the current directory.

This function generates a ParseError exception when it encounters an error while parsing the sequence of input arguments.

Returns a list with all the arguments extracted from the input argv sequence as instances of the Argument class. If non-parametric arguments are being interpreted as file paths, each non-parametric item is expanded to its corresponding full file path. If non-parametric arguments are being parsed as view identifiers, each non-parametric item is replaced (if appropriate) by its full view identifier. Otherwise, non-parametric items are returned unchanged.

◆ RecursiveDirSearchArgument()

String PCL_FUNC pcl::RecursiveDirSearchArgument ( )

Returns the identifier of the argument used by ExtractArguments() for automatic toggle of recursive directory searches. By default, this is the –r[+|-] argument.

◆ ReplaceEnvironmentVariables()

String PCL_FUNC pcl::ReplaceEnvironmentVariables ( const String s)

Returns a copy of a source string s where all references to environment variables have been replaced with their corresponding values.

This function finds all occurrences of environment variables of the form:

$<env_name>

where <env_name> is any sequence of alphabetic, decimal, or underscore characters. If <env_name> corresponds to an existing environment variable of the calling process, the entire $<env_name> sequence is replaced with the variable's value. References to nonexistent environment variables, as well as empty references (isolated $ characters), are replaced with an empty string (removed).

This function works recursively: it can replace environment variables inside the values of environment variables. The routine performs replacements recursively until no $ character is found in the string.

◆ SearchDirectory()

StringList PCL_FUNC pcl::SearchDirectory ( const String filePath,
bool  recursive = false 
)

Auxiliary directory search routine used by ExtractArguments().

Returns a list of full file paths corresponding to a template wild file specification (filePath), optionally recursing the directory tree, starting from the directory specified in filePath.

◆ SetRecursiveDirSearchArgument()

void PCL_FUNC pcl::SetRecursiveDirSearchArgument ( const String id)

Sets the identifier of the argument used by ExtractArguments() for automatic toggle of recursive directory searches.

Parameters
idNew identifier for the automatic recursive search argument. N.B.: When specifying this argument, don't include the '-' standard parameter prefix.