Namespaces | Classes | Typedefs | Functions | Variables
basis Namespace Reference

Namespaces

 argparse
 
 diff3
 
 os
 
 util
 
 utilities
 
 which
 

Classes

class  CmdLine
 Manages command line definition and parsing of arguments. More...
 
class  ExistingDirectoryConstraint
 Constrain argument values to paths of existing directories. More...
 
class  ExistingFileConstraint
 Constrain argument values to paths of existing files. More...
 
class  MultiArg
 An argument that allows multiple values of type T to be specified. More...
 
class  NegativeValueConstraint
 Constrain argument values to negative values. More...
 
class  NonZeroValueConstraint
 Constrain argument values to non-zero values. More...
 
class  PositiveValueConstraint
 Constrain argument values to positive values. More...
 
class  Subprocess
 Platform-independent interface to create and control a subprocess. More...
 
class  ValueArg
 An argument that allows multiple values of type T to be specified. More...
 
class  ZeroOrNegativeValueConstraint
 Constrain argument values to zero or negative values. More...
 
class  ZeroOrPositiveValueConstraint
 Constrain argument values to zero or positive values. More...
 

Typedefs

typedef TCLAP::Arg Arg
 Base type of command-line arguments. More...
 
typedef TCLAP::ArgException ArgException
 Exception thrown by command-line parsing library. More...
 
typedef TCLAP::ArgParseException ArgParseException
 Exception thrown on command-line argument parsing error. More...
 
typedef TCLAP::SpecificationException CmdLineException
 Exception thrown when command-line specification is wrong. More...
 
typedef TCLAP::CmdLineParseException CmdLineParseException
 Exception thrown on command-line parsing error. More...
 
typedef basis::ValueArg< double > DoubleArg
 Floating-point argument (double precision). More...
 
typedef TCLAP::ExitException ExitException
 Exception thrown by command-line parsing library to indicate that program should exit with the given exit code. More...
 
typedef basis::ValueArg< float > FloatArg
 Floating-point argument. More...
 
typedef basis::ValueArg< int > Int32Arg
 Signed 32-bit integer argument. More...
 
typedef basis::ValueArg< long > Int64Arg
 Signed 64-bit integer argument. More...
 
typedef basis::ValueArg< int > IntArg
 Alias for Int32Arg. More...
 
typedef basis::MultiArg< double > MultiDoubleArg
 Floating-point argument (double precision, multiple occurrences allowed). More...
 
typedef basis::MultiArg< float > MultiFloatArg
 Floating-point argument (multiple occurrences allowed). More...
 
typedef basis::MultiArg< int > MultiInt32Arg
 Signed 32-bit integer argument (multiple occurrences allowed). More...
 
typedef basis::MultiArg< long > MultiInt64Arg
 Signed 64-bit integer argument (multiple occurrences allowed). More...
 
typedef basis::MultiArg< int > MultiIntArg
 Alias for MultiInt32Arg. More...
 
typedef basis::MultiArg< std::string > MultiStringArg
 String argument (multiple occurrences allowed). More...
 
typedef TCLAP::MultiSwitchArg MultiSwitchArg
 Counts occurrences of option switch. More...
 
typedef basis::MultiArg< unsigned int > MultiUInt32Arg
 Unsigned 32-bit integer argument (multiple occurrences allowed). More...
 
typedef basis::MultiArg< unsigned long > MultiUInt64Arg
 Unsigned 64-bit integer argument (multiple occurrences allowed). More...
 
typedef basis::MultiArg< unsigned int > MultiUIntArg
 Alias for MultiUInt32Arg. More...
 
typedef TCLAP::UnlabeledValueArg< std::string > PositionalArg
 Positional argument. More...
 
typedef TCLAP::UnlabeledMultiArg< std::string > PositionalArgs
 Positional arguments. More...
 
typedef basis::ValueArg< std::string > StringArg
 String argument. More...
 
typedef TCLAP::ValuesConstraint< std::string > StringValuesConstraint
 Constrains string arguments to allow only predefined values. More...
 
typedef TCLAP::SwitchArg SwitchArg
 Switch to enable/disable option. More...
 
