SOFA API  014b24ea
Open source framework for multi-physics simuation
sofa::helper::Utils Class Reference

#include <Utils.h>

Contains possibly useful functions, that don't fit anywhere else. More...

Detailed Description

Contains possibly useful functions, that don't fit anywhere else.

Static Public Member Functions

static std::wstring widenString (const std::string &s)
 Convert a string to a wstring. More...
 
static std::string narrowString (const std::wstring &ws)
 Convert a wstring to a string. More...
 
static std::string downcaseString (const std::string &s)
 Convert a string to lower case. More...
 
static std::string upcaseString (const std::string &s)
 Convert a string to upper case. More...
 
static const std::string & getExecutablePath ()
 Get the path of the executable that is currently running. More...
 
static const std::string & getExecutableDirectory ()
 Get the path to the directory of the executable that is currently running. More...
 
static const std::string & getSofaPathPrefix ()
 Get the path to the "root" path of Sofa (i.e. the build directory or the installation prefix). More...
 
static const std::string getSofaPathTo (const std::string &pathFromBuildDir)
 Construct a path based on the build dir path of Sofa. More...
 
static std::map< std::string, std::string > readBasicIniFile (const std::string &path)
 Read a file written in a very basic ini-like format. More...
 

Function details

std::string sofa::helper::Utils::downcaseString ( const std::string &  s)
static

Convert a string to lower case.

const std::string & sofa::helper::Utils::getExecutableDirectory ( )
static

Get the path to the directory of the executable that is currently running.

const std::string & sofa::helper::Utils::getExecutablePath ( )
static

Get the path of the executable that is currently running.

Note that this function uses various non-portable tricks to achieve its goal, and it might not be the most reliable thing ever written.

const std::string & sofa::helper::Utils::getSofaPathPrefix ( )
static

Get the path to the "root" path of Sofa (i.e. the build directory or the installation prefix).

Warning
This function is meant to be used only by the applications that are distributed with SOFA
Returns
The ABSOLUTE path of Sofa build dir (or install dir)
const std::string sofa::helper::Utils::getSofaPathTo ( const std::string &  pathFromBuildDir)
static

Construct a path based on the build dir path of Sofa.

Warning
This function is meant to be used only by the applications that are distributed with SOFA: it uses getSofaPathPrefix()
Returns
The ABSOLUTE path of anything in Sofa build dir (or install dir)
std::string sofa::helper::Utils::narrowString ( const std::wstring &  ws)
static

Convert a wstring to a string.

Returns
The converted string on success, or a empty string on failure.
std::map< std::string, std::string > sofa::helper::Utils::readBasicIniFile ( const std::string &  path)
static

Read a file written in a very basic ini-like format.

For each line that contains a '=' character, (e.g. "key=value"), the returned map will contains a pair <"key", "value">. Other lines will be ignored.

std::string sofa::helper::Utils::upcaseString ( const std::string &  s)
static

Convert a string to upper case.

std::wstring sofa::helper::Utils::widenString ( const std::string &  s)
static

Convert a string to a wstring.

Returns
The converted string on success, or a empty string on failure.