| CRM64Pro GDK v0.19.0 A free cross-platform game development kit built on top of SDL 3.0

Loading...
Searching...
No Matches
Tool
Core modules

## Description

Tool module providing generic utility methods [v26.06.1].

### Overview

The Tool module provides a collection of generic and useful utility methods for common operations including hashing, encryption, random number generation, file management and string manipulation.

### Key features

- Hashing algorithms: CRC32 and high-performance XXH3 64-bit
- Simple encryption: Fast XOR-based buffer encryption/decryption
- Random number generators: Multiple PRNG implementations with different characteristics.
- File utilities: OS-level file management operations
- String utilities: Conversion and manipulation methods

### Hashing algorithms

CRC32 | Standard cyclic redundancy check algorithm
XXH3 64-bit | High-performance non-cryptographic hashing algorithm

### Pseudorandom number generators

Three PRNG implementations are available with different performance and memory trade-offs:

MWC | Multiply-with-carry algorithm. Period: 2^131104. Very fast with 16KB memory footprint
WELL512 | Well Equidistributed Long-period Linear algorithm. Period: 2^512. Fast with only 64 bytes memory footprint
PCG32 | Permuted Congruential Generator. Period: 2^64. Fast, statistically good, and small footprint (16 bytes)

For further information, check the development blog entry on https://www.megastormsystems.com/news/testing-random-number-generators-in-crm64pro about PRNG algorithms.

### Utility methods

Encryption | Fast XOR of memory buffers for simple encryption/decryption
Math | Round values to specified precision
File management | OS-level operations: check file existence, verify file extensions, etc.
String-zero | Null-terminated string manipulation methods
String conversion | String to/from integer and float conversion methods
String/Vector | Vector string to file and string to vector string methods

### Best practices

- Use XXH3 instead of CRC32 when performance is critical and cryptographic strength is not required
- Choose WELL512 for memory-constrained scenarios; use MWC when maximum period length is needed
- Use the file management methods for cross-platform file operations
- Prefer the built-in string conversion methods over standard library alternatives for consistency and strict parsing behavior
- Access the module exclusively through Main::tool()

Note
  The Tool module is a singleton, automatically created once Main is instantiated. You can get a reference to this module using Main::tool() method.
  The Tool module is automatically released when Main::terminate() is called. At this time, any resource still loaded will be released, avoiding resource leaks.

## Classes
class | CRM64Pro::Tool
| Tool class. More...

## Enumerations
enum | CRM64Pro::eMsgBoxType : Sint32 { CRM64Pro::MBT_EMPTY = 0 , CRM64Pro::MBT_ERROR = 1 , CRM64Pro::MBT_WARNING = 2 , CRM64Pro::MBT_INFO = 3 , CRM64Pro::MBT_QUESTION = 4 }
| Message box type. More...
enum | CRM64Pro::eMsgBoxButton : Uint32 { CRM64Pro::MBB_NONE = 0 , CRM64Pro::MBB_OK = 1 , CRM64Pro::MBB_CANCEL = 2 , CRM64Pro::MBB_YES = 4 , CRM64Pro::MBB_NO = 8 }

