|
|
|
@@ -1,144 +0,0 @@
|
|
|
|
|
#ifndef FX_DS_STRING_H_
|
|
|
|
|
#define FX_DS_STRING_H_
|
|
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <fx/encoding.h>
|
|
|
|
|
#include <fx/iterator.h>
|
|
|
|
|
#include <fx/macros.h>
|
|
|
|
|
#include <fx/status.h>
|
|
|
|
|
#include <fx/stringstream.h>
|
|
|
|
|
|
|
|
|
|
FX_DECLS_BEGIN;
|
|
|
|
|
|
|
|
|
|
struct fx_stream;
|
|
|
|
|
struct fx_string_p;
|
|
|
|
|
|
|
|
|
|
#define FX_TYPE_STRING (fx_string_get_type())
|
|
|
|
|
#define FX_TYPE_STRING_ITERATOR (fx_string_iterator_get_type())
|
|
|
|
|
|
|
|
|
|
FX_DECLARE_TYPE(fx_string);
|
|
|
|
|
FX_DECLARE_TYPE(fx_string_iterator);
|
|
|
|
|
|
|
|
|
|
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_string)
|
|
|
|
|
FX_TYPE_CLASS_DECLARATION_END(fx_string)
|
|
|
|
|
|
|
|
|
|
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_string_iterator)
|
|
|
|
|
FX_TYPE_CLASS_DECLARATION_END(fx_string_iterator)
|
|
|
|
|
|
|
|
|
|
#define FX_CSTR(s) (fx_string_create_from_cstr(s))
|
|
|
|
|
#define FX_RV_CSTR(s) (FX_RV(fx_string_create_from_cstr(s)))
|
|
|
|
|
|
|
|
|
|
typedef enum fx_strlen_flags {
|
|
|
|
|
FX_STRLEN_NORMAL = 0,
|
|
|
|
|
FX_STRLEN_IGNORE_ESC = 0x01u,
|
|
|
|
|
FX_STRLEN_IGNORE_MOD = 0x02u,
|
|
|
|
|
FX_STRLEN_CODEPOINTS = 0x04u,
|
|
|
|
|
} fx_strlen_flags;
|
|
|
|
|
|
|
|
|
|
typedef enum fx_string_tokenise_flags {
|
|
|
|
|
FX_STRING_TOK_F_NORMAL = 0x00u,
|
|
|
|
|
FX_STRING_TOK_F_INCLUDE_EMPTY_TOKENS = 0x01u,
|
|
|
|
|
} fx_string_tokenise_flags;
|
|
|
|
|
|
|
|
|
|
FX_API fx_type fx_string_get_type(void);
|
|
|
|
|
FX_API fx_type fx_string_iterator_get_type(void);
|
|
|
|
|
|
|
|
|
|
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_string, FX_TYPE_STRING);
|
|
|
|
|
FX_API fx_string *fx_string_create_from_cstr(const char *s);
|
|
|
|
|
FX_API fx_string *fx_string_create_from_wstr(const fx_wchar *s);
|
|
|
|
|
FX_API fx_string *fx_string_create_from_c(char c, size_t count);
|
|
|
|
|
FX_API fx_string *fx_string_duplicate(const fx_string *str);
|
|
|
|
|
|
|
|
|
|
FX_API char *fx_string_steal(fx_string *str);
|
|
|
|
|
FX_API fx_status fx_string_reserve(fx_string *str, size_t capacity);
|
|
|
|
|
FX_API fx_status fx_string_replace(
|
|
|
|
|
fx_string *str,
|
|
|
|
|
size_t start,
|
|
|
|
|
size_t length,
|
|
|
|
|
const char *new_data);
|
|
|
|
|
FX_API fx_status fx_string_replace_all(fx_string *str, const char *new_data);
|
|
|
|
|
FX_API fx_status fx_string_replace_all_with_stringstream(
|
|
|
|
|
fx_string *str,
|
|
|
|
|
const fx_stringstream *new_data);
|
|
|
|
|
FX_API fx_status fx_string_remove(fx_string *str, size_t start, size_t length);
|
|
|
|
|
FX_API fx_status fx_string_transform(fx_string *str, int (*transformer)(int));
|
|
|
|
|
FX_API fx_status fx_string_trim(fx_string *str);
|
|
|
|
|
static inline fx_status fx_string_transform_uppercase(fx_string *str)
|
|
|
|
|
{
|
|
|
|
|
return fx_string_transform(str, toupper);
|
|
|
|
|
}
|
|
|
|
|
static inline fx_status fx_string_transform_lowercase(fx_string *str)
|
|
|
|
|
{
|
|
|
|
|
return fx_string_transform(str, tolower);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FX_API fx_status fx_string_append_c(fx_string *dest, char c);
|
|
|
|
|
FX_API fx_status fx_string_append_wc(fx_string *dest, fx_wchar c);
|
|
|
|
|
FX_API fx_status fx_string_append_s(fx_string *dest, const fx_string *src);
|
|
|
|
|
FX_API fx_status fx_string_append_cstr(fx_string *dest, const char *src);
|
|
|
|
|
FX_API fx_status fx_string_append_wstr(fx_string *dest, const fx_wchar *src);
|
|
|
|
|
FX_API fx_status
|
|
|
|
|
fx_string_append_cstrf(fx_string *dest, const char *format, ...);
|
|
|
|
|
|
|
|
|
|
FX_API fx_status fx_string_prepend_c(fx_string *dest, char c);
|
|
|
|
|
FX_API fx_status fx_string_prepend_wc(fx_string *dest, fx_wchar c);
|
|
|
|
|
FX_API fx_status fx_string_prepend_cstr(fx_string *dest, const char *src);
|
|
|
|
|
FX_API fx_status fx_string_prepend_wstr(fx_string *dest, const fx_wchar *src);
|
|
|
|
|
FX_API fx_status
|
|
|
|
|
fx_string_prepend_cstrf(fx_string *dest, const char *format, ...);
|
|
|
|
|
|
|
|
|
|
FX_API fx_status fx_string_insert_c(fx_string *dest, char c, size_t at);
|
|
|
|
|
FX_API fx_status fx_string_insert_wc(fx_string *dest, fx_wchar c, size_t at);
|
|
|
|
|
FX_API fx_status
|
|
|
|
|
fx_string_insert_s(fx_string *dest, const fx_string *src, size_t at);
|
|
|
|
|
FX_API fx_status
|
|
|
|
|
fx_string_insert_cstr(fx_string *dest, const char *src, size_t at);
|
|
|
|
|
FX_API fx_status
|
|
|
|
|
fx_string_insert_wstr(fx_string *dest, const fx_wchar *src, size_t at);
|
|
|
|
|
FX_API fx_status
|
|
|
|
|
fx_string_insert_cstrn(fx_string *dest, const char *src, size_t len, size_t at);
|
|
|
|
|
FX_API fx_status
|
|
|
|
|
fx_string_insert_wstrn(fx_string *dest, const char *src, size_t len, size_t at);
|
|
|
|
|
FX_API fx_status
|
|
|
|
|
fx_string_insert_cstrf(fx_string *dest, size_t at, const char *format, ...);
|
|
|
|
|
FX_API void fx_string_clear(fx_string *str);
|
|
|
|
|
|
|
|
|
|
FX_API fx_iterator *fx_string_tokenise(
|
|
|
|
|
fx_string *str,
|
|
|
|
|
const char *delims[],
|
|
|
|
|
size_t nr_delims,
|
|
|
|
|
fx_string_tokenise_flags flags);
|
|
|
|
|
|
|
|
|
|
FX_API size_t fx_string_get_size(const fx_string *str, fx_strlen_flags flags);
|
|
|
|
|
FX_API size_t fx_string_get_capacity(const fx_string *str);
|
|
|
|
|
|
|
|
|
|
FX_API bool fx_string_compare(const fx_string *a, const fx_string *b);
|
|
|
|
|
|
|
|
|
|
FX_API char fx_string_get_first_char(const fx_string *str);
|
|
|
|
|
FX_API char fx_string_get_last_char(const fx_string *str);
|
|
|
|
|
|
|
|
|
|
FX_API void fx_string_pop_back(fx_string *str);
|
|
|
|
|
|
|
|
|
|
FX_API const char *fx_string_get_cstr(const fx_string *str);
|
|
|
|
|
FX_API fx_string *fx_string_get_substr(
|
|
|
|
|
const fx_string *str,
|
|
|
|
|
size_t start,
|
|
|
|
|
size_t len);
|
|
|
|
|
|
|
|
|
|
FX_API int fx_string_iterator_begin(
|
|
|
|
|
const fx_string *string,
|
|
|
|
|
fx_string_iterator *it);
|
|
|
|
|
FX_API bool fx_string_iterator_next(fx_string_iterator *it);
|
|
|
|
|
// FX_API fx_status fx_string_iterator_erase(fx_string_iterator *it);
|
|
|
|
|
FX_API bool fx_string_iterator_is_valid(const fx_string_iterator *it);
|
|
|
|
|
|
|
|
|
|
FX_API char *fx_strdup(const char *s);
|
|
|
|
|
FX_API size_t fx_strlen(const char *s, fx_strlen_flags flags);
|
|
|
|
|
FX_API fx_wchar *fx_wstrdup(const fx_wchar *s);
|
|
|
|
|
FX_API size_t fx_wstrlen(const fx_wchar *s);
|
|
|
|
|
|
|
|
|
|
FX_API uint64_t fx_string_hash(const fx_string *s);
|
|
|
|
|
|
|
|
|
|
FX_DECLS_END;
|
|
|
|
|
|
|
|
|
|
#endif
|