ds: formatting tweaks
This commit is contained in:
+213
-62
@@ -1,7 +1,7 @@
|
||||
#include <ctype.h>
|
||||
#include <fx/core/stream.h>
|
||||
#include <fx/core/stringstream.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
@@ -27,7 +27,8 @@ enum iterator_mode {
|
||||
|
||||
struct fx_string_p {
|
||||
/* length of string in bytes, not including null-terminator.
|
||||
* a multi-byte utf-8 codepoint will be counted as multiple bytes here */
|
||||
* a multi-byte utf-8 codepoint will be counted as multiple bytes here
|
||||
*/
|
||||
unsigned int s_len;
|
||||
/* length of string in codepoints, not including null-terminator.
|
||||
* a multi-byte utf-8 codepoint will be counted as one codepoint here */
|
||||
@@ -76,8 +77,11 @@ static char *string_ptr(const struct fx_string_p *str)
|
||||
}
|
||||
|
||||
static enum fx_status convert_codepoint_range_to_byte_range(
|
||||
const struct fx_string_p *str, size_t cp_start, size_t cp_length,
|
||||
size_t *out_byte_start, size_t *out_byte_length)
|
||||
const struct fx_string_p *str,
|
||||
size_t cp_start,
|
||||
size_t cp_length,
|
||||
size_t *out_byte_start,
|
||||
size_t *out_byte_length)
|
||||
{
|
||||
const char *s = string_ptr(str);
|
||||
size_t byte_offset = 0, byte_length = 0;
|
||||
@@ -146,7 +150,9 @@ static char *get_next_codepoint(struct fx_string_p *str, char *this_codepoint)
|
||||
return this_codepoint + len;
|
||||
}
|
||||
|
||||
static char *get_previous_codepoint(struct fx_string_p *str, char *this_codepoint)
|
||||
static char *get_previous_codepoint(
|
||||
struct fx_string_p *str,
|
||||
char *this_codepoint)
|
||||
{
|
||||
char *start = string_ptr(str);
|
||||
char *end = this_codepoint - 1;
|
||||
@@ -260,7 +266,8 @@ static int string_change_capacity(struct fx_string_p *str, size_t capacity)
|
||||
}
|
||||
|
||||
if (!is_now_inline) {
|
||||
/* string was inline, and now large enough to require a buffer. */
|
||||
/* string was inline, and now large enough to require a buffer.
|
||||
*/
|
||||
return string_make_large(str, capacity);
|
||||
}
|
||||
|
||||
@@ -322,7 +329,10 @@ static fx_status string_reserve(struct fx_string_p *str, size_t capacity)
|
||||
}
|
||||
|
||||
static enum fx_status replace_ansi(
|
||||
struct fx_string_p *str, size_t start, size_t length, const char *new_data)
|
||||
struct fx_string_p *str,
|
||||
size_t start,
|
||||
size_t length,
|
||||
const char *new_data)
|
||||
{
|
||||
fx_status status = FX_SUCCESS;
|
||||
size_t new_data_len = strlen(new_data);
|
||||
@@ -361,7 +371,10 @@ static enum fx_status replace_ansi(
|
||||
}
|
||||
|
||||
static enum fx_status replace_utf8(
|
||||
struct fx_string_p *str, size_t start, size_t length, const char *new_data)
|
||||
struct fx_string_p *str,
|
||||
size_t start,
|
||||
size_t length,
|
||||
const char *new_data)
|
||||
{
|
||||
if (start >= str->s_codepoints) {
|
||||
return FX_ERR_INVALID_ARGUMENT;
|
||||
@@ -382,12 +395,17 @@ static enum fx_status replace_utf8(
|
||||
size_t old_data_offset = 0, old_data_nr_bytes = 0;
|
||||
size_t old_data_nr_codepoints = length;
|
||||
enum fx_status status = convert_codepoint_range_to_byte_range(
|
||||
str, start, length, &old_data_offset, &old_data_nr_bytes);
|
||||
str,
|
||||
start,
|
||||
length,
|
||||
&old_data_offset,
|
||||
&old_data_nr_bytes);
|
||||
if (!FX_OK(status)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
size_t new_total_bytes = str->s_len - old_data_nr_bytes + new_data_nr_bytes;
|
||||
size_t new_total_bytes
|
||||
= str->s_len - old_data_nr_bytes + new_data_nr_bytes;
|
||||
if (new_total_bytes > str->s_max) {
|
||||
status = string_reserve(str, new_total_bytes);
|
||||
}
|
||||
@@ -415,7 +433,10 @@ static enum fx_status replace_utf8(
|
||||
}
|
||||
|
||||
static fx_status string_replace(
|
||||
struct fx_string_p *str, size_t start, size_t length, const char *new_data)
|
||||
struct fx_string_p *str,
|
||||
size_t start,
|
||||
size_t length,
|
||||
const char *new_data)
|
||||
{
|
||||
if (str->s_len == str->s_codepoints) {
|
||||
return replace_ansi(str, start, length, new_data);
|
||||
@@ -424,7 +445,9 @@ static fx_status string_replace(
|
||||
return replace_utf8(str, start, length, new_data);
|
||||
}
|
||||
|
||||
static fx_status string_replace_all(struct fx_string_p *str, const char *new_data)
|
||||
static fx_status string_replace_all(
|
||||
struct fx_string_p *str,
|
||||
const char *new_data)
|
||||
{
|
||||
size_t new_len = strlen(new_data);
|
||||
string_reserve(str, new_len);
|
||||
@@ -437,7 +460,8 @@ static fx_status string_replace_all(struct fx_string_p *str, const char *new_dat
|
||||
}
|
||||
|
||||
static fx_status string_replace_all_with_stringstream(
|
||||
struct fx_string_p *str, const fx_stringstream *new_data)
|
||||
struct fx_string_p *str,
|
||||
const fx_stringstream *new_data)
|
||||
{
|
||||
size_t new_len = fx_stringstream_get_length(new_data);
|
||||
string_reserve(str, new_len);
|
||||
@@ -451,7 +475,10 @@ static fx_status string_replace_all_with_stringstream(
|
||||
return FX_SUCCESS;
|
||||
}
|
||||
|
||||
static enum fx_status remove_ansi(struct fx_string_p *str, size_t start, size_t length)
|
||||
static enum fx_status remove_ansi(
|
||||
struct fx_string_p *str,
|
||||
size_t start,
|
||||
size_t length)
|
||||
{
|
||||
fx_status status = FX_SUCCESS;
|
||||
|
||||
@@ -479,11 +506,18 @@ static enum fx_status remove_ansi(struct fx_string_p *str, size_t start, size_t
|
||||
return FX_SUCCESS;
|
||||
}
|
||||
|
||||
static enum fx_status remove_utf8(struct fx_string_p *str, size_t start, size_t length)
|
||||
static enum fx_status remove_utf8(
|
||||
struct fx_string_p *str,
|
||||
size_t start,
|
||||
size_t length)
|
||||
{
|
||||
size_t remove_offset = 0, remove_nr_bytes = 0;
|
||||
enum fx_status status = convert_codepoint_range_to_byte_range(
|
||||
str, start, length, &remove_offset, &remove_nr_bytes);
|
||||
str,
|
||||
start,
|
||||
length,
|
||||
&remove_offset,
|
||||
&remove_nr_bytes);
|
||||
if (!FX_OK(status)) {
|
||||
return status;
|
||||
}
|
||||
@@ -506,7 +540,9 @@ static enum fx_status remove_utf8(struct fx_string_p *str, size_t start, size_t
|
||||
}
|
||||
|
||||
static enum fx_status string_remove(
|
||||
struct fx_string_p *str, size_t start, size_t length)
|
||||
struct fx_string_p *str,
|
||||
size_t start,
|
||||
size_t length)
|
||||
{
|
||||
if (str->s_len == str->s_codepoints) {
|
||||
return remove_ansi(str, start, length);
|
||||
@@ -515,7 +551,9 @@ static enum fx_status string_remove(
|
||||
return remove_utf8(str, start, length);
|
||||
}
|
||||
|
||||
static fx_status string_transform(struct fx_string_p *str, int (*transformer)(int))
|
||||
static fx_status string_transform(
|
||||
struct fx_string_p *str,
|
||||
int (*transformer)(int))
|
||||
{
|
||||
char *s = string_ptr(str);
|
||||
for (size_t i = 0; i < str->s_len; i++) {
|
||||
@@ -612,7 +650,10 @@ static fx_status string_trim(struct fx_string_p *str)
|
||||
}
|
||||
|
||||
static enum fx_status string_insert_cstr_ansi(
|
||||
struct fx_string_p *dest, const char *src, size_t nr_bytes, size_t at)
|
||||
struct fx_string_p *dest,
|
||||
const char *src,
|
||||
size_t nr_bytes,
|
||||
size_t at)
|
||||
{
|
||||
if (at >= dest->s_len) {
|
||||
at = dest->s_len;
|
||||
@@ -637,7 +678,9 @@ static enum fx_status string_insert_cstr_ansi(
|
||||
}
|
||||
|
||||
static enum fx_status string_insert_cstr_utf8(
|
||||
struct fx_string_p *dest, const char *src, size_t nr_bytes,
|
||||
struct fx_string_p *dest,
|
||||
const char *src,
|
||||
size_t nr_bytes,
|
||||
size_t codepoint_offset)
|
||||
{
|
||||
if (codepoint_offset >= dest->s_codepoints) {
|
||||
@@ -651,7 +694,11 @@ static enum fx_status string_insert_cstr_utf8(
|
||||
byte_offset = dest->s_len;
|
||||
} else {
|
||||
status = convert_codepoint_range_to_byte_range(
|
||||
dest, 0, codepoint_offset, NULL, &byte_offset);
|
||||
dest,
|
||||
0,
|
||||
codepoint_offset,
|
||||
NULL,
|
||||
&byte_offset);
|
||||
}
|
||||
|
||||
if (!FX_OK(status)) {
|
||||
@@ -678,7 +725,10 @@ static enum fx_status string_insert_cstr_utf8(
|
||||
}
|
||||
|
||||
static enum fx_status string_insert_wstr_ansi(
|
||||
struct fx_string_p *dest, const fx_wchar *src, size_t nr_codepoints, size_t at)
|
||||
struct fx_string_p *dest,
|
||||
const fx_wchar *src,
|
||||
size_t nr_codepoints,
|
||||
size_t at)
|
||||
{
|
||||
if (at >= dest->s_len) {
|
||||
at = dest->s_len;
|
||||
@@ -723,7 +773,9 @@ static enum fx_status string_insert_wstr_ansi(
|
||||
}
|
||||
|
||||
static enum fx_status string_insert_wstr_utf8(
|
||||
struct fx_string_p *dest, const fx_wchar *src, size_t nr_codepoints,
|
||||
struct fx_string_p *dest,
|
||||
const fx_wchar *src,
|
||||
size_t nr_codepoints,
|
||||
size_t codepoint_offset)
|
||||
{
|
||||
if (codepoint_offset >= dest->s_codepoints) {
|
||||
@@ -748,7 +800,11 @@ static enum fx_status string_insert_wstr_utf8(
|
||||
move_offset = dest->s_len;
|
||||
} else {
|
||||
status = convert_codepoint_range_to_byte_range(
|
||||
dest, 0, codepoint_offset, NULL, &move_offset);
|
||||
dest,
|
||||
0,
|
||||
codepoint_offset,
|
||||
NULL,
|
||||
&move_offset);
|
||||
}
|
||||
|
||||
if (!FX_OK(status)) {
|
||||
@@ -783,7 +839,10 @@ static enum fx_status string_insert_wstr_utf8(
|
||||
}
|
||||
|
||||
static enum fx_status string_insert_cstr(
|
||||
struct fx_string_p *dest, const char *src, size_t nr_bytes, size_t at)
|
||||
struct fx_string_p *dest,
|
||||
const char *src,
|
||||
size_t nr_bytes,
|
||||
size_t at)
|
||||
{
|
||||
if (dest->s_len == dest->s_codepoints) {
|
||||
return string_insert_cstr_ansi(dest, src, nr_bytes, at);
|
||||
@@ -793,7 +852,10 @@ static enum fx_status string_insert_cstr(
|
||||
}
|
||||
|
||||
static enum fx_status string_insert_wstr(
|
||||
struct fx_string_p *dest, const fx_wchar *src, size_t nr_codepoints, size_t at)
|
||||
struct fx_string_p *dest,
|
||||
const fx_wchar *src,
|
||||
size_t nr_codepoints,
|
||||
size_t at)
|
||||
{
|
||||
if (dest->s_len == dest->s_codepoints) {
|
||||
return string_insert_wstr_ansi(dest, src, nr_codepoints, at);
|
||||
@@ -803,25 +865,36 @@ static enum fx_status string_insert_wstr(
|
||||
}
|
||||
|
||||
static enum fx_status string_insertf(
|
||||
struct fx_string_p *dest, size_t at, const char *format, va_list arg)
|
||||
struct fx_string_p *dest,
|
||||
size_t at,
|
||||
const char *format,
|
||||
va_list arg)
|
||||
{
|
||||
char buf[1024];
|
||||
size_t len = vsnprintf(buf, sizeof buf, format, arg);
|
||||
return string_insert_cstr(dest, buf, len, at);
|
||||
}
|
||||
|
||||
static enum fx_status string_insert_c(struct fx_string_p *dest, char c, size_t at)
|
||||
static enum fx_status string_insert_c(
|
||||
struct fx_string_p *dest,
|
||||
char c,
|
||||
size_t at)
|
||||
{
|
||||
return string_insert_cstr(dest, &c, 1, at);
|
||||
}
|
||||
|
||||
static enum fx_status string_insert_wc(struct fx_string_p *dest, fx_wchar c, size_t at)
|
||||
static enum fx_status string_insert_wc(
|
||||
struct fx_string_p *dest,
|
||||
fx_wchar c,
|
||||
size_t at)
|
||||
{
|
||||
return string_insert_wstr(dest, &c, 1, at);
|
||||
}
|
||||
|
||||
static enum fx_status string_insert_s(
|
||||
struct fx_string_p *dest, const struct fx_string_p *src, size_t at)
|
||||
struct fx_string_p *dest,
|
||||
const struct fx_string_p *src,
|
||||
size_t at)
|
||||
{
|
||||
return string_insert_cstr(dest, string_ptr(src), src->s_len, at);
|
||||
}
|
||||
@@ -858,7 +931,9 @@ static bool has_prefix(const char *s, const char *prefix, size_t *prefix_len)
|
||||
}
|
||||
|
||||
static bool has_prefixes(
|
||||
const char *s, const char **prefixes, size_t nr_prefixes,
|
||||
const char *s,
|
||||
const char **prefixes,
|
||||
size_t nr_prefixes,
|
||||
size_t *selected_prefix_len)
|
||||
{
|
||||
for (size_t i = 0; i < nr_prefixes; i++) {
|
||||
@@ -929,14 +1004,16 @@ static enum fx_status find_next_token(struct fx_string_iterator_p *it)
|
||||
}
|
||||
|
||||
it->_ds = offset + prefix_len;
|
||||
it->string_value = fx_string_ptr(it->_tmp);
|
||||
it->string_value = fx_string_get_cstr(it->_tmp);
|
||||
it->string_length = it->_tmp_p->s_len;
|
||||
it->string_codepoints = it->_tmp_p->s_codepoints;
|
||||
return FX_SUCCESS;
|
||||
}
|
||||
|
||||
static fx_iterator *string_tokenise(
|
||||
struct fx_string_p *str, const char *delims[], size_t nr_delims,
|
||||
struct fx_string_p *str,
|
||||
const char *delims[],
|
||||
size_t nr_delims,
|
||||
fx_string_tokenise_flags flags)
|
||||
{
|
||||
if (!nr_delims) {
|
||||
@@ -970,7 +1047,9 @@ static fx_iterator *string_tokenise(
|
||||
return it_obj;
|
||||
}
|
||||
|
||||
static size_t string_get_size(const struct fx_string_p *str, fx_strlen_flags flags)
|
||||
static size_t string_get_size(
|
||||
const struct fx_string_p *str,
|
||||
fx_strlen_flags flags)
|
||||
{
|
||||
switch (flags) {
|
||||
case FX_STRLEN_NORMAL:
|
||||
@@ -987,7 +1066,9 @@ static size_t string_get_capacity(const struct fx_string_p *str)
|
||||
return str->s_max;
|
||||
}
|
||||
|
||||
static bool string_compare(const struct fx_string_p *a, const struct fx_string_p *b)
|
||||
static bool string_compare(
|
||||
const struct fx_string_p *a,
|
||||
const struct fx_string_p *b)
|
||||
{
|
||||
if (a->s_len != b->s_len) {
|
||||
return false;
|
||||
@@ -1041,7 +1122,10 @@ static void string_pop_back(struct fx_string_p *str)
|
||||
str->s_len--;
|
||||
}
|
||||
|
||||
static fx_string *string_substr(const struct fx_string_p *str, size_t start, size_t len)
|
||||
static fx_string *string_substr(
|
||||
const struct fx_string_p *str,
|
||||
size_t start,
|
||||
size_t len)
|
||||
{
|
||||
if (start > string_get_size(str, FX_STRLEN_NORMAL)) {
|
||||
return NULL;
|
||||
@@ -1052,7 +1136,8 @@ static fx_string *string_substr(const struct fx_string_p *str, size_t start, siz
|
||||
}
|
||||
|
||||
fx_string *newstr = fx_string_create();
|
||||
struct fx_string_p *newstr_p = fx_object_get_private(newstr, FX_TYPE_STRING);
|
||||
struct fx_string_p *newstr_p
|
||||
= fx_object_get_private(newstr, FX_TYPE_STRING);
|
||||
string_reserve(newstr_p, len);
|
||||
|
||||
const char *src = string_ptr(str) + start;
|
||||
@@ -1146,32 +1231,57 @@ fx_status fx_string_reserve(fx_string *str, size_t capacity)
|
||||
}
|
||||
|
||||
fx_status fx_string_replace(
|
||||
fx_string *str, size_t start, size_t length, const char *new_data)
|
||||
fx_string *str,
|
||||
size_t start,
|
||||
size_t length,
|
||||
const char *new_data)
|
||||
{
|
||||
FX_CLASS_DISPATCH_STATIC(
|
||||
FX_TYPE_STRING, string_replace, str, start, length, new_data);
|
||||
FX_TYPE_STRING,
|
||||
string_replace,
|
||||
str,
|
||||
start,
|
||||
length,
|
||||
new_data);
|
||||
}
|
||||
|
||||
fx_status fx_string_replace_all(fx_string *str, const char *new_data)
|
||||
{
|
||||
FX_CLASS_DISPATCH_STATIC(FX_TYPE_STRING, string_replace_all, str, new_data);
|
||||
FX_CLASS_DISPATCH_STATIC(
|
||||
FX_TYPE_STRING,
|
||||
string_replace_all,
|
||||
str,
|
||||
new_data);
|
||||
}
|
||||
|
||||
fx_status fx_string_replace_all_with_stringstream(
|
||||
fx_string *str, const fx_stringstream *new_data)
|
||||
fx_string *str,
|
||||
const fx_stringstream *new_data)
|
||||
{
|
||||
FX_CLASS_DISPATCH_STATIC(
|
||||
FX_TYPE_STRING, string_replace_all_with_stringstream, str, new_data);
|
||||
FX_TYPE_STRING,
|
||||
string_replace_all_with_stringstream,
|
||||
str,
|
||||
new_data);
|
||||
}
|
||||
|
||||
enum fx_status fx_string_remove(fx_string *str, size_t start, size_t length)
|
||||
{
|
||||
FX_CLASS_DISPATCH_STATIC(FX_TYPE_STRING, string_remove, str, start, length);
|
||||
FX_CLASS_DISPATCH_STATIC(
|
||||
FX_TYPE_STRING,
|
||||
string_remove,
|
||||
str,
|
||||
start,
|
||||
length);
|
||||
}
|
||||
|
||||
fx_status fx_string_transform(fx_string *str, int (*transformer)(int))
|
||||
{
|
||||
FX_CLASS_DISPATCH_STATIC(FX_TYPE_STRING, string_transform, str, transformer);
|
||||
FX_CLASS_DISPATCH_STATIC(
|
||||
FX_TYPE_STRING,
|
||||
string_transform,
|
||||
str,
|
||||
transformer);
|
||||
}
|
||||
|
||||
fx_status fx_string_trim(fx_string *str)
|
||||
@@ -1189,29 +1299,46 @@ enum fx_status fx_string_insert_wc(fx_string *dest, fx_wchar c, size_t at)
|
||||
FX_CLASS_DISPATCH_STATIC(FX_TYPE_STRING, string_insert_wc, dest, c, at);
|
||||
}
|
||||
|
||||
enum fx_status fx_string_insert_s(fx_string *dest, const fx_string *src, size_t at)
|
||||
enum fx_status fx_string_insert_s(
|
||||
fx_string *dest,
|
||||
const fx_string *src,
|
||||
size_t at)
|
||||
{
|
||||
struct fx_string_p *dest_p = fx_object_get_private(dest, FX_TYPE_STRING);
|
||||
const struct fx_string_p *src_p = fx_object_get_private(src, FX_TYPE_STRING);
|
||||
struct fx_string_p *dest_p
|
||||
= fx_object_get_private(dest, FX_TYPE_STRING);
|
||||
const struct fx_string_p *src_p
|
||||
= fx_object_get_private(src, FX_TYPE_STRING);
|
||||
return string_insert_s(dest_p, src_p, at);
|
||||
}
|
||||
|
||||
enum fx_status fx_string_insert_cstr(fx_string *dest, const char *src, size_t at)
|
||||
enum fx_status fx_string_insert_cstr(
|
||||
fx_string *dest,
|
||||
const char *src,
|
||||
size_t at)
|
||||
{
|
||||
struct fx_string_p *dest_p = fx_object_get_private(dest, FX_TYPE_STRING);
|
||||
struct fx_string_p *dest_p
|
||||
= fx_object_get_private(dest, FX_TYPE_STRING);
|
||||
return string_insert_cstr(dest_p, src, strlen(src), at);
|
||||
}
|
||||
|
||||
enum fx_status fx_string_insert_wstr(fx_string *dest, const fx_wchar *src, size_t at)
|
||||
enum fx_status fx_string_insert_wstr(
|
||||
fx_string *dest,
|
||||
const fx_wchar *src,
|
||||
size_t at)
|
||||
{
|
||||
struct fx_string_p *dest_p = fx_object_get_private(dest, FX_TYPE_STRING);
|
||||
struct fx_string_p *dest_p
|
||||
= fx_object_get_private(dest, FX_TYPE_STRING);
|
||||
return string_insert_wstr(dest_p, src, fx_wstrlen(src), at);
|
||||
}
|
||||
|
||||
enum fx_status fx_string_insert_cstrf(
|
||||
fx_string *dest, size_t at, const char *format, ...)
|
||||
fx_string *dest,
|
||||
size_t at,
|
||||
const char *format,
|
||||
...)
|
||||
{
|
||||
struct fx_string_p *dest_p = fx_object_get_private(dest, FX_TYPE_STRING);
|
||||
struct fx_string_p *dest_p
|
||||
= fx_object_get_private(dest, FX_TYPE_STRING);
|
||||
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
@@ -1222,15 +1349,24 @@ enum fx_status fx_string_insert_cstrf(
|
||||
}
|
||||
|
||||
enum fx_status fx_string_insert_cstrn(
|
||||
fx_string *dest, const char *src, size_t len, size_t at)
|
||||
fx_string *dest,
|
||||
const char *src,
|
||||
size_t len,
|
||||
size_t at)
|
||||
{
|
||||
FX_CLASS_DISPATCH_STATIC(
|
||||
FX_TYPE_STRING, string_insert_cstr, dest, src, len, at);
|
||||
FX_TYPE_STRING,
|
||||
string_insert_cstr,
|
||||
dest,
|
||||
src,
|
||||
len,
|
||||
at);
|
||||
}
|
||||
|
||||
enum fx_status fx_string_append_cstrf(fx_string *dest, const char *format, ...)
|
||||
{
|
||||
struct fx_string_p *dest_p = fx_object_get_private(dest, FX_TYPE_STRING);
|
||||
struct fx_string_p *dest_p
|
||||
= fx_object_get_private(dest, FX_TYPE_STRING);
|
||||
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
@@ -1242,7 +1378,8 @@ enum fx_status fx_string_append_cstrf(fx_string *dest, const char *format, ...)
|
||||
|
||||
enum fx_status fx_string_prepend_cstrf(fx_string *dest, const char *format, ...)
|
||||
{
|
||||
struct fx_string_p *dest_p = fx_object_get_private(dest, FX_TYPE_STRING);
|
||||
struct fx_string_p *dest_p
|
||||
= fx_object_get_private(dest, FX_TYPE_STRING);
|
||||
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
@@ -1258,11 +1395,18 @@ void fx_string_clear(fx_string *str)
|
||||
}
|
||||
|
||||
fx_iterator *fx_string_tokenise(
|
||||
fx_string *str, const char *delims[], size_t nr_delims,
|
||||
fx_string *str,
|
||||
const char *delims[],
|
||||
size_t nr_delims,
|
||||
fx_string_tokenise_flags flags)
|
||||
{
|
||||
FX_CLASS_DISPATCH_STATIC(
|
||||
FX_TYPE_STRING, string_tokenise, str, delims, nr_delims, flags);
|
||||
FX_TYPE_STRING,
|
||||
string_tokenise,
|
||||
str,
|
||||
delims,
|
||||
nr_delims,
|
||||
flags);
|
||||
}
|
||||
|
||||
size_t fx_string_get_size(const fx_string *str, fx_strlen_flags flags)
|
||||
@@ -1304,7 +1448,12 @@ const char *fx_string_get_cstr(const fx_string *str)
|
||||
|
||||
fx_string *fx_string_substr(const fx_string *str, size_t start, size_t len)
|
||||
{
|
||||
FX_CLASS_DISPATCH_STATIC(FX_TYPE_STRING, string_substr, str, start, len);
|
||||
FX_CLASS_DISPATCH_STATIC(
|
||||
FX_TYPE_STRING,
|
||||
string_substr,
|
||||
str,
|
||||
start,
|
||||
len);
|
||||
}
|
||||
|
||||
uint64_t fx_string_hash(const fx_string *str)
|
||||
@@ -1495,12 +1644,14 @@ static enum fx_status iterator_move_next(const fx_iterator *obj)
|
||||
}
|
||||
}
|
||||
|
||||
static fx_iterator_value chars_iterator_get_value(struct fx_string_iterator_p *it)
|
||||
static fx_iterator_value chars_iterator_get_value(
|
||||
struct fx_string_iterator_p *it)
|
||||
{
|
||||
return FX_ITERATOR_VALUE_INT(it->char_value);
|
||||
}
|
||||
|
||||
static fx_iterator_value tokens_iterator_get_value(struct fx_string_iterator_p *it)
|
||||
static fx_iterator_value tokens_iterator_get_value(
|
||||
struct fx_string_iterator_p *it)
|
||||
{
|
||||
return FX_ITERATOR_VALUE_CPTR(it->string_value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user