Loading...
Searching...
No Matches
CAPI_String.h
Go to the documentation of this file.
1/**************************************************************************************************
2 * This file is a part of Ultralight. *
3 * *
4 * See <https://ultralig.ht> for licensing and more. *
5 * *
6 * (C) 2024 Ultralight, Inc. *
7 **************************************************************************************************/
8
9///
10/// @file CAPI_String.h
11///
12/// Unicode string container (natively UTF-8).
13///
14/// `#include <Ultralight/CAPI/CAPI_String.h>`
15///
16/// This class is used to represent strings in Ultralight. It can be created from a variety of
17/// string types (ASCII, UTF-8, UTF-16) and accessed as a null-terminated UTF-8 buffer.
18///
19#ifndef ULTRALIGHT_CAPI_STRING_H
20#define ULTRALIGHT_CAPI_STRING_H
21
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/******************************************************************************
29 * String
30 *****************************************************************************/
31
32///
33/// Create string from null-terminated ASCII C-string.
34///
36
37///
38/// Create string from UTF-8 buffer.
39///
40ULExport ULString ulCreateStringUTF8(const char* str, size_t len);
41
42///
43/// Create string from UTF-16 buffer.
44///
46
47///
48/// Create string from copy of existing string.
49///
51
52///
53/// Destroy string (you should destroy any strings you explicitly Create).
54///
56
57///
58/// Get native UTF-8 buffer data (always null-terminated).
59///
61
62///
63/// Get length (in bytes) of the UTF-8 buffer data, not including null terminator.
64///
66
67///
68/// Whether this string is empty or not.
69///
71
72///
73/// Replaces the contents of 'str' with the contents of 'new_str'
74///
76
77///
78/// Replaces the contents of 'str' with the contents of a C-string.
79///
80ULExport void ulStringAssignCString(ULString str, const char* c_str);
81
82#ifdef __cplusplus
83} // extern "C"
84#endif
85
86#endif // ULTRALIGHT_CAPI_STRING_H
Various defines and utility functions for the C API.
unsigned short ULChar16
Definition CAPI_Defines.h:52
struct C_String * ULString
Definition CAPI_Defines.h:65
#define ULExport
Definition CAPI_Defines.h:38
ULExport char * ulStringGetData(ULString str)
Get native UTF-8 buffer data (always null-terminated).
ULExport ULString ulCreateStringUTF8(const char *str, size_t len)
Create string from UTF-8 buffer.
ULExport bool ulStringIsEmpty(ULString str)
Whether this string is empty or not.
ULExport void ulStringAssignCString(ULString str, const char *c_str)
Replaces the contents of 'str' with the contents of a C-string.
ULExport ULString ulCreateStringFromCopy(ULString str)
Create string from copy of existing string.
ULExport void ulDestroyString(ULString str)
Destroy string (you should destroy any strings you explicitly Create).
ULExport ULString ulCreateStringUTF16(ULChar16 *str, size_t len)
Create string from UTF-16 buffer.
ULExport ULString ulCreateString(const char *str)
Create string from null-terminated ASCII C-string.
ULExport void ulStringAssignString(ULString str, ULString new_str)
Replaces the contents of 'str' with the contents of 'new_str'.
ULExport size_t ulStringGetLength(ULString str)
Get length (in bytes) of the UTF-8 buffer data, not including null terminator.