DataTypeClass

Applies to:Fast Math Parser
Class:uCalc.DataType
Class for working with uCalc data types
Remarks
Class member Description
AllocArray Allocates an array of the given data type
AllocByPtr Allocates a scalar of the given type and copies data from the area indicated by the Pointer
AllocScalar Allocates a scalar of the given data type
ByteSize Returns the size (in bytes) of one unit of data for this data type
DataTypeHandle Handle for uCalc Data Type
GetItem Returns the uCalc.Item handle of the data type
Handle Returns the handle of the data type object
Index Returns the index of the data type
Name Returns the name of the data type
ReleaseArray Releases an array that was allocated with AllocArray
ReleaseScalar Releases a scalar that was allocated with AllocScalar
ResetArray Resets the value of data that was allocated with SetScalar to the default value of the given data type
ResetScalar Resets the value of data that was allocated with SetScalar to the default value of the given data type
SetArray Sets the value of an array at a given memory location that was allocated by AllocArray
SetScalar Sets the value of a scalar at a given memory location that was allocated by AllocScalar
SwapScalarValues swaps the pointers of two variables that were allocated with AllocScalar or AllocArray
ToString (ByPtr) Retuns a string representing the value at the given address formatted for the given data type
ToString (ByStr) Retuns a formatted string of the given data type representing the value that was passed as text
Example 1: returning data type names for the different definitions of the "+" operator

Dim PlusOperator = uc.GetItemOf("+")

while PlusOperator.ItemHandle <>  0 

   Console.WriteLine("Def: " + PlusOperator.Text() + "  Type: " + PlusOperator.GetDataType().Name())
   PlusOperator = PlusOperator.NextOverload()
End while

' Output
' Def: Operator_: 70 +{x}  Type: double
' Def: Operator_: 50 {x} + {y}  Type: double
' Def: Operator_: 50 {x As Int32} + {y As Int32} As Int32  Type: Int32
' Def: Operator_: 50 {x As String} + {y As String} As String  Type: string
' Def: Operator_: 50 {x} + {y As Complex} As Complex  Type: complex
' Def: Operator_: 50 {x As Complex} + {y} As Complex  Type: complex
' Def: Operator_: 50 {x As Complex} + {y As Complex} As Complex  Type: complex

          

var PlusOperator = uc.GetItemOf("+");

while (PlusOperator.ItemHandle != null) {
   Console.WriteLine("Def: " + PlusOperator.Text() + "  Type: " + PlusOperator.GetDataType().Name());
   PlusOperator = PlusOperator.NextOverload();
}
// Output
// Def: Operator: 70 +{x}  Type: double
// Def: Operator: 50 {x} + {y}  Type: double
// Def: Operator: 50 {x As Int32} + {y As Int32} As Int32  Type: Int32
// Def: Operator: 50 {x As String} + {y As String} As String  Type: string
// Def: Operator: 50 {x} + {y As Complex} As Complex  Type: complex
// Def: Operator: 50 {x As Complex} + {y} As Complex  Type: complex
// Def: Operator: 50 {x As Complex} + {y As Complex} As Complex  Type: complex

          

//var PlusOperator = uc.GetItemOf('+');

      while PlusOperator.ItemHandle <>  0  do
begin
    
         WriteLn('Def: ' + PlusOperator.Text() + '  Type: ' + PlusOperator.GetDataType().Name());
         PlusOperator = PlusOperator.NextOverload();

End;
      // Output
// Def: Operator_: 70 +{x}  Type: double
// Def: Operator_: 50 {x} + {y}  Type: double
// Def: Operator_: 50 {x As Int32} + {y As Int32} As Int32  Type: Int32
// Def: Operator_: 50 {x As String} + {y As String} As String  Type: string
// Def: Operator_: 50 {x} + {y As Complex} As Complex  Type: complex
// Def: Operator_: 50 {x As Complex} + {y} As Complex  Type: complex
// Def: Operator_: 50 {x As Complex} + {y As Complex} As Complex  Type: complex

          

auto PlusOperator = uc.GetItemOf("+");

while (PlusOperator.ItemHandle != NULL) {
   cout << "Def: " << PlusOperator.Text() << "  Type: " << PlusOperator.GetDataType().Name() << endl;
   PlusOperator = PlusOperator.NextOverload();
}
// Output
// Def: Operator: 70 +{x}  Type: double
// Def: Operator: 50 {x} + {y}  Type: double
// Def: Operator: 50 {x As Int} + {y As Int} As Int  Type: int
// Def: Operator: 50 {x As String} + {y As String} As String  Type: string
// Def: Operator: 50 {x} + {y As Complex} As Complex  Type: complex
// Def: Operator: 50 {x As Complex} + {y} As Complex  Type: complex
// Def: Operator: 50 {x As Complex} + {y As Complex} As Complex  Type: complex

          

auto PlusOperator = uc.GetItemOf("+");

while (PlusOperator.ItemHandle != 0) {
   Console::WriteLine("Def: " + PlusOperator.Text() + "  Type: " + PlusOperator.GetDataType().Name());
   PlusOperator = PlusOperator.NextOverload();
}
// Output
// Def: Operator: 70 +{x}  Type: double
// Def: Operator: 50 {x} + {y}  Type: double
// Def: Operator: 50 {x As Int} + {y As Int} As Int  Type: int
// Def: Operator: 50 {x As String} + {y As String} As String  Type: string
// Def: Operator: 50 {x} + {y As Complex} As Complex  Type: complex
// Def: Operator: 50 {x As Complex} + {y} As Complex  Type: complex
// Def: Operator: 50 {x As Complex} + {y As Complex} As Complex  Type: complex

          
Prev | Next