#include "Stroika/Foundation/StroikaPreComp.h"
#include <cstdarg>
#include <cstring>
#include <string>
#include "Stroika/Foundation/Characters/Character.h"
#include "Stroika/Foundation/Common/Common.h"
#include "Utilities.inl"
Go to the source code of this file.
Namespaces | |
namespace | Stroika::Foundation |
namespace | Stroika::Foundation::Characters |
Functions | |
template<IPossibleCharacterRepresentation T> | |
size_t | Stroika::Foundation::Characters::CString::Length (const T *p) |
Measure the length of the argument c-string (NUL-terminated string). | |
template<typename T > | |
bool | Stroika::Foundation::Characters::CString::Equals (const T *lhs, const T *rhs) |
strcmp or wsccmp() as appropriate == 0 | |
template<typename T > | |
void | Stroika::Foundation::Characters::CString::Copy (T *dest, size_t nEltsInDest, const T *src) |
Safe variant of strncpy() - which always NUL-terminates the string. | |
template<typename T > | |
void | Stroika::Foundation::Characters::CString::Cat (T *dest, size_t nEltsInDest, const T *src2Append) |
Safe variant of strncat() - which always NUL-terminates the string. DIFFERNT arguments however, so not safe direct substitution. | |
string | Stroika::Foundation::Characters::CString::LimitLength (const string &str, size_t maxLen, bool keepLeft=true) |
template<typename TCHAR > | |
basic_string< TCHAR > | Stroika::Foundation::Characters::CString::LTrim (const basic_string< TCHAR > &text) |
string | Stroika::Foundation::Characters::CString::StripTrailingCharIfAny (const string &s, char c) |
unsigned int | Stroika::Foundation::Characters::CString::HexString2Int (const string &s) |
template<typename T > | |
T | Stroika::Foundation::Characters::CString::String2Int (const string &s) |
size_t Stroika::Foundation::Characters::CString::Length | ( | const T * | p | ) |
Measure the length of the argument c-string (NUL-terminated string).
Measure the length of the argument c-string (NUL-terminated string). Overloaded version of strlen/wcslen.
Only implemented for char/wchar_t. Reason for this is so code using old-style C++ strings can leverage overloading!
Definition at line 17 of file Characters/CString/Utilities.inl.
void Stroika::Foundation::Characters::CString::Copy | ( | T * | dest, |
size_t | nEltsInDest, | ||
const T * | src | ||
) |
Safe variant of strncpy() - which always NUL-terminates the string.
Copy the C-string pointed to by 'src' to the location pointed to by 'dest'. 'nEltsInDest' - as the name suggests - is the number of elements in the array pointed to by 'dest' - not the max string length for 'dest.
This function will always nul-terminate, and it is illegal to call it with a value of zero for nEltsInDest.
This is basically like strcpy/strncpy, except with better logic for nul-termination.
Note - the arguments are not in exactly the same order as strncpy() - with the length of the buffer for the first string before the second string.
Definition at line 100 of file Characters/CString/Utilities.inl.
void Stroika::Foundation::Characters::CString::Cat | ( | T * | dest, |
size_t | nEltsInDest, | ||
const T * | src2Append | ||
) |
Safe variant of strncat() - which always NUL-terminates the string. DIFFERNT arguments however, so not safe direct substitution.
Note - the arguments are not in exactly the same order as strncpy() - with the length of the buffer for the first string before the second string.
Definition at line 150 of file Characters/CString/Utilities.inl.
string Stroika::Foundation::Characters::CString::LimitLength | ( | const string & | str, |
size_t | maxLen, | ||
bool | keepLeft = true |
||
) |
Definition at line 246 of file Characters/CString/Utilities.cpp.
basic_string< TCHAR > Stroika::Foundation::Characters::CString::LTrim | ( | const basic_string< TCHAR > & | text | ) |
Definition at line 200 of file Characters/CString/Utilities.inl.
string Stroika::Foundation::Characters::CString::StripTrailingCharIfAny | ( | const string & | s, |
char | c | ||
) |
This could be generalized to accomodate TRIM/merge with TRIM, but it sometimes used to trim other characters (like trailing CRLF, or trailing '.').
Definition at line 274 of file Characters/CString/Utilities.cpp.
unsigned int Stroika::Foundation::Characters::CString::HexString2Int | ( | const string & | s | ) |
Convert the given hex-format string to an unsigned integer. String2Int will return 0 if no valid parse, and UINT_MAX on overflow.
Definition at line 289 of file Characters/CString/Utilities.cpp.
T Stroika::Foundation::Characters::CString::String2Int | ( | const string & | s | ) |
Convert the given decimal-format integral string to any integer type ( e.g. signed char, unsigned short int, long long int, uint32_t etc).
String2Int will return 0 if no valid parse, and numeric_limits<T>::min on underflow, numeric_limits<T>::max on overflow.
CONSIDER!
Definition at line 281 of file Characters/CString/Utilities.inl.