chsvlib
chsv helper source code
String processing utility

Functions and classes for working with strings. More...

Collaboration diagram for String processing utility:

Modules

 Printf formatting and IO functions
 Portable printf-like formatting. Own implementation of function of the printf family with strict respect to ISO/IEC 9899:1999 (aka C99) and ISO/IEC 9899:2011 (aka C11) standards, with ISO/IEC TR 24731-1 boundary checking extensions. The functions also support some of Microsoft-specific formatting sequences as well as some chsvlib-specific extensions.
 
 Text encoding
 Functions and classes for transcoding of strings.
 

Classes

struct  AutoCString< CharType >
 A template of a class specifying std::unique_ptr to manage multibyte and wide C strings allocated using one of the allocation functions of the chsvmem.h header, such as AllocateString, AllocateAndFormatString or AllocateAndFormatStringByTags. A class template instance deallocates corresponding memory using the FreeString function or its derivatives. More...
 
struct  ci_char_traits< char_t >
 Redefines the char_traits interface in order to process strings independently of character case. More...
 

Typedefs

typedef std::basic_string< char, std::char_traits< char >, ::Chusov::Memory::allocator< char > > string
 An instantiation of the standard basic_string class template for handling multi-byte strings allocated and freed by functions that facilitate the Chusov::Memory::AllocateData and Chusov::Memory::FreeData functions, e.g. AllocateStringA or FreeStringA.
 
typedef std::basic_string< wchar_t, std::char_traits< wchar_t >, ::Chusov::Memory::allocator< wchar_t > > wstring
 An instantiation of the standard basic_string class template for handling wide strings allocated and freed by functions that facilitate the Chusov::Memory::AllocateData and Chusov::Memory::FreeData functions, e.g. AllocateStringW or FreeStringW.
 
typedef std::basic_string< char, std::char_traits< char >, ::Chusov::Memory::secure_allocator< char > > string_s
 An instantiation of the standard basic_string class template for handling multi-byte strings allocated and securely freed by AllocateStringA and SecureFreeStringA.
 
typedef std::basic_string< wchar_t, std::char_traits< wchar_t >, ::Chusov::Memory::secure_allocator< wchar_t > > wstring_s
 An instantiation of the standard basic_string class template for handling wide strings allocated and securely freed by AllocateStringW and SecureFreeStringW.
 
typedef std::basic_string< char, ci_char_traits< char > > ci_string
 A typedef for case-independent variant of std::basic_string specialized for multibyte characters. More...
 
typedef std::basic_string< wchar_t, ci_char_traits< wchar_t > > ci_wstring
 A typedef for case-independent wide variant of std::basic_string specialized for wide characters. More...
 
typedef std::basic_string_view< char, ci_char_traits< char > > ci_string_view
 A typedef for a case-independent variant of std::basic_string_view specialized for multibyte characters. More...
 
typedef std::basic_string_view< wchar_t, ci_char_traits< wchar_t > > ci_wstring_view
 A typedef for a case-independent variant of std::basic_string_view specialized for wide characters. More...
 

Functions

std::size_t strLen (const char *pszStr) noexcept
 Returns a size, in bytes, of a zero terminated string excluding the terminating zero. Implements the behaviour of the standard strlen function of the string.h header. More...
 
std::size_t wcsLen (const wchar_t *pszStr) noexcept
 Returns a size, in wide characters, of a zero terminated wide string excluding the terminating zero. Implements the behaviour of the standard wcslen function of the wchar.h header. More...
 
std::size_t strnLen_s (const char *pszStr, std::size_t cchStr) noexcept
 Returns a size, in bytes, of a string excluding the terminating zero, if any. The function implements the strnlen_s function of the ISO/IEC TR 24731-1 standard. More...
 
std::size_t wcsnLen_s (const wchar_t *pszStr, std::size_t cchStr) noexcept
 Returns a size, in wide characters, of a string excluding the terminating zero, if any. The function implements the wcsnlen_s function of the ISO/IEC TR 24731-1 standard. More...
 
char * strCpy (char *restrict pDest, const char *restrict pszSrc) noexcept
 Performs a copying of a zero-terminated string from a source buffer to a destination one. Implements the behaviour of the standard strcpy function of the string.h header. More...
 
