libdom
|
#include <assert.h>
#include <ctype.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include <parserutils/charset/utf8.h>
#include "core/string.h"
#include "core/document.h"
#include "utils/utils.h"
Classes | |
struct | dom_string_internal |
Typedefs | |
typedef struct dom_string_internal | dom_string_internal |
Enumerations | |
enum | dom_string_type { DOM_STRING_CDATA = 0 , DOM_STRING_INTERNED = 1 } |
typedef struct dom_string_internal dom_string_internal |
A DOM string
Strings are reference counted so destruction is performed correctly.
enum dom_string_type |
dom_exception _dom_exception_from_lwc_error | ( | lwc_error | err | ) |
Convert a lwc_error to a dom_exception
err | The input lwc_error |
dom_exception dom_string_at | ( | dom_string * | str, |
uint32_t | index, | ||
uint32_t * | ch ) |
Get the UCS4 character at position index
index | The position of the charater |
ch | The UCS4 character |
size_t dom_string_byte_length | ( | const dom_string * | str | ) |
Get the byte length of this dom_string
str | The dom_string object |
bool dom_string_caseless_isequal | ( | const dom_string * | s1, |
const dom_string * | s2 ) |
Case insensitively compare two DOM strings
s1 | The first string to compare |
s2 | The second string to compare |
bool dom_string_caseless_lwc_isequal | ( | const dom_string * | s1, |
lwc_string * | s2 ) |
Case insensitively compare DOM string with lwc_string
s1 | The first string to compare |
s2 | The second string to compare |
Returns false if either are NULL.
dom_exception dom_string_concat | ( | dom_string * | s1, |
dom_string * | s2, | ||
dom_string ** | result ) |
Concatenate two dom strings
s1 | The first string |
s2 | The second string |
result | Pointer to location to receive result |
The returned string will be referenced. The client should dereference it once it has finished with it.
dom_exception dom_string_create | ( | const uint8_t * | ptr, |
size_t | len, | ||
dom_string ** | str ) |
Create a DOM string from a string of characters
ptr | Pointer to string of characters |
len | Length, in bytes, of string of characters |
str | Pointer to location to receive result |
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_exception dom_string_create_interned | ( | const uint8_t * | ptr, |
size_t | len, | ||
dom_string ** | str ) |
Create an interned DOM string from a string of characters
ptr | Pointer to string of characters |
len | Length, in bytes, of string of characters |
str | Pointer to location to receive result |
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.
const char * dom_string_data | ( | const dom_string * | str | ) |
Get the raw character data of the dom_string.
str | The dom_string object |
void dom_string_destroy | ( | dom_string * | str | ) |
uint32_t dom_string_hash | ( | dom_string * | str | ) |
Calculate a hash value from a dom string
str | The string to calculate a hash of |
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
str | The string to search in |
chr | UCS4 value to look for |
dom_exception dom_string_insert | ( | dom_string * | target, |
dom_string * | source, | ||
uint32_t | offset, | ||
dom_string ** | result ) |
Insert data into a dom string at the given location
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 |
The returned string will have its reference count increased. The client should dereference it once it has finished with it.
dom_exception dom_string_intern | ( | dom_string * | str, |
struct lwc_string_s ** | lwcstr ) |
Make the dom_string be interned
str | The dom_string to be interned |
lwcstr | The result lwc_string |
bool dom_string_isequal | ( | const dom_string * | s1, |
const dom_string * | s2 ) |
Case sensitively compare two DOM strings
s1 | The first string to compare |
s2 | The second string to compare |
uint32_t dom_string_length | ( | dom_string * | str | ) |
Get the length, in characters, of a dom string
str | The string to measure the length of |
bool dom_string_lwc_isequal | ( | const dom_string * | s1, |
lwc_string * | s2 ) |
Case sensitively compare DOM string with lwc_string
s1 | The first string to compare |
s2 | The second string to compare |
Returns false if either are NULL.
dom_exception dom_string_replace | ( | dom_string * | target, |
dom_string * | source, | ||
uint32_t | i1, | ||
uint32_t | i2, | ||
dom_string ** | result ) |
Replace a section of a dom string
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 |
The returned string will have its reference count increased. The client should dereference it once it has finished with it.
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
str | The string to search in |
chr | UCS4 value to look for |
dom_exception dom_string_substr | ( | dom_string * | str, |
uint32_t | i1, | ||
uint32_t | i2, | ||
dom_string ** | result ) |
Extract a substring from a dom string
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 |
The returned string will have its reference count increased. The client should dereference it once it has finished with it.
dom_exception dom_string_tolower | ( | dom_string * | source, |
bool | ascii_only, | ||
dom_string ** | lower ) |
Convert the given string to lowercase
source | |
ascii_only | Whether to only convert [a-z] to [A-Z] |
lower | Result pointer for lowercase string. Caller owns ref |
dom_exception dom_string_toupper | ( | dom_string * | source, |
bool | ascii_only, | ||
dom_string ** | upper ) |
Convert the given string to uppercase
source | |
ascii_only | Whether to only convert [a-z] to [A-Z] |
upper | Result pointer for uppercase string. Caller owns ref |
dom_exception dom_string_whitespace_op | ( | dom_string * | s, |
enum dom_whitespace_op | op, | ||
dom_string ** | ret ) |
Perform whitespace operations on given string
s | Given string |
op | Whitespace operation(s) to perform |
ret | New string with whitespace ops performed. Caller owns ref |