jaffarCommon
Loading...
Searching...
No Matches
Functions
string.hpp File Reference

Contains common functions related to manipulating strings. More...

#include <algorithm>
#include <sstream>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string>
#include <vector>
Include dependency graph for string.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename Out >
__JAFFAR_COMMON__INLINE__ void jaffarCommon::string::split (const std::string &s, char delim, Out result)
 
__JAFFAR_COMMON__INLINE__ std::vector< std::string > jaffarCommon::string::split (const std::string &s, char delim)
 
__JAFFAR_COMMON__INLINE__ std::string jaffarCommon::string::formatString (const char *format,...)
 
__JAFFAR_COMMON__INLINE__ std::string jaffarCommon::string::dumpBinary (const void *data, const size_t size)
 

Detailed Description

Contains common functions related to manipulating strings.

Function Documentation

◆ dumpBinary()

__JAFFAR_COMMON__INLINE__ std::string jaffarCommon::string::dumpBinary ( const void *  data,
const size_t  size 
)

Converts a binary input into a readable hex string

Parameters
[in]dataBinary data to print
[in]sizeNumber of bytes in the input data
Returns
The C++ string produced

◆ formatString()

__JAFFAR_COMMON__INLINE__ std::string jaffarCommon::string::formatString ( const char *  format,
  ... 
)

Converts a C-formatted string into a C++ string

Parameters
[in]formatThe format string
[in]...The arguments to the format string
Returns
The C++ string produced

◆ split() [1/2]

__JAFFAR_COMMON__INLINE__ std::vector< std::string > jaffarCommon::string::split ( const std::string &  s,
char  delim 
)

Function to split a string into a vector of sub-strings delimited by a character

Parameters
[in]sThe input string
[in]delimThe separator that divides the substrings
Returns
A vector containing all the substrings

◆ split() [2/2]

template<typename Out >
__JAFFAR_COMMON__INLINE__ void jaffarCommon::string::split ( const std::string &  s,
char  delim,
Out  result 
)

[Internal] Function to split a string into a sub-strings collection delimited by a character

Note
Taken from stack overflow answer to https://stackoverflow.com/questions/236129/how-do-i-iterate-over-the-words-of-a-string By Evan Teran
Parameters
[in]sThe input string
[in]delimThe separator that divides the substrings
[out]resultThe storage where the substring collection wil be stored