wchar_t * wcsCpy (wchar_t *restrict pDest, const wchar_t *restrict pszSrc) noexcept
 Performs a copying of a zero-terminated wide string from a source buffer to a destination one. Implements the behaviour of the standard wcscpy function of the wchar.h header. More...
 
errno_t strCpy_s (char *restrict pDest, rsize_t cchDest, const char *restrict pszSrc) noexcept
 Copies a zero-terminated source string, including a terminating null character, to a destination buffer of the specified size. More...
 
errno_t wcsCpy_s (wchar_t *restrict pDest, rsize_t cchDest, const wchar_t *restrict pszSrc) noexcept
 Copies a zero-terminated source string, including a terminating null character, to a destination buffer of the specified size. More...
 
template<class CHAR_TYPE >
std::size_t tcsLen (const CHAR_TYPE *pszStr) noexcept
 Resolves to strLen, to wcsLen or to ucpsLen depending on the template parameter. More...
 
template<class CHAR_TYPE >
std::size_t tcsnLen_s (const CHAR_TYPE *pszStr, std::size_t cchStr) noexcept
 Resolves to strnLen_s, to wcsnLen_s or to ucpsnLen_s depending on the template parameter. More...
 
template<class CHAR_TYPE >
CHAR_TYPE * tcsCpy (CHAR_TYPE *restrict pszDest, const CHAR_TYPE *restrict pszSrc) noexcept
 Resolves to strCpy, to wcsCpy or to ucpsCpy depending on the template parameter. More...
 
template<class CHAR_TYPE >
errno_t tcsCpy_s (CHAR_TYPE *restrict pszDest, rsize_t cchDest, const CHAR_TYPE *restrict pszSrc) noexcept
 Resolves to strCpy_s, to wcsCpy_s or to ucpsCpy_s depending on the template parameter. More...
 
template<class CHAR_TYPE >
CHAR_TYPE * CstrLiteral (char *pszByteStr, wchar_t *pszWideStr)
 Returns an argument of CHAR_TYPE type. More...
 
template<class CHAR_TYPE >
const CHAR_TYPE * CstrLiteral (const char *pszByteStr, const wchar_t *pszWideStr)
 Returns an argument of const CHAR_TYPE type. More...
 
int GetUniqueStringA (char *lpStr, std::size_t cchStr) noexcept
 Generates an UUID as a C string and writes it into the output buffer. More...
 
int GetUniqueStringW (wchar_t *lpStr, std::size_t cchStr) noexcept
 Generates an UUID as a wide C string and writes it into the output buffer. More...
 
template<class CHAR_TYPE >
bool GetUniqueString (CHAR_TYPE *lpStr, std::size_t cchStr) noexcept
 Generates an UUID as a C string and writes it into the output buffer. More...
 
ci_string operator""_cis (const char *str, std::size_t count)
 Returns a case-independent string constructed from a C-string literal. More...
 
constexpr ci_string_view operator""_cisv (const char *str, std::size_t count)
 Returns a case-independent string view object constructed from a C-string literal. More...
 
template<class T >
from_string (const char *pszValue)
 A set of templates providing an interface to convert an argument specifying a C or C++ string to a value of a specified type. . More...
 
template<class T >
from_string (const wchar_t *pszValue)
 A set of templates providing an interface to convert an argument specifying a C or C++ string to a value of a specified type. . More...
 
template<class T >
from_string (const char *pszValue, int base=10)
 A set of templates providing an interface to convert an argument specifying a C or C++ string to a value of a specified type. This template is available (i.e. participates in overload resolution) when the type is integral. . More...
 
template<class T >
from_string (const wchar_t *pszValue, int base=10)
 A set of templates providing an interface to convert an argument specifying a C or C++ string to a value of a specified type. This template is available (i.e. participates in overload resolution) when the type is integral. . More...
 

Memory allocation functions

Portable allocation functions

typedef AutoCString< char > AutoCStringA
 An alias for the Chusov::String::AutoCString template instantiated for multibyte strings.
 
typedef AutoCString< wchar_t > AutoCStringW
 An alias for the Chusov::String::AutoCString template instantiated for wide strings.
 
char * AllocateStringA (std::size_t cch) noexcept
 Allocates an uninitialized string of the specified size, in bytes, plus a room for a terminating zero. More...
 
wchar_t * AllocateStringW (std::size_t cch) noexcept
 Allocates an uninitialized string of the specified size, in wide symbols, plus a room for the terminating zero. More...
 