## Functions
bool | CRM64Pro::Tool::info (Sint32 iMode=0) override
| Request Tool module information.
Uint32 | CRM64Pro::Tool::crc32 (const void *pBuffer, size_t iSize, Uint32 iPreviousCRC32=0)
| CRC32 checksum of a memory buffer.
Uint32 | CRM64Pro::Tool::crc32 (const string &sFile)
| CRC32 checksum of a file.
Uint64 | CRM64Pro::Tool::xxHash3 (const void *pBuffer, size_t iSize, Uint64 iSeed=0)
| xxHash3 64-bit checksum of a memory buffer.
void * | CRM64Pro::Tool::xxHash3Init (Uint64 iSeed=0)
| Initialize xxHash3 64-bit for use with multiple memory buffers.
Sint32 | CRM64Pro::Tool::xxHash3Update (void *pState, const void *pBuffer, size_t iSize)
| Feed a new memory buffer to xxHash3 64-bit.
Uint64 | CRM64Pro::Tool::xxHash3Digest (void *pState)
| Get current xxHash3 64-bit checksum for the accumulated memory buffers.
Sint32 | CRM64Pro::Tool::xxHash3End (void *pState)
| Finalize xxHash3 64-bit used with multiple memory buffers.
Sint32 | CRM64Pro::Tool::xorBuffer (void *pSrc, size_t iSize, Uint8 cKey)
| Apply XOR to a memory buffer.
bool | CRM64Pro::Tool::decodeBase64 (const string &sInput, string &sOutput, bool bCleanInput=false)
| Decode a base64 string.
bool | CRM64Pro::Tool::decompressZlib (const void *pCompressed, Sint32 iCompressedSize, void *pUncompressed, Sint32 iUncompressedSize)
| Decompress a zlib compressed data block.
void | CRM64Pro::Tool::randSeedMWC (Uint32 iSeed)
| Initializes the Multiply-with-carry(MWC) random number generator with a seed.
Uint32 | CRM64Pro::Tool::randMWC ()
| Generates a random 32-bit integer using Multiply-with-carry(MWC) algorithm.
double | CRM64Pro::Tool::randRealMWC ()
| Generates a random 64-bit real number using Multiply-with-carry(MWC) algorithm.
void | CRM64Pro::Tool::randSeedWELL (Uint32 iSeed, Uint32 *pSeedTable=nullptr)
| Initializes the WELL512 random number generator with a seed.
Uint32 | CRM64Pro::Tool::randWELL (Uint32 *pSeedState=nullptr, Uint32 *pSeedTable=nullptr)
| Generates a random 32-bit integer using WELL512 algorithm.
double | CRM64Pro::Tool::randRealWELL (Uint32 *pSeedState=nullptr, Uint32 *pSeedTable=nullptr)
| Generates a random 64-bit real number using WELL512 algorithm.
void | CRM64Pro::Tool::randSeedPCG (Uint64 iSeed, Uint64 iSeq, Uint64 *pState=nullptr, Uint64 *pInc=nullptr)
| Initializes the PCG32 random number generator with a seed and a sequence selector.
Uint32 | CRM64Pro::Tool::randPCG (Uint64 *pState=nullptr, Uint64 *pInc=nullptr)
| Generates a random 32-bit integer using PCG32 algorithm.
double | CRM64Pro::Tool::randRealPCG (Uint64 *pState=nullptr, Uint64 *pInc=nullptr)
| Generates a random 64-bit real number using PCG32 algorithm.
float | CRM64Pro::Tool::round (float fNum)
| Round a float value.
double | CRM64Pro::Tool::round (double dNum)
| Round a double value.
string | CRM64Pro::Tool::pathNormalize (const string &sPath)
| Normalize path separators.
bool | CRM64Pro::Tool::dirExists (const string &sPath)
| Check if a directory exists.
bool | CRM64Pro::Tool::dirCreate (const string &sPath)
| Create parent directories for a path.
bool | CRM64Pro::Tool::fileExists (const string &sPath)
| Check if a file exists.
bool | CRM64Pro::Tool::fileRemove (const string &sPath)
| Remove a file (with wildcard support).
bool | CRM64Pro::Tool::fileRename (const string &sOldPath, const string &sNewPath)
| Rename or move a file or directory.
bool | CRM64Pro::Tool::fileGetAbsolutePath (const string &sPath, string &sAbsolutePath)
| Get an engine-normalized absolute path.
bool | CRM64Pro::Tool::fileGetExePath (string &sPath)
| Get the executable path.
bool | CRM64Pro::Tool::fileGetName (const string &sPath, string &sFileName)
| Get the filename.
bool | CRM64Pro::Tool::fileGetDir (const string &sPath, string &sDirName)
| Get the directory.
bool | CRM64Pro::Tool::fileGetExtension (const string &sPath, string &sExtensionName)
| Get the extension.
bool | CRM64Pro::Tool::fileCheckExtension (const string &sPath, const string &sExt)
| Check if a filename contains a given extension.
bool | CRM64Pro::Tool::fileOpenDialog (const string &sTitle, const char *szFilter, string &sSelectedFile)
| Create a native file open dialog.
bool | CRM64Pro::Tool::fileSaveDialog (const string &sTitle, const char *szFilter, string &sSelectedFile)
| Create a native file save dialog.
eMsgBoxButton | CRM64Pro::Tool::messageBox (const string &sTitle, const string &sMsg, eMsgBoxButton eMBB=MBB_OK, eMsgBoxType eMBT=MBT_INFO, Sint32 iTTL=0, Sint32 idCustomPanel=-1, Sint32 idScreen=-1)
| Create a message box.
bool | CRM64Pro::Tool::szCopy (char *szDst, const char *szSrc, size_t iSize)
| Copy a string-zero avoiding buffer overflow.
bool | CRM64Pro::Tool::getDateStamp (string &sString) const
| Get current date+time stamp.
bool | CRM64Pro::Tool::strCompare (const string &sOne, const string &sTwo)
| Case insensitive string comparison.
bool | CRM64Pro::Tool::strToLowerCase (string &sString)
| Convert the string to lower case.
bool | CRM64Pro::Tool::strToUpperCase (string &sString)
| Convert the string to upper case.
bool | CRM64Pro::Tool::strTovStr (const string &sString, const string &sSplit, vector< string > &vString)
| Split a string into a vector of string given a split string.
Sint32 | CRM64Pro::Tool::strDecToInt (const string &sString)
| Convert a given string with a number in decimal format to a Sint32 number.
bool | CRM64Pro::Tool::intToStrDec (Sint32 iNum, string &sString)
| Convert a 32-bit signed integer to a string in decimal format.
bool | CRM64Pro::Tool::strToFloat (const string &sString, float &fValue)
| Convert a given string with a floating-point number to a float.
bool | CRM64Pro::Tool::floatToStr (float fNum, string &sString)
| Convert a float to a string.
Sint32 | CRM64Pro::Tool::strHexToInt (const string &sString)
| Convert a given string with a number in hexadecimal format to a Sint32 number.
bool | CRM64Pro::Tool::intToStrHex (Sint32 iNum, string &sString)
| Convert a 32-bit signed integer to a string in hexadecimal format.
bool | CRM64Pro::Tool::vStrToFile (const vector< string > &vString, const string &sFileName)
| Save a vector<string> to a filename.
bool | CRM64Pro::Tool::fileTovStr (vector< string > &vString, const string &sFileName)
| Load lines of a filename into a vector<string>.

