Class: Wx::Variant

Inherits:
Object show all
Includes:
Enumerable
Defined in:
lib/wx/doc/gen/variant.rb,
lib/wx/doc/variant.rb

Overview

Note:

This class is untracked and should not be derived from nor instances extended!

The Variant class represents a container for any type.

A variant’s value can be changed at run time, possibly to a different type of value. In wxRuby Wx::Variant is the only available Wx variant class (unlike in C++) and almost exclusively for use in combination with the property grid classes (see the PG module).

By default Wx::Variant can store values of type bool, Integer, Float, String, Time (or Date / DateTime), Array of String, Array of Variant, Font, Colour and ColourPropertyValue. In addition Wx::Variant can store any Ruby Object.

An optional name member is associated with a Wx::Variant.

In wxRuby Wx::Variant also provides the standard conversion methods #to_i, #to_s and #to_f for supported value types. In case of incompatible value types these methods will raise a TypeError exception.

Requires:

  • USE_VARIANT

Instance Method Summary collapse

Methods inherited from Object

#is_same_as, #un_share

Constructor Details

#initializeWx::Variant #initialize(data, name = ('')) ⇒ Wx::Variant #initialize(variant) ⇒ Wx::Variant #initialize(value, name = ('')) ⇒ Wx::Variant #initialize(value, name = ('')) ⇒ Wx::Variant #initialize(value, name = ('')) ⇒ Wx::Variant #initialize(value, name = ('')) ⇒ Wx::Variant #initialize(value, name = ('')) ⇒ Wx::Variant #initialize(value, name = ('')) ⇒ Wx::Variant #initialize(value, name = ('')) ⇒ Wx::Variant #initialize(val, name = ('')) ⇒ Wx::Variant #initialize(val, name = ('')) ⇒ Wx::Variant

Returns a new instance of Variant.

Overloads:

  • #initializeWx::Variant

    Default constructor.

  • #initialize(data, name = ('')) ⇒ Wx::Variant

    Constructs a variant directly with a Wx::VariantData object.

    Wx::Variant will take ownership of the Wx::VariantData and will not increase its reference count.

    Parameters:

    • data (Object)
    • name (String) (defaults to: (''))
  • #initialize(variant) ⇒ Wx::Variant

    Constructs a variant from another variant by increasing the reference count.

    Parameters:

    • variant (nil, String, Integer, Float, Time, Wx::Font, Wx::Colour, Wx::Variant, Array<WxVariant>, Array<String>, ObjectWx::PG::ColourPropertyValue)
  • #initialize(value, name = ('')) ⇒ Wx::Variant

    Constructs a variant from a string.

    Parameters:

    • value (String)
    • name (String) (defaults to: (''))
  • #initialize(value, name = ('')) ⇒ Wx::Variant

    Constructs a variant from a long.

    Parameters:

    • value (Integer)
    • name (String) (defaults to: (''))
  • #initialize(value, name = ('')) ⇒ Wx::Variant

    Constructs a variant from a bool.

    Parameters:

    • value (Boolean)
    • name (String) (defaults to: (''))
  • #initialize(value, name = ('')) ⇒ Wx::Variant

    Constructs a variant from a double.

    Parameters:

    • value (Float)
    • name (String) (defaults to: (''))
  • #initialize(value, name = ('')) ⇒ Wx::Variant

    Constructs a variant from a LongLong.

    Parameters:

    • value (Integer)
    • name (String) (defaults to: (''))
  • #initialize(value, name = ('')) ⇒ Wx::Variant

    Constructs a variant from a ULongLong.

    Parameters:

    • value (Integer)
    • name (String) (defaults to: (''))
  • #initialize(value, name = ('')) ⇒ Wx::Variant

    Constructs a variant from a list of variants.

    Parameters:

    • value (Array<Wx::Variant>)
    • name (String) (defaults to: (''))
  • #initialize(val, name = ('')) ⇒ Wx::Variant

    Constructs a variant from a DateTime.

    Parameters:

    • val (Time, Date, DateTime)
    • name (String) (defaults to: (''))
  • #initialize(val, name = ('')) ⇒ Wx::Variant

    Constructs a variant from a ArrayString.

    Parameters:

    • val (Array<String>)
    • name (String) (defaults to: (''))


