Functions | Variables
xsstring.c File Reference
#include "xsstring.h"
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
Include dependency graph for xsstring.c:

Go to the source code of this file.

Functions

uint8_t const * advanceUtf8 (const uint8_t *p)
 
int compareChar (void const *a, void const *b)
 The function to use for comparing two items. More...
 
void copyChar (char *to, char const *from)
 The function to use for copying the data of from to to. More...
 
int32_t shiftUtf8 (int32_t t, uint8_t const *p, int bytes)
 
void swapChar (char *a, char *b)
 The function to use for swapping the data of two array items. More...
 
void XsString_append (XsString *thisPtr, XsString const *other)
 This function concatenates the other to this. More...
 
void XsString_assign (XsString *thisPtr, XsSize count, const char *src)
 Reinitializes the XsArray with space for count items and copies them from src. More...
 
void XsString_assignCharArray (XsString *thisPtr, const char *src)
 This function determines the size of src and copies the contents to the object. More...
 
void XsString_assignWCharArray (XsString *thisPtr, const wchar_t *src)
 This function determines the size of src and copies the contents to the object after converting it from a unicode string to a multibyte character string. More...
 
void XsString_construct (XsString *thisPtr)
 Initializes the XsString object as an empty string. More...
 
int XsString_contains (XsString const *thisPtr, XsString const *other, int caseSensitive, XsSize *offset)
 Returns whether this string contains other. More...
 
XsSize XsString_copyToWCharArray (const XsString *thisPtr, wchar_t *dest, XsSize size)
 This function copies the contents of the object to a unicode wchar_t array. More...
 
void XsString_destruct (XsString *thisPtr)
 Clears and frees memory allocated by the XsArray. More...
 
int XsString_empty (XsString const *thisPtr)
 Returns true when the supplied string is empty. More...
 
int XsString_endsWith (XsString const *thisPtr, XsString const *other, int caseSensitive)
 Returns whether this string ends with other. More...
 
void XsString_erase (XsString *thisPtr, XsSize index, XsSize count)
 Removes a count items from the list starting at index. More...
 
ptrdiff_t XsString_findSubStr (XsString const *thisPtr, XsString const *needle)
 Find the first occurrence of needle in the string. More...
 
void XsString_mid (XsString *thisPtr, XsString const *source, XsSize start, XsSize count)
 Copy a substring of the source string. More...
 
void XsString_push_back (XsString *thisPtr, char c)
 Append character c to the string. More...
 
void XsString_push_backWChar (XsString *thisPtr, wchar_t c)
 Append unicode character c to the string. More...
 
void XsString_replaceAll (XsString *thisPtr, XsString const *src, XsString const *dst)
 Replace all occurrences of src with dst, modifying thisPtr. More...
 
void XsString_resize (XsString *thisPtr, XsSize count)
 This function resizes the contained string to the desired size, while retaining its contents. More...
 
void XsString_reverse (XsString *thisPtr)
 Reverses the contents of the string. More...
 
void XsString_sort (XsString *thisPtr)
 Sorts the string. More...
 
int XsString_startsWith (XsString const *thisPtr, XsString const *other, int caseSensitive)
 Returns whether this string starts with other. More...
 
void XsString_trimmed (XsString *thisPtr, XsString const *source)
 Fills thisPtr with a copy of source with all its leading and trailing whitespace removed. More...
 
wchar_t XsString_utf8At (XsString const *thisPtr, XsSize index)
 The decoded UTF-8 character at index index in the UTF-8 encoded string. More...
 
XsSize XsString_utf8Len (XsString const *thisPtr)
 Returns the number of characters in a UTF-8 encoded string. More...
 

Variables

const XsArrayDescriptor g_xsStringDescriptor
 Descriptor for XsInt64Array. More...
 

Function Documentation

◆ advanceUtf8()

uint8_t const* advanceUtf8 ( const uint8_t *  p)

Definition at line 301 of file xsstring.c.

◆ compareChar()

int compareChar ( void const *  a,
void const *  b 
)

The function to use for comparing two items.

Parameters
aLeft hand side of comparison.
bRight hand side of comparison.
Returns
The function will return 0 when the items are equal. When greater/less comparison is possible, the function should return < 0 if a < b and > 0 if a > b.
Note
Specialization for char

Definition at line 101 of file xsstring.c.

