CVB.Net 14.0
StringUtilities Class Reference

Several utility functions that make interfacing managed and unmanaged DLLs easier. More...

Public Member Functions

delegate TRes StringQuery< TRes, TSize > (StringBuilder s, ref TSize size)
 String query function. More...
 
delegate TRes StringsQuery< TRes, TSize > (StringBuilder s1, ref TSize size1, StringBuilder s2, ref TSize size2)
 String query function. More...
 
delegate TRes StringQueryFixedLength< TRes > (StringBuilder s, int size)
 String query functions for string queries that do not support the initial query for the string's length, but operate with a maximum length instead (which has been set on the string builder passed as the first argument). More...
 
delegate bool Succeeded< TRes > (TRes value)
 Result value verification function. More...
 
delegate void OnFailure< TRes > (TRes value)
 Delegate to be called when an unmanaged call failed. More...
 

Static Public Member Functions

static string GetUnmanagedString< TRes, TSize > (StringQuery< TRes, TSize >[] queries, Succeeded< TRes > succeeded, OnFailure< TRes > onFailure=null, bool assertNoError=true)
 Retrieves an unmanaged string from a function that follows the convention that a size query is possible by passing a null pointer first. More...
 
static string[] GetUnmanagedStrings< TRes, TSize > (StringsQuery< TRes, TSize >[] queries, Succeeded< TRes > succeeded, OnFailure< TRes > onFailure=null)
 Retrieves two unmanaged strings from a function that follows the convention that a size query is possible by passing a null pointer first. More...
 
static string GetUnmanagedString< TRes > (StringQueryFixedLength< TRes >[] queries, int capacity, Succeeded< TRes > succeeded)
 Retrieves an unmanaged string from a function that follows the convention that a size query is possible by passing a null pointer first. More...
 
static TRes UnmanagedStringCall< TRes > (Func< TRes >[] functions)
 Call helper that receives the operating-system-dependent unmanaged functions to be called as an array. Element 0 in the array is assumed to be the correct function to call on Windows, element 1 is the function to be called on Linux. More...
 
static void UnmanagedStringCall (Action[] functions)
 Call helper that receives the operating-system-dependent unmanaged functions to be called as an array. Element 0 in the array is assumed to be the correct function to call on Windows, element 1 is the function to be called on Linux. More...
 

Detailed Description

Several utility functions that make interfacing managed and unmanaged DLLs easier.

Member Function Documentation

◆ GetUnmanagedString< TRes >()

static string GetUnmanagedString< TRes > ( StringQueryFixedLength< TRes >[]  queries,
int  capacity,
Succeeded< TRes >  succeeded 
)
static

Retrieves an unmanaged string from a function that follows the convention that a size query is possible by passing a null pointer first.

Template Parameters
TResReturn type of the query function.
Parameters
queriesQuery functions (element 0: to be called on Windows, element 1: to be called on Linux)
succeededverification function that checks the result returned by the query function.
capacityCapacity to use on the string builder.
Returns
Retrieved string or null if retrieval failed.

◆ GetUnmanagedString< TRes, TSize >()

static string GetUnmanagedString< TRes, TSize > ( StringQuery< TRes, TSize >[]  queries,
Succeeded< TRes >  succeeded,
OnFailure< TRes >  onFailure = null,
bool  assertNoError = true 
)
static

Retrieves an unmanaged string from a function that follows the convention that a size query is possible by passing a null pointer first.

Template Parameters
TResReturn type of the query function.
TSizeSize type used by the query function.
Parameters
queriesQuery functions (element 0: to be called on Windows, element 1: to be called on Linux)
succeededverification function that checks the result returned by the query function.
onFailureAction to be taken when the unmanaged call failed.
assertNoErrorIf true is set, it assert that there was no error on any query call. If false is set and any query call ended up with an error, then null will be returned.
Returns
Retrieved string or null if retrieval failed.

◆ GetUnmanagedStrings< TRes, TSize >()

static string[] GetUnmanagedStrings< TRes, TSize > ( StringsQuery< TRes, TSize >[]  queries,
Succeeded< TRes >  succeeded,
OnFailure< TRes >  onFailure = null 
)
static

Retrieves two unmanaged strings from a function that follows the convention that a size query is possible by passing a null pointer first.

Template Parameters
TResReturn type of the query function.
TSizeSize type used by the query function.
Parameters
queriesQuery functions (element 0: to be called on Windows, element 1: to be called on Linux)
succeededverification function that checks the result returned by the query function.
onFailureAction to be taken when the unmanaged call failed.
Returns
An array of retrieved strings or null if retrieval failed.

◆ OnFailure< TRes >()

delegate void OnFailure< TRes > ( TRes  value)

Delegate to be called when an unmanaged call failed.

Template Parameters
TResType of result to be communicated.

◆ StringQuery< TRes, TSize >()

delegate TRes StringQuery< TRes, TSize > ( StringBuilder  s,
ref TSize  size 
)

String query function.

Template Parameters
TResResult type of the query function.
TSizeSize type used by the query function.
Parameters
sString builder passed to the query function.
sizeSize passed to the query function.
Returns
Return value.

◆ StringQueryFixedLength< TRes >()

delegate TRes StringQueryFixedLength< TRes > ( StringBuilder  s,
int  size 
)

String query functions for string queries that do not support the initial query for the string's length, but operate with a maximum length instead (which has been set on the string builder passed as the first argument).

Template Parameters
TResreturn type of the query function
Parameters
sString builder to receive the string.
sizeSize of the buffer allocated in the string builder.
Returns

◆ StringsQuery< TRes, TSize >()

delegate TRes StringsQuery< TRes, TSize > ( StringBuilder  s1,
ref TSize  size1,
StringBuilder  s2,
ref TSize  size2 
)

String query function.

Template Parameters
TResResult type of the query function.
TSizeSize type used by the query function.
Parameters
s1The first string builder passed to the query function.
size1The first string Size passed to the query function.
s2The second string builder passed to the query function.
size2The second string Size passed to the query function.
Returns
Return value.

◆ Succeeded< TRes >()

delegate bool Succeeded< TRes > ( TRes  value)

Result value verification function.

Template Parameters
TResType of result to be verified.
Parameters
valueValue to be verified.
Returns
Bool value, indicating success or failure.

◆ UnmanagedStringCall()

static void UnmanagedStringCall ( Action[]  functions)
static

Call helper that receives the operating-system-dependent unmanaged functions to be called as an array. Element 0 in the array is assumed to be the correct function to call on Windows, element 1 is the function to be called on Linux.

Parameters
functionsList of operating-system-dependent functions.

◆ UnmanagedStringCall< TRes >()

static TRes UnmanagedStringCall< TRes > ( Func< TRes >[]  functions)
static

Call helper that receives the operating-system-dependent unmanaged functions to be called as an array. Element 0 in the array is assumed to be the correct function to call on Windows, element 1 is the function to be called on Linux.

Template Parameters
TResReturn type of the function called.
Parameters
functionsList of operating-system-dependent functions.
Returns
Return value from the function call.