EpcTools
An event based multi-threaded C++ development framework.
Static Public Member Functions | List of all members
EUtility Class Reference

Class that contains various utility functions. More...

#include <eutil.h>

Static Public Member Functions

static Int indexOf (cpStr path, Char search, Int start=0)
 Retrieves the byte index of the search value within the supplied path. More...
 
static Int indexOfAny (cpStr path, cpStr search)
 Retrieves the byte index of any of the search values within the supplied path. More...
 
static Int lastIndexOfAny (cpStr path, cpStr search)
 Retrieves the last byte index of any of the search values within the supplied path. More...
 
static std::vector< EStringsplit (cpStr s, cpStr delims)
 Splits a string into substrings that are based on the characters in the delimiter array. More...
 
static EStringreplaceAll (EString &str, cpStr srch, size_t srchlen, cpStr rplc, size_t rplclen)
 replaces all occurances of the search string in the provided string with the replacement string. More...
 
static EString replaceAllCopy (const EString &str, cpStr srch, size_t srchlen, cpStr rplc, size_t rplclen)
 replaces all occurances of the search string in the provided string with the replacement string returning a new string. More...
 
static std::string string_format (const char *format,...)
 Formats a string using the supplied format string. Uses printf format specifiers. More...
 
static void string_format (std::string &dest, const char *format,...)
 Formats a string using the supplied format string. Uses printf format specifiers. More...
 
static Void copy_file (const std::string &dst, const std::string &src)
 Copies the source file to the destination location. More...
 
static Void copy_file (const char *dst, const std::string &src)
 Copies the source file to the destination location. More...
 
static Void copy_file (const std::string &dst, const char *src)
 Copies the source file to the destination location. More...
 
static Void copy_file (const char *dst, const char *src)
 Copies the source file to the destination location. More...
 
static Void delete_file (const std::string &fn)
 Deletes the supplied file. More...
 
static Void delete_file (const char *fn)
 Deletes the supplied file. More...
 
static Bool file_exists (cpStr fn)
 Determines if the supplied file exists. More...
 
static std::string currentTime ()
 Returns a string representation of the current system time. More...
 

Detailed Description

Class that contains various utility functions.

Member Function Documentation

◆ copy_file() [1/4]

void EUtility::copy_file ( const char *  dst,
const char *  src 
)
static

Copies the source file to the destination location.

Parameters
dstthe destination file name.
srcthe source file name.

◆ copy_file() [2/4]

static Void EUtility::copy_file ( const char *  dst,
const std::string &  src 
)
inlinestatic

Copies the source file to the destination location.

Parameters
dstthe destination file name.
srcthe source file name.

◆ copy_file() [3/4]

static Void EUtility::copy_file ( const std::string &  dst,
const char *  src 
)
inlinestatic

Copies the source file to the destination location.

Parameters
dstthe destination file name.
srcthe source file name.

◆ copy_file() [4/4]

static Void EUtility::copy_file ( const std::string &  dst,
const std::string &  src 
)
inlinestatic

Copies the source file to the destination location.

Parameters
dstthe destination file name.
srcthe source file name.

◆ currentTime()

std::string EUtility::currentTime ( )
static

Returns a string representation of the current system time.

Returns
a string representation of the current system time.

◆ delete_file() [1/2]

void EUtility::delete_file ( const char *  fn)
static

Deletes the supplied file.

Parameters
fnthe file name to delete.

◆ delete_file() [2/2]

static Void EUtility::delete_file ( const std::string &  fn)
inlinestatic

Deletes the supplied file.

Parameters
fnthe file name to delete.

◆ file_exists()

static Bool EUtility::file_exists ( cpStr  fn)
inlinestatic

Determines if the supplied file exists.

Returns
True if the file exists, otherwise False.

◆ indexOf()

Int EUtility::indexOf ( cpStr  path,
Char  search,
Int  start = 0 
)
static

Retrieves the byte index of the search value within the supplied path.

Parameters
paththe string to search.
searchthe character to search for.
startthe byte offset in path where to start the search.
Returns
the index where the value was located.

◆ indexOfAny()

Int EUtility::indexOfAny ( cpStr  path,
cpStr  search 
)
static

Retrieves the byte index of any of the search values within the supplied path.

Parameters
paththe string to search.
searchthe characters to search for.
Returns
the index where the value was located.

◆ lastIndexOfAny()

Int EUtility::lastIndexOfAny ( cpStr  path,
cpStr  search 
)
static

Retrieves the last byte index of any of the search values within the supplied path.

Parameters
paththe string to search.
searchthe characters to search for.
Returns
the index where the value was located.

◆ replaceAll()

EString & EUtility::replaceAll ( EString str,
cpStr  srch,
size_t  srchlen,
cpStr  rplc,
size_t  rplclen 
)
static

replaces all occurances of the search string in the provided string with the replacement string.

Parameters
strthe string to make the replacements in.
srchthe search string.
srchlenthe length of the search string.
rplcthe replacement string.
rplclenthe length of the replacement string.
Returns
a reference to the updated string.

◆ replaceAllCopy()

EString EUtility::replaceAllCopy ( const EString str,
cpStr  srch,
size_t  srchlen,
cpStr  rplc,
size_t  rplclen 
)
static

replaces all occurances of the search string in the provided string with the replacement string returning a new string.

Parameters
strthe string to make the replacements in.
srchthe search string.
srchlenthe length of the search string.
rplcthe replacement string.
rplclenthe length of the replacement string.
Returns
the updated string.

◆ split()

std::vector< EString > EUtility::split ( cpStr  s,
cpStr  delims 
)
static

Splits a string into substrings that are based on the characters in the delimiter array.

Parameters
sthe string to split.
delimsthe list of delimiting characters.
Returns
a vector (array) of the resulting strings.

◆ string_format() [1/2]

std::string EUtility::string_format ( const char *  format,
  ... 
)
static

Formats a string using the supplied format string. Uses printf format specifiers.

Parameters
formatthe format specification string.
Returns
the new formatted string.

◆ string_format() [2/2]

void EUtility::string_format ( std::string &  dest,
const char *  format,
  ... 
)
static

Formats a string using the supplied format string. Uses printf format specifiers.

Parameters
desta string reference where the formatted string will be output.
formatthe format specification string.

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