SOFA API  ca665544
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 & getUserLocalDirectory ()
 Get the path to the current user local config directory. More...
 
static const std::string & getSofaUserLocalDirectory ()
 Get the path to the SOFA directory into the current user local config directory. 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

◆ downcaseString()

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

Convert a string to lower case.

◆ getExecutableDirectory()

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

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

◆ getExecutablePath()

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.

◆ getSofaPathPrefix()

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)

◆ getSofaPathTo()

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)

◆ getSofaUserLocalDirectory()

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

Get the path to the SOFA directory into the current user local config directory.

◆ getUserLocalDirectory()

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

Get the path to the current user local config directory.

◆ narrowString()

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.

◆ readBasicIniFile()

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.

◆ upcaseString()

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

Convert a string to upper case.

◆ widenString()

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.