Nix (Dev) 3.5.10
dev - 3.5.10 - 1af9301
Loading...
Searching...
No Matches
CStringTools Class Reference

#include <CStringTools.hpp>

Static Public Member Functions

static char * createCopyMemory (const void *bufferSrc, uint64_t numBytes)
 Create from an existent buffer.
 
static std::string convertToUTF8 (std::string_view text)
 Convert the given text to UTF-8.
 
static char * copy (const char *str)
 Create a copy of the given buffer.
 
static void copyBuffer (const std::string &str, uint64_t sizeBuffer, char *buffer)
 
static void copyMemory (void *bufferDst, const void *bufferSrc, uint64_t numBytes)
 Copies the memory from bufferSrc to bufferDst the amount of bytes given in <numBytes>
 
static void copyMemoryReversed (void *bufferDst, const void *bufferSrc, uint64_t numBytes)
 Copy memory from bufferSrc to bufferDst in a reverse way.
 
static void deleteCharIntoString (char *stringBuffer, uint64_t indPos)
 Remove the character at position, next characters are displaced to left.
 
static void insertCharIntoString (char *stringBuffer, uint64_t tamBuffer, uint64_t indPos, char charInsert)
 Insert a character into a position of a string.
 
static void memoryInitialize (void *buffer, uint64_t numBytes, unsigned char value)
 Initialize the buffer with the given char the number of bytes given.
 
static std::string generateRandomPasswordString (uint32_t minLength, uint32_t maxLength, bool lowerTypes, bool upperTypes, bool numTypes)
 Genera un string aleatorio con el tamaño comprendido entre el min y max con mínimo un caracter de cada uno que se solicita.
 
static std::vector< std::string > split (const std::string &str, std::string_view separator)
 Splits the given string into an array of substrings separated by the separator given.
 
static std::vector< std::string > splitByLength (const std::string &str, uint64_t maxLength)
 Splits a given message into smaller sizes messages to fit in a maximum length.
 
static std::string strDate (uint16_t day, uint16_t month, uint16_t year)
 Returns a formatted string of the date.
 
static std::string strTime (uint16_t hour, uint16_t minutes, uint16_t seconds)
 Returns a formatted string of the time.
 
static char * initialExtractUntilChar (const char *str, char c)
 Extracts the substring from the beggining to the last instance of the given char.
 
static char * endExtractFromChar (const char *str, char c)
 Extract the existent substring from the last occurrence of the given char.
 
static std::string truncateWithPoints (const std::string &str, uint64_t maxLength)
 

Member Function Documentation

◆ convertToUTF8()

std::string CStringTools::convertToUTF8 ( std::string_view text)
static

Convert the given text to UTF-8.

Deprecated
Use charset.hpp instead
Parameters
text
Returns
Parameters
textThe text to convert
Returns
std::string The converted text

◆ copy()

char * CStringTools::copy ( const char * str)
static

Create a copy of the given buffer.

Deprecated
Parameters
str
Returns
Parameters
strThe buffer to copy
Returns
char* The copy of the buffer

◆ copyBuffer()

void CStringTools::copyBuffer ( const std::string & str,
uint64_t sizeBuffer,
char * buffer )
static

Copy a string into a buffer

Parameters
strString to copy
sizeBufferSize of buffer
bufferBuffer which will contain given string (output parameter)

◆ copyMemory()

void CStringTools::copyMemory ( void * bufferDst,
const void * bufferSrc,
uint64_t numBytes )
static

Copies the memory from bufferSrc to bufferDst the amount of bytes given in <numBytes>

Parameters
bufferDstThe buffer where copy the data
bufferSrcThe buffer whence get the data
numBytesThe number of bytes to copy

◆ copyMemoryReversed()

void CStringTools::copyMemoryReversed ( void * bufferDst,
const void * bufferSrc,
uint64_t numBytes )
static

Copy memory from bufferSrc to bufferDst in a reverse way.

Parameters
bufferDstThe buffer where copy the data
bufferSrcThe buffer whence get the data
numBytesThe number of bytes to copy

◆ createCopyMemory()

