#include <inttypes.h>
#include <stddef.h>
#include <libwapcaplet/libwapcaplet.h>
#include <dom/functypes.h>
#include <dom/core/exceptions.h>
Go to the source code of this file.
|
void | dom_string_destroy (dom_string *str) |
|
dom_exception | dom_string_create (const uint8_t *ptr, size_t len, dom_string **str) |
|
dom_exception | dom_string_create_interned (const uint8_t *ptr, size_t len, dom_string **str) |
|
dom_exception | dom_string_intern (dom_string *str, struct lwc_string_s **lwcstr) |
|
bool | dom_string_isequal (const dom_string *s1, const dom_string *s2) |
|
bool | dom_string_caseless_isequal (const dom_string *s1, const dom_string *s2) |
|
bool | dom_string_lwc_isequal (const dom_string *s1, lwc_string *s2) |
|
bool | dom_string_caseless_lwc_isequal (const dom_string *s1, lwc_string *s2) |
|
uint32_t | dom_string_index (dom_string *str, uint32_t chr) |
|
uint32_t | dom_string_rindex (dom_string *str, uint32_t chr) |
|
uint32_t | dom_string_length (dom_string *str) |
|
const char * | dom_string_data (const dom_string *str) |
|
size_t | dom_string_byte_length (const dom_string *str) |
|
dom_exception | dom_string_at (dom_string *str, uint32_t index, uint32_t *ch) |
|
dom_exception | dom_string_concat (dom_string *s1, dom_string *s2, dom_string **result) |
|
dom_exception | dom_string_substr (dom_string *str, uint32_t i1, uint32_t i2, dom_string **result) |
|
dom_exception | dom_string_insert (dom_string *target, dom_string *source, uint32_t offset, dom_string **result) |
|
dom_exception | dom_string_replace (dom_string *target, dom_string *source, uint32_t i1, uint32_t i2, dom_string **result) |
|
dom_exception | dom_string_toupper (dom_string *source, bool ascii_only, dom_string **upper) |
|
dom_exception | dom_string_tolower (dom_string *source, bool ascii_only, dom_string **lower) |
|
uint32_t | dom_string_hash (dom_string *str) |
|
◆ dom_string
typedef struct dom_string dom_string |
◆ dom_string_at()
Get the UCS4 character at position index
- Parameters
-
index | The position of the charater |
ch | The UCS4 character |
- Returns
- DOM_NO_ERR on success, appropriate dom_exception on failure.
◆ dom_string_byte_length()
size_t dom_string_byte_length |
( |
const dom_string * | str | ) |
|
◆ dom_string_caseless_isequal()
Case insensitively compare two DOM strings
- Parameters
-
s1 | The first string to compare |
s2 | The second string to compare |
- Returns
- true if strings match, false otherwise
◆ dom_string_caseless_lwc_isequal()
bool dom_string_caseless_lwc_isequal |
( |
const dom_string * | s1, |
|
|
lwc_string * | s2 ) |
Case insensitively compare DOM string with lwc_string
- Parameters
-
s1 | The first string to compare |
s2 | The second string to compare |
- Returns
- true if strings match, false otherwise
Returns false if either are NULL.
◆ dom_string_concat()
Concatenate two dom strings
- Parameters
-
s1 | The first string |
s2 | The second string |
result | Pointer to location to receive result |
- Returns
- DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion
The returned string will be referenced. The client should dereference it once it has finished with it.
◆ dom_string_create()
Create a DOM string from a string of characters
- Parameters
-
ptr | Pointer to string of characters |
len | Length, in bytes, of string of characters |
str | Pointer to location to receive result |
- Returns
- DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion
The returned string will already be referenced, so there is no need to explicitly reference it.
The string of characters passed in will be copied for use by the returned DOM string.
◆ dom_string_create_interned()
Create an interned DOM string from a string of characters
- Parameters
-
ptr | Pointer to string of characters |
len | Length, in bytes, of string of characters |
str | Pointer to location to receive result |
- Returns
- DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion
The returned string will already be referenced, so there is no need to explicitly reference it.
The string of characters passed in will be copied for use by the returned DOM string.
◆ dom_string_data()
const char * dom_string_data |
( |
const dom_string * | str | ) |
|
Get the raw character data of the dom_string.
- Note
- : This function is just provided for the convenience of accessing the raw C string character, no change on the result string is allowed.
Get the raw character data of the dom_string.
- Parameters
-
- Returns
- The C string pointer
- Note
- : This function is just provided for the convenience of accessing the raw C string character, no change on the result string is allowed.
◆ dom_string_destroy()
◆ dom_string_hash()
Calculate a hash value from a dom string
- Parameters
-
str | The string to calculate a hash of |
- Returns
- The hash value associated with the string
◆ dom_string_index()
uint32_t dom_string_index |
( |
dom_string * | str, |
|
|
uint32_t | chr ) |
Get the index of the first occurrence of a character in a dom string
- Parameters
-
str | The string to search in |
chr | UCS4 value to look for |
- Returns
- Character index of found character, or -1 if none found
◆ dom_string_insert()
Insert data into a dom string at the given location
- Parameters
-
target | Pointer to string to insert into |
source | Pointer to string to insert |
offset | Character offset of location to insert at |
result | Pointer to location to receive result |
- Returns
- DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion, DOM_INDEX_SIZE_ERR if ::offset > len(::target).
The returned string will have its reference count increased. The client should dereference it once it has finished with it.
◆ dom_string_intern()
Make the dom_string be interned
- Parameters
-
str | The dom_string to be interned |
lwcstr | The result lwc_string
|
- Returns
- DOM_NO_ERR on success, appropriate dom_exception on failure.
◆ dom_string_isequal()
Case sensitively compare two DOM strings
- Parameters
-
s1 | The first string to compare |
s2 | The second string to compare |
- Returns
- true if strings match, false otherwise
◆ dom_string_length()
Get the length, in characters, of a dom string
- Parameters
-
str | The string to measure the length of |
- Returns
- The length of the string, in characters
◆ dom_string_lwc_isequal()
bool dom_string_lwc_isequal |
( |
const dom_string * | s1, |
|
|
lwc_string * | s2 ) |
Case sensitively compare DOM string with lwc_string
- Parameters
-
s1 | The first string to compare |
s2 | The second string to compare |
- Returns
- true if strings match, false otherwise
Returns false if either are NULL.
◆ dom_string_replace()
Replace a section of a dom string
- Parameters
-
target | Pointer to string of which to replace a section |
source | Pointer to replacement string |
i1 | Character index of start of region to replace |
i2 | Character index of end of region to replace |
result | Pointer to location to receive result |
- Returns
- DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion.
The returned string will have its reference count increased. The client should dereference it once it has finished with it.
◆ dom_string_rindex()
uint32_t dom_string_rindex |
( |
dom_string * | str, |
|
|
uint32_t | chr ) |
Get the index of the last occurrence of a character in a dom string
- Parameters
-
str | The string to search in |
chr | UCS4 value to look for |
- Returns
- Character index of found character, or -1 if none found
◆ dom_string_substr()
Extract a substring from a dom string
- Parameters
-
str | The string to extract from |
i1 | The character index of the start of the substring |
i2 | The character index of the end of the substring |
result | Pointer to location to receive result |
- Returns
- DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion
The returned string will have its reference count increased. The client should dereference it once it has finished with it.
◆ dom_string_tolower()
Convert the given string to lowercase
- Parameters
-
source | |
ascii_only | Whether to only convert [a-z] to [A-Z] |
lower | Result pointer for lowercase string. Caller owns ref |
- Returns
- DOM_NO_ERR on success.
- Note
- Right now, will return DOM_NOT_SUPPORTED_ERR if ascii_only is false.
◆ dom_string_toupper()
Convert the given string to uppercase
- Parameters
-
source | |
ascii_only | Whether to only convert [a-z] to [A-Z] |
upper | Result pointer for uppercase string. Caller owns ref |
- Returns
- DOM_NO_ERR on success.
- Note
- Right now, will return DOM_NOT_SUPPORTED_ERR if ascii_only is false.