![]() |
MapLink Pro 11.1.1.0.
Envitia MapLink Pro: The Ultimate Mapping Application Toolkit
|
This class encapsulates a discriminated union for use with the TSL... classes. It can hold instances or arrays of the following set of base types:
These types are defined by the enumeration TSLVariantType.
Public Types | |
typedef unsigned char | Byte_ |
TSLVariant () | |
TSLVariant (const TSLVariant &rhs) | |
~TSLVariant () | |
TSLVariant & | operator= (const TSLVariant &rhs) |
bool | operator== (const TSLVariant &other) const |
void | clear () |
bool | compareValues (const TSLVariant &other) const |
void | copyVal (const TSLVariant *val) |
bool | getStringLen (int *len) const |
bool | getStringVal (char *val, int len) const |
bool | getTimeVal (TSLTimeType *val) const |
TSLVariantType | getType () const |
bool | getVal (bool *val) const |
bool | getVal (char *val) const |
bool | getVal (char *val[]) const |
bool | getVal (short *val) const |
bool | getVal (int *val) const |
bool | getVal (float *val) const |
bool | getVal (double *val) const |
bool | getVal (const char **val) const |
bool | getVal (TSLEntityID *val) const |
bool | getVal (unsigned int *val) const |
bool | getVal (unsigned char **blobs, int *blobLengths, TSLSimpleString *mimeTypes, TSLSimpleString *urls, TSLSimpleString *roles) const |
bool | getVal (TSLSimpleString *codes, TSLSimpleString *codeSpaces) const |
bool | getVal (double *measurements, TSLSimpleString *uoms) const |
bool | getVal (void **ptr) const |
bool | getVal (TSLVariant *ptr) const |
bool | getVal (bool &val, int index) const |
bool | getVal (short &val, int index) const |
bool | getVal (int &val, int index) const |
bool | getVal (float &val, int index) const |
bool | getVal (double &val, int index) const |
bool | getVal (TSLEntityID &val, int index) const |
int | getValueAsString (char *str, int len, const char *format=0) const |
void | id (const char *str) |
void | getID (char str[3]) const |
void | init () |
bool | isArray () const |
bool | isExternalReference () const |
void | isExternalReference (bool isExternal) |
bool | isNil () const |
void | isNil (bool nil) |
void | setReferenceVal (const char *const val[], unsigned char N=1) |
void | setStringVal (const char *val, bool promote=false) |
void | setTimeVal (const TSLTimeType *val, unsigned char N=1) |
void | setURIVal (const char *const val[], unsigned char N=1) |
void | setVal (const bool *val, unsigned char N=1) |
void | setVal (const char *val, unsigned char N=1) |
void | setVal (const char *const val[], unsigned char N=1) |
void | setVal (const short *val, unsigned char N=1) |
void | setVal (const int *val, unsigned char N=1) |
void | setVal (const float *val, unsigned char N=1) |
void | setVal (const double *val, unsigned char N=1) |
void | setVal (const TSLEntityID *val, unsigned char N=1) |
void | setVal (const unsigned int *val, unsigned char N=1) |
void | setVal (const unsigned char *const *blobs, int *blobLengths, const char *const *mimeTypes, const char *const *urls, const char *const *roles, unsigned char N=1) |
void | setVal (const char **codes, const char **codeSpaces, unsigned char N=1) |
void | setVal (double *measurements, const char **uoms, unsigned char N=1) |
void | setVal (void *ptr) |
void | setVal (const TSLVariant *ptr, unsigned char N) |
unsigned char | size () const |
typedef unsigned char TSLVariant::Byte_ |
|
inline |
Default constructor.
|
inline |
Copy constructor.
|
inline |
Destructor - this will delete any memory it owns (this is always the case where memory is allocated as a result of streaming in).
|
inline |
Sets the object to empty.
|
inline |
Comparison function. Returns true if the value of the other object is the same as this object. The 'id' fields are ignored.
|
inline |
Copies the value of the TSLVariant and its type (based on the type of the value).
This copies the value from the specified TSLVariant, without modifying the ID.
val | The value to set - only the value is taken over, not the ID. |
|
inline |
This method returns the description id (which is a 2 Byte_ element) of the attribute.
The user is responsible for passing a large enough buffer. A minimum of 3 bytes is required.
str | The returned id descriptor, which is NULL terminated. str must point to an array of 3 bytes minimum. |
|
inline |
Get length required to hold the value if a string value is held.
If the variant is of type CHAR or NULL or a single STR, returns the size of the string, including null terminator, held by the object, otherwise fails. This is the buffer to allocate and the size to give to getStringVal if the string is not to be truncated.
len | Returns the number of characters needed to store the string held in the variant, plus a terminating null. If the string is type NULL the value 1 will be returned. |
|
inline |
Get the value if a string value is held. To obtain the value as a string even if the variant holds a non-string type, use getValueAsString.
The string is truncated if necessary according to the maximum length specified (this is the length of the buffer passed, including space for the null terminator). A suitable value can be obtained by calling getStringLen if the buffer is to be dynamically allocated to avoid truncation.
val | The address of an array of characters, which must be at least as large as the value passed to len. This will receive the string, including a terminating null. If the variant is of type NULL, a single null terminator will be copied. |
len | length of the buffer passed to val. The string written to val will not exceed this length, including null terminator. |
|
inline |
Returns the value of the TSLVariant (based on the type of the supplied argument).
val | The address of an array of values to be received from the variant. The array must be at least as large as the size of the variant. If the variant has size 1, it is legal to pass the address of a single variable to receive the value. |
|
inline |
Returns the type of the TSLVariant.
|
inline |
Returns the value of the TSLVariant (based on the type of the supplied argument).
val | The value returned will be stored in this variable. |
index | The index of the value to return. |
|
inline |
Returns the value of the TSLVariant (based on the type of the supplied argument).
val | The address of an array of values to be received from the variant. The array must be at least as large as the size of the variant. If the variant has size 1, it is legal to pass the address of a single variable to receive the value. |
|
inline |
Returns the value of the TSLVariant (based on the type of the supplied argument).
NOTE: This overload obtains a string value if the string is less than 255 characters long, and fails if a longer string is held. To cope with arbitrary length strings, use getStringVal.
val | The address of an array of values to be received from the variant. The array must be at least as large as the size of the variant. If the variant has size 1, it is legal to pass the address of a single variable to receive the value. |
|
inline |
Returns the value of the TSLVariant (based on the type of the supplied argument). This overload is for arrays of strings or when a long string was stored.
NOTE: If accessing a single string it is more convenient to use getStringVal.
NOTE: Pass an array of pointers to this method. The pointers need not be initialised. On return, the pointers will point to strings allocated by the method. THE CALLER MUST DELETE THESE STRINGS AFTER USE.
val | The address of an array of values to be received from the variant. |
|
inline |
Returns the value of the TSLVariant (based on the type of the supplied argument).
Note, the memory returned here is owned by the variant, should not be deleted and may be deleted upon modification of the variant.
For type TSLVariantTypeChar, this returns a single pointer to a null terminated string. For type TSLVariantTypeNull, this returns a single pointer to a zero-length, null terminated string. For type TSLVariantTypeStr, this returns size() pointers to null terminated strings.
val | The address of an array of values to be received from the variant. The array must be at least as large as the size of the variant. If the variant has size 1, it is legal to pass the address of a single variable to receive the value. |
|
inline |
Returns the value of the TSLVariant (based on the type of the supplied argument).
val | The value returned will be stored in this variable. |
index | The index of the value to return. |
|
inline |
Retrieves an array of Measurement objects which are being stored by the TSLVariant.
measurements | An array of doubles which will be populated with the measurement values held by the variant. |
uoms | An array of TSLSimpleStrings which will be populated with the uom values held by the variant. |
|
inline |
Returns the value of the TSLVariant (based on the type of the supplied argument).
val | The address of an array of values to be received from the variant. The array must be at least as large as the size of the variant. If the variant has size 1, it is legal to pass the address of a single variable to receive the value. |
|
inline |
Returns the value of the TSLVariant (based on the type of the supplied argument).
val | The value returned will be stored in this variable. |
index | The index of the value to return. |
|
inline |
Returns the value of the TSLVariant (based on the type of the supplied argument).
val | The address of an array of values to be received from the variant. The array must be at least as large as the size of the variant. If the variant has size 1, it is legal to pass the address of a single variable to receive the value. |
|
inline |
Returns the value of the TSLVariant (based on the type of the supplied argument).
val | The value returned will be stored in this variable. |
index | The index of the value to return. |
|
inline |
Returns the value of the TSLVariant (based on the type of the supplied argument).
val | The address of an array of values to be received from the variant. The array must be at least as large as the size of the variant. If the variant has size 1, it is legal to pass the address of a single variable to receive the value. |
|
inline |
Returns the value of the TSLVariant (based on the type of the supplied argument).
val | The value returned will be stored in this variable. |
index | The index of the value to return. |
|
inline |
Returns the value of the TSLVariant (based on the type of the supplied argument).
val | The address of an array of values to be received from the variant. The array must be at least as large as the size of the variant. If the variant has size 1, it is legal to pass the address of a single variable to receive the value. |
|
inline |
Returns the value of the TSLVariant (based on the type of the supplied argument).
val | The value returned will be stored in this variable. |
index | The index of the value to return. |
|
inline |
Returns the value of the TSLVariant (based on the type of the supplied argument).
val | The address of an array of values to be received from the variant. The array must be at least as large as the size of the variant. If the variant has size 1, it is legal to pass the address of a single variable to receive the value. |
|
inline |
Retrieves an array of Code objects which are being stored by the TSLVariant.
codes | An array of TSLSimpleStrings which will be populated with the code values held by the variant. |
codeSpaces | An array of TSLSimpleStrings which will be populated with the code space values held by the variant. |
|
inline |
Returns the value of the TSLVariant (based on the type of the supplied argument).
ptr | The address of an array of values to be received from the variant. The array must be at least as large as the size of the variant. If the variant has size 1, it is legal to pass the address of a single variable to receive the value. |
|
inline |
Retrieves an array of Binary objects which are being stored by the TSLVariant.
blobs | An array of arrays of unsigned chars which are big enough to store the corresponding blob held by the variant. To retrieve the length of the blob call the getBlobLen method, specifying the necessary index for the given point in the array. |
blobLengths | An array of lengths which specify the length of the buffer passed to each blob. The value written to blob will not exceed this length. |
mimeTypes | An array of TSLSimpleStrings which will be populated with the mime Types being held by the variant. |
urls | An array of TSLSimpleStrings which will be populated with the URLs being held by the variant. |
roles | An array of TSLSimpleStrings which will be populated with the roles being held by the variant. |
|
inline |
Returns the value of the TSLVariant (based on the type of the supplied argument).
val | The address of an array of values to be received from the variant. The array must be at least as large as the size of the variant. If the variant has size 1, it is legal to pass the address of a single variable to receive the value. |
|
inline |
Retrieves a pointer which is being stored by the TSLVariant.
Notes:
ptr | A pointer to a 'void *'. The actual pointer value will be assigned. |
|
inline |
Converts the contents of the variant to a string using simple formatting.
If you know that the variant always contains a string then use getStringVal / getStringLen instead.
If called with a null str parameter, calculates the size of buffer required to hold the returned value without truncation, including a null terminator. In this case the len parameter is ignored. If called with a nun-null str parameter, the value is formatted into the given buffer. In this case the len parameter specifies the size of the buffer str. The output is truncated if necessary so that the buffer size is not exceeded and it always contains a terminator.
For arrays, all the values are returned, separated by a comma and a space.
The length returned may sometimes be a slight over-estimate of the required length.
Note: This function does not support variants of type BLOB, CODE, MEASUREMENT and VARIANT.
str | pass the address of a string to be populated, or pass zero to find the required length. |
len | If str is nonzero, specifies the size of the buffer, limiting the output. |
format | If this is non-zero, specifies the 'printf' style format used. If not specified, uses True/False for booleans, "%d" for integers, "%g" for floats and "%s" for strings. Array entries are separated by ','. |
|
inline |
This method sets the description id (which is a 2 Byte_ element) of the attribute.
str | The id descriptor. |
|
inline |
Initialises the TSLVariant to empty.
|
inline |
Query method.
Returns true if the variant is an array.
Always returns true if a string is held, unless the string is empty in which case it returns false.
|
inline |
Gets whether this TSLVariant is an external reference This works with all types of variant, although typically used with map Attachments in which case a string is stored.
|
inline |
Sets whether this TSLVariant is an external reference. This works with all types of variant, although typically used with map Attachments in which case a string is stored.
|
inline |
Gets whether this TSLVariant is nil. This works with all types of variant. If true, the current value should not be used
|
inline |
Sets whether this TSLVariant is nil. This works with all types of variant and does not affect the value current held.
|
inline |
Assignment operator.
|
inline |
Comparison operator. Returns true if both the id and the value of the other object are the same as this object.
|
inline |
This overload stores an array of strings. If N is 1 then a single string is stored.
If the value is actually a pointer to an array of elements, the optional parameter must be set to the size of the array.
To retrieve this value at a later stage, use getStringLen and getStringVal.
val | The value. |
N | The size of the array. |
A pointer to a (single) variable is treated as a 1-element array.
|
inline |
Given a string, sets the value of the TSLVariant and its type. If the string is empty then the variant will be type NULL. If the string is not empty and is shorter than 255 characters then it will be saved as type CHAR. Otherwise the string will be saved as type STR.
val | String to be saved |
promote | If true store the value as a TSLVariantTypeString even if it may be classed as a TSLVariantTypeChar. |
|
inline |
Sets the value of the TSLVariant and its type (based on the type of the value).
If the value is actually a pointer to an array of elements, the optional parameter must be set to the size of the array.
val | The value. |
N | The size of the array. |
A pointer to a (single) variable is treated as a 1-element array.
|
inline |
This overload stores an array of strings. If N is 1 then a single string is stored.
If the value is actually a pointer to an array of elements, the optional parameter must be set to the size of the array.
To retrieve this value at a later stage, use getStringLen and getStringVal.
val | The value. |
N | The size of the array. |
A pointer to a (single) variable is treated as a 1-element array.
|
inline |
Sets the value of the TSLVariant and its type (based on the type of the value).
If the value is actually a pointer to an array of elements, the optional parameter must be set to the size of the array.
val | The value. |
N | The size of the array. |
A pointer to a (single) variable is treated as a 1-element array.
|
inline |
Store an array of Code objects in the TSLVariant.
codes | An array of codes to store. |
codeSpaces | An optional array of code spaces to store. |
N | The number of values in the array. |
|
inline |
This overload stores an array of strings as type STR. If N is 1 then a single string is stored. The type is always STR regardless of the number or length of the strings.
If the value is actually a pointer to an array of elements, the optional parameter must be set to the size of the array.
val | The value. |
N | The size of the array. |
A pointer to a (single) variable is treated as a 1-element array.
|
inline |
This overload internally calls setStringVal. This treats the val parameter as a single null-terminated string. The string is then stored as a NULL type if it was empty, as CHAR type if it has 1 to 254 characters, or as STR type if 255 characters or longer. A null terminator is stored.
Note: The parameter N is ignored.
val | The value. |
N | Ignored in this overload. |
|
inline |
Sets the value of the TSLVariant and its type (based on the type of the value).
If the value is actually a pointer to an array of elements, the optional parameter must be set to the size of the array.
val | The value. |
N | The size of the array. |
A pointer to a (single) variable is treated as a 1-element array.
|
inline |
Sets the value of the TSLVariant and its type (based on the type of the value).
If the value is actually a pointer to an array of elements, the optional parameter must be set to the size of the array.
val | The value. |
N | The size of the array. |
A pointer to a (single) variable is treated as a 1-element array.
|
inline |
Sets the value of the TSLVariant and its type (based on the type of the value).
If the value is actually a pointer to an array of elements, the optional parameter must be set to the size of the array.
val | The value. |
N | The size of the array. |
A pointer to a (single) variable is treated as a 1-element array.
|
inline |
Sets the value of the TSLVariant and its type (based on the type of the value).
If the value is actually a pointer to an array of elements, the optional parameter must be set to the size of the array.
val | The value. |
N | The size of the array. |
A pointer to a (single) variable is treated as a 1-element array.
|
inline |
Sets the value of the TSLVariant and its type (based on the type of the value).
This copies the value from the specified TSLVariant, without modifying the ID.
val | The value to set - only the value is taken over, not the ID. |
N | Ignored in this overload |
|
inline |
Sets the value of the TSLVariant and its type (based on the type of the value).
If the value is actually a pointer to an array of elements, the optional parameter must be set to the size of the array.
Note: There are two methods that take a TSLVariant. They have different functionality. This version 'stores' a TSLVariant or an array of TSLVariant's within this TSLVariant. The other version has been deprecated and replaced with the method copyVal.
ptr | The value. |
N | The size of the array. |
A pointer to a (single) variable is treated as a 1-element array.
|
inline |
Store an array of Binary objects in the TSLVariant.
blobs | An array of blobs to store. |
blobLengths | An array of lengths which specify the length of each blob which is being stored. |
mimeTypes | An optional array of mime types to store. |
urls | An optional array of urls to store. |
roles | An optional array of roles to store. |
N | The number of values in the array. |
|
inline |
Sets the value of the TSLVariant and its type (based on the type of the value).
This copies the value from the specified TSLVariant, without modifying the ID.
val | The value to set - only the value is taken over, not the ID. |
N | Ignored in this overload |
|
inline |
Store an array of Measurement objects in the TSLVariant.
measurements | An array of measurements to store. |
uoms | An optional array of uoms to store. |
N | The number of values in the array. |
|
inline |
Sets the value of the TSLVariant and its type (based on the type of the value).
Notes:
ptr | A 'void *' ptr to set. The TSLVariant does not take ownership. |
|
inline |
Returns the number of array elements that the (pointer) value is referencing. Non-pointer values always return 0. The value returned is confusing if a single string is stored: it may return 1 if the string is longer than 254 characters or if it was stored using the array overload. Use getStringLen to obtain string sizes.