ROVariant
Overview
This class is designed to read and write a Delphi-compatible variant type. The variant type can be used to represent a piece of data of unknown type and can hold different/changing types of data at runtime.
A number of properties are defined in this class to access the data as regular Objective-C types. The class tries to convert the data in all possible ways but if the data conversion is impossible in the particular case (e.g. a GUID can not be converted to a number) an exception with name ROVariantError will be thrown. The similar exception is thrown in response to attempt to treat the data as an array while a single value is stored.
Location
- Reference: ROVariant.h
- Namespace: RemObjectsSDK
- Ancestry: NSObject | ROVariant
arrayCount
Returns the number of array elements if the ROVariant instance holds the array. An exception will be thrown if the data is not an array.
@property (readonly) int arrayCount
arrayDataType
Returns the array data type code (ROVariantTypeCode enumeration) if the ROVariant instance holds the array. An exception will be thrown if the data is not an array.
@property (readonly) enum ROVariantTypeCode arrayDataType
asBool
Reads or writes the data as boolean.
@property () BOOL asBool
asData assign
Reads or writes the data as a raw binary data. Will return an internal binary representation of any regular data type if one is stored.
@property (assign) NSData *asData
asDate assign
Reads or writes the data as date-time value.
@property (assign) NSDate *asDate
asDecimal assign
Reads or writes the data as fixed-point number value.
@property (assign) NSDecimalNumber *asDecimal
asDouble
Reads or writes the data as floating-point number value.
@property () double asDouble
asGuid assign
Reads or writes the data as ROGuid value.
@property (assign) ROGuid *asGuid
asInt64
Reads or writes the data as 64 bits integer value.
@property () int64 asInt64
asInteger
Reads or writes the data as integer value.
@property () int asInteger
asString assign
Reads or writes the data as string value (16 bits per character).
@property (assign) NSString *asString
asUtfString
Reads or writes the data as UTF-8 encoded value (8 bits per character).
@property () char *asUtfString
asVariant assign
Reads or writes the data as variant value.
@property (assign) ROVariant *asVariant
dataType
Returns the data type code (ROVariantTypeCode enumeration) of the data stored in the ROVariant instance.
@property (readonly) enum ROVariantTypeCode dataType
emptyVariant
Creates a ROVariant instance containing no value.
+ (ROVariant *) emptyVariant
getItemAtIndex:
Allows to read the array element if ROVariant instance holds an array data. An exception will be thrown in the instance holds a single value.
- (ROVariant *) getItemAtIndex:(int)aIndex
Parameters:
- aIndex: A zero-based index of the element to read.
initWithDataType:value:
- (InstanceType) initWithDataType:(enum ROVariantTypeCode)aDataType value:(id<NSCopying>)aValue
Parameters:
- aDataType:
- aValue:
isEmpty
Returns YES if the instance contains no value.
@property (readonly) BOOL isEmpty
isNull
Returns YES if the instance contains NULL value. Note: NULL here is provided for compatibility with Delphi and has nothing to do with C-style NULL representing an empty pointer.
@property (readonly) BOOL isNull
nullVariant
Creates a ROVariant instance containing Delphi-compatible NULL value.
+ (ROVariant *) nullVariant
setArrayLength:type:
Prepares the ROVariant instance to hold an array of specified length and element data type. If the instance already contains an array of the same data type the method will resize the array preserving the content as possible.
- (void) setArrayLength:(int)aLength type:(enum ROVariantTypeCode)aDataType
Parameters:
- aLength: The length of the array to store.
- aDataType: The data type code (see ROVariantTypeCode) of the array elements.
setEmpty
Clears any value stored in the ROVariant instance resetting it to empty state.
- (void) setEmpty
setItem:atIndex:
Stores the data into the array element specified by index. The ROVariant instance must be prepared to hold an array with a setArrayLength:type: call.
- (void) setItem:(ROVariant *)aItem atIndex:(int)aIndex
Parameters:
- aItem: The value to store.
- aIndex: The index in the array to store the value at.
setNull
Clears any value stored in the ROVariant instance resetting it to Delphi-compatible NULL state.
- (void) setNull
value
Provides read-only access to the internal data storage of the ROVariant instance.
@property (readonly) id<NSObject, NSCopying> value
variantWithBool:
Wrap boolen value into ROVariant instance
+ (ROVariant *) variantWithBool:(BOOL)value
Parameters:
- value: BOOL value we need to convert to ROVariant
variantWithString:
Wrap NSString value into ROVariant instance
+ (ROVariant *) variantWithString:(NSString *)string
Parameters:
- string: NSString value we need to convert to ROVariant
arrayCount
Returns the number of array elements if the ROVariant instance holds the array. An exception will be thrown if the data is not an array.
@property (readonly) int arrayCount
arrayDataType
Returns the array data type code (ROVariantTypeCode enumeration) if the ROVariant instance holds the array. An exception will be thrown if the data is not an array.
@property (readonly) enum ROVariantTypeCode arrayDataType
asBool
Reads or writes the data as boolean.
@property () BOOL asBool
asData assign
Reads or writes the data as a raw binary data. Will return an internal binary representation of any regular data type if one is stored.
@property (assign) NSData *asData
asDate assign
Reads or writes the data as date-time value.
@property (assign) NSDate *asDate
asDecimal assign
Reads or writes the data as fixed-point number value.
@property (assign) NSDecimalNumber *asDecimal
asDouble
Reads or writes the data as floating-point number value.
@property () double asDouble
asGuid assign
Reads or writes the data as ROGuid value.
@property (assign) ROGuid *asGuid
asInt64
Reads or writes the data as 64 bits integer value.
@property () int64 asInt64
asInteger
Reads or writes the data as integer value.
@property () int asInteger
asString assign
Reads or writes the data as string value (16 bits per character).
@property (assign) NSString *asString
asUtfString
Reads or writes the data as UTF-8 encoded value (8 bits per character).
@property () char *asUtfString
asVariant assign
Reads or writes the data as variant value.
@property (assign) ROVariant *asVariant
dataType
Returns the data type code (ROVariantTypeCode enumeration) of the data stored in the ROVariant instance.
@property (readonly) enum ROVariantTypeCode dataType
isEmpty
Returns YES if the instance contains no value.
@property (readonly) BOOL isEmpty
isNull
Returns YES if the instance contains NULL value. Note: NULL here is provided for compatibility with Delphi and has nothing to do with C-style NULL representing an empty pointer.
@property (readonly) BOOL isNull
value
Provides read-only access to the internal data storage of the ROVariant instance.
@property (readonly) id<NSObject, NSCopying> value
emptyVariant
Creates a ROVariant instance containing no value.
+ (ROVariant *) emptyVariant
nullVariant
Creates a ROVariant instance containing Delphi-compatible NULL value.
+ (ROVariant *) nullVariant
variantWithBool:
Wrap boolen value into ROVariant instance
+ (ROVariant *) variantWithBool:(BOOL)value
Parameters:
- value: BOOL value we need to convert to ROVariant
variantWithString:
Wrap NSString value into ROVariant instance
+ (ROVariant *) variantWithString:(NSString *)string
Parameters:
- string: NSString value we need to convert to ROVariant
getItemAtIndex:
Allows to read the array element if ROVariant instance holds an array data. An exception will be thrown in the instance holds a single value.
- (ROVariant *) getItemAtIndex:(int)aIndex
Parameters:
- aIndex: A zero-based index of the element to read.
initWithDataType:value:
- (InstanceType) initWithDataType:(enum ROVariantTypeCode)aDataType value:(id<NSCopying>)aValue
Parameters:
- aDataType:
- aValue:
setArrayLength:type:
Prepares the ROVariant instance to hold an array of specified length and element data type. If the instance already contains an array of the same data type the method will resize the array preserving the content as possible.
- (void) setArrayLength:(int)aLength type:(enum ROVariantTypeCode)aDataType
Parameters:
- aLength: The length of the array to store.
- aDataType: The data type code (see ROVariantTypeCode) of the array elements.
setEmpty
Clears any value stored in the ROVariant instance resetting it to empty state.
- (void) setEmpty
setItem:atIndex:
Stores the data into the array element specified by index. The ROVariant instance must be prepared to hold an array with a setArrayLength:type: call.
- (void) setItem:(ROVariant *)aItem atIndex:(int)aIndex
Parameters:
- aItem: The value to store.
- aIndex: The index in the array to store the value at.
setNull
Clears any value stored in the ROVariant instance resetting it to Delphi-compatible NULL state.
- (void) setNull
- ROVariantTypeCode enumeration