Auxiliary implementations for use in C++ source code. More...
Classes | |
class | sbia::basis::ExecutableTargetInfo |
Provides information about executable build targets. More... | |
Modules | |
Command-line Parsing Library | |
Command-line parsing library for C++. | |
Testing Framework | |
Testing framework for C++. | |
Files | |
file | basis.h |
Main include file of BASIS C++ Utilities. | |
Defines | |
#define | HAVE_LONG_LONG 1 |
Whether the long long type is supported by the compiler. | |
#define | HAVE_PTHREAD 1 |
Whether the pthread library is available. | |
#define | HAVE_SSTREAM 1 |
Whether the ANSI string stream classes are available. | |
#define | HAVE_STRSTREAM 0 |
Whether the obsolete string stream classes are available. | |
#define | HAVE_TR1_TUPLE 1 |
Whether the tr1/tuple header file is available. | |
#define | LINUX (defined (linux) || defined (__linux)) |
Whether the sources are compiled on a Linux system. | |
#define | MACOS (defined (__APPLE__) || defined (__OSX__)) |
Whether the sources are compiled on a Mac OS system. | |
#define | SBIA_BASIS_NAMESPACE ::sbia::basis |
Full project own namespace identifier. | |
#define | SBIA_BASIS_NAMESPACE_BEGIN namespace sbia { namespace basis { |
Macro used to enter project own namespace. | |
#define | SBIA_BASIS_NAMESPACE_END } } |
Macro used to exit project own namespace. | |
#define | UNIX (!WINDOWS) |
Whether the sources are compiled on a Unix-based system. | |
#define | WINDOWS (defined (_WIN32) || defined (WIN32) || defined (_WINDOWS)) |
Whether the sources are compiled on a Windows system. | |
Functions | |
int | sbia::basis::execute_process (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. | |
int | sbia::basis::execute_process (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. | |
bool | sbia::basis::executing_in_build_tree () |
Whether the executable was executed from within the build tree. | |
string | sbia::basis::get_data_directory () |
Get absolute path of directory containing auxiliary data. | |
string | sbia::basis::get_executable_path (const std::string &target) |
Get canonical path of executable file. | |
string | sbia::basis::get_installation_prefix () |
Get absolute path of installation directory. | |
string | sbia::basis::get_libexec_directory () |
Get absolute path of directory containing auxiliary executables. | |
string | sbia::basis::get_library_directory () |
Get absolute path of directory containing libraries. | |
string | sbia::basis::get_runtime_directory () |
Get absolute path of directory containing runtime executables. | |
void | sbia::basis::print_contact (const char *contact=NULL) |
Print contact information. | |
void | sbia::basis::print_version (const char *name, const char *copyright=NULL, const char *license=NULL) |
Print version information. | |
Variables | |
PROJECT_NAMESPACE_CXX | |
CMake variable of C++ namespace of project. |
Auxiliary implementations for use in C++ source code.
#define HAVE_STRSTREAM 0 |
#define HAVE_TR1_TUPLE 1 |
#define SBIA_BASIS_NAMESPACE ::sbia::basis |
Full project own namespace identifier.
This macro should preferably be used when referring to the project own namespace. The namespace can then be renamed later on without affecting written source code.
#define SBIA_BASIS_NAMESPACE_BEGIN namespace sbia { namespace basis { |
Macro used to enter project own namespace.
Example:
SBIA_BASIS_NAMESPACE_BEGIN // project source code within project own namespace SBIA_BASIS_NAMESPACE_END
#define SBIA_BASIS_NAMESPACE_END } } |
Macro used to exit project own namespace.
Example:
SBIA_BASIS_NAMESPACE_BEGIN // project source code within project own namespace SBIA_BASIS_NAMESPACE_END
int sbia::basis::execute_process | ( | 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 get_executable_path() if the given first argument is a know build target name. Otherwise, the command-line is used unmodified.
[in] | cmd | Command-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] | quiet | Turns off output of stdout of child process to stdout of parent process. |
[out] | out | Output stream where command output is written to. |
[in] | allow_fail | If 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] | verbose | Verbosity of output messages. Does not affect verbosity of executed command. |
[in] | simulate | Whether to simulate command execution only. |
SubprocessException | If subprocess creation failed or command returned a non-zero exit code while allow_fail is false. |
Definition at line 155 of file stdaux.cxx.
int sbia::basis::execute_process | ( | 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 get_executable_path() if the given first argument is a know build target name. Otherwise, the command-line is used unmodified.
[in,out] | args | Command-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. Note that as a side effect, the first argument of the input vector is replaced by the absolute path of the actual executable file if applicable. |
[in] | quiet | Turns off output of stdout of child process to stdout of parent process. |
[out] | out | Output stream where command output is written to. |
[in] | allow_fail | If 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] | verbose | Verbosity of output messages. Does not affect verbosity of executed command. |
[in] | simulate | Whether to simulate command execution only. |
SubprocessException | If subprocess creation failed or command returned a non-zero exit code while allow_fail is false. |
Definition at line 163 of file stdaux.cxx.
bool sbia::basis::executing_in_build_tree | ( | ) |
Whether the executable was executed from within the build tree.
Definition at line 70 of file stdaux.cxx.
std::string sbia::basis::get_data_directory | ( | ) |
Get absolute path of directory containing auxiliary data.
Definition at line 120 of file stdaux.cxx.
std::string sbia::basis::get_executable_path | ( | const std::string & | target | ) |
Get canonical path of executable file.
This function uses the static instance of the class ExecutableTargetInfo in order to obtain the required information to be able to determine the absolute path of the executable file which was built and/or installed as the specified build target.
[in] | target | Name/UID of build target. |
Definition at line 134 of file stdaux.cxx.
std::string sbia::basis::get_installation_prefix | ( | ) |
Get absolute path of installation directory.
This function returns the absolute path of the installation prefix path. If the installation was not moved after a "make install", the returned directory corresponds to the value of the INSTALL_PREFIX CMake variable as specified during the build of the executable file. Note, however, that even when the installation tree was moved after the configuration and build of the software, the correct path is returned as long as the relative directory structure of the installation tree is maintained. This is because the path is determined relative to the directory of the executable itself, knowning in which path this executable is located relative to the INSTALL_PREFIX.
Definition at line 80 of file stdaux.cxx.
std::string sbia::basis::get_libexec_directory | ( | ) |
Get absolute path of directory containing auxiliary executables.
Definition at line 100 of file stdaux.cxx.
std::string sbia::basis::get_library_directory | ( | ) |
Get absolute path of directory containing libraries.
Definition at line 110 of file stdaux.cxx.
std::string sbia::basis::get_runtime_directory | ( | ) |
Get absolute path of directory containing runtime executables.
Definition at line 90 of file stdaux.cxx.
void sbia::basis::print_contact | ( | const char * | contact = NULL | ) |
Print contact information.
[in] | contact | Name of the contact. Defaults to "SBIA Group <sbia-software at uphs.upenn.edu>". |
Definition at line 58 of file stdaux.cxx.
void sbia::basis::print_version | ( | const char * | name, |
const char * | copyright = NULL , |
||
const char * | license = NULL |
||
) |
Print version information.
[in] | name | Program name. |
[in] | copyright | Copyright notice. Defaults to University of Pennsylvania without year if NULL. If an empty string is given, i.e., copyright = "", no copyright notice is written. |
[in] | license | License notice. Defaults to official software license used at SBIA if NULL. If an empty string is given, i.e., license = "", no license notice is written. |
Definition at line 41 of file stdaux.cxx.
CMake variable of C++ namespace of project.
The C++ namespace of a BASIS project is made up of its name in lower case only as well as the namespace the project belongs to, i.e., the namespace of the project this project is a module of.
Example:
namespace sbia { namespace basis { // your code goes here } }
Definition at line 145 of file ProjectSettings.cmake.