NTVariant
@interface NTVariant : NSObject {
void *swigCPtr;
BOOL swigCMemOwn;
}
JSON value. Can contain JSON-style structured data, including objects and arrays.
-
Checks if this object is equal to the specified object.
Declaration
Objective-C
- (BOOL)isEqual:(id)object;
Parameters
object
The reference object.
Return Value
True when objects are equal, false otherwise.
-
Returns the hash value of this object.
Declaration
Objective-C
- (NSUInteger)hash;
Return Value
The hash value of this object.
-
Constructs a null Variant object.
Declaration
Objective-C
- (id)init;
-
Constructs Variant object from a boolean.
Declaration
Objective-C
- (id)initWithBoolVal:(BOOL)boolVal;
Parameters
boolVal
The boolean value.
-
Constructs Variant object from an integer.
Declaration
Objective-C
- (id)initWithLongVal:(long long)longVal;
Parameters
longVal
The integer value.
-
Constructs Variant object from a double.
Declaration
Objective-C
- (id)initWithDoubleVal:(double)doubleVal;
Parameters
doubleVal
The double value.
-
Constructs Variant object from a string.
Declaration
Objective-C
- (id)initWithString:(NSString *)string;
Parameters
string
The string value.
-
Constructs Variant object from a list of values.
Declaration
Objective-C
- (id)initWithArray:(NTVariantVector *)array;
Parameters
array
The array of JSON values.
-
Constructs Variant object from a map of values.
Declaration
Objective-C
- (id)initWithObject:(NTStringVariantMap *)object;
Parameters
object
The map of JSON values.
-
Returns the type of this variant.
Declaration
Objective-C
- (enum NTVariantType)getType;
Return Value
The type of this variant.
-
Returns the string value of this variant.
Declaration
Objective-C
- (NSString *)getString;
Return Value
The string value of the variant. If the variant is not string, empty string will be returned.
-
Returns the boolean value of this variant.
Declaration
Objective-C
- (BOOL)getBool;
Return Value
The boolean value of the variant. If the variant is not boolean, false will be returned.
-
Returns the integer value of this variant.
Declaration
Objective-C
- (long long)getLong;
Return Value
The integer value of the variant. If the variant is not integer, 0 will be returned.
-
Returns the floating point value of this variant.
Declaration
Objective-C
- (double)getDouble;
Return Value
The floating point value of the variant. If the variant is integer, it will be converted to floating point. Otherwise 0.0 is be returned.
-
Returns the number of elements in the array.
Declaration
Objective-C
- (int)getArraySize;
Return Value
The number of elements in the array if the variant is of array type. Otherwise 0 is returned.
-
Returns the element of array at specified position.
Declaration
Objective-C
- (NTVariant *)getArrayElement:(int)idx;
Parameters
idx
The index of the array element to return (starting from 0).
Return Value
The array element at specified position or null type if the element does not exist or the variant is not an array.
-
Returns all the keys in the object.
Declaration
Objective-C
- (NTStringVector *)getObjectKeys;
Return Value
The list containing all the keys of the object if the variant is of object type. Otherwise empty list is returned.
-
Returns true if object elements contains the specified key.
Declaration
Objective-C
- (BOOL)containsObjectKey:(NSString *)key;
Parameters
key
The key of the object element to check.
Return Value
True if the specified key exists in the object. If the element is not an object or the key does not exist, false is returned.
-
Returns the element of object with the specified key.
Declaration
Objective-C
- (NTVariant *)getObjectElement:(NSString *)key;
Parameters
key
The key of the object element to return.
Return Value
The object element with the specified key or null type if the element does not exist or the variant is not an object.
-
Checks for equality between this and another variant object.
Declaration
Objective-C
- (BOOL)isEqualInternal:(NTVariant *)var;
Parameters
var
The other variant object.
Return Value
True if equal.
-
Returns the hash value of this object.
Declaration
Objective-C
- (int)hashInternal;
Return Value
The hash value of this object.
-
Converts the variant to JSON string.
Declaration
Objective-C
- (NSString *)description;
Return Value
The JSON string corresponding to the variant.
-
Creates a Variant object from a JSON string representation.
Warning
Throws NSException If the string parsing fails.Declaration
Objective-C
+ (NTVariant *)fromString:(NSString *)str;
Parameters
str
The JSON string to use for the variant.
Return Value
The corresponding Variant object.
-
Undocumented
Declaration
Objective-C
-(void)dealloc;