180
# File 'lib/wx/doc/gen/variant.rb', line 180

def initialize(*args) end

Instance Method Details

#==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean

Overloads:

  • #==(value) ⇒ Boolean

    Equality test operator.

    Parameters:

    • value (nil, String, Integer, Float, Time, Wx::Font, Wx::Colour, Wx::Variant, Array<WxVariant>, Array<String>, ObjectWx::PG::ColourPropertyValue)

    Returns:

    • (Boolean)
  • #==(value) ⇒ Boolean

    Equality test operator.

    Parameters:

    • value (String)

    Returns:

    • (Boolean)
  • #==(value) ⇒ Boolean

    Equality test operator.

    Parameters:

    • value (String)

    Returns:

    • (Boolean)
  • #==(value) ⇒ Boolean

    Equality test operator.

    Parameters:

    • value (String)

    Returns:

    • (Boolean)
  • #==(value) ⇒ Boolean

    Equality test operator.

    Parameters:

    • value (Integer)

    Returns:

    • (Boolean)
  • #==(value) ⇒ Boolean

    Equality test operator.

    Parameters:

    • value (Boolean)

    Returns:

    • (Boolean)
  • #==(value) ⇒ Boolean

    Equality test operator.

    Parameters:

    • value (Float)

    Returns:

    • (Boolean)
  • #==(value) ⇒ Boolean

    Equality test operator.

    Parameters:

    • value (Integer)

    Returns:

    • (Boolean)
  • #==(value) ⇒ Boolean

    Equality test operator.

    Parameters:

    • value (Integer)

    Returns:

    • (Boolean)
  • #==(value) ⇒ Boolean

    Equality test operator.

    Parameters:

    Returns:

    • (Boolean)
  • #==(value) ⇒ Boolean

    Equality test operator.

    Parameters:

    Returns:

    • (Boolean)
  • #==(value) ⇒ Boolean

    Equality test operator.

    Parameters:

    Returns:

    • (Boolean)
  • #==(value) ⇒ Boolean

    Equality test operator.

    Parameters:

    • value (Array<String>)

    Returns:

    • (Boolean)
  • #==(value) ⇒ Boolean

    Equality test operator.

    Parameters:

    • value (Time, Date, DateTime)

    Returns:

    • (Boolean)


119
# File 'lib/wx/doc/gen/variant.rb', line 119

def ==(*args) end

#append(value) ⇒ void

This method returns an undefined value.

Appends a value to the list.

Parameters:

  • value (nil, String, Integer, Float, Time, Wx::Font, Wx::Colour, Wx::Variant, Array<WxVariant>, Array<String>, ObjectWx::PG::ColourPropertyValue)


32
# File 'lib/wx/doc/gen/variant.rb', line 32

def append(value) end

#array_string?true, false

Checks if Variant contains an ArrayString (array of String) value (not null).

Returns:

  • (true, false)


136
# File 'lib/wx/doc/variant.rb', line 136

def array_string?; end

#assign(value) ⇒ self #assign(value) ⇒ self #assign(value) ⇒ self #assign(value) ⇒ self #assign(value) ⇒ self #assign(value) ⇒ self #assign(value) ⇒ self #assign(value) ⇒ self #assign(value) ⇒ self #assign(value) ⇒ self #assign(value) ⇒ self #assign(value) ⇒ self Also known as: <<

Replaces the value of the current variant with the given value