◆ copyChar()

void copyChar ( char *  to,
char const *  from 
)

The function to use for copying the data of from to to.

Parameters
toPointer to item to copy to.
fromPointer to item to copy from.
Note
Specialization for char

Definition at line 94 of file xsstring.c.

◆ shiftUtf8()

int32_t shiftUtf8 ( int32_t  t,
uint8_t const *  p,
int  bytes 
)

Definition at line 342 of file xsstring.c.

◆ swapChar()

void swapChar ( char *  a,
char *  b 
)

The function to use for swapping the data of two array items.

Parameters
aPointer to first item to swap.
bPointer to second item to swap.
Note
Specialization for char

Definition at line 85 of file xsstring.c.

◆ XsString_append()

void XsString_append ( XsString thisPtr,
XsString const *  other 
)

This function concatenates the other to this.

Definition at line 257 of file xsstring.c.

◆ XsString_assign()

void XsString_assign ( XsString thisPtr,
XsSize  count,
const char *  src 
)

Reinitializes the XsArray with space for count items and copies them from src.

This function reinitializes the object reserving space for at least count items in the buffer. count may be 0. If src is not 0, count items will be copied from src. Previous data will be cleared automatically, but the reserved space will not be reduced.

Parameters
countthe number of items in src
srca pointer to an array of items
See also
XsArray_reserve
Note
Specialization for XsString

Definition at line 142 of file xsstring.c.

◆ XsString_assignCharArray()

void XsString_assignCharArray ( XsString thisPtr,
const char *  src 
)

This function determines the size of src and copies the contents to the object.

Definition at line 172 of file xsstring.c.

◆ XsString_assignWCharArray()

void XsString_assignWCharArray ( XsString thisPtr,
const wchar_t *  src 
)

This function determines the size of src and copies the contents to the object after converting it from a unicode string to a multibyte character string.

Definition at line 181 of file xsstring.c.

◆ XsString_construct()

void XsString_construct ( XsString thisPtr)

Initializes the XsString object as an empty string.

This function initializes the object as an empty string.

Definition at line 126 of file xsstring.c.

◆ XsString_contains()

int XsString_contains ( XsString const *  thisPtr,
XsString const *  other,
int  caseSensitive,
XsSize offset 
)

Returns whether this string contains other.

Parameters
otherThe string to match with this string
caseSensitiveWhether to compare case sensitive or not (case insensitive is the default)
offsetwhen not null, this will be filled with the offset at which other was found
Returns
true when the string contains the given string

Definition at line 460 of file xsstring.c.

◆ XsString_copyToWCharArray()

XsSize XsString_copyToWCharArray ( const XsString thisPtr,
wchar_t *  dest,
XsSize  size 
)

This function copies the contents of the object to a unicode wchar_t array.

Definition at line 215 of file xsstring.c.

◆ XsString_destruct()

void XsString_destruct ( XsString thisPtr)

Clears and frees memory allocated by the XsArray.

Note
After XsArray_destruct is called, the object is empty but valid, ie. it can be used as if XsArray_construct has been called on it.
Specialization for XsString

Definition at line 134 of file xsstring.c.

◆ XsString_empty()

int XsString_empty ( XsString const *  thisPtr)

Returns true when the supplied string is empty.

Returns
true when the string is empty

Definition at line 493 of file xsstring.c.

◆ XsString_endsWith()

int XsString_endsWith ( XsString const *  thisPtr,
XsString const *  other,
int  caseSensitive 
)

Returns whether this string ends with other.

Parameters
otherThe string to match with the end of this string
caseSensitiveWhether to compare case sensitive or not
Returns
true when the string ends with the given string

Definition at line 398 of file xsstring.c.

◆ XsString_erase()

void XsString_erase ( XsString thisPtr,
XsSize  index,
XsSize  count 
)

Removes a count items from the list starting at index.

Note
The function maintains the terminating 0 character

Definition at line 276 of file xsstring.c.

◆ XsString_findSubStr()

ptrdiff_t XsString_findSubStr ( XsString const *  thisPtr,
XsString const *  needle 
)

Find the first occurrence of needle in the string.

Parameters
needleThe string to find
Returns
The offset of needle or -1 if it was not found

Definition at line 537 of file xsstring.c.

◆ XsString_mid()

