Grijjy FoundationUnits Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers |
Unit Grijjy.SysUtils
Description
System level utilities
Overview
Classes, Interfaces, Objects and Records
Functions and Procedures
Variables
Description
Functions and Procedures
function goGetMachineName: String; |
Returns the name of the machine.
Tech notes:
On Windows, returns result from GetComputerName.
On other platforms, returns result from Posix gethostname api
|
function goGetCurrentProcessId: UInt32; |
Returns the ID of the current process.
|
function goToHexString(const ABytes: TBytes): String; |
Converts a byte array to a hex string.
Note: the returned string is in lowercase format.
Parameters
- ABytes
- the array of bytes to convert.
Returns
A string containing 2 hex digits for each converted byte. |
function goParseHexString(const AString: String): TBytes; |
Converts a hex string to a byte array.
Note: AString may contain both lowercase and uppercase hex digits, and it may contain an even or odd number of characters. If the string contains an odd number of characters, then it is prefixed with an additional 0.
Parameters
- AString
- the string to convert.
Returns
The converted byte array. Exceptions raised
EArgumentException
- if the string contains illegal characters.
|
function goTryParseHexString(const AString: String; out ABytes: TBytes): Boolean; |
Tries to convert a hex string to a byte array.
Note: AString may contain both lowercase and uppercase hex digits, and it may contain an even or odd number of characters. If the string contains an odd number of characters, then it is prefixed with an additional 0.
Parameters
- AString
- the string to convert.
- ABytes
- is set to the converted byte array.
Returns
True on success, False on failure. |
function goCharToHex(const AChar: Char): Byte; |
Converts a digit to a byte.
Note: AChar may be both lowercase and uppercase.
Parameters
- AChar
- the character to convert.
Returns
The value of the hex digit. Exceptions raised
EArgumentException
- if the characeter is an illegal hex character.
|
function goUtf16ToUtf8(const ASource: String): TBytes; overload; |
Fast Unicode to UTF-8 conversion.
Note: This function is optimized for speed and doesn't perform any error checking. If ASource contains invalid characters, then the result will be invalid as well. As a result, this version is 2-10 times faster than TEncoding.UTF8.GetBytes.
Parameters
- ASource
- Unicode string.
Returns
A byte array with the UTF-8 data. |
function goUtf16ToUtf8(const ASource: String; const ASourceLength: Integer; const ABuffer: Pointer): Integer; overload; |
Fast Unicode to UTF-8 conversion using a provided buffer.
Note: This function is optimized for speed and doesn't perform any error checking. If ASource contains invalid characters, then the result will be invalid as well. As a result, this version is 2-10 times faster than TEncoding.UTF8.GetBytes.
Parameters
- ASource
- Unicode string.
- ASourceLength
- the number of characters in ASource to use.
- ABuffer
- pointer to the buffer to store the UTF-8 data into. The buffer must be at least large enough to store ((ASourceLength + 1) * 3) bytes.
Returns
The number of UTF-8 bytes stored in the buffer. |
function goUtf8ToUtf16(const ASource: TBytes): String; overload; inline; |
Fast UTF-8 to Unicode conversion.
Note: This function is optimized for speed and doesn't perform any error checking. If ASource contains invalid bytes, then the result will be invalid as well. As a result, this version is 2-35 times faster than TEncoding.UTF8.GetString.
Parameters
- ASource
- the UTF-8 data.
Returns
The Unicode string. |
function goUtf8ToUtf16(const ASource: Pointer; const ASourceLength: Integer): String; overload; |
Fast UTF-8 to Unicode conversion.
Note: This function is optimized for speed and doesn't perform any error checking. If ASource contains invalid bytes, then the result will be invalid as well. As a result, this version is 2-35 times faster than TEncoding.UTF8.GetString.
Parameters
- ASource
- pointer to the UTF-8 data.
- ASourceLength
- the number of bytes in ASource to use.
Returns
The Unicode string. |
function goUtf8ToUtf16(const ASource: Pointer; const ASourceLength: Integer; const ABuffer: Pointer): Integer; overload; |
Fast UTF-8 to Unicode conversion using a provided buffer.
Note: This function is optimized for speed and doesn't perform any error checking. If ASource contains invalid bytes, then the result will be invalid as well. As a result, this version is 2-35 times faster than TEncoding.UTF8.GetString.
Parameters
- ASource
- pointer to the UTF-8 data.
- ASourceLength
- the number of bytes in ASource to use.
- ABuffer
- pointer to the buffer to store the UTF-16 characters into. The buffer must be at least large enough to store (ASourceLength + 1) WideChar's.
Returns
The number of WideChar's (NOT bytes) stored in the buffer. |
function goMurmurHash2(const AData; ALen: Integer): Integer; |
Calculates a Murmur hash (v2) of a block of data. See https://sites.google.com/site/murmurhash/
This hash function is *much* faster than Delphi's built-in BobJenkinsHash and is also better in avoiding hash collisions.
Parameters
- AData
- the data to calulate the hash for
- ALen
- the size of the data (in bytes).
Returns
The hash value for the data. |
procedure goReverseBytes(const ABytes: TBytes; const AIndex, ALength: Integer); |
Reverses the bytes in (part of) a byte array.
Parameters
- ABytes
- the byte array.
- AIndex
- the index to start reversing.
- ALength
- the number of bytes to reverse.
Exceptions raised
EArgumentOutOfRangeException
- (AIndex + ALength) is out of range.
|
Variables
goUSFormatSettings: TFormatSettings; |
Format settings that always use a period ('.') as a decimal separator
|
Generated by P2PasDoc 0.13.0 on 2017-04-25 12:54:26
|