Overloads:

  • #assign(value) ⇒ self

    Equality test operator.

    Parameters:

    Returns:

    • (self)
  • #assign(value) ⇒ self

    Equality test operator.

    Parameters:

    • value (String)

    Returns:

    • (self)
  • #assign(value) ⇒ self

    Equality test operator.

    Parameters:

    • value (Integer)

    Returns:

    • (self)
  • #assign(value) ⇒ self

    Equality test operator.

    Parameters:

    • value (true, false)

    Returns:

    • (self)
  • #assign(value) ⇒ self

    Equality test operator.

    Parameters:

    • value (Float)

    Returns:

    • (self)
  • #assign(value) ⇒ self

    Equality test operator.

    Parameters:

    • value (Integer)

    Returns:

    • (self)
  • #assign(value) ⇒ self

    Equality test operator.

    Parameters:

    • value (Integer)

    Returns:

    • (self)
  • #assign(value) ⇒ self

    Equality test operator.

    Parameters:

    • value (::Object)

    Returns:

    • (self)
  • #assign(value) ⇒ self

    Equality test operator.

    Parameters:

    Returns:

    • (self)
  • #assign(value) ⇒ self

    Equality test operator.

    Parameters:

    Returns:

    • (self)
  • #assign(value) ⇒ self

    Equality test operator.

    Parameters:

    • value (Array<String>)

    Returns:

    • (self)
  • #assign(value) ⇒ self

    Equality test operator.

    Parameters:

    • value (Time, Date, DateTime)

    Returns:

    • (self)


73
# File 'lib/wx/doc/variant.rb', line 73

def assign(*args) end

#bool?true, false

Checks if Variant contains a boolean value (not null).

Returns:

  • (true, false)


97
# File 'lib/wx/doc/variant.rb', line 97

def bool?; end

#clearvoid

This method returns an undefined value.

Makes the variant null by deleting the internal data and set the name to EmptyString.



36
# File 'lib/wx/doc/gen/variant.rb', line 36

def clear; end

#clear_listvoid

This method returns an undefined value.

Deletes the contents of the list.



40
# File 'lib/wx/doc/gen/variant.rb', line 40

def clear_list; end

#cloneWx::Variant

Calls #dup.

Returns:



177
# File 'lib/wx/doc/variant.rb', line 177

def clone; end

#colour?true, false

Checks if Variant contains a Colour value (not null).

Returns:

  • (true, false)


149
# File 'lib/wx/doc/variant.rb', line 149

def colour?; end

#colour_property_value?true, false

Checks if Variant contains a ColourPropertyValue value (not null).

Returns:

  • (true, false)


158
# File 'lib/wx/doc/variant.rb', line 158

def colour_property_value?; end

#date_time?true, false

Checks if Variant contains a (wx)DateTime value (not null). (Note that the DateTime values in question concern wxDateTime and not the Ruby DateTime class; in fact wxDateTime is normally returned as a Ruby Time value)

Returns:

  • (true, false)


120
# File 'lib/wx/doc/variant.rb', line 120

def date_time?; end

#delete(item) ⇒ Boolean

Deletes the zero-based item from the list.

Parameters:

  • item (Integer)

Returns:

  • (Boolean)


45
# File 'lib/wx/doc/gen/variant.rb', line 45

def delete(item) end

#double?true, false

Checks if Variant contains a double value (not null).

Returns:

  • (true, false)


124
# File 'lib/wx/doc/variant.rb', line 124

def double?; end

#dupWx::Variant

Copy constructs a Variant instance.

Returns:



173
# File 'lib/wx/doc/variant.rb', line 173

def dup; end

#each {|item| ... } ⇒ ::Object #eachEnumerator

When a block is given iterates all items of a variant list passing each item to the block. Returns an enumerator when no block is given.

Overloads:

  • #each {|item| ... } ⇒ ::Object

    Returns result of last block execution.

    Yield Parameters:

    Returns:

    • (::Object)

      result of last block execution

  • #eachEnumerator

    Returns an enumerator.

    Returns:

    • (Enumerator)

      an enumerator



22
# File 'lib/wx/doc/variant.rb', line 22

def each; end

#font?true, false

Checks if Variant contains a Font value (not null).

Returns:

  • (true, false)


140
# File 'lib/wx/doc/variant.rb', line 140

def font?; end

#get_array_stringArray<String> Also known as: array_string

Returns the string array value.

Returns:

  • (Array<String>)


