libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_string.h
Go to the documentation of this file.
1/*! \file
2 * \brief Low-level C string and character-based functions
3 * \ingroup strings
4 *
5 * This file contains the lowest-level string API for working
6 * with individual characters or C strings.
7 *
8 * \note
9 * Typically, it's much easier to work with higher-level string
10 * APIs built around these utilities.
11 *
12 * \sa GblStringView, GblStringRef, GblStringBuffer
13 *
14 * \todo
15 * - gblStrdupa()
16 * - gblStrndupa()
17 * - Unit tests
18 * - Consider moving bulk of GblStringView operations
19 *
20 * \author 2023 Falco Girgis
21 * \copyright MIT License
22 */
23
24#ifndef GIMBAL_STRING_H
25#define GIMBAL_STRING_H
26
27#include "../core/gimbal_decls.h"
28
30
31/*! \name Per-Character
32 * \brief Methods for dealing with individual ASCII characters
33 * @{
34 */
35//! Returns the numeric value of the given base-10 ASCII digit
37//! Returns the numeric value of the given hexadecimal ASCII digit
39//! @}
40
41/*! \name C Strings
42 * \brief Methods for operating on NULL-terminated C strings
43 * @{
44 */
45//! Returns the length of the given NULL-terminated C string or \p len, if it's less than it's length
46GBL_EXPORT size_t gblStrnlen (const char* pStr1,
47 size_t length) GBL_NOEXCEPT;
48//! Compares the two NULL-terminaed C strings without case-sensitivity
49GBL_EXPORT int gblStrCaseCmp (const char* pStr1,
50 const char* pStr2) GBL_NOEXCEPT;
51//! Compares up to \p length bytes of the two C strings without case-sensitivity
52GBL_EXPORT int gblStrnCaseCmp (const char* pStr1,
53 const char* pStr2,
54 size_t length) GBL_NOEXCEPT;
55//! Searches for the beginning of the \p pSub substring within \p pStr
56GBL_EXPORT char* gblStrCaseStr (const char* pStr,
57 const char* pSub) GBL_NOEXCEPT;
58//! Duplicates the given string, returning a new one allocatedon the heap
59GBL_EXPORT char* gblStrdup (const char* pString) GBL_NOEXCEPT;
60//! Duplicates up to \p length bytes of the given string on the heap
61GBL_EXPORT char* gblStrndup (const char* pString,
62 size_t length) GBL_NOEXCEPT;
63//! Reverses up to \p length bytes within the given character array
64GBL_EXPORT char* gblStrnReverse (char* pString,
65 size_t length) GBL_NOEXCEPT;
66//! @}
67
69
70#endif // GIMBAL_STRING_H
#define GBL_NOEXCEPT
#define GBL_DECLS_BEGIN
#define GBL_EXPORT
int gblStrCaseCmp(const char *pStr1, const char *pStr2)
Compares the two NULL-terminaed C strings without case-sensitivity.
char * gblStrnReverse(char *pString, size_t length)
Reverses up to length bytes within the given character array.
int gblAsciiHexDigitValue(char c)
Returns the numeric value of the given hexadecimal ASCII digit.
char * gblStrndup(const char *pString, size_t length)
Duplicates up to length bytes of the given string on the heap.
char * gblStrdup(const char *pString)
Duplicates the given string, returning a new one allocatedon the heap.
int gblAsciiDigitValue(char c)
Returns the numeric value of the given base-10 ASCII digit.
int gblStrnCaseCmp(const char *pStr1, const char *pStr2, size_t length)
Compares up to length bytes of the two C strings without case-sensitivity.
size_t gblStrnlen(const char *pStr1, size_t length)
Returns the length of the given NULL-terminated C string or len, if it's less than it's length.
char * gblStrCaseStr(const char *pStr, const char *pSub)
Searches for the beginning of the pSub substring within pStr.