## Enumeration Type Documentation

## ◆ eMsgBoxType

enum CRM64Pro::eMsgBoxType : Sint32

Message box type.

Enumerator
MBT_EMPTY | No icon is displayed.
MBT_ERROR | Error icon is displayed.
MBT_WARNING | Warning icon is displayed.
MBT_INFO | Information icon is displayed.
MBT_QUESTION | Question icon is displayed.

## ◆ eMsgBoxButton

enum CRM64Pro::eMsgBoxButton : Uint32

Message box button flags. 'eMBB' parameter in Tool::messageBox().

Enumerator
MBB_NONE | No button is displayed.
MBB_OK | OK button is displayed.
MBB_CANCEL | Cancel button is displayed.
MBB_YES | Yes button is displayed.
MBB_NO | No button is displayed.

## Function Documentation

## ◆ info()

bool CRM64Pro::Tool::info | ( | Sint32 | iMode = 0 | ) |
| override

Request Tool module information.

Writes information to the default log.

Parameters

  iMode | Reserved for future use. Pass 0.

Returns
  true on success, or false on failure.

## ◆ crc32() [1/2]

Uint32 CRM64Pro::Tool::crc32 | ( | const void * | pBuffer,
|  | size_t | iSize,
|  | Uint32 | iPreviousCRC32 = 0 )

CRC32 checksum of a memory buffer.

This algorithm takes approximately 8 CPU cycles per byte.

