40 #ifndef ZYDIS_INTERNAL_STRING_H
41 #define ZYDIS_INTERNAL_STRING_H
43 #include <Zycore/LibC.h>
44 #include <Zycore/String.h>
45 #include <Zycore/Types.h>
102 #define ZYDIS_STRING_ASSERT_NULLTERMINATION(string) \
103 ZYAN_ASSERT(*(char*)((ZyanU8*)(string)->vector.data + (string)->vector.size - 1) == '\0');
108 #define ZYDIS_STRING_NULLTERMINATE(string) \
109 *(char*)((ZyanU8*)(string)->vector.data + (string)->vector.size - 1) = '\0';
131 ZYAN_ASSERT(destination && source);
132 ZYAN_ASSERT(!destination->vector.allocator);
133 ZYAN_ASSERT(destination->vector.size && source->string.vector.size);
135 if (destination->vector.size + source->string.vector.size - 1 > destination->vector.capacity)
137 return ZYAN_STATUS_INSUFFICIENT_BUFFER_SIZE;
140 ZYAN_MEMCPY((
char*)destination->vector.data + destination->vector.size - 1,
141 source->string.vector.data, source->string.vector.size - 1);
143 destination->vector.size += source->string.vector.size - 1;
146 return ZYAN_STATUS_SUCCESS;
162 ZYAN_ASSERT(destination && source);
163 ZYAN_ASSERT(!destination->vector.allocator);
164 ZYAN_ASSERT(destination->vector.size && source->string.vector.size);
166 if (destination->vector.size + source->string.vector.size - 1 > destination->vector.capacity)
168 return ZYAN_STATUS_INSUFFICIENT_BUFFER_SIZE;
171 ZYAN_MEMCPY((
char*)destination->vector.data + destination->vector.size - 1,
172 source->string.vector.data, source->string.vector.size - 1);
180 const ZyanUSize index = destination->vector.size - 1;
181 const ZyanUSize count = source->string.vector.size - 1;
182 char* s = (
char*)destination->vector.data + index;
183 for (ZyanUSize i = index; i < index + count; ++i)
186 if ((c >=
'A') && (c <=
'Z'))
196 const ZyanUSize index = destination->vector.size - 1;
197 const ZyanUSize count = source->string.vector.size - 1;
198 char* s = (
char*)destination->vector.data + index;
199 for (ZyanUSize i = index; i < index + count; ++i)
202 if ((c >=
'a') && (c <=
'z'))
214 destination->vector.size += source->string.vector.size - 1;
217 return ZYAN_STATUS_SUCCESS;
231 ZYAN_ASSERT(destination && source);
232 ZYAN_ASSERT(!destination->vector.allocator);
233 ZYAN_ASSERT(destination->vector.size && source->
size);
235 if (destination->vector.size + source->
size > destination->vector.capacity)
237 return ZYAN_STATUS_INSUFFICIENT_BUFFER_SIZE;
240 ZYAN_MEMCPY((
char*)destination->vector.data + destination->vector.size - 1, source->
data,
241 (ZyanUSize)source->
size + 1);
243 destination->vector.size += source->
size;
246 return ZYAN_STATUS_SUCCESS;
262 ZYAN_ASSERT(destination && source);
263 ZYAN_ASSERT(!destination->vector.allocator);
264 ZYAN_ASSERT(destination->vector.size && source->
size);
266 if (destination->vector.size + source->
size > destination->vector.capacity)
268 return ZYAN_STATUS_INSUFFICIENT_BUFFER_SIZE;
271 ZYAN_MEMCPY((
char*)destination->vector.data + destination->vector.size - 1, source->
data,
272 (ZyanUSize)source->
size + 1);
280 const ZyanUSize index = destination->vector.size - 1;
281 const ZyanUSize count = source->
size;
282 char* s = (
char*)destination->vector.data + index;
283 for (ZyanUSize i = index; i < index + count; ++i)
286 if ((c >=
'A') && (c <=
'Z'))
296 const ZyanUSize index = destination->vector.size - 1;
297 const ZyanUSize count = source->
size;
298 char* s = (
char*)destination->vector.data + index;
299 for (ZyanUSize i = index; i < index + count; ++i)
302 if ((c >=
'a') && (c <=
'z'))
314 destination->vector.size += source->
size;
317 return ZYAN_STATUS_SUCCESS;
341 const ZyanStringView* prefix,
const ZyanStringView* suffix);
361 ZyanU8 padding_length, ZyanBool force_sign,
const ZyanStringView* prefix,
362 const ZyanStringView* suffix)
379 ZYAN_ASSERT(value >= 0);
404 ZyanBool uppercase,
const ZyanStringView* prefix,
const ZyanStringView* suffix);
429 ZyanU8 padding_length, ZyanBool uppercase, ZyanBool force_sign,
const ZyanStringView* prefix,
430 const ZyanStringView* suffix)
447 ZYAN_ASSERT(value >= 0);
Defines the immutable and storage-efficient ZydisShortString struct, which is used to store strings i...
#define ZYDIS_MAKE_SHORTSTRING(string)
Declares a ZydisShortString from a static C-style string.
Definition: ShortString.h:81
Status code definitions and check macros.
ZyanStatus ZydisStringAppendHexU(ZyanString *string, ZyanU64 value, ZyanU8 padding_length, ZyanBool uppercase, const ZyanStringView *prefix, const ZyanStringView *suffix)
Formats the given unsigned ordinal value to its hexadecimal text-representation and appends it to the...
ZydisLetterCase_
Defines the ZydisLetterCase enum.
Definition: String.h:65
@ ZYDIS_LETTER_CASE_UPPER
Converts the given text to uppercase letters.
Definition: String.h:77
@ ZYDIS_LETTER_CASE_REQUIRED_BITS
The minimum number of bits required to represent all values of this enum.
Definition: String.h:86
@ ZYDIS_LETTER_CASE_MAX_VALUE
Maximum value of this enum.
Definition: String.h:82
@ ZYDIS_LETTER_CASE_DEFAULT
Uses the given text "as is".
Definition: String.h:69
@ ZYDIS_LETTER_CASE_LOWER
Converts the given text to lowercase letters.
Definition: String.h:73
ZYAN_INLINE ZyanStatus ZydisStringAppendDecS(ZyanString *string, ZyanI64 value, ZyanU8 padding_length, ZyanBool force_sign, const ZyanStringView *prefix, const ZyanStringView *suffix)
Formats the given signed ordinal value to its decimal text-representation and appends it to the strin...
Definition: String.h:360
ZYAN_INLINE ZyanStatus ZydisStringAppendCase(ZyanString *destination, const ZyanStringView *source, ZydisLetterCase letter_case)
Appends the content of the source string to the end of the destination string, converting the charact...
Definition: String.h:159
ZYAN_INLINE ZyanStatus ZydisStringAppendShortCase(ZyanString *destination, const ZydisShortString *source, ZydisLetterCase letter_case)
Appends the content of the source short-string to the end of the destination string,...
Definition: String.h:259
enum ZydisLetterCase_ ZydisLetterCase
Defines the ZydisLetterCase enum.
ZyanStatus ZydisStringAppendDecU(ZyanString *string, ZyanU64 value, ZyanU8 padding_length, const ZyanStringView *prefix, const ZyanStringView *suffix)
Formats the given unsigned ordinal value to its decimal text-representation and appends it to the str...
ZYAN_INLINE ZyanStatus ZydisStringAppendShort(ZyanString *destination, const ZydisShortString *source)
Appends the content of the source short-string to the end of the destination string.
Definition: String.h:228
ZYAN_INLINE ZyanStatus ZydisStringAppendHexS(ZyanString *string, ZyanI64 value, ZyanU8 padding_length, ZyanBool uppercase, ZyanBool force_sign, const ZyanStringView *prefix, const ZyanStringView *suffix)
Formats the given signed ordinal value to its hexadecimal text-representation and appends it to the s...
Definition: String.h:428
#define ZYDIS_STRING_NULLTERMINATE(string)
Writes a terminating '\0' character at the end of the string data.
Definition: String.h:108
ZYAN_INLINE ZyanStatus ZydisStringAppend(ZyanString *destination, const ZyanStringView *source)
Appends the content of the source string to the end of the destination string.
Definition: String.h:129
#define ZYDIS_STRING_ASSERT_NULLTERMINATION(string)
Checks for a terminating '\0' character at the end of the string data.
Definition: String.h:102
Defines the ZydisShortString struct.
Definition: ShortString.h:59
ZyanU8 size
The length (number of characters) of the string (without 0-termination).
Definition: ShortString.h:67
const char * data
The buffer that contains the actual (null-terminated) string.
Definition: ShortString.h:63