Zydis  v3.1.0
String.h File Reference

Provides some internal, more performant, but unsafe helper functions for the ZyanString data-type. More...

#include <Zycore/LibC.h>
#include <Zycore/String.h>
#include <Zycore/Types.h>
#include <Zydis/ShortString.h>
#include <Zydis/Status.h>
Include dependency graph for String.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ZYDIS_STRING_ASSERT_NULLTERMINATION(string)    ZYAN_ASSERT(*(char*)((ZyanU8*)(string)->vector.data + (string)->vector.size - 1) == '\0');
 Checks for a terminating '\0' character at the end of the string data. More...
 
#define ZYDIS_STRING_NULLTERMINATE(string)    *(char*)((ZyanU8*)(string)->vector.data + (string)->vector.size - 1) = '\0';
 Writes a terminating '\0' character at the end of the string data. More...
 

Typedefs

typedef enum ZydisLetterCase_ ZydisLetterCase
 Defines the ZydisLetterCase enum. More...
 

Enumerations

enum  ZydisLetterCase_ {
  ZYDIS_LETTER_CASE_DEFAULT , ZYDIS_LETTER_CASE_LOWER , ZYDIS_LETTER_CASE_UPPER , ZYDIS_LETTER_CASE_MAX_VALUE = ZYDIS_LETTER_CASE_UPPER ,
  ZYDIS_LETTER_CASE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_LETTER_CASE_MAX_VALUE)
}
 Defines the ZydisLetterCase enum. More...
 

Functions

ZYAN_INLINE ZyanStatus ZydisStringAppend (ZyanString *destination, const ZyanStringView *source)
 Appends the content of the source string to the end of the destination string. More...
 
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 characters to the specified letter-case. More...
 
ZYAN_INLINE ZyanStatus ZydisStringAppendShort (ZyanString *destination, const ZydisShortString *source)
 Appends the content of the source short-string to the end of the destination string. More...
 
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, converting the characters to the specified letter-case. More...
 
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 string. More...
 
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 string. More...
 
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 string. More...
 
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 string. More...
 

Detailed Description

Provides some internal, more performant, but unsafe helper functions for the ZyanString data-type.

Most of these functions are very similar to the ones in Zycore/String.h, but inlined and without optional overhead like parameter-validation checks, etc ...

The ZyanString data-type is able to dynamically allocate memory on the heap, but as Zydis is designed to be a non-'malloc'ing library, all functions in this file assume that the instances they are operating on are created with a user-defined static-buffer.

Macro Definition Documentation

◆ ZYDIS_STRING_ASSERT_NULLTERMINATION

#define ZYDIS_STRING_ASSERT_NULLTERMINATION (   string)     ZYAN_ASSERT(*(char*)((ZyanU8*)(string)->vector.data + (string)->vector.size - 1) == '\0');

Checks for a terminating '\0' character at the end of the string data.

◆ ZYDIS_STRING_NULLTERMINATE

#define ZYDIS_STRING_NULLTERMINATE (   string)     *(char*)((ZyanU8*)(string)->vector.data + (string)->vector.size - 1) = '\0';

Writes a terminating '\0' character at the end of the string data.

Typedef Documentation

◆ ZydisLetterCase

Defines the ZydisLetterCase enum.

Enumeration Type Documentation

◆ ZydisLetterCase_

Defines the ZydisLetterCase enum.

Enumerator
ZYDIS_LETTER_CASE_DEFAULT 

Uses the given text "as is".

ZYDIS_LETTER_CASE_LOWER 

Converts the given text to lowercase letters.

ZYDIS_LETTER_CASE_UPPER 

Converts the given text to uppercase letters.

ZYDIS_LETTER_CASE_MAX_VALUE 

Maximum value of this enum.

ZYDIS_LETTER_CASE_REQUIRED_BITS 

The minimum number of bits required to represent all values of this enum.

Function Documentation

◆ ZydisStringAppend()

ZYAN_INLINE ZyanStatus ZydisStringAppend ( ZyanString *  destination,
const ZyanStringView *  source 
)

Appends the content of the source string to the end of the destination string.

Parameters
destinationThe destination string.
sourceThe source string.
Returns
A zyan status code.

◆ ZydisStringAppendCase()

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 characters to the specified letter-case.

Parameters
destinationThe destination string.
sourceThe source string.
letter_caseThe desired letter-case.
Returns
A zyan status code.

◆ ZydisStringAppendDecS()

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 string.

Parameters
stringA pointer to the ZyanString instance.
valueThe value.
padding_lengthPadds the converted value with leading zeros, if the number of chars is less than the padding_length.
force_signSet ZYAN_TRUE, to force printing of the + sign for positive numbers.
prefixThe string to use as prefix or ZYAN_NULL, if not needed.
suffixThe string to use as suffix or ZYAN_NULL, if not needed.
Returns
A zyan status code.

This function will fail, if the ZYAN_STRING_IS_IMMUTABLE flag is set for the specified ZyanString instance.

◆ ZydisStringAppendDecU()

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 string.

Parameters
stringA pointer to the ZyanString instance.
valueThe value.
padding_lengthPadds the converted value with leading zeros, if the number of chars is less than the padding_length.
prefixThe string to use as prefix or ZYAN_NULL, if not needed.
suffixThe string to use as suffix or ZYAN_NULL, if not needed.
Returns
A zyan status code.

This function will fail, if the ZYAN_STRING_IS_IMMUTABLE flag is set for the specified ZyanString instance.

◆ ZydisStringAppendHexS()

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 string.

Parameters
stringA pointer to the string.
valueThe value.
padding_lengthPadds the converted value with leading zeros, if the number of chars is less than the padding_length (the sign char is ignored).
uppercaseSet ZYAN_TRUE to print the hexadecimal value in uppercase letters instead of lowercase ones.
force_signSet to ZYAN_TRUE, to force printing of the + sign for positive numbers.
prefixThe string to use as prefix or NULL, if not needed.
suffixThe string to use as suffix or NULL, if not needed.
Returns
ZYAN_STATUS_SUCCESS, if the function succeeded, or ZYAN_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not sufficient to append the given value.

The string-buffer pointer is increased by the number of chars written, if the call was successful.

◆ ZydisStringAppendHexU()

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 string.

Parameters
stringA pointer to the ZyanString instance.
valueThe value.
padding_lengthPadds the converted value with leading zeros, if the number of chars is less than the padding_length.
uppercaseSet ZYAN_TRUE to use uppercase letters ('A'-'F') instead of lowercase ones ('a'-'f').
prefixThe string to use as prefix or ZYAN_NULL, if not needed.
suffixThe string to use as suffix or ZYAN_NULL, if not needed.
Returns
A zyan status code.

This function will fail, if the ZYAN_STRING_IS_IMMUTABLE flag is set for the specified ZyanString instance.

◆ ZydisStringAppendShort()

ZYAN_INLINE ZyanStatus ZydisStringAppendShort ( ZyanString *  destination,
const ZydisShortString source 
)

Appends the content of the source short-string to the end of the destination string.

Parameters
destinationThe destination string.
sourceThe source string.
Returns
A zyan status code.

◆ ZydisStringAppendShortCase()

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, converting the characters to the specified letter-case.

Parameters
destinationThe destination string.
sourceThe source string.
letter_caseThe desired letter-case.
Returns
A zyan status code.