kzs_string.hpp File Reference

Standard library string function wrappers. More...

#include <kanzi/core/legacy/kzs_types.hpp>
#include <kanzi/core/legacy/debug/kzs_error.hpp>
#include <kanzi/core/legacy/wrappers/kzs_arg.hpp>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>

Functions

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

Detailed Description

Standard library string function wrappers.

Copyright 2008-2017 by Rightware. All rights reserved.

Function Documentation

KZ_INLINE kzString kzsStrstr ( kzString  string1,
kzString  string2 
)

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

KZ_INLINE kzString kzsStrchr ( kzString  string1,
kzChar  ch 
)

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

KZ_INLINE void kzsStrcat ( kzMutableString  head,
kzString  tail 
)

Concatenate tail onto the end of head.

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 void kzsStrcpy ( kzMutableString  destination,
kzString  source 
)

Copy the source string to the destination.

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.

KZ_INLINE kzInt kzsAtoi ( kzString  string)

Convert a string into an integer.

KZ_INLINE kzFloat kzsAtof ( kzString  string)

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

KZ_INLINE kzInt kzsStrcmp ( kzString  first,
kzString  second 
)

Compare two strings.

Return value is 0 if the strings are equal.

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.

KZ_INLINE kzBool kzsIsSpace ( const kzChar  string)

Return true if the string is a whitespace.

KZ_INLINE kzBool kzsIsDigit ( kzChar  ch)

Return true if the character is a digit.

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
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.

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.

See also
kzcStringFormat for format information.
kzsError kzsStringFormatGetLength ( kzString  format,
KZ_CONST_ARGLIST kzArgList arguments,
kzUint out_length 
)

Get the formatted length of the string.

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.

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.

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.