Parameters

  pBuffer | pointer to the memory buffer.
  iSize | size in bytes of the memory buffer.
  iPreviousCRC32 | supports rolling mechanism: if you already have a buffer and its CRC32, you can append new data and calculate the updated CRC32 using your original value as seed. Default 0.

Returns
  CRC32 checksum of the memory buffer.

## ◆ crc32() [2/2]

Uint32 CRM64Pro::Tool::crc32 | ( | const string & | sFile | ) |

CRC32 checksum of a file.

Internally, it calls to memory buffer crc32() method.

Parameters

  sFile | string containing the [directory]+filename+[extension].

Returns
  CRC32 checksum of the file.

## ◆ xxHash3()

Uint64 CRM64Pro::Tool::xxHash3 | ( | const void * | pBuffer,
|  | size_t | iSize,
|  | Uint64 | iSeed = 0 )

xxHash3 64-bit checksum of a memory buffer.

This algorithm is very fast and returns a 64-bit hash.

Parameters

  pBuffer | pointer to the memory buffer.
  iSize | size in bytes of the memory buffer.
  iSeed | can be used to alter the result predictably. Default 0.

Returns
  xxHash3 64-bit checksum of the memory buffer.

## ◆ xxHash3Init()

void * CRM64Pro::Tool::xxHash3Init | ( | Uint64 | iSeed = 0 | ) |

Initialize xxHash3 64-bit for use with multiple memory buffers.

Parameters

  iSeed | can be used to alter the result predictably. Default 0.

Returns
  Owned opaque state pointer, or nullptr on failure.

Note
  The caller must release it with xxHash3End(). Do not modify the returned state.

## ◆ xxHash3Update()

Sint32 CRM64Pro::Tool::xxHash3Update | ( | void * | pState,
|  | const void * | pBuffer,
|  | size_t | iSize )

Feed a new memory buffer to xxHash3 64-bit.

Parameters

  pState | a void* state previously created by xxHash3Init().
  pBuffer | pointer to the memory buffer.
  iSize | size in bytes of the memory buffer.

Returns
  0 on success, or a negative error code on failure.

## ◆ xxHash3Digest()

Uint64 CRM64Pro::Tool::xxHash3Digest | ( | void * | pState | ) |

Get current xxHash3 64-bit checksum for the accumulated memory buffers.

Parameters

  pState | a void* state created by xxHash3Init() and used on xxHash3Update().

Returns
  xxHash3 64-bit checksum of the memory buffers.

## ◆ xxHash3End()

Sint32 CRM64Pro::Tool::xxHash3End | ( | void * | pState | ) |

Finalize xxHash3 64-bit used with multiple memory buffers.

Parameters

  pState | a void* state created by xxHash3Init().

Returns
  0 on success, or a negative error code on failure.

## ◆ xorBuffer()

Sint32 CRM64Pro::Tool::xorBuffer | ( | void * | pSrc,
|  | size_t | iSize,
|  | Uint8 | cKey )

Apply XOR to a memory buffer.

Simple encryption/decryption tasks can use this method.

Parameters

  pSrc | pointer to the memory buffer.
  iSize | buffer size in bytes.
  cKey | 8-bit XOR key.

Returns
  0 on success, or a negative error code on failure.

## ◆ decodeBase64()

bool CRM64Pro::Tool::decodeBase64 | ( | const string & | sInput,
|  | string & | sOutput,
|  | bool | bCleanInput = false )

Decode a base64 string.

Parameters

  sInput | string containing the base64 encoded string.
  sOutput | string containing the decoded base64 string.
  bCleanInput | true to remove non-base64 characters before decoding, false to decode the input as-is.

Returns
  true on success, or false on failure.

## ◆ decompressZlib()

bool CRM64Pro::Tool::decompressZlib | ( | const void * | pCompressed,
|  | Sint32 | iCompressedSize,
|  | void * | pUncompressed,
|  | Sint32 | iUncompressedSize )

Decompress a zlib compressed data block.

Parameters

  pCompressed | pointer to compressed data.
  iCompressedSize | compressed data buffer size.
  pUncompressed | pointer to the decompressed data. You must create this buffer and once done with it, free it.
  iUncompressedSize | uncompressed data buffer size.

