Photon Quantum 3.0.0

Static Public Member Functions | Static Public Attributes | List of all members
Quantum.QString Class Reference

Base class for DSL-generated variable QString(N) fields. QString supports UTF-16 (Unicode in .NET). N represents the total size of the string in bytes minus 2 bytes used for bookkeeping. In other words QString(64) will use 64 bytes for a string with a max byte length of 62 bytes, i.e. up to 31 UTF-16 characters. More...

Static Public Member Functions

static unsafe bool AreEqual< T > (ref T qstr, object other)
 Check if two QStrings are equal. (CompareOrdinal) compares two strings by evaluating the numeric values of the corresponding characters in each string. More...
 
static bool CanHold (string str, int maxByteCount)
 Checks if the input string bytes are less than or equal to the given byte count. More...
 
static int CompareOrdinal< T > (ref T qstr, byte *bytes, ushort byteCount)
 Compares a string and a strings byte representation by evaluating the numeric values of the corresponding characters in each string. More...
 
static int CompareOrdinal< T > (ref T qstr, string str)
 Compares a QString and a string by evaluating the numeric values of the corresponding characters in each string. More...
 
static int CompareOrdinal< T, U > (ref T qstr1, ref U qstr2)
 Compares two different QStrings types by evaluating the numeric values of the corresponding characters in each string. More...
 
static void ConstructFrom< T > (string str, int maxByteCount, out T qstr)
 Creates a QString from a string. More...
 
static void ConstructNoByteCountCheck< T > (string str, int characterCount, int maxByteCount, out T qstr)
 Create a QString from a string without checking the byte count. More...
 
static int GetFittingCharacterCount (string str, int maxByteCount)
 Calculate the number of characters that fit into the given byte count. More...
 
static int GetFittingCharacterCount (string str, int maxByteCount, out int actualByteCount)
 Calculate the number of characters that fit into the given byte count. More...
 
static int GetLength< T > (ref T qstr)
 Get the length of a QString. More...
 
static string GetString< T > (ref T qstr)
 Convert the QString to a String. More...
 
static void Print (void *ptr, FramePrinter printer)
 Prints the QString using a FramePrinter. More...
 

Static Public Attributes

const string ByteCountFieldName = nameof(QStringCommonLayout.byteCount)
 Byte count field name More...
 
const string BytesFieldName = nameof(QStringCommonLayout.bytes)
 Bytes field name More...
 

Detailed Description

Base class for DSL-generated variable QString(N) fields. QString supports UTF-16 (Unicode in .NET). N represents the total size of the string in bytes minus 2 bytes used for bookkeeping. In other words QString(64) will use 64 bytes for a string with a max byte length of 62 bytes, i.e. up to 31 UTF-16 characters.

Member Function Documentation

◆ AreEqual< T >()

static unsafe bool Quantum.QString.AreEqual< T > ( ref T  qstr,
object  other 
)
inlinestatic

Check if two QStrings are equal. (CompareOrdinal) compares two strings by evaluating the numeric values of the corresponding characters in each string.

Template Parameters
TQString type
Parameters
qstrString a
otherOther string
Returns
true if string are equal
Type Constraints
T :unmanaged 
T :IQString 

◆ CanHold()

static bool Quantum.QString.CanHold ( string  str,
int  maxByteCount 
)
inlinestatic

Checks if the input string bytes are less than or equal to the given byte count.

Parameters
strString to check
maxByteCountMax bytes
Returns
true if required bytes for the string is below or equal to the given size

◆ CompareOrdinal< T >() [1/2]

static int Quantum.QString.CompareOrdinal< T > ( ref T  qstr,
byte *  bytes,
ushort  byteCount 
)
inlinestatic

Compares a string and a strings byte representation by evaluating the numeric values of the corresponding characters in each string.