char * CStringTools::createCopyMemory ( const void * bufferSrc,
uint64_t numBytes )
static

Create from an existent buffer.

Deprecated
Parameters
bufferSrc
numBytes
Returns
Parameters
bufferSrcThe buffer whence get the data to copy
numBytesThe amount of bytes to copy
Returns
char* The buffer created

◆ deleteCharIntoString()

void CStringTools::deleteCharIntoString ( char * stringBuffer,
uint64_t indPos )
static

Remove the character at position, next characters are displaced to left.

Parameters
stringBufferString base where the character is
indPosPosition of Character to remove

◆ endExtractFromChar()

char * CStringTools::endExtractFromChar ( const char * str,
char c )
static

Extract the existent substring from the last occurrence of the given char.

Parameters
strThe string whence extract the substring
cThe char to look for the last occurrence
Returns
char* The substring or nullptr in case that the char had not been found

◆ generateRandomPasswordString()

std::string CStringTools::generateRandomPasswordString ( uint32_t minLength,
uint32_t maxLength,
bool lowerTypes,
bool upperTypes,
bool numTypes )
static

Genera un string aleatorio con el tamaño comprendido entre el min y max con mínimo un caracter de cada uno que se solicita.

Parameters
minLengthTamaño minimo del string generado.
maxLengthTamaño máximo del string generado.
lowerTypesSi se requiere al menos un caracter en minúsculas.
upperTypesSi se requiere al menos un caracter en mayúsculas.
numTypesSi se requiere al menos un caracter numérico.
Returns
Un string del tamaño comprendido entre minLength y maxLength con los caracteres solicitados.
Note
Esta función está especialmente diseñara para generar contraseñas.

◆ initialExtractUntilChar()

char * CStringTools::initialExtractUntilChar ( const char * str,
char c )
static

Extracts the substring from the beggining to the last instance of the given char.

Parameters
strThe buffer whence get the substring
cThe char to limitate the substring
Returns
char* The substring or nullptr in case that the char had not been found

◆ insertCharIntoString()

void CStringTools::insertCharIntoString ( char * stringBuffer,
uint64_t tamBuffer,
uint64_t indPos,
char charInsert )
static

Insert a character into a position of a string.

Parameters
stringBufferstring where to insert
tamBuffermax size of the string
indPosposition to insert
charInsertcharacter to insert

◆ memoryInitialize()

void CStringTools::memoryInitialize ( void * buffer,
uint64_t numBytes,
unsigned char value )
static

Initialize the buffer with the given char the number of bytes given.

Parameters
bufferThe buffer which initialize
numBytesThe number of bytes to initialize
valueThe value to initialize the buffer with

◆ split()

std::vector< std::string > CStringTools::split ( const std::string & str,
std::string_view separator )
static

Splits the given string into an array of substrings separated by the separator given.

Parameters
strThe string to split
separatorThe separator of the substrings
Returns
std::vector<std::string> The vector of substrings

◆ splitByLength()

std::vector< std::string > CStringTools::splitByLength ( const std::string & str,
uint64_t maxLength )
static

Splits a given message into smaller sizes messages to fit in a maximum length.

Parameters
strThe string to split.
maxLengthThe max size of each split bit.
Returns
std::vector<std::string> The vector of substrings
Note
This function was specially made for splitting messages in Diamar.

◆ strDate()

std::string CStringTools::strDate ( uint16_t day,
uint16_t month,
uint16_t year )
static

Returns a formatted string of the date.

Parameters
dayThe day
monthThe month
yearThe year
Returns
std::string The date as a string

◆ strTime()

std::string CStringTools::strTime ( uint16_t hour,
uint16_t minutes,
uint16_t seconds )
static

Returns a formatted string of the time.

Parameters
hourThe hour
minutesThe minutes
secondsThe seconds
Returns
std::string The time as a string

◆ truncateWithPoints()

std::string CStringTools::truncateWithPoints ( const std::string & str,
uint64_t maxLength )
static
Parameters
str
maxLength
Returns
std::string

The documentation for this class was generated from the following files: