API Guides > ConceptRT 3.x
Scalar types & Real-time string

Scalar types

Base scalar types

ConceptRT redefines many basic types to abstract types that may change of size depending on the target / compiler.

Example basic types
Int32 doubleWord = Int32Max;
UInt16 unsignedWord = 45000;
Pointer pointer = NULL;
PCChar8 message = "Hello world";
Float64 doubleReal = 6.4563;
UInt8 byte = UInt8Max;
Example advanced types
// SmartType
SmartInt32 doubleWord; // auto-initialize to 0
doubleWord = 56;
Int32 value = doubleWord;
// Nullable
Nullable<Float64> userValue; // initialized to NULL - Undefined
userValue = 8.567;
if (userValue != NullableNull)
{
Float64 value = userValue;
}
else
THROW_RT_EXCEPTION("Value not set by the user");

TimeSpan

todo example of code

TimeStamp

todo example of code

Real-time string

Realtime String Working with character strings is very common. String literal such as "This is a literal string" or C-style strings terminated with a null character, literally a '\0' character, are handled by the type PCChar8. See Literal and C-Like strings operations for more details. To be able to build dynamic message and use String in real-time context String classes brings the required deterministic functionalities.

Many functionalities work with both base types (BaseStaticString and PCChar8) such as Concatenation, Comparison, Conversion, Extraction, Alignment, Format & Trim and Encoding/Decoding.

String & ToString
// String & ToString
Int32 loadedElement = 8;
bool successful = true;
Float64 distance = 12.435;
String message = "Element loaded : " + ToString(loadedElement) +
". Success : " + ToString(successful) +
". Distance : " + ToString(distance);
String operations
// String operations
String string = " Hello world ";
Int32 length = string.GetLength();
bool contains = string.Contains("Hello"); // contains is true
Int32 world = string.Find("world"); // world equals 7
Int32 compare = string.Compare("Good bye world"); // compare equals -1
String left = string.Left(6); // left equals " Hello"
String right = string.Right(6); // right equals "world "
String mid = string.Mid(1, 11); // mid equals "Hello world"
string.TrimLeft(); // string equals "Hello world "
string.TrimRight(); // string equals "Hello world"
StaticString and concatenation
// StaticString : Larger or smaller String
StaticString<40> smallString = "Hello ";
StaticString<400> hugeString = "World";
// Concatenation
smallString += hugeString;
Equal
// Equal
bool compare = hugeString == "Hello World"; // compare is true
bool sameText = SameText(hugeString, "hello world");// sameText is true
Size & Length
// Size & Length
Int32 size = hugeString.GetSize(); // size equals 400
bool sameLength = hugeString.GetLength() == Length("hello world"); // sameLength is true
Parsing
// Parsing
String numberString = "12";
String markString = "5.9";
String completeString = "true";
Int32 number = numberString.ValInt();
Float64 mark = markString.ValFloat();
bool complete = completeString.ValBool();
Extracting
// Extracting
String pointsValues = "10.2, 2.1; 6.321, 546.2;1234.1234,0.9876;";
Float64 points[10][2];
String partX;
String partY;
Int32 index = 0;
do
{
Extract(partX, pointsValues, ',');
Extract(partY, pointsValues, ';');
points[index][0] = partX.ValFloat();
points[index][1] = partY.ValFloat();
index++;
}
while (!pointsValues.IsEmpty() && index < 10);