Zydis  v4.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 <Zycore/Format.h>
#include <Zydis/ShortString.h>
#include <Zycore/Defines.h>
#include <Zycore/Status.h>
#include <Zycore/Vector.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 force_leading_number, 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 force_leading_number, 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 to append.
padding_lengthPadds the converted value with leading zeros, if the number of chars is less than the padding_length.
force_signEnable this option to print 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 to append.
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  force_leading_number,
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 ZyanString instance.
valueThe value to append.
padding_lengthPadds the converted value with leading zeros, if the number of chars is less than the padding_length (the sign char does not count).
force_leading_numberEnable this option to prepend a leading 0, if the first character is non-numeric.
uppercaseEnable this option to use uppercase letters ('A'-'F') instead of lowercase ones ('a'-'f').
force_signEnable this option to print 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.

◆ ZydisStringAppendHexU()

ZyanStatus ZydisStringAppendHexU ( ZyanString *  string,
ZyanU64  value,
ZyanU8  padding_length,
ZyanBool  force_leading_number,
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 to append.
padding_lengthPads the converted value with leading zeros if the number of chars is less than the padding_length.
force_leading_numberEnable this option to prepend a leading 0 if the first character is non-numeric.
uppercaseEnable this option 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.