typedef basis::ValueArg< unsigned int > UInt32Arg
 Unsigned 32-bit integer argument. More...
 
typedef basis::ValueArg< unsigned long > UInt64Arg
 Unsigned 64-bit integer argument. More...
 
typedef basis::ValueArg< unsigned int > UIntArg
 Alias for UInt32Arg. More...
 

Functions

std::string bindir ()
 Get absolute path to directory containing runtime executables. More...
 
std::string datadir ()
 Get absolute path to directory containing auxiliary data. More...
 
int execute (const std::string &cmd, bool quiet=false, std::ostream *out=NULL, bool allow_fail=false, int verbose=0, bool simulate=false)
 Execute command as subprocess. More...
 
int execute (std::vector< std::string > args, bool quiet=false, std::ostream *out=NULL, bool allow_fail=false, int verbose=0, bool simulate=false)
 Execute command as subprocess. More...
 
std::string exedir (const std::string &name=std::string())
 Get directory of executable file. More...
 
std::string exename (const std::string &name=std::string())
 Get name of executable file. More...
 
std::string exepath (const std::string &name=std::string())
 Get absolute path of executable file. More...
 
int get_terminal_columns ()
 Get maximum number of columns of terminal window. More...
 
int get_terminal_lines ()
 Get maximum number of lines of terminal window. More...
 
void get_terminal_size (int &lines, int &columns)
 Get size of terminal window. More...
 
bool istarget (const std::string &name)
 Determine whether a given build target is known. More...
 
std::string libdir ()
 Get absolute path to directory containing libraries. More...
 
std::string libexecdir ()
 Get absolute path to directory containing auxiliary executables. More...
 
void print_contact (const char *contact=NULL)
 Print contact information. More...
 
void print_version (const char *name, const char *version=NULL, const char *project=NULL, const char *copyright=NULL, const char *license=NULL)
 Print version information including copyright and license notices. More...
 
std::ostream & print_wrapped (std::ostream &os, const std::string &text, int width, int indent, int offset)
 Print text, wrapped at a fixed maximum number of columns. More...
 
std::string targetuid (const std::string &name)
 Get UID of build target. More...
 

Variables

const char * CONTACT = "andreas.schuh.84@gmail.com"
 Default contact to use for help output of executables. More...
 
const char * COPYRIGHT = "2011-12 University of Pennsylvania, 2013-14 Carnegie Mellon University, 2013-16 Andreas Schuh"
 Default copyright of executables. More...
 
const char * LICENSE = "See https://cmake-basis.github.io/download.html#license or COPYING file."
 Default license of executables. More...
 
const char * PROJECT = "BASIS"
 The project name. More...
 
const char * RELEASE = "v3.3 (fb18c98)"
 Complete version information as output by –version option. More...
 
const char * VERSION = "3.3.1"
 The version string given as "<major>.<minor>.<patch>". More...
 
const unsigned int VERSION_MAJOR = 3
 The major version number. More...
 
const unsigned int VERSION_MINOR = 3
 The minor version number. More...
 
const unsigned int VERSION_PATCH = 0
 The patch number. More...
 

Typedef Documentation

§ ArgException

typedef TCLAP::ArgException basis::ArgException

Exception thrown by command-line parsing library.

Definition at line 60 of file except.h.

§ ArgParseException

typedef TCLAP::ArgParseException basis::ArgParseException

Exception thrown on command-line argument parsing error.

Definition at line 67 of file except.h.

§ CmdLineException

typedef TCLAP::SpecificationException basis::CmdLineException

Exception thrown when command-line specification is wrong.

Definition at line 73 of file except.h.

§ CmdLineParseException

typedef TCLAP::CmdLineParseException basis::CmdLineParseException

Exception thrown on command-line parsing error.

Definition at line 70 of file except.h.

§ ExitException

typedef TCLAP::ExitException basis::ExitException

Exception thrown by command-line parsing library to indicate that program should exit with the given exit code.

Definition at line 64 of file except.h.

Function Documentation

§ bindir()

string basis::bindir ( )

Get absolute path to directory containing runtime executables.