Returns
  true on success, or false on failure.

## ◆ randSeedMWC()

void CRM64Pro::Tool::randSeedMWC | ( | Uint32 | iSeed | ) |

Initializes the Multiply-with-carry(MWC) random number generator with a seed.

Parameters

  iSeed | any Uint32 from [0,4294967295] interval.

## ◆ randMWC()

Uint32 CRM64Pro::Tool::randMWC | ( |  | ) |

Generates a random 32-bit integer using Multiply-with-carry(MWC) algorithm.

Returns
  random integer from [0,4294967295] interval.

## ◆ randRealMWC()

double CRM64Pro::Tool::randRealMWC | ( |  | ) |

Generates a random 64-bit real number using Multiply-with-carry(MWC) algorithm.

Returns
  random real from [0,1] interval.

## ◆ randSeedWELL()

void CRM64Pro::Tool::randSeedWELL | ( | Uint32 | iSeed,
|  | Uint32 * | pSeedTable = nullptr )

Initializes the WELL512 random number generator with a seed.

Parameters

  iSeed | any Uint32 from [0,4294967295] interval.
  pSeedTable | pointer to an array of 16 Uint32 for storing the seed output. Default nullptr uses an internal array.

## ◆ randWELL()

Uint32 CRM64Pro::Tool::randWELL | ( | Uint32 * | pSeedState = nullptr,
|  | Uint32 * | pSeedTable = nullptr )

Generates a random 32-bit integer using WELL512 algorithm.

Parameters

  pSeedState | pointer to an Uint32 containing the WELL512 algorithm state. Default nullptr uses internal state.
  pSeedTable | pointer to an array of 16 Uint32 containing the seed current status. Default nullptr uses internal array.

Returns
  random integer from [0,4294967295] interval.

## ◆ randRealWELL()

double CRM64Pro::Tool::randRealWELL | ( | Uint32 * | pSeedState = nullptr,
|  | Uint32 * | pSeedTable = nullptr )

Generates a random 64-bit real number using WELL512 algorithm.

Parameters

  pSeedState | pointer to an Uint32 containing the WELL512 algorithm state. Default nullptr uses internal state.
  pSeedTable | pointer to an array of 16 Uint32 containing the seed current status. Default nullptr uses internal array.

Returns
  random real from [0,1] interval.

## ◆ randSeedPCG()

void CRM64Pro::Tool::randSeedPCG | ( | Uint64 | iSeed,
|  | Uint64 | iSeq,
|  | Uint64 * | pState = nullptr,
|  | Uint64 * | pInc = nullptr )

Initializes the PCG32 random number generator with a seed and a sequence selector.

Parameters

  iSeed | 64-bit seed for the state.
  iSeq | 64-bit sequence selector (stream id).
  pState | optional caller-managed generator state. Use nullptr to operate on the internal shared generator state.
  pInc | optional caller-managed generator increment. Use nullptr to operate on the internal shared generator state.

## ◆ randPCG()

Uint32 CRM64Pro::Tool::randPCG | ( | Uint64 * | pState = nullptr,
|  | Uint64 * | pInc = nullptr )

Generates a random 32-bit integer using PCG32 algorithm.

Parameters

  pState | optional caller-managed generator state. Use nullptr to operate on the internal shared generator state.
  pInc | optional caller-managed generator increment. Use nullptr to operate on the internal shared generator state.

Returns
  random integer from [0,4294967295] interval.

## ◆ randRealPCG()

double CRM64Pro::Tool::randRealPCG | ( | Uint64 * | pState = nullptr,
|  | Uint64 * | pInc = nullptr )

Generates a random 64-bit real number using PCG32 algorithm.

Parameters

  pState | optional caller-managed generator state. Use nullptr to operate on the internal shared generator state.
  pInc | optional caller-managed generator increment. Use nullptr to operate on the internal shared generator state.

Returns
  random real from [0,1] interval.

## ◆ round() [1/2]

float CRM64Pro::Tool::round | ( | float | fNum | ) |

