MapLink Pro 11.1.1.0.
Envitia MapLink Pro: The Ultimate Mapping Application Toolkit
Loading...
Searching...
No Matches
TSLVariant Class Reference

Detailed Description

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:

  • TSLVariantTypeBool (bool),
  • TSLVariantTypeChar (8bit char),
  • TSLVariantTypeShort (16bit short),
  • TSLVariantTypeLong (32bit long),
  • TSLVariantTypeFloat (32bit float),
  • TSLVariantTypeDouble (64bit double),
  • TSLVariantTypeStr (string),
  • TSLVariantTypeNull (null string - different from a 'nil' variant which can apply to any type).
  • TSLVariantTypeEntityID (TSLEntityID)
  • TSLVariantTypeULong (32bit unsigned long)
  • TSLVariantTypeBinary (TSLVariant::Binary)
  • TSLVariantTypeDateTime (TSLTimeType)
  • TSLVariantTypeCode (TSLVariant::Code)
  • TSLVariantTypeMeasurement (TSLVariant::Measurement)
  • TSLVariantTypeReference (string)
  • TSLVariantTypeURI (string)
  • TSLVariantTypePtr (void * pointer, 32bit when compiled 32bit, 64bit when compiled 64bit)
  • TSLVariantTypeVariant (A collection of other TSLVariants)

These types are defined by the enumeration TSLVariantType.

NOTE:

  1. TSLVariantTypeChar stores an array of characters, TSLVariantTypeStr stores an array of strings. Since all arrays have a maximum size of 255, TSLVariantTypeChar is limited to 255-character strings. Use an array of strings to store arbitrary-length strings (the array may have one entry, to store a single string).
  2. For single strings, getVal( const char * val ) is the easiest for querying. The easiest way to deal setting string data, or arrays of string data, is to use the setStringVal / getStringVal / getStringLen. methods rather than the overloaded getVal / setVal methods.
  3. A null string ("") is treated as a non-array (isArray() returns false) of type TSLVariantTypeNull - getVal( const char * val ) handles this correctly.
  4. All arrays are limited to 255 entries maximum.
  5. For compatibility with 64bit non-Windows Operating Systems such as Linux/Solaris/DEC-Alpha which have 8-byte longs, longs are treated as ints internally to this class.
  6. Variants may be 'nil' - which can be tested or set using the 'isNil' method. If this is true then the variant value should not be queried.
  7. Variants may be external references - such as a database key or hyperlink. If so, then the 'isExternalReference' flag is set
  8. TSLVariantTypePtr are not persistent, i.e. they are not eligible for streaming.

Public Types

typedef unsigned char Byte_
 
 TSLVariant ()
 
 TSLVariant (const TSLVariant &rhs)
 
 ~TSLVariant ()
 
