Final Platform Layer  0.9.6-beta
Functions
String functions

This category contains tons of functions for converting/manipulating strings. More...

Functions

fpl_common_api char * fplCopyString (const char *source, char *dest, const size_t maxDestLen)
 Copies the given source string into a destination string. More...
 
fpl_common_api char * fplCopyStringLen (const char *source, const size_t sourceLen, char *dest, const size_t maxDestLen)
 Copies the given source string with a constrained length into a destination string. More...
 
fpl_common_api char * fplEnforcePathSeparator (char *path)
 Ensures that the given string always ends with a path separator. More...
 
fpl_common_api char * fplEnforcePathSeparatorLen (char *path, size_t maxPathLen)
 Ensures that the given string always ends with a path separator with length constrained. More...
 
fpl_common_api size_t fplFormatString (char *destBuffer, const size_t maxDestBufferLen, const char *format,...)
 Fills out the given destination string buffer with a formatted string, using the format specifier and variable arguments. More...
 
fpl_common_api size_t fplFormatStringArgs (char *destBuffer, const size_t maxDestBufferLen, const char *format, va_list argList)
 Fills out the given destination string buffer with a formatted string, using the format specifier and the arguments list. More...
 
fpl_common_api size_t fplGetStringLength (const char *str)
 Counts the number of characters without including the zero terminator. More...
 
fpl_common_api bool fplIsStringEqual (const char *a, const char *b)
 Compares two strings and returns a boolean indicating the equality. More...
 
fpl_common_api bool fplIsStringEqualLen (const char *a, const size_t aLen, const char *b, const size_t bLen)
 Compares two strings with constrained lengths and returns a boolean indicating the equality. More...
 
fpl_common_api bool fplIsStringMatchWildcard (const char *source, const char *wildcard)
 Matches the given string by the given wildcard and returns a boolean indicating the match. More...
 
fpl_common_api size_t fplS32ToString (const int32_t value, char *buffer, const size_t maxBufferLen)
 Converts the given 32-bit integer value into a string. More...
 
fpl_common_api char * fplStringAppend (const char *appended, char *buffer, size_t maxBufferLen)
 Appends the source string to the given buffer. More...
 
fpl_common_api char * fplStringAppendLen (const char *appended, const size_t appendedLen, char *buffer, size_t maxBufferLen)
 Appends the source string to the given buffer constrained by length. More...
 
fpl_common_api int32_t fplStringToS32 (const char *str)
 Converts the given string into a 32-bit integer. More...
 
fpl_common_api int32_t fplStringToS32Len (const char *str, const size_t len)
 Converts the given string into a 32-bit integer constrained by string length. More...
 
fpl_platform_api size_t fplUTF8StringToWideString (const char *utf8Source, const size_t utf8SourceLen, wchar_t *wideDest, const size_t maxWideDestLen)
 Converts the given 8-bit UTF-8 source ANSI string with length in a 16-bit wide string. More...
 
fpl_platform_api size_t fplWideStringToUTF8String (const wchar_t *wideSource, const size_t wideSourceLen, char *utf8Dest, const size_t maxUtf8DestLen)
 Converts the given 16-bit source wide string with length in an 8-bit UTF-8 ANSI string. More...
 

Detailed Description

This category contains tons of functions for converting/manipulating strings.

Function Documentation

◆ fplCopyString()

fpl_common_api char* fplCopyString ( const char *  source,
char *  dest,
const size_t  maxDestLen 
)

Copies the given source string into a destination string.

Parameters
sourceThe source string
destThe destination string buffer
maxDestLenThe total number of characters available in the destination buffer
Returns
Returns the pointer to the last written character or fpl_null.
Note
Null terminator is included always.

◆ fplCopyStringLen()

fpl_common_api char* fplCopyStringLen ( const char *  source,
const size_t  sourceLen,
char *  dest,
const size_t  maxDestLen 
)

Copies the given source string with a constrained length into a destination string.

Parameters
sourceThe source string
sourceLenThe number of characters to copy
destThe destination string buffer
maxDestLenThe total number of characters available in the destination buffer
Returns
Returns the pointer to the last written character or fpl_null.
Note
Null terminator is included always.

◆ fplEnforcePathSeparator()

fpl_common_api char* fplEnforcePathSeparator ( char *  path)

Ensures that the given string always ends with a path separator.

Parameters
pathThe path string
Returns
Returns a pointer to the last written character or fpl_null.
Note
This function is unsafe as it does not know the maximum length of the string!

◆ fplEnforcePathSeparatorLen()

fpl_common_api char* fplEnforcePathSeparatorLen ( char *  path,
size_t  maxPathLen 
)

Ensures that the given string always ends with a path separator with length constrained.

Parameters
pathThe target path string
maxPathLenThe max length of the target path
Returns
Returns a pointer to the last written character or fpl_null.

◆ fplFormatString()

fpl_common_api size_t fplFormatString ( char *  destBuffer,
const size_t  maxDestBufferLen,
const char *  format,
  ... 
)

Fills out the given destination string buffer with a formatted string, using the format specifier and variable arguments.

