Performs system basic operations such as directory creation, timing, threading, file picking.
More...
#include <System.hpp>
|
static bool | showPicker (Picker mode, const std::string &startDir, std::string &outPath, const std::string &extensions="") |
|
static bool | createDirectory (const std::string &directory) |
|
static void | ping () |
|
static double | time () |
|
static std::string | timestamp () |
|
static uint64_t | hash64 (const void *data, size_t size) |
|
static uint32_t | hash32 (const void *data, size_t size) |
|
template<typename ThreadFunc > |
static void | forParallel (size_t low, size_t high, ThreadFunc func) |
|
static const char * | widen (const std::string &str) |
|
static std::string | narrow (char *str) |
|
Performs system basic operations such as directory creation, timing, threading, file picking.
◆ Picker
The file picker mode.
Enumerator |
---|
Load | Load an existing file.
|
Directory | open or create a directory.
|
Save | Save to a new or existing file.
|
◆ createDirectory()
bool System::createDirectory |
( |
const std::string & |
directory | ) |
|
|
static |
Create a directory.
- Parameters
-
directory | the path to the directory to create |
- Returns
- true if the creation is successful.
- Note
- If the directory already exists, it will fail.
- Warning
- This function will not create intermediate directories.
◆ forParallel()
template<typename ThreadFunc >
static void System::forParallel |
( |
size_t |
low, |
|
|
size_t |
high, |
|
|
ThreadFunc |
func |
|
) |
| |
|
inlinestatic |
Multi-threaded for-loop.
- Parameters
-
low | lower (included) bound |
high | higher (excluded) bound |
func | the function to execute at each iteration, will receive the index of the element as a unique argument. Signature: void func(size_t i) |
- Note
- For now only an increment by one is supported.
◆ hash32()
uint32_t System::hash32 |
( |
const void * |
data, |
|
|
size_t |
size |
|
) |
| |
|
static |
Compute a 32 bits hash of the input data
- Parameters
-
data | the data to hash |
size | the number of bytes of data to consider |
- Returns
- the computed hash
◆ hash64()
uint64_t System::hash64 |
( |
const void * |
data, |
|
|
size_t |
size |
|
) |
| |
|
static |
Compute a 64 bits hash of the input data
- Parameters
-
data | the data to hash |
size | the number of bytes of data to consider |
- Returns
- the computed hash
◆ narrow()
std::string System::narrow |
( |
char * |
str | ) |
|
|
static |
Convert a string from the system representation.
- Parameters
-
- Returns
- the corresponding UTF8 standard string
◆ ping()
Notify the user by sending a 'Bell' signal.
◆ showPicker()
bool System::showPicker |
( |
Picker |
mode, |
|
|
const std::string & |
startDir, |
|
|
std::string & |
outPath, |
|
|
const std::string & |
extensions = "" |
|
) |
| |
|
static |
Present a filesystem document picker to the user, using native controls.
- Parameters
-
mode | the type of item to ask to the user (load, save, directory) |
startDir | the initial directory when the picker is opened |
outPath | the path to the item selected by the user |
extensions | (optional) the extensions allowed, separated by "," or ";" |
- Returns
- true if the user picked an item, false if cancelled.
◆ time()
Return the current value of a time counter.
- Returns
- the current counter value, in seconds.
◆ timestamp()
std::string System::timestamp |
( |
| ) |
|
|
static |
Obtain a YYYY_MM_DD_HH_MM_SS timestamp of the current time.
- Returns
- the string representation
◆ widen()
const char * System::widen |
( |
const std::string & |
str | ) |
|
|
static |
Convert a string to the system representation.
- Parameters
-
str | a UTF8 standard string |
- Returns
- the corresponding system string
The documentation for this class was generated from the following files:
- src/engine/system/System.hpp
- src/engine/system/System.cpp