10 #define BLITZ_STRING_H
21 #define BBSTRING_SIZE_CALC(len) (sizeof (BBString) + (len) * sizeof (BBChar))
31 #define BBSTRING_SIZE(str) BBSTRING_SIZE_CALC((str)->length)
33 #ifndef BB_ENABLE_EXPERIMENTAL
39 # define BBSTRING_MAX_LENGTH ((BBSize)(65536 / sizeof (BBChar) - sizeof (BBString)))
41 # define BBSTRING_MAX_LENGTH ((BBSize)(BBSIZE_MAX / sizeof (BBChar)) - sizeof (BBString))
42 #endif // BB_ENABLE_EXPERIMENTAL
61 #define BBSTRING_ALLOC(len) \
65 BBSTRING_SIZE_CALC(len), \
77 #define BBSTRING_FROMBUFFER(buffer, len) \
79 BB_ASSERT((len) > 0 && (len) < BBSTRING_MAX_LENGTH, "Invalid buffer length"); \
80 BBString *_str = BBSTRING_ALLOC((len)); \
81 _str->length = (len); \
82 memcpy(_str->buf, (buffer), (len) * sizeof (BBChar)); \
150 #define BBNULLSTRING (&bbEmptyString)
152 #ifdef BB_ENABLE_HELPER
154 bool bb_string_buffer_equals(
const BBChar * restrict str_buf,
155 const BBChar * restrict cmp_buf,
156 BBSize len) __attribute__ ((pure));
158 #endif // BB_ENABLE_HELPER
335 BBString* bbStringFromCString(
const char *c_str);
355 BBString* bbStringFromUTF8String(
const char *utf8_str);
425 #define BBSTRING_SIDE_ISVALID(side) \
426 ((side) >= BBSTRING_SIDE_LEFT && (side) <= BBSTRING_SIDE_RIGHT)
490 BBInt bbStringAsc(
const BBString *str) __attribute__ ((pure));
498 #define BBSTRING_NOTFOUND (-1)
626 char* bbStringToCString(
const BBString *str);
649 char* bbStringToUTF8String(
const BBString *str);
773 BBBool bbStringIsLower(
const BBString *str) __attribute__ ((pure));
783 BBBool bbStringIsUpper(
const BBString *str) __attribute__ ((pure));
793 BBBool bbStringIsASCII(
const BBString *str) __attribute__ ((pure));
797 char* bbTmpCString(
const BBString *str);
799 char* bbTmpUTF8String(
const BBString *str);
803 #endif // BLITZ_STRING_H