Returns
Absolute path to directory containing runtime executables.

Definition at line 203 of file basis.cxx.

§ datadir()

string basis::datadir ( )

Get absolute path to directory containing auxiliary data.

Returns
Absolute path to directory containing auxiliary data.

Definition at line 233 of file basis.cxx.

§ execute() [1/2]

int basis::execute ( const std::string &  cmd,
bool  quiet = false,
std::ostream *  out = NULL,
bool  allow_fail = false,
int  verbose = 0,
bool  simulate = false 
)

Execute command as subprocess.

This function is a replacement for system() on Unix and is furthermore less platform dependent. The first argument of the given command-line string is mapped to an absolute executable file using exepath() if the given first argument is a know build target name. Otherwise, the command-line is used unmodified.

Parameters
[in]cmdCommand-line given as double quoted string. Arguments containing whitespaces have to be quoted using double quotes. Use a backslash (\) to escape double quotes inside an argument as well as to escape a backslash itself (required if backslash at end of double quoted argument, e.g., "this argument \\").
[in]quietTurns off output of stdout of child process to stdout of parent process.
[out]outOutput stream where command output is written to.
[in]allow_failIf true, no exception is thrown if the exit code of the child process is non-zero. Otherwise, a SubprocessException object is thrown in that case.
[in]verboseVerbosity of output messages. Does not affect verbosity of executed command.
[in]simulateWhether to simulate command execution only.
Returns
Exit code of command or -1 if subprocess creation failed.
Exceptions
SubprocessErrorIf subprocess creation failed or command returned a non-zero exit code while allow_fail is false.

Definition at line 297 of file basis.cxx.

§ execute() [2/2]

int basis::execute ( std::vector< std::string >  args,
bool  quiet = false,
std::ostream *  out = NULL,
bool  allow_fail = false,
int  verbose = 0,
bool  simulate = false 
)

Execute command as subprocess.

This function is a replacement for system() on Unix and is furthermore less platform dependent. The first argument of the given command-line string is mapped to an absolute executable file using exepath() if the given first argument is a know build target name. Otherwise, the command-line is used unmodified.

Parameters
[in,out]argsCommand-line given as argument vector. The first argument has to be either a build target name or the name/path of the command to execute.
[in]quietTurns off output of stdout of child process to stdout of parent process.
[out]outOutput stream where command output is written to.
[in]allow_failIf true, no exception is thrown if the exit code of the child process is non-zero. Otherwise, a SubprocessException object is thrown in that case.
[in]verboseVerbosity of output messages. Does not affect verbosity of executed command.
[in]simulateWhether to simulate command execution only.
Returns
Exit code of command or -1 if subprocess creation failed.
Exceptions
SubprocessErrorIf subprocess creation failed or command returned a non-zero exit code while allow_fail is false.

Definition at line 305 of file basis.cxx.

§ exedir()

string basis::exedir ( const std::string &  name = std::string())

Get directory of executable file.

Parameters
[in]nameName of command or NULL.
Returns
Absolute path to directory containing executable or an empty string if not found. If name is NULL, the directory of this executable is returned.
See also
exepath()

Definition at line 287 of file basis.cxx.

§ exename()

string basis::exename ( const std::string &  name = std::string())

Get name of executable file.

Note
The name of the executable may or may not include the file name extension depending on the executable type and operating system. Hence, this function is neither an equivalent to os::path::basename(exepath()) nor os::path::filename(exepath()). In particular, on Windows, the .exe and .com extension is not included in the returned executable name.
Parameters
[in]nameName of command or NULL.
Returns
Name of executable file or an empty string if not found. If name is NULL, the name of this executable is returned.
See also
exepath()

Definition at line 281 of file basis.cxx.

§ exepath()

string basis::exepath ( const std::string &  name = std::string())

Get absolute path of executable file.

This function determines the absolute file path of an executable. If no arguments are given, the absolute path of this executable is returned. If the command names a known executable build target, the absolute path to the corresonding built (and installed) executable file is returned. Otherwise, the named command is searched in the system PATH and its absolute path returned if found. If the executable is not found, an empty string is returned.

