sbgECom Library  5.2.590-stable
Interface SBG Systems IMU/AHRS/INS
Loading...
Searching...
No Matches
sbgString.h File Reference

Character string. More...

Go to the source code of this file.

Data Structures

struct  _SbgString
 
struct  _SbgStringIterator
 

Macros

#define SBG_STRING_INTERNAL_BUFFER_MIN_SIZE   (4)
 
#define SBG_STRING_INTERNAL_BUFFER_DEFAULT_SIZE   (16)
 

Typedefs

typedef struct _SbgString SbgString
 
typedef struct _SbgStringIterator SbgStringIterator
 

Functions

SBG_COMMON_LIB_API void sbgStringConstructEmpty (SbgString *pString)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringConstruct (SbgString *pString, const SbgString *pSourceString)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringConstructCString (SbgString *pString, const char *pCString)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringConstructVF (SbgString *pString, const char *pFormat, va_list args) SBG_CHECK_FORMAT(printf
 
SBG_COMMON_LIB_API SbgErrorCode SBG_COMMON_LIB_API SbgErrorCode sbgStringConstructF (SbgString *pString, const char *pFormat,...) SBG_CHECK_FORMAT(printf
 
SBG_COMMON_LIB_API SbgErrorCode SBG_COMMON_LIB_API SbgErrorCode SBG_COMMON_LIB_API SbgErrorCode sbgStringConstructStatic (SbgString *pString, const char *pCString, char *pBuffer, size_t size)
 
SBG_COMMON_LIB_API void sbgStringConstructReadOnly (SbgString *pString, const char *pCString)
 
SBG_COMMON_LIB_API void sbgStringDestroy (SbgString *pString)
 
SBG_COMMON_LIB_API int32_t sbgStringCompare (const SbgString *pString, const SbgString *pOtherString)
 
SBG_COMMON_LIB_API int32_t sbgStringCompareCString (const SbgString *pString, const char *pCString)
 
SBG_COMMON_LIB_API int32_t sbgStringCompareIgnoreCase (const SbgString *pString, const SbgString *pOtherString)
 
SBG_COMMON_LIB_API int32_t sbgStringCompareIgnoreCaseCString (const SbgString *pString, const char *pCString)
 
SBG_COMMON_LIB_API size_t sbgStringHash (const SbgString *pString)
 
SBG_COMMON_LIB_API size_t sbgStringGetLength (const SbgString *pString)
 
SBG_COMMON_LIB_API const char * sbgStringGetCString (const SbgString *pString)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringCharAt (const SbgString *pString, size_t index, char *pChar)
 
SBG_COMMON_LIB_API size_t sbgStringFind (const SbgString *pString, const SbgString *pStringToFind)
 
SBG_COMMON_LIB_API size_t sbgStringFindCString (const SbgString *pString, const char *pCString)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringSubstring (const SbgString *pString, size_t startIndex, size_t endIndex, SbgString *pSubstring)
 
SBG_COMMON_LIB_API bool sbgStringStartsWith (const SbgString *pString, const char *pCString)
 
SBG_COMMON_LIB_API bool sbgStringEndsWith (const SbgString *pString, const char *pCString)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringGetLastError (const SbgString *pString)
 
SBG_COMMON_LIB_API void sbgStringClearLastError (SbgString *pString)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringSetCharAt (SbgString *pString, size_t index, char c)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringAppend (SbgString *pString, const SbgString *pAppendString)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringAppendCString (SbgString *pString, const char *pCString)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringAppendVF (SbgString *pString, const char *pFormat, va_list args) SBG_CHECK_FORMAT(printf
 
SBG_COMMON_LIB_API SbgErrorCode SBG_COMMON_LIB_API SbgErrorCode sbgStringAppendF (SbgString *pString, const char *pFormat,...) SBG_CHECK_FORMAT(printf
 
SBG_COMMON_LIB_API SbgErrorCode SBG_COMMON_LIB_API SbgErrorCode SBG_COMMON_LIB_API SbgErrorCode sbgStringAssign (SbgString *pString, const SbgString *pAssignString)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringAssignCString (SbgString *pString, const char *pCString)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringAssignVF (SbgString *pString, const char *pFormat, va_list args) SBG_CHECK_FORMAT(printf
 
SBG_COMMON_LIB_API SbgErrorCode SBG_COMMON_LIB_API SbgErrorCode sbgStringAssignF (SbgString *pString, const char *pFormat,...) SBG_CHECK_FORMAT(printf
 
SBG_COMMON_LIB_API SbgErrorCode SBG_COMMON_LIB_API SbgErrorCode SBG_COMMON_LIB_API SbgErrorCode sbgStringMove (SbgString *pString, SbgString *pSourceString)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringMoveCString (SbgString *pString, char *pCString)
 
SBG_COMMON_LIB_API char * sbgStringExtract (SbgString *pString)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringClear (SbgString *pString)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringToUpperCase (SbgString *pString)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringToLowerCase (SbgString *pString)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringTrimLeft (SbgString *pString)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringTrimRight (SbgString *pString)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringTrim (SbgString *pString)
 
SBG_COMMON_LIB_API void sbgStringTruncate (SbgString *pString, size_t length)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringFromInt8 (SbgString *pString, int8_t value)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringToInt8 (const SbgString *pString, int8_t *pValue)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringFromUint8 (SbgString *pString, uint8_t value)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringToUint8 (const SbgString *pString, uint8_t *pValue)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringFromInt16 (SbgString *pString, int16_t value)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringToInt16 (const SbgString *pString, int16_t *pValue)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringFromUint16 (SbgString *pString, uint16_t value)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringToUint16 (const SbgString *pString, uint16_t *pValue)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringFromInt32 (SbgString *pString, int32_t value)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringToInt32 (const SbgString *pString, int32_t *pValue)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringFromUint32 (SbgString *pString, uint32_t value)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringToUint32 (const SbgString *pString, uint32_t *pValue)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringFromInt64 (SbgString *pString, int64_t value)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringToInt64 (const SbgString *pString, int64_t *pValue)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringFromUint64 (SbgString *pString, uint64_t value)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringToUint64 (const SbgString *pString, uint64_t *pValue)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringFromFloat (SbgString *pString, float value)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringToFloat (const SbgString *pString, float *pValue)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringFromDouble (SbgString *pString, double value)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringToDouble (const SbgString *pString, double *pValue)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringFromStreamBuffer (SbgString *pString, SbgStreamBuffer *pStream)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringToStreamBuffer (const SbgString *pString, SbgStreamBuffer *pStream)
 
SBG_COMMON_LIB_API void sbgStringIteratorConstruct (SbgStringIterator *pIterator, const SbgString *pString)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringIteratorWalk (SbgStringIterator *pIterator, const char *pSeparators, bool skipEmptyTokens, SbgString *pToken)
 
SBG_COMMON_LIB_API SbgErrorCode sbgStringCopy (char *pDestination, const char *pSource, size_t destMaxSize)
 
SBG_COMMON_LIB_API const char * sbgStringFirstValidChar (const char *pInputStr)
 

Detailed Description

Character string.

Author
SBG Systems
Date
March 20, 2020
License

The MIT license

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Macro Definition Documentation

◆ SBG_STRING_INTERNAL_BUFFER_MIN_SIZE

#define SBG_STRING_INTERNAL_BUFFER_MIN_SIZE   (4)

Minimum size of the internal buffer, in bytes.

This constant must be strictly positive in order to guarantee that no errors can occur during the construction of an empty string.

◆ SBG_STRING_INTERNAL_BUFFER_DEFAULT_SIZE

#define SBG_STRING_INTERNAL_BUFFER_DEFAULT_SIZE   (16)

Default size of the internal buffer, in bytes.

Typedef Documentation

◆ SbgString

typedef struct _SbgString SbgString

String.

The buffer contains a C null-terminated string. The null-terminating character is not considered to be part of the string content.

Attempts to modify a read-only string lead to undefined behavior.

Attempts to modify a string while the last modification operation error is set are canceled and return the last error code.

◆ SbgStringIterator

String iterator.

Function Documentation

◆ sbgStringConstructEmpty()

SBG_COMMON_LIB_API void sbgStringConstructEmpty ( SbgString * pString)

String constructor.

The rationale for this constructor is to guarantee that no errors may occur on the construction of empty strings.

Parameters
[in]pStringString.

References SBG_COMMON_LIB_API.

◆ sbgStringConstruct()

SBG_COMMON_LIB_API SbgErrorCode sbgStringConstruct ( SbgString * pString,
const SbgString * pSourceString )

String constructor.

The string content is initialized from the given source string. If that string is NULL, the string is initialized with an empty content.

Parameters
[in]pStringString.
[in]pSourceStringSource string, may be NULL.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API.

◆ sbgStringConstructCString()

SBG_COMMON_LIB_API SbgErrorCode sbgStringConstructCString ( SbgString * pString,
const char * pCString )

String constructor.

The string content is initialized from the given C null-terminated string.

Parameters
[in]pStringString.
[in]pCStringC null-terminated string.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API.

◆ sbgStringConstructVF()

SBG_COMMON_LIB_API SbgErrorCode sbgStringConstructVF ( SbgString * pString,
const char * pFormat,
va_list args )

String constructor.

The string content is initialized from formatted data from a variable argument list.

Parameters
[in]pStringString.
[in]pFormatFormat.
[in]argsVariable argument list.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API.

◆ sbgStringConstructF()

SBG_COMMON_LIB_API SbgErrorCode SBG_COMMON_LIB_API SbgErrorCode sbgStringConstructF ( SbgString * pString,
const char * pFormat,
... )

String constructor.

The string content is initialized from formatted data.

Parameters
[in]pStringString.
[in]pFormatFormat.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API.

◆ sbgStringConstructStatic()

SBG_COMMON_LIB_API SbgErrorCode SBG_COMMON_LIB_API SbgErrorCode SBG_COMMON_LIB_API SbgErrorCode sbgStringConstructStatic ( SbgString * pString,
const char * pCString,
char * pBuffer,
size_t size )

String constructor.

The string content is initialized from the given C null-terminated string.

If the C null-terminated string is NULL then the string contains the content of the given buffer before construction. In this case the content of the given buffer must be a C null-terminated string.

The given buffer is owned by the string and must not be modified while the string is in use. After destroying the string, the buffer contains the content of the string immediately before destruction.

Parameters
[in]pStringString.
[in]pCStringC null-terminated string, may be NULL.
[in]pBufferBuffer.
[in]sizeBuffer size, in bytes.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringConstructStatic().

Referenced by sbgStringConstructStatic().

◆ sbgStringConstructReadOnly()

SBG_COMMON_LIB_API void sbgStringConstructReadOnly ( SbgString * pString,
const char * pCString )

String constructor.

The string cannot be modified.

The given C null-terminated string provides both the statically allocated buffer for the string, as well as its content. It is owned by the string and must not be modified.

Parameters
[in]pStringString.
[in]pCStringC null-terminated string.

References SBG_COMMON_LIB_API, and sbgStringConstructReadOnly().

Referenced by sbgStringConstructReadOnly().

◆ sbgStringDestroy()

SBG_COMMON_LIB_API void sbgStringDestroy ( SbgString * pString)

String destructor.

Parameters
[in]pStringString.

References SBG_COMMON_LIB_API, and sbgStringDestroy().

Referenced by sbgStringDestroy().

◆ sbgStringCompare()

SBG_COMMON_LIB_API int32_t sbgStringCompare ( const SbgString * pString,
const SbgString * pOtherString )

Compare a string to another string.

Parameters
[in]pStringString.
[in]pOtherStringOther string.
Returns
The return value is 0 if both strings are equal, less than 0 if the string value is less than the other string value, greater than 0 if the string value is greater than the other string value.

References SBG_COMMON_LIB_API, and sbgStringCompare().

Referenced by sbgStringCompare().

◆ sbgStringCompareCString()

SBG_COMMON_LIB_API int32_t sbgStringCompareCString ( const SbgString * pString,
const char * pCString )

Compare a string to a C null-terminated string.

Parameters
[in]pStringString.
[in]pCStringC null-terminated string.
Returns
The return value is 0 if the string is equal to the C null-terminated string, less than 0 if the string value is less than the C null-terminated string value, greater than 0 if the string value is greater than the C null-terminated string value.

References SBG_COMMON_LIB_API, and sbgStringCompareCString().

Referenced by sbgStringCompareCString().

◆ sbgStringCompareIgnoreCase()

SBG_COMMON_LIB_API int32_t sbgStringCompareIgnoreCase ( const SbgString * pString,
const SbgString * pOtherString )

Compare a string to another string, ignoring case differences.

Parameters
[in]pStringString.
[in]pOtherStringOther string.
Returns
The return value is 0 if both strings are equal, less than 0 if the string value is less than the other string value, greater than 0 if the string value is greater than the other string value.

References SBG_COMMON_LIB_API, and sbgStringCompareIgnoreCase().

Referenced by sbgStringCompareIgnoreCase().

◆ sbgStringCompareIgnoreCaseCString()

SBG_COMMON_LIB_API int32_t sbgStringCompareIgnoreCaseCString ( const SbgString * pString,
const char * pCString )

Compare a string to a C null-terminated string, ignoring case differences.

Parameters
[in]pStringString.
[in]pCStringC null-terminated string.
Returns
The return value is 0 if the string is equal to the C null-terminated string, less than 0 if the string value is less than the C null-terminated string value, greater than 0 if the string value is greater than the C null-terminated string value.

References SBG_COMMON_LIB_API, and sbgStringCompareIgnoreCaseCString().

Referenced by sbgStringCompareIgnoreCaseCString().

◆ sbgStringHash()

SBG_COMMON_LIB_API size_t sbgStringHash ( const SbgString * pString)

Compute the hash value of a string.

Parameters
[in]pStringString.
Returns
Hash value.

References SBG_COMMON_LIB_API, and sbgStringHash().

Referenced by sbgStringHash().

◆ sbgStringGetLength()

SBG_COMMON_LIB_API size_t sbgStringGetLength ( const SbgString * pString)

Get the length of a string (not including the terminating null character), in bytes.

Parameters
[in]pStringString.
Returns
Length, in bytes.

References SBG_COMMON_LIB_API, and sbgStringGetLength().

Referenced by sbgStringGetLength().

◆ sbgStringGetCString()

SBG_COMMON_LIB_API const char * sbgStringGetCString ( const SbgString * pString)

Get a C null-terminated string version of a string.

The pointer returned remains valid until the next modification operation on the string.

Parameters
[in]pStringString.
Returns
C null-terminated string.

References SBG_COMMON_LIB_API, and sbgStringGetCString().

Referenced by sbgStringGetCString().

◆ sbgStringCharAt()

SBG_COMMON_LIB_API SbgErrorCode sbgStringCharAt ( const SbgString * pString,
size_t index,
char * pChar )

Get a character in a string.

Parameters
[in]pStringString.
[in]indexIndex.
[out]pCharCharacter.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringCharAt().

Referenced by sbgStringCharAt().

◆ sbgStringFind()

SBG_COMMON_LIB_API size_t sbgStringFind ( const SbgString * pString,
const SbgString * pStringToFind )

Get the index of the first occurrence of a string in a string.

Parameters
[in]pStringString.
[in]pStringToFindString to find.
Returns
Index of the first occurrence or SIZE_MAX if not found.

References SBG_COMMON_LIB_API, and sbgStringFind().

Referenced by sbgStringFind().

◆ sbgStringFindCString()

SBG_COMMON_LIB_API size_t sbgStringFindCString ( const SbgString * pString,
const char * pCString )

Get the index of the first occurrence of the given C null-terminated string in a string.

Parameters
[in]pStringString.
[in]pCStringC null-terminated string.
Returns
Index of the first occurrence or SIZE_MAX if not found.

References SBG_COMMON_LIB_API, and sbgStringFindCString().

Referenced by sbgStringFindCString().

◆ sbgStringSubstring()

SBG_COMMON_LIB_API SbgErrorCode sbgStringSubstring ( const SbgString * pString,
size_t startIndex,
size_t endIndex,
SbgString * pSubstring )

Get a substring from a string.

The substring must be constructed before calling this function. If an error occurs, the last error of the substring is set by this function.

Parameters
[in]pStringString.
[in]startIndexStart index.
[in]endIndexEnd index.
[out]pSubstringSubstring.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringSubstring().

Referenced by sbgStringSubstring().

◆ sbgStringStartsWith()

SBG_COMMON_LIB_API bool sbgStringStartsWith ( const SbgString * pString,
const char * pCString )

Check if a C null-terminated string is at the beginning of a string.

Parameters
[in]pStringString.
[in]pCStringC null-terminated string.
Returns
True if the C null-terminated string is at the beginning.

References SBG_COMMON_LIB_API, and sbgStringStartsWith().

Referenced by sbgStringStartsWith().

◆ sbgStringEndsWith()

SBG_COMMON_LIB_API bool sbgStringEndsWith ( const SbgString * pString,
const char * pCString )

Check if a C null-terminated string is at the end of a string.

Parameters
[in]pStringString.
[in]pCStringC null-terminated string.
Returns
True if the C null-terminated string is at the end.

References SBG_COMMON_LIB_API, and sbgStringEndsWith().

Referenced by sbgStringEndsWith().

◆ sbgStringGetLastError()

SBG_COMMON_LIB_API SbgErrorCode sbgStringGetLastError ( const SbgString * pString)

Get the last error of a modification operation on a string.

Parameters
[in]pStringString.
Returns
Last modification error.

References SBG_COMMON_LIB_API, and sbgStringGetLastError().

Referenced by sbgStringGetLastError().

◆ sbgStringClearLastError()

SBG_COMMON_LIB_API void sbgStringClearLastError ( SbgString * pString)

Clear the last modification operation error of a string.

Parameters
[in]pStringString.

References SBG_COMMON_LIB_API, and sbgStringClearLastError().

Referenced by sbgStringClearLastError().

◆ sbgStringSetCharAt()

SBG_COMMON_LIB_API SbgErrorCode sbgStringSetCharAt ( SbgString * pString,
size_t index,
char c )

Set a character in a string.

The given index must be strictly lower than the string length. The given character must not be a null character.

Parameters
[in]pStringString.
[in]indexIndex.
[in]cCharacter.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringSetCharAt().

Referenced by sbgStringSetCharAt().

◆ sbgStringAppend()

SBG_COMMON_LIB_API SbgErrorCode sbgStringAppend ( SbgString * pString,
const SbgString * pAppendString )

Append a string to another string.

Parameters
[in]pStringString.
[in]pAppendStringString to append.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringAppend().

Referenced by sbgStringAppend().

◆ sbgStringAppendCString()

SBG_COMMON_LIB_API SbgErrorCode sbgStringAppendCString ( SbgString * pString,
const char * pCString )

Append a C null-terminated string to a string.

Parameters
[in]pStringString.
[in]pCStringC null-terminated string.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringAppendCString().

Referenced by sbgStringAppendCString().

◆ sbgStringAppendVF()

SBG_COMMON_LIB_API SbgErrorCode sbgStringAppendVF ( SbgString * pString,
const char * pFormat,
va_list args )

Append formatted data from a variable argument list to a string.

The string format, as well as the variable argument list, are the same as for vprintf.

Parameters
[in]pStringString.
[in]pFormatFormat.
[in]argsVariable argument list.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringAppendVF().

Referenced by sbgStringAppendVF().

◆ sbgStringAppendF()

SBG_COMMON_LIB_API SbgErrorCode SBG_COMMON_LIB_API SbgErrorCode sbgStringAppendF ( SbgString * pString,
const char * pFormat,
... )

Append formatted data to a string.

The string format, as well as the variable arguments, are the same as for printf.

Parameters
[in]pStringString.
[in]pFormatFormat.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringAppendF().

Referenced by sbgStringAppendF().

◆ sbgStringAssign()

Assign a string to another string.

Parameters
[in]pStringString.
[in]pAssignStringString to assign.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringAssign().

Referenced by sbgStringAssign().

◆ sbgStringAssignCString()

SBG_COMMON_LIB_API SbgErrorCode sbgStringAssignCString ( SbgString * pString,
const char * pCString )

Assign a C null-terminated string to a string.

Parameters
[in]pStringString.
[in]pCStringC null-terminated string.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringAssignCString().

Referenced by sbgStringAssignCString().

◆ sbgStringAssignVF()

SBG_COMMON_LIB_API SbgErrorCode sbgStringAssignVF ( SbgString * pString,
const char * pFormat,
va_list args )

Assign formatted data from a variable argument list to a string.

The string format, as well as the variable argument list, are the same as for vprintf.

Parameters
[in]pStringString.
[in]pFormatFormat.
[in]argsVariable argument list.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringAssignVF().

Referenced by sbgStringAssignVF().

◆ sbgStringAssignF()

SBG_COMMON_LIB_API SbgErrorCode SBG_COMMON_LIB_API SbgErrorCode sbgStringAssignF ( SbgString * pString,
const char * pFormat,
... )

Assign formatted data to a string.

The string format, as well as the variable arguments, are the same as for printf.

Parameters
[in]pStringString.
[in]pFormatFormat.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringAssignF().

Referenced by sbgStringAssignF().

◆ sbgStringMove()

Move content between two strings.

On return, if successful, the source string is empty.

Parameters
[in]pStringString.
[in]pSourceStringSource string.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringMove().

Referenced by sbgStringMove().

◆ sbgStringMoveCString()

SBG_COMMON_LIB_API SbgErrorCode sbgStringMoveCString ( SbgString * pString,
char * pCString )

Move a dynamically allocated C null-terminated string into a string.

The C string must have been allocated using a standard C allocation function, such as malloc() or strdup().

On return, if successful, the C string buffer is owned by the string.

Parameters
[in]pStringString.
[in]pCStringC null-terminated string.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringMoveCString().

Referenced by sbgStringMoveCString().

◆ sbgStringExtract()

SBG_COMMON_LIB_API char * sbgStringExtract ( SbgString * pString)

Extract the content of a string.

If successful, the content returned is a C null-terminated string, becomes owned by the caller, may be released with free(), and the given string becomes empty.

Parameters
[in]pStringString.
Returns
C null-terminated string, NULL if an error occurred.

References SBG_COMMON_LIB_API, and sbgStringExtract().

Referenced by sbgStringExtract().

◆ sbgStringClear()

SBG_COMMON_LIB_API SbgErrorCode sbgStringClear ( SbgString * pString)

Clear a string.

After returning from this call the string is empty.

Parameters
[in]pStringString.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringClear().

Referenced by sbgStringClear().

◆ sbgStringToUpperCase()

SBG_COMMON_LIB_API SbgErrorCode sbgStringToUpperCase ( SbgString * pString)

Convert all the characters of a string to upper case.

Parameters
[in]pStringString.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringToUpperCase().

Referenced by sbgStringToUpperCase().

◆ sbgStringToLowerCase()

SBG_COMMON_LIB_API SbgErrorCode sbgStringToLowerCase ( SbgString * pString)

Convert all the characters of a string to lower case.

Parameters
[in]pStringString.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringToLowerCase().

Referenced by sbgStringToLowerCase().

◆ sbgStringTrimLeft()

SBG_COMMON_LIB_API SbgErrorCode sbgStringTrimLeft ( SbgString * pString)

Remove all spacing characters at the beginning of a string.

Parameters
[in]pStringString.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringTrimLeft().

Referenced by sbgStringTrimLeft().

◆ sbgStringTrimRight()

SBG_COMMON_LIB_API SbgErrorCode sbgStringTrimRight ( SbgString * pString)

Remove all spacing characters at the end of a string.

Parameters
[in]pStringString.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringTrimRight().

Referenced by sbgStringTrimRight().

◆ sbgStringTrim()

SBG_COMMON_LIB_API SbgErrorCode sbgStringTrim ( SbgString * pString)

Remove all spacing characters at the beginning and the end of a string.

Parameters
[in]pStringString.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringTrim().

Referenced by sbgStringTrim().

◆ sbgStringTruncate()

SBG_COMMON_LIB_API void sbgStringTruncate ( SbgString * pString,
size_t length )

Truncate a string.

If the given length is greater than or equal to the length of the string, this function doesn't modify the string.

Parameters
[in]pStringString.
[in]lengthLength, in bytes.

References SBG_COMMON_LIB_API, and sbgStringTruncate().

Referenced by sbgStringTruncate().

◆ sbgStringFromInt8()

SBG_COMMON_LIB_API SbgErrorCode sbgStringFromInt8 ( SbgString * pString,
int8_t value )

Convert and assign a 8-bits signed integer value to a string.

Parameters
[in]pStringString.
[in]valueValue.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringFromInt8().

Referenced by sbgStringFromInt8().

◆ sbgStringToInt8()

SBG_COMMON_LIB_API SbgErrorCode sbgStringToInt8 ( const SbgString * pString,
int8_t * pValue )

Convert a string to a 8-bits signed integer value.

Parameters
[in]pStringString.
[out]pValueValue.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringToInt8().

Referenced by sbgStringToInt8().

◆ sbgStringFromUint8()

SBG_COMMON_LIB_API SbgErrorCode sbgStringFromUint8 ( SbgString * pString,
uint8_t value )

Convert and assign a 8-bits unsigned integer value to a string.

Parameters
[in]pStringString.
[in]valueValue
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringFromUint8().

Referenced by sbgStringFromUint8().

◆ sbgStringToUint8()

SBG_COMMON_LIB_API SbgErrorCode sbgStringToUint8 ( const SbgString * pString,
uint8_t * pValue )

Convert a string to a 8-bits unsigned integer value.

Parameters
[in]pStringString.
[out]pValueValue.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringToUint8().

Referenced by sbgStringToUint8().

◆ sbgStringFromInt16()

SBG_COMMON_LIB_API SbgErrorCode sbgStringFromInt16 ( SbgString * pString,
int16_t value )

Convert and assign a 16-bits signed integer value to a string.

Parameters
[in]pStringString.
[in]valueValue.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringFromInt16().

Referenced by sbgStringFromInt16().

◆ sbgStringToInt16()

SBG_COMMON_LIB_API SbgErrorCode sbgStringToInt16 ( const SbgString * pString,
int16_t * pValue )

Convert a string to a 16-bits signed integer value.

Parameters
[in]pStringString.
[out]pValueValue.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringToInt16().

Referenced by sbgStringToInt16().

◆ sbgStringFromUint16()

SBG_COMMON_LIB_API SbgErrorCode sbgStringFromUint16 ( SbgString * pString,
uint16_t value )

Convert and assign a 16-bits unsigned integer value to a string.

Parameters
[in]pStringString.
[in]valueValue
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringFromUint16().

Referenced by sbgStringFromUint16().

◆ sbgStringToUint16()

SBG_COMMON_LIB_API SbgErrorCode sbgStringToUint16 ( const SbgString * pString,
uint16_t * pValue )

Convert a string to a 16-bits unsigned integer value.

Parameters
[in]pStringString.
[out]pValueValue.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringToUint16().

Referenced by sbgStringToUint16().

◆ sbgStringFromInt32()

SBG_COMMON_LIB_API SbgErrorCode sbgStringFromInt32 ( SbgString * pString,
int32_t value )

Convert and assign a 32-bits signed integer value to a string.

Parameters
[in]pStringString.
[in]valueValue.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringFromInt32().

Referenced by sbgStringFromInt32().

◆ sbgStringToInt32()

SBG_COMMON_LIB_API SbgErrorCode sbgStringToInt32 ( const SbgString * pString,
int32_t * pValue )

Convert a string to a 32-bits signed integer value.

Parameters
[in]pStringString.
[out]pValueValue.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringToInt32().

Referenced by sbgStringToInt32().

◆ sbgStringFromUint32()

SBG_COMMON_LIB_API SbgErrorCode sbgStringFromUint32 ( SbgString * pString,
uint32_t value )

Convert and assign a 32-bits unsigned integer value to a string.

Parameters
[in]pStringString.
[in]valueValue
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringFromUint32().

Referenced by sbgStringFromUint32().

◆ sbgStringToUint32()

SBG_COMMON_LIB_API SbgErrorCode sbgStringToUint32 ( const SbgString * pString,
uint32_t * pValue )

Convert a string to a 32-bits unsigned integer value.

Parameters
[in]pStringString.
[out]pValueValue.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringToUint32().

Referenced by sbgStringToUint32().

◆ sbgStringFromInt64()

SBG_COMMON_LIB_API SbgErrorCode sbgStringFromInt64 ( SbgString * pString,
int64_t value )

Convert and assign a 64-bits signed integer value to a string.

Parameters
[in]pStringString.
[in]valueValue.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringFromInt64().

Referenced by sbgStringFromInt64().

◆ sbgStringToInt64()

SBG_COMMON_LIB_API SbgErrorCode sbgStringToInt64 ( const SbgString * pString,
int64_t * pValue )

Convert a string to a 64-bits signed integer value.

Parameters
[in]pStringString.
[out]pValueValue.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringToInt64().

Referenced by sbgStringToInt64().

◆ sbgStringFromUint64()

SBG_COMMON_LIB_API SbgErrorCode sbgStringFromUint64 ( SbgString * pString,
uint64_t value )

Convert and assign a 64-bits unsigned integer value to a string.

Parameters
[in]pStringString.
[in]valueValue
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringFromUint64().

Referenced by sbgStringFromUint64().

◆ sbgStringToUint64()

SBG_COMMON_LIB_API SbgErrorCode sbgStringToUint64 ( const SbgString * pString,
uint64_t * pValue )

Convert a string to a 64-bits unsigned integer value.

Parameters
[in]pStringString.
[out]pValueValue.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringToUint64().

Referenced by sbgStringToUint64().

◆ sbgStringFromFloat()

SBG_COMMON_LIB_API SbgErrorCode sbgStringFromFloat ( SbgString * pString,
float value )

Convert and assign a float value to a string.

Parameters
[in]pStringString.
[in]valueValue.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringFromFloat().

Referenced by sbgStringFromFloat().

◆ sbgStringToFloat()

SBG_COMMON_LIB_API SbgErrorCode sbgStringToFloat ( const SbgString * pString,
float * pValue )

Convert a string to a float value.

Parameters
[in]pStringString.
[out]pValueValue.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringToFloat().

Referenced by sbgStringToFloat().

◆ sbgStringFromDouble()

SBG_COMMON_LIB_API SbgErrorCode sbgStringFromDouble ( SbgString * pString,
double value )

Convert and assign a double value to a string.

Parameters
[in]pStringString.
[in]valueValue.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringFromDouble().

Referenced by sbgStringFromDouble().

◆ sbgStringToDouble()

SBG_COMMON_LIB_API SbgErrorCode sbgStringToDouble ( const SbgString * pString,
double * pValue )

Convert a string to a double value.

Parameters
[in]pStringString.
[out]pValueValue.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringToDouble().

Referenced by sbgStringToDouble().

◆ sbgStringFromStreamBuffer()

SBG_COMMON_LIB_API SbgErrorCode sbgStringFromStreamBuffer ( SbgString * pString,
SbgStreamBuffer * pStream )

Read a string from a stream buffer.

Parameters
[in]pStringString.
[in]pStreamStream buffer.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringFromStreamBuffer().

Referenced by sbgStringFromStreamBuffer().

◆ sbgStringToStreamBuffer()

SBG_COMMON_LIB_API SbgErrorCode sbgStringToStreamBuffer ( const SbgString * pString,
SbgStreamBuffer * pStream )

Write a string to a stream buffer.

Parameters
[in]pStringString.
[out]pStreamStream buffer.
Returns
SBG_NO_ERROR if successful.

References SBG_COMMON_LIB_API, and sbgStringToStreamBuffer().

Referenced by sbgStringToStreamBuffer().

◆ sbgStringIteratorConstruct()

SBG_COMMON_LIB_API void sbgStringIteratorConstruct ( SbgStringIterator * pIterator,
const SbgString * pString )

String iterator constructor.

If the given string is modified while the iterator is used, the behavior is undefined.

Parameters
[in]pIteratorString iterator.
[in]pStringString.

References SBG_COMMON_LIB_API, and sbgStringIteratorConstruct().

Referenced by sbgStringIteratorConstruct().

◆ sbgStringIteratorWalk()

SBG_COMMON_LIB_API SbgErrorCode sbgStringIteratorWalk ( SbgStringIterator * pIterator,
const char * pSeparators,
bool skipEmptyTokens,
SbgString * pToken )

Walk to the next token of a string.

The token string must be constructed before calling this function. If an error occurs, the last error of the token string is set by this function.

Parameters
[in]pIteratorString iterator.
[in]pSeparatorsC null-terminated string containing separator characters.
[in]skipEmptyTokensIf true, empty tokens are skipped.
[out]pTokenToken.
Returns
SBG_NO_ERROR if successful, SBG_NOT_READY if there are no more tokens.

References SBG_COMMON_LIB_API, and sbgStringIteratorWalk().

Referenced by sbgStringIteratorWalk().

◆ sbgStringCopy()

SBG_COMMON_LIB_API SbgErrorCode sbgStringCopy ( char * pDestination,
const char * pSource,
size_t destMaxSize )

Safely copy source string to destination according to destination provided buffer size.

This method tends to replace strncpy where you would like to safely copy a string with buffer overflow checking. If the provided output buffer is too small, the method will return a valid NULL terminated C string in destination. This condition will be returned using SBG_BUFFER_OVERFLOW error code.

Parameters
[out]pDestinationThe destination string that should hold the copied input string.
[in]pSourceThe source NULL terminated C string to copy to the destination.
[in]destMaxSizeThe destination buffer size including the null terminating char.
Returns
SBG_NO_ERROR if the source string has been copied to destination SBG_BUFFER_OVERFLOW if the destination is too small to hold the source string.

References SBG_COMMON_LIB_API, and sbgStringCopy().

Referenced by sbgStringCopy().

◆ sbgStringFirstValidChar()

SBG_COMMON_LIB_API const char * sbgStringFirstValidChar ( const char * pInputStr)

Skip all spacing characters from the beginning of a string.

Parameters
[in]pInputStrPointer on a read only string to trim.
Returns
Pointer to the first useful char.

References SBG_COMMON_LIB_API, and sbgStringFirstValidChar().

Referenced by sbgStringFirstValidChar().