184
# File 'lib/wx/doc/gen/variant.rb', line 184

def get_array_string; end

#get_boolBoolean Also known as: bool

Returns the boolean value.

Returns:

  • (Boolean)


189
# File 'lib/wx/doc/gen/variant.rb', line 189

def get_bool; end

#get_charString Also known as: char

Returns the character value.

Returns:

  • (String)


194
# File 'lib/wx/doc/gen/variant.rb', line 194

def get_char; end

#get_colourWx::Colour Also known as: colour

Returns colour value.

Returns:



153
# File 'lib/wx/doc/variant.rb', line 153

def get_colour; end

#get_colour_property_valueWx::PG::ColourPropertyValue Also known as: colour_property_value

Returns colour property value.



162
# File 'lib/wx/doc/variant.rb', line 162

def get_colour_property_value; end

#get_countInteger Also known as: count

Returns the number of elements in the list.

Returns:

  • (Integer)


49
# File 'lib/wx/doc/gen/variant.rb', line 49

def get_count; end

#get_date_timeTime, ... Also known as: date_time

Returns the date value.

Returns:

  • (Time, Date, DateTime)


206
# File 'lib/wx/doc/gen/variant.rb', line 206

def get_date_time; end

#get_doubleFloat Also known as: double

Returns the floating point value.

Returns:

  • (Float)


211
# File 'lib/wx/doc/gen/variant.rb', line 211

def get_double; end

#get_fontWx::Font Also known as: font

Returns font value.

Returns:



144
# File 'lib/wx/doc/variant.rb', line 144

def get_font; end

#get_longInteger Also known as: long

Returns the integer value.

Returns:

  • (Integer)


216
# File 'lib/wx/doc/gen/variant.rb', line 216

def get_long; end

#get_long_longInteger Also known as: long_long

Returns the signed 64-bit integer value.

Returns:

  • (Integer)


221
# File 'lib/wx/doc/gen/variant.rb', line 221

def get_long_long; end

#get_nameWx::String Also known as: name

Returns a constant reference to the variant name.

Returns:

  • (Wx::String)


226
# File 'lib/wx/doc/gen/variant.rb', line 226

def get_name; end

#get_objectObject Also known as: object

Returns a pointer to the internal variant data.

To take ownership of this data, you must call its Wx::VariantData#inc_ref method. When you stop using it, Wx::VariantData#dec_ref must be called as well.

Returns:



201
# File 'lib/wx/doc/gen/variant.rb', line 201

def get_object; end

#get_stringString Also known as: string

Gets the string value.

Returns:

  • (String)


231
# File 'lib/wx/doc/gen/variant.rb', line 231

def get_string; end

#get_typeString Also known as: type

Returns the value type as a string.

The built-in types are:

  • “bool”

  • “char”

  • “datetime”

  • “double”

  • “list”

  • “long”

  • “longlong”

  • “string”

  • “ulonglong”

  • “arrstring”

If the variant is null, the value type returned is the string “null” (not the empty string).

If the variant contains an arbitrary Ruby Object, the value type returned is the result of variant.get_object.class.name.

Returns:

  • (String)


253
# File 'lib/wx/doc/gen/variant.rb', line 253

def get_type; end

#get_u_long_longInteger Also known as: u_long_long

Returns the unsigned 64-bit integer value.

Returns:

  • (Integer)


258
# File 'lib/wx/doc/gen/variant.rb', line 258

def get_u_long_long; end

#insert(value) ⇒ void

This method returns an undefined value.

Inserts a value at the front of the list.

Parameters:

  • value (nil, String, Integer, Float, Time, Wx::Font, Wx::Colour, Wx::Variant, Array<WxVariant>, Array<String>, ObjectWx::PG::ColourPropertyValue)


55
# File 'lib/wx/doc/gen/variant.rb', line 55

def insert(value) end

#integer?true, false

Checks if Variant contains an integer value (long|long long|unsigned long long).

Returns:

  • (true, false)


113
# File 'lib/wx/doc/variant.rb', line 113