TSLVariantoperator= (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
 

Member Typedef Documentation

◆ Byte_

typedef unsigned char TSLVariant::Byte_

Constructor & Destructor Documentation

◆ TSLVariant() [1/2]

TSLVariant::TSLVariant ( )
inline

Default constructor.

◆ TSLVariant() [2/2]

TSLVariant::TSLVariant ( const TSLVariant & rhs)
inline

Copy constructor.

◆ ~TSLVariant()

TSLVariant::~TSLVariant ( )
inline

Destructor - this will delete any memory it owns (this is always the case where memory is allocated as a result of streaming in).

Member Function Documentation

◆ clear()

void TSLVariant::clear ( )
inline

Sets the object to empty.

◆ compareValues()

bool TSLVariant::compareValues ( const TSLVariant & other) const
inline

Comparison function. Returns true if the value of the other object is the same as this object. The 'id' fields are ignored.

◆ copyVal()

void TSLVariant::copyVal ( const TSLVariant * val)
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.

Parameters
valThe value to set - only the value is taken over, not the ID.

◆ getID()

void TSLVariant::getID ( char str[3]) const
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.

Parameters
strThe returned id descriptor, which is NULL terminated. str must point to an array of 3 bytes minimum.

◆ getStringLen()

bool TSLVariant::getStringLen ( int * len) const
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.

Parameters
lenReturns 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.
Returns
true if the variant is type CHAR or NULL or STR with size 1, false otherwise.

◆ getStringVal()

bool TSLVariant::getStringVal ( char * val,
int len ) const
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.

Parameters
valThe 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.
lenlength of the buffer passed to val. The string written to val will not exceed this length, including null terminator.
Returns
true if the variant is type CHAR, NULL, STR, URI or REFERENCE with size 1, false otherwise.

◆ getTimeVal()

bool TSLVariant::getTimeVal ( TSLTimeType * val) const
inline

Returns the value of the TSLVariant (based on the type of the supplied argument).

Parameters
valThe 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.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getType()

TSLVariantType TSLVariant::getType ( ) const
inline

Returns the type of the TSLVariant.

◆ getVal() [1/21]

bool TSLVariant::getVal ( bool & val,
int index ) const
inline

Returns the value of the TSLVariant (based on the type of the supplied argument).

Parameters
valThe value returned will be stored in this variable.
indexThe index of the value to return.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getVal() [2/21]

bool TSLVariant::getVal ( bool * val) const
inline

Returns the value of the TSLVariant (based on the type of the supplied argument).

Parameters
valThe 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.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getVal() [3/21]

bool TSLVariant::getVal ( char * val) const
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.

Parameters
valThe 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.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getVal() [4/21]

bool TSLVariant::getVal ( char * val[]) const
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.

Parameters
valThe address of an array of values to be received from the variant.
Note
The array must be at least as large as the size of the variant. UNLIKE the other overloads, if the variant has size 1, it is NOT legal to pass the address of a single variable to receive the value.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getVal() [5/21]

bool TSLVariant::getVal ( const char ** val) const
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.

Parameters
valThe 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.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getVal() [6/21]

bool TSLVariant::getVal ( double & val,
int index ) const
inline

Returns the value of the TSLVariant (based on the type of the supplied argument).

Parameters
valThe value returned will be stored in this variable.
indexThe index of the value to return.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getVal() [7/21]

bool TSLVariant::getVal ( double * measurements,
TSLSimpleString * uoms ) const
inline

Retrieves an array of Measurement objects which are being stored by the TSLVariant.

Parameters
measurementsAn array of doubles which will be populated with the measurement values held by the variant.
uomsAn array of TSLSimpleStrings which will be populated with the uom values held by the variant.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getVal() [8/21]

bool TSLVariant::getVal ( double * val) const
inline

Returns the value of the TSLVariant (based on the type of the supplied argument).

Parameters
valThe 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.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getVal() [9/21]

bool TSLVariant::getVal ( float & val,
int index ) const
inline

Returns the value of the TSLVariant (based on the type of the supplied argument).

Parameters
valThe value returned will be stored in this variable.
indexThe index of the value to return.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getVal() [10/21]

bool TSLVariant::getVal ( float * val) const
inline

Returns the value of the TSLVariant (based on the type of the supplied argument).

Parameters
valThe 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.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getVal() [11/21]

bool TSLVariant::getVal ( int & val,
int index ) const
inline

Returns the value of the TSLVariant (based on the type of the supplied argument).

Parameters
valThe value returned will be stored in this variable.
indexThe index of the value to return.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getVal() [12/21]

bool TSLVariant::getVal ( int * val) const
inline

Returns the value of the TSLVariant (based on the type of the supplied argument).

Parameters
valThe 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.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getVal() [13/21]

bool TSLVariant::getVal ( short & val,
int index ) const
inline

Returns the value of the TSLVariant (based on the type of the supplied argument).

Parameters
valThe value returned will be stored in this variable.
indexThe index of the value to return.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getVal() [14/21]

bool TSLVariant::getVal ( short * val) const
inline

Returns the value of the TSLVariant (based on the type of the supplied argument).

Parameters
valThe 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.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getVal() [15/21]

bool TSLVariant::getVal ( TSLEntityID & val,
int index ) const
inline

Returns the value of the TSLVariant (based on the type of the supplied argument).

Parameters
valThe value returned will be stored in this variable.
indexThe index of the value to return.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getVal() [16/21]

bool TSLVariant::getVal ( TSLEntityID * val) const
inline

Returns the value of the TSLVariant (based on the type of the supplied argument).

Parameters
valThe 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.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getVal() [17/21]

bool TSLVariant::getVal ( TSLSimpleString * codes,
TSLSimpleString * codeSpaces ) const
inline

Retrieves an array of Code objects which are being stored by the TSLVariant.

Parameters
codesAn array of TSLSimpleStrings which will be populated with the code values held by the variant.
codeSpacesAn array of TSLSimpleStrings which will be populated with the code space values held by the variant.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getVal() [18/21]

bool TSLVariant::getVal ( TSLVariant * ptr) const
inline

Returns the value of the TSLVariant (based on the type of the supplied argument).

Parameters
ptrThe 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.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getVal() [19/21]

bool TSLVariant::getVal ( unsigned char ** blobs,
int * blobLengths,
TSLSimpleString * mimeTypes,
TSLSimpleString * urls,
TSLSimpleString * roles ) const
inline

Retrieves an array of Binary objects which are being stored by the TSLVariant.

Parameters
blobsAn 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.
blobLengthsAn array of lengths which specify the length of the buffer passed to each blob. The value written to blob will not exceed this length.
mimeTypesAn array of TSLSimpleStrings which will be populated with the mime Types being held by the variant.
urlsAn array of TSLSimpleStrings which will be populated with the URLs being held by the variant.
rolesAn array of TSLSimpleStrings which will be populated with the roles being held by the variant.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getVal() [20/21]

bool TSLVariant::getVal ( unsigned int * val) const
inline

Returns the value of the TSLVariant (based on the type of the supplied argument).

Parameters
valThe 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.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getVal() [21/21]

bool TSLVariant::getVal ( void ** ptr) const
inline

Retrieves a pointer which is being stored by the TSLVariant.

Notes:

  1. Pointers are not streamed.
  2. What the pointer actually points to is dependent on the context of use. This is primarily used by the Editor SDK.
Parameters
ptrA pointer to a 'void *'. The actual pointer value will be assigned.
Returns
true if the value type is the same type as the TSLVariant; false otherwise.

◆ getValueAsString()

int TSLVariant::getValueAsString ( char * str,
int len,
const char * format = 0 ) const
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.

Parameters
strpass the address of a string to be populated, or pass zero to find the required length.
lenIf str is nonzero, specifies the size of the buffer, limiting the output.
formatIf 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 ','.
Returns
the required length of buffer if str is zero, or the total buffer bytes used if str is non-zero, always including the null terminator.

◆ id()

const char * TSLVariant::id ( const char * str)
inline

This method sets the description id (which is a 2 Byte_ element) of the attribute.

Parameters
strThe id descriptor.

◆ init()

void TSLVariant::init ( )
inline

Initialises the TSLVariant to empty.

◆ isArray()

bool TSLVariant::isArray ( ) const
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.

◆ isExternalReference() [1/2]

bool TSLVariant::isExternalReference ( ) const
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.

◆ isExternalReference() [2/2]

void TSLVariant::isExternalReference ( bool isExternal)
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.

◆ isNil() [1/2]

bool TSLVariant::isNil ( ) const
inline

Gets whether this TSLVariant is nil. This works with all types of variant. If true, the current value should not be used

◆ isNil() [2/2]

void TSLVariant::isNil ( bool nil)
inline

Sets whether this TSLVariant is nil. This works with all types of variant and does not affect the value current held.

◆ operator=()

TSLVariant & TSLVariant::operator= ( const TSLVariant & rhs)
inline

Assignment operator.

◆ operator==()

bool TSLVariant::operator== ( const TSLVariant & other) const
inline

Comparison operator. Returns true if both the id and the value of the other object are the same as this object.

◆ setReferenceVal()

void TSLVariant::setReferenceVal ( const char *const val[],
unsigned char N = 1 )
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.

Parameters
valThe value.
NThe size of the array.

A pointer to a (single) variable is treated as a 1-element array.

◆ setStringVal()

void TSLVariant::setStringVal ( const char * val,
bool promote = false )
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.

Parameters
valString to be saved
promoteIf true store the value as a TSLVariantTypeString even if it may be classed as a TSLVariantTypeChar.

◆ setTimeVal()

void TSLVariant::setTimeVal ( const TSLTimeType * val,
unsigned char N = 1 )
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.

Parameters
valThe value.
NThe size of the array.

A pointer to a (single) variable is treated as a 1-element array.

◆ setURIVal()

void TSLVariant::setURIVal ( const char *const val[],
unsigned char N = 1 )
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.

Parameters
valThe value.
NThe size of the array.

A pointer to a (single) variable is treated as a 1-element array.

◆ setVal() [1/14]

void TSLVariant::setVal ( const bool * val,
unsigned char N = 1 )
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.

Parameters
valThe value.
NThe size of the array.

A pointer to a (single) variable is treated as a 1-element array.

◆ setVal() [2/14]

void TSLVariant::setVal ( const char ** codes,
const char ** codeSpaces,
unsigned char N = 1 )
inline

Store an array of Code objects in the TSLVariant.

Parameters
codesAn array of codes to store.
codeSpacesAn optional array of code spaces to store.
NThe number of values in the array.

◆ setVal() [3/14]

void TSLVariant::setVal ( const char *const val[],
unsigned char N = 1 )
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.

Parameters
valThe value.
NThe size of the array.

A pointer to a (single) variable is treated as a 1-element array.

◆ setVal() [4/14]

void TSLVariant::setVal ( const char * val,
unsigned char N = 1 )
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.

Parameters
valThe value.
NIgnored in this overload.

◆ setVal() [5/14]

void TSLVariant::setVal ( const double * val,
unsigned char N = 1 )
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.

Parameters
valThe value.
NThe size of the array.

A pointer to a (single) variable is treated as a 1-element array.

◆ setVal() [6/14]

void TSLVariant::setVal ( const float * val,
unsigned char N = 1 )
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.

Parameters
valThe value.
NThe size of the array.

A pointer to a (single) variable is treated as a 1-element array.

◆ setVal() [7/14]

void TSLVariant::setVal ( const int * val,
unsigned char N = 1 )
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.

Parameters
valThe value.
NThe size of the array.

A pointer to a (single) variable is treated as a 1-element array.

◆ setVal() [8/14]

void TSLVariant::setVal ( const short * val,
unsigned char N = 1 )
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.

Parameters
valThe value.
NThe size of the array.

A pointer to a (single) variable is treated as a 1-element array.

◆ setVal() [9/14]

void TSLVariant::setVal ( const TSLEntityID * val,
unsigned char N = 1 )
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.

Parameters
valThe value to set - only the value is taken over, not the ID.
NIgnored in this overload

◆ setVal() [10/14]

void TSLVariant::setVal ( const TSLVariant * ptr,
unsigned char N )
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.

Parameters
ptrThe value.
NThe size of the array.

A pointer to a (single) variable is treated as a 1-element array.

◆ setVal() [11/14]

void TSLVariant::setVal ( const unsigned char *const * blobs,
int * blobLengths,
const char *const * mimeTypes,
const char *const * urls,
const char *const * roles,
unsigned char N = 1 )
inline

Store an array of Binary objects in the TSLVariant.

Parameters
blobsAn array of blobs to store.
blobLengthsAn array of lengths which specify the length of each blob which is being stored.
mimeTypesAn optional array of mime types to store.
urlsAn optional array of urls to store.
rolesAn optional array of roles to store.
NThe number of values in the array.

◆ setVal() [12/14]

void TSLVariant::setVal ( const unsigned int * val,
unsigned char N = 1 )
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.

Parameters
valThe value to set - only the value is taken over, not the ID.
NIgnored in this overload

◆ setVal() [13/14]

void TSLVariant::setVal ( double * measurements,
const char ** uoms,
unsigned char N = 1 )
inline

Store an array of Measurement objects in the TSLVariant.

Parameters
measurementsAn array of measurements to store.
uomsAn optional array of uoms to store.
NThe number of values in the array.

◆ setVal() [14/14]

void TSLVariant::setVal ( void * ptr)
inline

Sets the value of the TSLVariant and its type (based on the type of the value).

Notes:

  1. Pointers are not streamed.
  2. What the pointer actually points to is dependent on the context of use. This is primarily used by the Editor SDK.
Parameters
ptrA 'void *' ptr to set. The TSLVariant does not take ownership.

◆ size()

unsigned char TSLVariant::size ( ) const
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.