void XsString_mid ( XsString thisPtr,
XsString const *  source,
XsSize  start,
XsSize  count 
)

Copy a substring of the source string.

The function copies up to count characters from source to the string, starting at offset start

Parameters
sourceThe source to copy from
startThe offset of the first character to copy
countThe maximum number of characters to copy

Definition at line 568 of file xsstring.c.

◆ XsString_push_back()

void XsString_push_back ( XsString thisPtr,
char  c 
)

Append character c to the string.

Parameters
cThe character to append

Definition at line 292 of file xsstring.c.

◆ XsString_push_backWChar()

void XsString_push_backWChar ( XsString thisPtr,
wchar_t  c 
)

Append unicode character c to the string.

Parameters
cThe character to append

Definition at line 227 of file xsstring.c.

◆ XsString_replaceAll()

void XsString_replaceAll ( XsString thisPtr,
XsString const *  src,
XsString const *  dst 
)

Replace all occurrences of src with dst, modifying thisPtr.

Parameters
srcSubstring to search for
dstSubstring to use as replacement

Definition at line 586 of file xsstring.c.

◆ XsString_resize()

void XsString_resize ( XsString thisPtr,
XsSize  count 
)

This function resizes the contained string to the desired size, while retaining its contents.

Parameters
countThe desired size of the string. This excludes the terminating 0 character.
See also
XsArray_resize

Definition at line 243 of file xsstring.c.

◆ XsString_reverse()

void XsString_reverse ( XsString thisPtr)

Reverses the contents of the string.

This reverses the contents in-place

Note
This does not take into account utf-8 encoded characters

Definition at line 515 of file xsstring.c.

◆ XsString_sort()

void XsString_sort ( XsString thisPtr)

Sorts the string.

This function sorts using qsort

Definition at line 505 of file xsstring.c.

◆ XsString_startsWith()

int XsString_startsWith ( XsString const *  thisPtr,
XsString const *  other,
int  caseSensitive 
)

Returns whether this string starts with other.

Parameters
otherThe string to match with the start of this string
caseSensitiveWhether to compare case sensitive or not
Returns
true when the string starts with the given string

Definition at line 430 of file xsstring.c.

◆ XsString_trimmed()

void XsString_trimmed ( XsString thisPtr,
XsString const *  source 
)

Fills thisPtr with a copy of source with all its leading and trailing whitespace removed.

Parameters
sourceThe original string to use as source.

Definition at line 633 of file xsstring.c.

◆ XsString_utf8At()

wchar_t XsString_utf8At ( XsString const *  thisPtr,
XsSize  index 
)

The decoded UTF-8 character at index index in the UTF-8 encoded string.

http://en.wikipedia.org/wiki/Utf-8#Description

Parameters
indexThe index of the character to return.
Returns
the decoded UTF-8 character at index index in the UTF-8 encoded string

Definition at line 355 of file xsstring.c.

◆ XsString_utf8Len()

XsSize XsString_utf8Len ( XsString const *  thisPtr)

Returns the number of characters in a UTF-8 encoded string.

http://en.wikipedia.org/wiki/Utf-8#Description

Returns
the number of characters in a UTF-8 encoded string

Definition at line 325 of file xsstring.c.

Variable Documentation

◆ g_xsStringDescriptor

const XsArrayDescriptor g_xsStringDescriptor
Initial value:
=
{
sizeof(char),
XSEXPCASTITEMSWAP swapChar,
0,
XSEXPCASTITEMCOPY copyChar,
0,
XSEXPCASTITEMCOPY copyChar,
XSEXPCASTITEMCOMP compareChar,
XSEXPCASTRAWCOPY XsArray_rawCopy
}

Descriptor for XsInt64Array.

Definition at line 111 of file xsstring.c.

XsArray::XsArray_rawCopy
void XsArray_rawCopy(void *to, void const *from, XsSize count, XsSize iSize)
Copies items optimized in a direct way.
Definition: xsarray.c:707
copyChar
void copyChar(char *to, char const *from)
The function to use for copying the data of from to to.
Definition: xsstring.c:94
swapChar
void swapChar(char *a, char *b)
The function to use for swapping the data of two array items.
Definition: xsstring.c:85
compareChar
int compareChar(void const *a, void const *b)
The function to use for comparing two items.
Definition: xsstring.c:101


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:21