def integer?; end

#is_nullBoolean Also known as: null?

Returns true if there is no data associated with this variant, false if there is data.

Returns:

  • (Boolean)


263
# File 'lib/wx/doc/gen/variant.rb', line 263

def is_null; end

#is_type(type) ⇒ Boolean Also known as: type?

Returns true if type matches the type of the variant, false otherwise.

Parameters:

  • type (String)

Returns:

  • (Boolean)


269
# File 'lib/wx/doc/gen/variant.rb', line 269

def is_type(type) end

#list?true, false

Checks if Variant contains a VariantList (array of Variant) value (not null).

Returns:

  • (true, false)


132
# File 'lib/wx/doc/variant.rb', line 132

def list?; end

#long?true, false

Checks if Variant contains a long value (not null).

Returns:

  • (true, false)


101
# File 'lib/wx/doc/variant.rb', line 101

def long?; end

#long_long?true, false

Checks if Variant contains a long long value (not null).

Returns:

  • (true, false)


105
# File 'lib/wx/doc/variant.rb', line 105

def long_long?; end

#make_nullvoid

This method returns an undefined value.

Makes the variant null by deleting the internal data.



274
# File 'lib/wx/doc/gen/variant.rb', line 274

def make_null; end

#make_stringString

Makes a string representation of the variant value (for any type).

Returns:

  • (String)


278
# File 'lib/wx/doc/gen/variant.rb', line 278

def make_string; end

#member(value) ⇒ Boolean

Returns true if value matches an element in the list.

Parameters:

  • value (nil, String, Integer, Float, Time, Wx::Font, Wx::Colour, Wx::Variant, Array<WxVariant>, Array<String>, ObjectWx::PG::ColourPropertyValue)

Returns:

  • (Boolean)


283
# File 'lib/wx/doc/gen/variant.rb', line 283

def member(value) end

#null_listvoid

This method returns an undefined value.

Makes an empty list.

This differs from a null variant which has no data; a null list is of type list, but the number of elements in the list is zero.



61
# File 'lib/wx/doc/gen/variant.rb', line 61

def null_list; end

#numeric?true, false

Checks if Variant contains an integer value (integer | double).

Returns:

  • (true, false)


128
# File 'lib/wx/doc/variant.rb', line 128

def numeric?; end

#object?(klass = Object) ⇒ true, false

Checks if Variant contains an unspecified Ruby object (not null or nil and not one of the other value types).

Parameters:

  • klass (Class) (defaults to: Object)

    the (base) class of the Ruby object to check

Returns:

  • (true, false)


169
# File 'lib/wx/doc/variant.rb', line 169

def object?(klass=Object) end

#string?true, false

Checks if Variant contains a String value (not null).

Returns:

  • (true, false)


93
# File 'lib/wx/doc/variant.rb', line 93

def string?; end

#to_fFloat

Convert contained object to floating point value if possible. Raises TypeError exception if incompatible.

Returns:

  • (Float)

    floating point value



84
# File 'lib/wx/doc/variant.rb', line 84

def to_f; end

#to_iInteger

Convert contained object to integer value if possible. Raises TypeError exception if incompatible.

Returns:

  • (Integer)

    integer value



79
# File 'lib/wx/doc/variant.rb', line 79

def to_i; end

#to_sString

Convert contained object to string value if possible. Raises TypeError exception if incompatible.

Returns:

  • (String)

    string value



89
# File 'lib/wx/doc/variant.rb', line 89

def to_s; end

#u_long_long?true, false

Checks if Variant contains an unsigned long long value (not null).

Returns:

  • (true, false)


109
# File 'lib/wx/doc/variant.rb', line 109

def u_long_long?; end

#unshareBoolean

Makes sure that any data associated with this variant is not shared with other variants.

For this to work, Wx::VariantData#clone must be implemented for the data types you are working with. Wx::VariantData#clone is implemented for all the default data types.

Returns:

  • (Boolean)


289
# File 'lib/wx/doc/gen/variant.rb', line 289

def unshare; end