Round a float value.

Parameters

  fNum | float to be rounded

Returns
  rounded float value

## ◆ round() [2/2]

double CRM64Pro::Tool::round | ( | double | dNum | ) |

Round a double value.

Parameters

  dNum | double to be rounded

Returns
  rounded double value

## ◆ pathNormalize()

string CRM64Pro::Tool::pathNormalize | ( | const string & | sPath | ) |

Normalize path separators.

Replaces Windows-style '\' separators with '/' so paths can be used consistently across supported platforms.

Parameters

  sPath | string containing a path.

Returns
  normalized path string.

## ◆ dirExists()

bool CRM64Pro::Tool::dirExists | ( | const string & | sPath | ) |

Check if a directory exists.

Parameters

  sPath | string containing the directory. Directory separators '\' and '/' are supported.

Returns
  true if the directory exists, or false otherwise. No error is reported.

## ◆ dirCreate()

bool CRM64Pro::Tool::dirCreate | ( | const string & | sPath | ) |

Create parent directories for a path.

Normalizes the path, extracts everything up to the last directory separator and creates that directory tree recursively. Directory separators '\' and '/' are supported.

Parameters

  sPath | string containing a file path or directory-like path (e.g. demoDir/file.txt, demoDir/subDir/).

Returns
  true on success, or false on failure.

Note
  If the parent directory already exists, returns success without doing anything.
  Paths without a directory separator are treated as current-directory files and return success without creating anything.

## ◆ fileExists()

bool CRM64Pro::Tool::fileExists | ( | const string & | sPath | ) |

Check if a file exists.

Parameters

  sPath | string containing [directory]+filename+[extension]. Directory separators '\' and '/' are supported.

Returns
  true if the file exists, or false otherwise. No error is reported.

## ◆ fileRemove()

bool CRM64Pro::Tool::fileRemove | ( | const string & | sPath | ) |

Remove a file (with wildcard support).

Parameters

  sPath | string containing [directory]+filename+[extension]. Directory separators '\' and '/' are supported. Wildcards '*' and '?' are supported.

Returns
  true on success, or false on failure.

## ◆ fileRename()

bool CRM64Pro::Tool::fileRename | ( | const string & | sOldPath,
|  | const string & | sNewPath )

Rename or move a file or directory.

Normalizes both paths and uses SDL filesystem support. If the destination already exists, it is replaced.

Parameters

  sOldPath | current file or directory path. Directory separators '\' and '/' are supported.
  sNewPath | new file or directory path. Directory separators '\' and '/' are supported.

Returns
  true on success, or false on failure.

## ◆ fileGetAbsolutePath()

bool CRM64Pro::Tool::fileGetAbsolutePath | ( | const string & | sPath,
|  | string & | sAbsolutePath )

Get an engine-normalized absolute path.

Resolves relative paths against SDL_GetCurrentDirectory(), normalizes separators, and collapses '.' and '..' path segments. The target path does not need to exist.

Parameters

  sPath | string containing [directory]+filename+[extension]. Directory separators '\' and '/' are supported.
  sAbsolutePath | a string variable with the absolute path. Not modified on error.

Returns
  true on success, or false on failure.

## ◆ fileGetExePath()

bool CRM64Pro::Tool::fileGetExePath | ( | string & | sPath | ) |

Get the executable path.

Parameters

  sPath | a string variable containing the full executable path. Will not be modified on error.

Returns
  true on success, or false on failure.

## ◆ fileGetName()

bool CRM64Pro::Tool::fileGetName | ( | const string & | sPath,
|  | string & | sFileName )

Get the filename.

Removes the directory and extension if present and gets only the filename.

Parameters

  sPath | string containing [directory]+filename+[extension]. Directory separators '\' and '/' are supported.
  sFileName | a string variable. Not modified on error.

Returns
  true on success, or false on failure.

## ◆ fileGetDir()

bool CRM64Pro::Tool::fileGetDir | ( | const string & | sPath,
|  | string & | sDirName )

Get the directory.

Removes the name and extension if present and gets only the directory.