Template Parameters
TQString type
Parameters
qstrQString string 1
bytesOther string 2 in bytes representation
byteCountOther string byte length
Returns
An integer that indicates the lexical relationship between the two comparands.
Type Constraints
T :unmanaged 
T :IQString 

◆ CompareOrdinal< T >() [2/2]

static int Quantum.QString.CompareOrdinal< T > ( ref T  qstr,
string  str 
)
inlinestatic

Compares a QString and a string by evaluating the numeric values of the corresponding characters in each string.

Template Parameters
TQString type
Parameters
qstrQString 1
strString 2
Returns
An integer that indicates the lexical relationship between the two comparands.
Type Constraints
T :unmanaged 
T :IQString 

◆ CompareOrdinal< T, U >()

static int Quantum.QString.CompareOrdinal< T, U > ( ref T  qstr1,
ref U  qstr2 
)
inlinestatic

Compares two different QStrings types by evaluating the numeric values of the corresponding characters in each string.

Template Parameters
TQString type
UQString type
Parameters
qstr1String 1
qstr2String 2
Returns
An integer that indicates the lexical relationship between the two comparands.
Type Constraints
T :unmanaged 
T :IQString 
U :unmanaged 
U :IQString 

◆ ConstructFrom< T >()

static void Quantum.QString.ConstructFrom< T > ( string  str,
int  maxByteCount,
out T  qstr 
)
inlinestatic

Creates a QString from a string.

Template Parameters
TQString type
Parameters
strString
maxByteCountMax byte count defined by the QString type
qstrResulting QString
Exceptions
ArgumentExceptionIs raised when the string is too long
Type Constraints
T :unmanaged 
T :IQString 

◆ GetFittingCharacterCount() [1/2]

static int Quantum.QString.GetFittingCharacterCount ( string  str,
int  maxByteCount 
)
inlinestatic

Calculate the number of characters that fit into the given byte count.

Parameters
strString
maxByteCountMax byte count defined by the QString type
Returns
The number of characters that fit into the given byte count.

◆ GetFittingCharacterCount() [2/2]

static int Quantum.QString.GetFittingCharacterCount ( string  str,
int  maxByteCount,
out int  actualByteCount 
)
inlinestatic

Calculate the number of characters that fit into the given byte count.

Parameters
strString
maxByteCountMax byte count defined by the QString type
actualByteCountIs set to the number of required bytes
Returns
The number of characters that fit into the given byte count.

◆ GetLength< T >()

static int Quantum.QString.GetLength< T > ( ref T  qstr)
inlinestatic

Get the length of a QString.

Template Parameters
TQString type
Parameters
qstrQString
Returns
Returns the character count.
Type Constraints
T :unmanaged 
T :IQString 

◆ GetString< T >()

static string Quantum.QString.GetString< T > ( ref T  qstr)
inlinestatic

Convert the QString to a String.

Template Parameters
TQString type
Parameters
qstrQString
Returns
String.
Type Constraints
T :unmanaged 
T :IQString 

◆ Print()

static void Quantum.QString.Print ( void *  ptr,
FramePrinter  printer 
)
inlinestatic

Prints the QString using a FramePrinter.

Parameters
ptrPointer to QString instance
printerPrinter object

◆ ConstructNoByteCountCheck< T >()

static void Quantum.QString.ConstructNoByteCountCheck< T > ( string  str,
int  characterCount,
int  maxByteCount,
out T  qstr 
)
inlinestatic

Create a QString from a string without checking the byte count.

Template Parameters
TQString type
Parameters
strString to convert
characterCountNot used
maxByteCountNot used
qstrResulting QString
Type Constraints
T :unmanaged 
T :IQString 

Member Data Documentation

◆ ByteCountFieldName

const string Quantum.QString.ByteCountFieldName = nameof(QStringCommonLayout.byteCount)
static

Byte count field name

◆ BytesFieldName

const string Quantum.QString.BytesFieldName = nameof(QStringCommonLayout.bytes)
static

Bytes field name