This page was last modified 07:16, 12 December 2007.
Opaque Data Types or Variants
From Forum Nokia Wiki
What it is
A Variant class is a class that can hold data of multiple different types. This code should work both on S60, S80 and UIQ devices as there is only Symbian generic code.
Variants are useful when you want to pass an unknown object or an object that could be multiple things to an API. At runtime the function can decide what to do based on the type of item and the value of that item type.
This is one of the things missing from Symbian, the variant class. Windows has a very useful COM structure that allows you to treat a structure as a "hold anything" object.
As Implemented in Windows
Windows does this using the VARIANT structure. This is also implemented as objects using the CVariant in MFC and _variant_t classes in the Windows COM compiler support SDK
Alternatives
There is quite a useful one in the extensions plugin ASK in the AIW API's however it is only supported under ARM builds and only on OS 9. variants.
This implementation works on Symbian OS 7.x to 9.x. I hav'nt tested it on earlier releases but there is nothing that would make it not work that I am aware of.
Implementation
The class is by itself rather simple, and it is an R class as owns resources, which differs from the Nokia one in this important regard.
Also the class is not as fully features as the Windows one, because Windows has a more flexible architecture when it comes to dealing with objects and arrays.
The following data types are supported in this implementation: Null Int32 Int64 Uid Time Real64 Real32 HBufC16 HBufC8
(Various variants of the last two e.g. a TDes descriptor passed in)
Other features
Variants can be compared for equality and inequality but not relativly (i.e. there is no support for greater than or less than)
They may also be serialized from streams. In fact the example code does that.
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Urgent! Please help! ProcessCommandParametersL | Svat_ | General Symbian C++ | 10 | 2007-10-12 11:48 |
| how to get the RGBvalues of an image | ramsnokia | Mobile Java Media (Graphics & Sounds) | 8 | 2005-07-28 06:44 |
| Multiple platforms in Carbide Express C++ | matpowel | Carbide.c++ and CodeWarrior Tools | 4 | 2008-07-03 10:25 |
| Media-formats on Java-Phones | kingnebu | Mobile Java Media (Graphics & Sounds) | 1 | 2005-05-14 13:30 |
| can i draw png icon on controls | JackSu | Symbian User Interface | 4 | 2007-08-22 10:19 |