Parameters

  sPath | string containing [directory]+filename+[extension]. Directory separators '\' and '/' are supported.
  sDirName | a string variable. Not modified on error.

Returns
  true on success, or false on failure.

## ◆ fileGetExtension()

bool CRM64Pro::Tool::fileGetExtension | ( | const string & | sPath,
|  | string & | sExtensionName )

Get the extension.

It removes the directory and name if present and gets only the extension.

Parameters

  sPath | string containing the [directory]+filename+[extension].
  sExtensionName | a string variable. Will not be modified on error.

Returns
  true on success, or false on failure.

## ◆ fileCheckExtension()

bool CRM64Pro::Tool::fileCheckExtension | ( | const string & | sPath,
|  | const string & | sExt )

Check if a filename contains a given extension.

Parameters

  sPath | string containing the [directory]+filename+[extension].
  sExt | the extension to be checked.

Returns
  true if the file path contains the given extension, or false otherwise.

## ◆ fileOpenDialog()

bool CRM64Pro::Tool::fileOpenDialog | ( | const string & | sTitle,
|  | const char * | szFilter,
|  | string & | sSelectedFile )

Create a native file open dialog.

Parameters

  sTitle | string containing dialog title.
  szFilter | pointer to a buffer containing pairs of nullptr-terminated filter strings. First string in each pair is a display string (e.g. "PNG Files"), second specifies the filter pattern (e.g. "*.png").
  sSelectedFile | string to contain the directory+filename+extension of the selected file.

Returns
  true on success (sSelectedFile contains the selected file) or false on failure.

## ◆ fileSaveDialog()

bool CRM64Pro::Tool::fileSaveDialog | ( | const string & | sTitle,
|  | const char * | szFilter,
|  | string & | sSelectedFile )

Create a native file save dialog.

Parameters

  sTitle | string containing dialog title.
  szFilter | pointer to a buffer containing pairs of nullptr-terminated filter strings. First string in each pair is a display string (e.g. "PNG Files"), second specifies the filter pattern (e.g. "*.png").
  sSelectedFile | string to contain the directory+filename+extension of the selected file.

Returns
  true on success (sSelectedFile contains the selected file) or false on failure.

## ◆ messageBox()

eMsgBoxButton CRM64Pro::Tool::messageBox | ( | const string & | sTitle,
|  | const string & | sMsg,
|  | eMsgBoxButton | eMBB = MBB_OK,
|  | eMsgBoxType | eMBT = MBT_INFO,
|  | Sint32 | iTTL = 0,
|  | Sint32 | idCustomPanel = -1,
|  | Sint32 | idScreen = -1 )

Create a message box.

Parameters

  sTitle | string containing the message box title. Can be empty.
  sMsg | string containing the message box body text. Can be empty.
  eMBB | message box button flags. Check ::MBB_OK, ::MBB_CANCEL, ::MBB_YES and ::MBB_NO. Values can be combined with bitwise OR. Default ::MBB_OK.
  eMBT | message box type. Check ::eMsgBoxType enum. Default ::MBT_INFO.
  iTTL | Time to live in milliseconds. 0 (default) for modal, otherwise modeless with specified duration.
  idCustomPanel | custom panel id for the message box. Default -1 uses internal message box panel.
  idScreen | screen id for the panel when using internal message box. Default -1 uses "default" screen.

Returns
  ::MBB_NONE on failure or no selection, otherwise the selected ::eMsgBoxButton.

## ◆ szCopy()

bool CRM64Pro::Tool::szCopy | ( | char * | szDst,
|  | const char * | szSrc,
|  | size_t | iSize )

Copy a string-zero avoiding buffer overflow.

It avoids buffer overflow and always appends a nullptr string termination.

Parameters

  szDst | destination char array of at least iSize size.
  szSrc | source char array of at least iSize size.
  iSize | maximum size of characters to copy.

Returns
  true on success, or false on failure.

## ◆ getDateStamp()

bool CRM64Pro::Tool::getDateStamp | ( | string & | sString | ) | const

Get current date+time stamp.

Parameters

  sString | string reference with the date+time stamp.

