TypedString - Instance and key value
Typed strings are odaba strings based on a complex data type definition. By means of the complex data type definition, string values can be interpreted and values from the string can be assigned to complex instances.
Typed strings can be provided in different string formats. Default is ESDFString , the extended self delimiter format (ESDF), which is an extension of the widely used CSV format.
Even though, ' ; ', ' | ', or tabulators ( ) can be used as property delimiters in ESDF strings simultaneously, it is suggested to use ';' as property delimiter, since this is the separator used, when typed strings are created by the system.
Although the specialization to odaba::Key can be used with all defined string types, the default type for Key is CSVString and the default property delimiter is ' | '.
Typed strings can be created from string variables or constants, which have to correspond syntactically string type set in the typed string. Later, when applying the string on a property or value handle, the type definition is retrieved from the handle in order to convert the string properly.
Typed strings need not to contain all property of the related complex data type. Missing properties (values) will be created and initialized as empty values.
Instead of object interchange format (OIF), ESDF is used as default, wich is structured in a similar way but does nor require property names, which is sufficient for internal use. In order to exchange data between databases, however, OIF should be used by setting the string type to OIFString ( stringType( OIFString ) ), instead.
In order to convert instances or keys into string or reverse, a type definition must have been set in the typed string. Type definitions are usually set, when the instance is passed as parameter to a Property or Value function.
Since type definition may change always when passed to a function, one has to be aware, that the currently associated type is the type resulting from the last operation. When using typed strings for data conversion (string to instance or reverse), it is a save way to set the required type definition before calling conversion functions.
Instances can be converted from internal to string format and reverse. Since ODABA supports several string formats, converting from internal to string depends on the selected string type ( stringType() ).
When assigning a string value to a typed string, the string is analyzed and the string type is derived from the string value. When no valid string has been passed, an exception is thrown. String types are recognized as follows:
- xml - first non-whitespace character is <
- oif - first token is an identifier
- esdf - first token is { or ( or constant
Changing the string type (e.g. stringType( OIFString ) ) will automatically change the string value for the instance, when a valid type definition has been set.
In order to set the string type for a a string value to be set, the string type should be set before assigning the string value.
// fragment: TypeDefinition td;
Instance inst;
inst.typeDefinition(td);
inst.setType(ESDFString);
inst = "Miller|Paul"; // assign esdf string value
inst.setType(OIFString); // convert to OIF string
output(inst); // name = "Miller"; first_name = "Paul";
- TypedString - Constructor
- assign - Assign typed string value
- clear - Clear string
- isEmpty - Is string empty
- operator= - Assign typed string value
- stringType - String type property
- typeDefinition - Type definition
- ~TypedString - Destructor

