Kanzi 3.9.10
kzs_string.hpp File Reference

Standard library string function wrappers. More...

Functions

KZ_INLINE kzFloat kzsAtof (kzString string)
 Convert a string into a float using current locale to determine decimal separator.
 
KZ_INLINE kzInt kzsAtoi (kzString string)
 Convert a string into an integer.
 
KZ_INLINE kzBool kzsIsDigit (kzChar ch)
 Return true if the character is a digit.
 
KZ_INLINE kzBool kzsIsSpace (const kzChar string)
 Return true if the string is a whitespace.
 
KZ_INLINE void kzsStrcat (kzMutableString head, kzString tail)
 Concatenate tail onto the end of head.
 
KZ_INLINE kzString kzsStrchr (kzString string1, kzChar ch)
 Return a pointer to the first occurrence of ch in string1.
 
KZ_INLINE kzInt kzsStrcmp (kzString first, kzString second)
 Compare two strings.
 
KZ_INLINE void kzsStrcpy (kzMutableString destination, kzString source)
 Copy the source string to the destination.
 
kzBool kzsStringFindNextCharacter (kzString string, kzChar ch, kzUint startIndex, kzUint *out_index)
 Finds the next position where given character is located in the given string.
 
kzsError kzsStringFormatGetLength (kzString format, KZ_CONST_ARGLIST kzArgList *arguments, kzUint *out_length)
 Get the formatted length of the string.
 
kzsError kzsStringFormatList (kzMutableString string, kzUint length, kzString format, KZ_CONST_ARGLIST kzArgList *arguments)
 vsnprintf()-like string formatter.
 
kzUnicodeChar kzsStringGetUnicodeCharacter (kzString string, kzUint *out_byteReadCount)
 Returns the unicode code point at the beginning of given string in UTF-8 format.
 
kzUint kzsStringGetUTF8ByteCount (kzUnicodeChar codePoint)
 Returns the number of bytes the given unicode code point requires in UTF-8 encoding.
 
kzUint kzsStringWriteUnicodeCharacter (kzMutableString string, kzUint bufferSize, kzUnicodeChar character)
 Encodes the given unicode character in UTF-8 format to the given string.
 
KZ_INLINE kzUint kzsStrlen (kzString string)
 Return the length of the string.
 
KZ_INLINE void kzsStrncat (kzMutableString head, kzString tail, kzUint count)
 Concatenate tail onto the end of head with at most count characters.
 
KZ_INLINE kzInt kzsStrncmp (kzString first, kzString second, kzUint n)
 Compare the n first characters of two strings.
 
KZ_INLINE void kzsStrncpy (kzMutableString destination, kzString source, kzUint n)
 Copy the source string to the destination.
 
KZ_INLINE kzString kzsStrstr (kzString string1, kzString string2)
 Return a pointer to the first occurrence of string2 in string1.
 
KZ_INLINE kzString kzsStrtok (kzMutableString string, kzString delimiters)
 Splits string into tokens.
 

Detailed Description

Standard library string function wrappers.

Copyright 2008-2017 by Rightware. All rights reserved.

Function Documentation

◆ kzsStrstr()

KZ_INLINE kzString kzsStrstr ( kzString string1,
kzString string2 )

Return a pointer to the first occurrence of string2 in string1.

◆ kzsStrchr()

KZ_INLINE kzString kzsStrchr ( kzString string1,
kzChar ch )

Return a pointer to the first occurrence of ch in string1.

◆ kzsStrcat()

KZ_INLINE void kzsStrcat ( kzMutableString head,
kzString tail )

Concatenate tail onto the end of head.

◆ kzsStrlen()

KZ_INLINE kzUint kzsStrlen ( kzString string)

Return the length of the string.

◆ kzsStrncat()

KZ_INLINE void kzsStrncat ( kzMutableString head,
kzString tail,
kzUint count )

Concatenate tail onto the end of head with at most count characters.

◆ kzsStrcpy()

KZ_INLINE void kzsStrcpy ( kzMutableString destination,
kzString source )

Copy the source string to the destination.

◆ kzsStrncpy()

KZ_INLINE void kzsStrncpy ( kzMutableString destination,
kzString source,
kzUint n )

Copy the source string to the destination.

Warning: This function does not zero-terminate the destination.

◆ kzsAtoi()

KZ_INLINE kzInt kzsAtoi ( kzString string)

Convert a string into an integer.

◆ kzsAtof()

KZ_INLINE kzFloat kzsAtof ( kzString string)

Convert a string into a float using current locale to determine decimal separator.

◆ kzsStrcmp()

KZ_INLINE kzInt kzsStrcmp ( kzString first,
kzString second )

Compare two strings.

Return value is 0 if the strings are equal.

◆ kzsStrncmp()

KZ_INLINE kzInt kzsStrncmp ( kzString first,
kzString second,
kzUint n )

Compare the n first characters of two strings.

Return value is 0 if the strings are equal.

◆ kzsIsSpace()

KZ_INLINE kzBool kzsIsSpace ( const kzChar string)

Return true if the string is a whitespace.

◆ kzsIsDigit()

KZ_INLINE kzBool kzsIsDigit ( kzChar ch)

Return true if the character is a digit.

◆ kzsStrtok()

KZ_INLINE kzString kzsStrtok ( kzMutableString string,
kzString delimiters )

Splits string into tokens.

On a first call, the function expects a string as argument for string, whose first character is used as the starting location to scan for tokens. In subsequent calls, the function expects a null pointer and uses the position right after the end of last token as the new starting location for scanning.

Parameters
stringString to split.
delimitersDelimiters used to split the string to tokens
Returns
Returns a pointer to the last token found in string

◆ kzsStringFindNextCharacter()

kzBool kzsStringFindNextCharacter ( kzString string,
kzChar ch,
kzUint startIndex,
kzUint * out_index )

Finds the next position where given character is located in the given string.

Search is started from the given index, which must be smaller than the length of the string. Returns false if the character is not found.

◆ kzsStringFormatList()

kzsError kzsStringFormatList ( kzMutableString string,
kzUint length,
kzString format,
KZ_CONST_ARGLIST kzArgList * arguments )

vsnprintf()-like string formatter.

Format parameter specifies how the resulting string is formatted. Arguments parameter provides the formatting arguments as variable arguments list.

◆ kzsStringFormatGetLength()

kzsError kzsStringFormatGetLength ( kzString format,
KZ_CONST_ARGLIST kzArgList * arguments,
kzUint * out_length )

Get the formatted length of the string.

◆ kzsStringGetUTF8ByteCount()

kzUint kzsStringGetUTF8ByteCount ( kzUnicodeChar codePoint)

Returns the number of bytes the given unicode code point requires in UTF-8 encoding.

◆ kzsStringWriteUnicodeCharacter()

kzUint kzsStringWriteUnicodeCharacter ( kzMutableString string,
kzUint bufferSize,
kzUnicodeChar character )

Encodes the given unicode character in UTF-8 format to the given string.

Number of bytes written is returned. 0 is returned, if the given character is invalid unicode code point. The string must be preallocated and have enough space for the necessary UTG-8 bytes of the unicode character.

◆ kzsStringGetUnicodeCharacter()

kzUnicodeChar kzsStringGetUnicodeCharacter ( kzString string,
kzUint * out_byteReadCount )

Returns the unicode code point at the beginning of given string in UTF-8 format.

Number of bytes read for the unicode code point is stored in out_byteReadCount.