void FreeStringA (char *lpszString) noexcept
 The function frees memory occupied by the string buffer the parameter points to. The memory must be allocated by one of the Chusov::Memory or Chusov::String allocation functions. More...
 
void FreeStringW (wchar_t *lpszString) noexcept
 The function frees memory occupied by the string buffer the parameter points to. The memory must be allocated by one of the Chusov::Memory or Chusov::String allocation functions. More...
 
char * AllocateAndCopyStringA (const char *pszRight) noexcept
 Allocates and returns a copy of a string. More...
 
wchar_t * AllocateAndCopyStringW (const wchar_t *pszRight) noexcept
 Allocates and returns a copy of a wide string. More...
 
wchar_t * AllocateWideFromMBS (const char *pszRight, std::size_t cbRight) noexcept
 Allocates and returns a wide copy of a multibyte string. More...
 
char * AllocateMBSFromWide (const wchar_t *pszRight, std::size_t cchRight) noexcept
 Allocates and returns a multibyte version of a wide string. More...
 
wchar_t * AllocateUCSFromUTF8 (const char *pszRight, std::size_t cbRight) noexcept
 Allocates and returns a wide UCS-2 (UCS-4) copy of a multibyte UTF-8 string. More...
 
char * AllocateUTF8FromUCS (const wchar_t *pszRight, std::size_t cchRight) noexcept
 Allocates and returns a multibyte UTF-8 version of a wide string given in the UCS-2 (UCS-4) format. More...
 
char * AllocateUniqueStringA () noexcept
 Allocates and returns a unique string which is a representation of an UUID generated internally. More...
 
wchar_t * AllocateUniqueStringW () noexcept
 Allocates and returns a unique string which is a representation of an UUID generated internally. More...
 
char * AllocateTempPathA () noexcept
 Allocates and returns an absolute path for a directory used for storing temporary files. More...
 
wchar_t * AllocateTempPathW () noexcept
 Allocates and returns an absolute path for a directory used for storing temporary files. More...
 
char * AllocateUniqueTempFileNameA (const char *lpszExtension) noexcept
 Allocates and returns an absolute a unique file name based on UUID and that is to be located in the system temporary directory. More...
 
wchar_t * AllocateUniqueTempFileNameW (const wchar_t *lpszExtension) noexcept
 Allocates and returns an absolute a unique file name based on UUID and that is to be located in the system temporary directory. More...
 
void SecureFreeStringA (volatile char *pszString) noexcept
 Performs secure deallocation of a string buffer randomizing its contents. It is designed to be a more secure version of FreeStringA. More...
 
void SecureFreeStringW (volatile wchar_t *pszString) noexcept
 Performs secure deallocation of a string buffer randomizing its contents. It is designed to be a more secure version of FreeStringW. More...
 
template<class CHAR_TYPE >
CHAR_TYPE * AllocateString (std::size_t cch) noexcept
 Allocates an uninitialized string of the specified size plus a room for the terminating zero. More...
 
template<class CHAR_TYPE >
void FreeString (CHAR_TYPE *lpszString) noexcept
 The function frees memory occupied by the string buffer the parameter points to. The memory must be allocated by one of the Chusov::Memory or Chusov::String allocation functions. More...
 
template<class RETURN_CHAR_TYPE , class SOURCE_CHAR_TYPE >
RETURN_CHAR_TYPE * AllocateAndCopyString (const SOURCE_CHAR_TYPE *pszRight) noexcept
 Allocates and returns a copy of a string. More...
 
template<class CHAR_TYPE >
CHAR_TYPE * AllocateUniqueString () noexcept
 Allocates and returns a unique string which is a representation of an UUID generated internally. More...
 
template<class CHAR_TYPE >
CHAR_TYPE * AllocateTempPath () noexcept
 Allocates and returns an absolute path for a directory used for storing temporary files. More...
 
template<class CHAR_TYPE >
CHAR_TYPE * AllocateUniqueTempFileName (const CHAR_TYPE *lpszExtension) noexcept
 Allocates and returns an absolute a unique file name based on UUID and that is to be located in the system temporary directory. More...
 
template<class CHAR_TYPE >
void SecureFreeString (volatile CHAR_TYPE *pszString) noexcept
 Performs secure deallocation of a string buffer randomizing its contents. It is designed to be a more secure version of FreeString. More...
 

Detailed Description

Functions and classes for working with strings.