Todo:
This function currently makes use of the which command implemented in Python and called as subprocess in order to search a command in the system PATH. This which command is part of BASIS and can also be used on Windows. However, a native C++ implementation would be desireable.
Parameters
[in]nameName of command or NULL.
Returns
Absolute path of executable or an empty string if not found. If name is NULL, the path of this executable is returned.
See also
exename()
exedir()

Definition at line 275 of file basis.cxx.

§ istarget()

bool basis::istarget ( const std::string &  name)

Determine whether a given build target is known.

Parameters
[in]nameName of build target.
Returns
Whether the named target is a known executable target.

Definition at line 269 of file basis.cxx.

§ libdir()

string basis::libdir ( )

Get absolute path to directory containing libraries.

Returns
Absolute path to directory containing libraries.

Definition at line 223 of file basis.cxx.

§ libexecdir()

string basis::libexecdir ( )

Get absolute path to directory containing auxiliary executables.

Returns
Absolute path to directory containing auxiliary executables.

Definition at line 213 of file basis.cxx.

§ print_contact()

void basis::print_contact ( const char *  contact = NULL)

Print contact information.

Parameters
[in]contactName of contact. If NULL, CONTACT is used.

Definition at line 247 of file basis.cxx.

§ print_version()

void basis::print_version ( const char *  name,
const char *  version = NULL,
const char *  project = NULL,
const char *  copyright = NULL,
const char *  license = NULL 
)

Print version information including copyright and license notices.

Parameters
[in]nameName of executable. Should not be set programmatically to the first argument of the main() function, but a string literal instead.
[in]versionVersion of executable, e.g., release of project this executable belongs to. Defaults to RELEASE.
[in]projectName of project this executable belongs to. If NULL, defaults to PROJECT. If an empty string, no project information is printed.
[in]copyrightThe copyright notice, excluding the common prefix "Copyright (c) " and suffix ". All rights reserved.". If NULL, COPYRIGHT is used. If an empty string, no copyright notice is printed.
[in]licenseInformation regarding licensing. If NULL, LICENSE is used. If an empty string, no license information is printed.

Definition at line 253 of file basis.cxx.

§ targetuid()

string basis::targetuid ( const std::string &  name)

Get UID of build target.

The UID of a build target is its name prepended by a namespace identifier which should be unique for each project.

Parameters
[in]nameName of build target.
Returns
UID of named build target.

Definition at line 263 of file basis.cxx.

Variable Documentation

§ CONTACT

const char * basis::CONTACT = "andreas.schuh.84@gmail.com"

Default contact to use for help output of executables.

Definition at line 47 of file basis.cxx.

§ COPYRIGHT

const char * basis::COPYRIGHT = "2011-12 University of Pennsylvania, 2013-14 Carnegie Mellon University, 2013-16 Andreas Schuh"

Default copyright of executables.

Definition at line 45 of file basis.cxx.

§ LICENSE

const char * basis::LICENSE = "See https://cmake-basis.github.io/download.html#license or COPYING file."

Default license of executables.

Definition at line 46 of file basis.cxx.

§ PROJECT

const char * basis::PROJECT = "BASIS"

The project name.

The project name.

Definition at line 37 of file basis.cxx.

§ RELEASE

const char * basis::RELEASE = "v3.3 (fb18c98)"

Complete version information as output by –version option.

Complete version information as output by –version option.

Definition at line 39 of file basis.cxx.

§ VERSION

const char * basis::VERSION = "3.3.1"

The version string given as "<major>.<minor>.<patch>".

The version string given as "<major>.<minor>.<patch>".

Definition at line 38 of file basis.cxx.

§ VERSION_MAJOR

const unsigned int basis::VERSION_MAJOR = 3

The major version number.

Definition at line 41 of file basis.cxx.

§ VERSION_MINOR

const unsigned int basis::VERSION_MINOR = 3

The minor version number.

Definition at line 42 of file basis.cxx.

§ VERSION_PATCH

const unsigned int basis::VERSION_PATCH = 0

The patch number.

Definition at line 43 of file basis.cxx.