Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site













SourceForge.net Logo

Application & environment utility

A number of utility functions to obtain information about your application and system environment.

 

 

Function List

 

String GetExeFilePath()

Returns the absolute path towards the application's binary.

 


 

String GetEnv(const char *id)

Returns the value of the environment variable id.

 


 

String GetExeDirFile(const char *fp)

Returns the absolute path of a file that is found in the folder where you application's binary resides.

fp..................................................the name of the file

 


 

String GetHomeDirectory()

Returns the absolute path of current user's home folder.

 


 

String GetHomeDirFile(const char *fp)

Returns the absolute path of a file that is found in the current user's home folder.

fp..................................................the name of the file

 


 

String GetExeTitle()

Returns the title of the application.

 


 

String GetTempDirectory()

Return the temporary directory.

 


 

String TempFile(const char *filename)

Returns the absolute path of a file in temporary directory.

 


 

String GetExeFolder()

Return the directory of application executable.

 


 

void UseHomeDirectoryConfig(bool b = true)

Sets the search path for configuration to either the current users' home folder or to the folder where the application's binary resides.

b...................................................use home folder (true) or application folder (false)

 


 

String ConfigFile(const char *file)

Returns the absolute path of a configuration file found in the configuration files search path.

file...............................................the name of the file

 


 

String ConfigFile()

Returns the default configuration file from the configuration files search path. The default configuration file is called [application title].cfg.

 


 

const Vector<String>& CommandLine()

Return a vector of strings containing the command line parameters.

 


 

const VectorMap<String, String>& Environment()

Returns a vector of strings with system environment variables.

 


 

void SetExitCode(int code)

Sets the exit code that will be returned on application exit.

code.............................................the exit code

 


 

int GetExitCode()

Gets the exit code that will be returned on application exit.

 


 

bool IsMainRunning()

Return true if the applications execution has reached and not yet exited the main function.

 


 

String GetDataFile(const char *filename)

This function is designed to retrieve the path of file that contains application specific data. Behaviour depends on whether application was started from 'theide' - in that case theide passes a reference to main package directory through environment variable "UPP_MAIN__" and the resulting file is in this directory. When started standalone, the function is equivalent to GetExeDirFile. Alternatively, application can call SetDataPath to define the directory.

 


 

String LoadDataFile(const char *filename)

Same as LoadFile(GetDataFile(filename)).

 


 

void SetDataPath(const char *path)

Defines explicit directory to be used with GetDataFile.

 


 

String GetComputerName()

Returns the name of computer.

 


 

String GetUserName()

Returns current user.

 


 

String GetDesktopManager()

Returns current GUI identifier. Predefined values are "windows", "gnome", "kde". If X11 desktop manager is not in this list, the value of "DESKTOP_SESSION" environment variable is returned.

 


 

void LaunchWebBrowser(const String& url)

Opens an URL in the default Web Browser.

url................................................the URL that will be opened in the browser

 


 

void SetHomeDirectory(const char *dir)

Sets the current user's home folder.

dir................................................the URL that will be opened in the browser

 


 

bool CpuMMX()

Returns true if CPU has MMX support.

 


 

template <class Tconst T& min(const T& a, const T& b, ...)

Returns the least of all arguments.

 


 

template <class Tconst T& max(const T& a, const T& b, ...)

Returns the greatest of all arguments.

 


 

template <class TT clamp(T x, T _min, T _max)

Returns x if it is between _min and _max.

If x is lower than _min it returns _min.

If x is higher than _max it returns _max.

 


 

template <class T, class T1, ...> int findarg(const T& x, const T1& p0, ...)

Searches the list of arguments for the value of x. If it is found, function returns the index of argument (starting with 0). If not found, -1 is returned.

 


 

template <class T, class T1, class V1, ..., class D>

D decode(const T& x, const T1& p0, const V1& v0, ..., const D& def)

template <class T, class T1, ...>

const char *decode(const T& x, const T1& p0, const char *v0, ..., const D& def)

Searches the list of argument pairs for the value of x to be equal to the first argument in the pair. If found, returns the second argument of pair. If no match is found, returns the last argument def.

 


 

bool CpuSSE()

Returns true if CPU has SSE support.

 


 

bool CpuSSE2()

Returns true if CPU has SSE2 support.

 


 

bool CpuSSE3()

Returns true if CPU has SSE3 support.

 


 

bool CpuHypervisor()

Checks whether CPU has hypervisor flag set. If it has, the program is running in virtual machine. Unfortunately, opposite is not true - some VMs run without this flag set.

 


 

int CPU_Cores()

Returns the number of cores the CPU has.

 

 

Last edit by cxl on 05/15/2018. Do you want to contribute?. T++