Parameters
destBufferThe destination string buffer
maxDestBufferLenThe total number of characters available in the destination buffer
formatThe string format
...The variable arguments
Returns
Returns the number of required/written characters, excluding the null-terminator
Note
This is most likely just a wrapper call to vsnprintf()

◆ fplFormatStringArgs()

fpl_common_api size_t fplFormatStringArgs ( char *  destBuffer,
const size_t  maxDestBufferLen,
const char *  format,
va_list  argList 
)

Fills out the given destination string buffer with a formatted string, using the format specifier and the arguments list.

Parameters
destBufferThe destination string buffer
maxDestBufferLenThe total number of characters available in the destination buffer
formatThe string format
argListThe arguments list
Returns
Returns the number of required/written characters, excluding the null-terminator
Note
This is most likely just a wrapper call to vsnprintf()

◆ fplGetStringLength()

fpl_common_api size_t fplGetStringLength ( const char *  str)

Counts the number of characters without including the zero terminator.

Parameters
strThe string source
Returns
Returns the number of characters of the given string or zero when the input string is fpl_null.

◆ fplIsStringEqual()

fpl_common_api bool fplIsStringEqual ( const char *  a,
const char *  b 
)

Compares two strings and returns a boolean indicating the equality.

Parameters
aThe first string
bThe second string
Returns
Returns true when both strings are equal, false otherwise.

◆ fplIsStringEqualLen()

fpl_common_api bool fplIsStringEqualLen ( const char *  a,
const size_t  aLen,
const char *  b,
const size_t  bLen 
)

Compares two strings with constrained lengths and returns a boolean indicating the equality.

Parameters
aThe first string
aLenThe number of characters for the first string
bThe second string
bLenThe number of characters for the second string
Returns
Returns true when both strings are equal, false otherwise.
Note
Len parameters do not include the null-terminator!

◆ fplIsStringMatchWildcard()

fpl_common_api bool fplIsStringMatchWildcard ( const char *  source,
const char *  wildcard 
)

Matches the given string by the given wildcard and returns a boolean indicating the match.

Parameters
sourceThe source string
wildcardThe wildcard string
Returns
Returns true when source string matches the wildcard, false otherwise.

◆ fplS32ToString()

fpl_common_api size_t fplS32ToString ( const int32_t  value,
char *  buffer,
const size_t  maxBufferLen 
)

Converts the given 32-bit integer value into a string.

Parameters
valueThe source value
maxBufferLenThe maximum length of the buffer
bufferThe target buffer
Returns
Returns the number of required/written characters, excluding the null-terminator

◆ fplStringAppend()

fpl_common_api char* fplStringAppend ( const char *  appended,
char *  buffer,
size_t  maxBufferLen 
)

Appends the source string to the given buffer.

Parameters
appendedThe appending source string
bufferThe target buffer
maxBufferLenThe max length of the target buffer
Returns
Returns a pointer to the last written character or fpl_null.

◆ fplStringAppendLen()

fpl_common_api char* fplStringAppendLen ( const char *  appended,
const size_t  appendedLen,
char *  buffer,
size_t  maxBufferLen 
)

Appends the source string to the given buffer constrained by length.

Parameters
appendedThe appending source string
appendedLenThe length of the appending source string
bufferThe target buffer
maxBufferLenThe max length of the target buffer
Returns
Returns a pointer to the last written character or fpl_null.

◆ fplStringToS32()

fpl_common_api int32_t fplStringToS32 ( const char *  str)

Converts the given string into a 32-bit integer.

Parameters
strThe source string
Returns
Returns a 32-bit integer converted from the given string

◆ fplStringToS32Len()

fpl_common_api int32_t fplStringToS32Len ( const char *  str,
const size_t  len 
)

Converts the given string into a 32-bit integer constrained by string length.

Parameters
strThe source string
lenThe length of the source string
Returns
Returns a 32-bit integer converted from the given string

◆ fplUTF8StringToWideString()

fpl_platform_api size_t fplUTF8StringToWideString ( const char *  utf8Source,
const size_t  utf8SourceLen,
wchar_t *  wideDest,
const size_t  maxWideDestLen 
)

Converts the given 8-bit UTF-8 source ANSI string with length in a 16-bit wide string.

Parameters
utf8SourceThe 8-bit source ANSI string
utf8SourceLenThe number of characters of the UTF-8 source ANSI string
wideDestThe 16-bit destination wide string buffer
maxWideDestLenThe total number of characters available in the destination buffer
Returns
Returns the number of required/written characters, excluding the null-terminator
Note
Null terminator is included always.

◆ fplWideStringToUTF8String()

fpl_platform_api size_t fplWideStringToUTF8String ( const wchar_t *  wideSource,
const size_t  wideSourceLen,
char *  utf8Dest,
const size_t  maxUtf8DestLen 
)

Converts the given 16-bit source wide string with length in an 8-bit UTF-8 ANSI string.

Parameters
wideSourceThe 16-bit source wide string
wideSourceLenThe number of characters of the source wide string
utf8DestThe 8-bit destination ANSI string buffer
maxUtf8DestLenThe total number of characters available in the destination buffer
Returns
Returns the number of required/written characters, excluding the null-terminator
Note
Null terminator is included always.