Returns
  true on success, or false on failure.

## ◆ strCompare()

bool CRM64Pro::Tool::strCompare | ( | const string & | sOne,
|  | const string & | sTwo )

Case insensitive string comparison.

Parameters

  sOne | string one.
  sTwo | string two.

Returns
  false when the strings are different and true if they are equal.

## ◆ strToLowerCase()

bool CRM64Pro::Tool::strToLowerCase | ( | string & | sString | ) |

Convert the string to lower case.

Parameters

  sString | string to be converted.

Returns
  true on success, or false on failure.

## ◆ strToUpperCase()

bool CRM64Pro::Tool::strToUpperCase | ( | string & | sString | ) |

Convert the string to upper case.

Parameters

  sString | string to be converted.

Returns
  true on success, or false on failure.

## ◆ strTovStr()

bool CRM64Pro::Tool::strTovStr | ( | const string & | sString,
|  | const string & | sSplit,
|  | vector< string > & | vString )

Split a string into a vector of string given a split string.

Parameters

  sString | original string to be split.
  sSplit | split string.
  vString | vector<string> to store split strings.

Returns
  true on success, or false on failure.

## ◆ strDecToInt()

Sint32 CRM64Pro::Tool::strDecToInt | ( | const string & | sString | ) |

Convert a given string with a number in decimal format to a Sint32 number.

Parameters

  sString | string containing the number in decimal format.

Returns
  the converted number.

Note
  This method is very fast. Implementation by DarthGizka (https://stackoverflow.com/questions/16826422/c-most-efficient-way-to-convert-string-to-int-faster-than-atoi)

## ◆ intToStrDec()

bool CRM64Pro::Tool::intToStrDec | ( | Sint32 | iNum,
|  | string & | sString )

Convert a 32-bit signed integer to a string in decimal format.

Parameters

  iNum | integer number.
  sString | string to store the result.

Returns
  true on success, or false on failure.

Note
  This method is very fast. Implementation by Arturo Martin-de-Nicolas (https://github.com/amdn/itoa_ljust).

## ◆ strToFloat()

bool CRM64Pro::Tool::strToFloat | ( | const string & | sString,
|  | float & | fValue )

Convert a given string with a floating-point number to a float.

Parameters

  sString | string containing the floating-point number.
  fValue | float to store the converted result.

Returns
  true on success, or false on failure.

Note
  Parsing is strict: the whole input must be consumed.

## ◆ floatToStr()

bool CRM64Pro::Tool::floatToStr | ( | float | fNum,
|  | string & | sString )

Convert a float to a string.

Parameters

  fNum | float number.
  sString | string to store the result.

Returns
  true on success, or false on failure.

## ◆ strHexToInt()

Sint32 CRM64Pro::Tool::strHexToInt | ( | const string & | sString | ) |

Convert a given string with a number in hexadecimal format to a Sint32 number.

Parameters

  sString | string containing the number in hexadecimal format. It supports string starting with '0x', '#' or without any prefix.

Returns
  the converted number.

## ◆ intToStrHex()

bool CRM64Pro::Tool::intToStrHex | ( | Sint32 | iNum,
|  | string & | sString )

Convert a 32-bit signed integer to a string in hexadecimal format.

Parameters

  iNum | integer number.
  sString | string to store the result.

Returns
  true on success, or false on failure.

## ◆ vStrToFile()

bool CRM64Pro::Tool::vStrToFile | ( | const vector< string > & | vString,
|  | const string & | sFileName )

Save a vector<string> to a filename.

Parameters

  vString | vector<string> to be dumped into an external filename. Each string will be saved on a separate line.
  sFileName | a string variable with the output file name.

Returns
  true on success, or false on failure.

## ◆ fileTovStr()

bool CRM64Pro::Tool::fileTovStr | ( | vector< string > & | vString,
|  | const string & | sFileName )

Load lines of a filename into a vector<string>.

Parameters

  vString | vector<string> to be loaded with lines of the filename.
  sFileName | a string variable with the input file name.

Returns
  true on success, or false on failure.