using descriptor in struct....

Login to reply to this topic.
Fri, 2006-01-20 17:16
Joined: 2003-11-28
Forum posts: 35
Hello,

I want to use a descriptor inside a structure. For example I have :

in a header file
...............
struct TTest
{
    TInt iInteger;
    const TDesC* iDescriptor; // is this ok to use?
//    HBufC* iDescriptor;
};

...................
My question is how can I use a descriptor for wich I don't know the exact length?

class CStructTest
{
    CStructTest(TTest& aTest);   
    ...........
   TTest& iTest;
};



CStructTest::CStructTest(TTest& aTest):iTest(aTest)
{
}


Fri, 2006-01-20 18:12
Joined: 2004-07-10
Forum posts: 364
Re: using descriptor in struct....
Hi, a few points
1) You can't use a TDesC*, TDesCs are abstract classes and you can't declare one like that(you only see them used in function declarations)
2) Instead you would declare a TBuf<X> if you know the size of string you want, or a HBuf if you want to grow the string dynamically.
3) HBuf's allocate their memory on the heap and thus you can't put one inside a struct because a struct is a T object and if you are using a heap based object you have to use a C object.
  • Login to reply to this topic.