×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Regular Contributor
    Join Date
    Jun 2008
    Posts
    69

    retrieve values from RArray

    Hi
    I inserted the objects of class TTableItem in a RArray.
    The declaration of class TTableItem is below
    class TTableItem
    {
    public:
    TTableItem(): iPrimeId(-1){};
    public:
    TInt iPrimeId;
    TBuf8<100> iName;
    TBuf8<20> iPhone;
    public:
    inline void Reset()
    {
    iPrimeId = 0;
    iName.Zero();
    iPhone.Zero();
    }
    };

    I can't find any function to retrieve the values from RArray.
    how can I retrieve the objects from RArray.

    awaiting for an early reply..
    by
    Remyag.

  2. #2
    Registered User
    Join Date
    Nov 2007
    Posts
    444

    Re: retrieve values from RArray

    Hi,

    RArray is just array in C++.
    You can retrieve the value stored in array using '[]'.

    TInt n = iRArray[i];

    Regards,
    Kavit.

  3. #3
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    61

    Re: retrieve values from RArray

    if you had defined your array something as RArray <TTableItem> arr;
    then use arr[i].iName or arr[i].iPhone
    its as simple as accessing a C++ array of user defined data types.

  4. #4
    Regular Contributor
    Join Date
    Jun 2008
    Posts
    69

    Re: retrieve values from RArray

    hi,
    Thanks for your quick reply.

    in your code
    TInt n = iRArray[i];
    the return type is TInt since iRArray[] containg integer value.
    But here the RArray containing the objects of class 'TTableItem'.
    I want to return each object in RArray
    for this I wrote code that is like below

    for(i=0;i<aMyTableItemArray.Count();i++){

    aMyTableItemArray.operator [](i);

    }
    here aMyTableItemArray is the Object of class RArray. and this array containig the object of class TTableItem.
    can I retrieve the value in aMyTableItemArray by using the built in function 'operator []()' of the clas RArray.
    IF it possible how can I correctly using the function 'operator []().
    or else please mention which method can I use here

    Thanks by
    Remyag

  5. #5
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    61

    Re: retrieve values from RArray

    i guess u r unnecessarily making things complecated
    for(i=0;i<aMyTableItemArray.Count();i++){

    aMyTableItemArray.operator [](i);

    }
    operator[]() and so are nothing but the overloaded versions of these operators.
    U litterally dont write like this as u have.

    RArray <TTableItem> arr;

    TInt id = arr.iPrimeID;
    and here id is surely going to be TInt because that is what arr.iPrimeID would return.check your class deninitions...similarly u can extract other variables iName and iPhone as well.

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,752

    Re: retrieve values from RArray

    Quote Originally Posted by remyag View Post
    in your code
    TInt n = iRArray[i];
    the return type is TInt since iRArray[] containg integer value.
    But here the RArray containing the objects of class 'TTableItem'.
    And where do you suspect the difference?
    RArray does not care about the contained type, its operator[]-s return a const/non const reference to the given element.
    Also note that operators are invented to make life easier, allow creation of more readable 'natural' code.
    That is why when someone writes "a.operator[](i)", it can be also written as "a[i]", you can choose which one looks better, they are the same.

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    27

    Re: retrieve values from RArray

    Hi,

    Is there any way to find out how many elements the RArray contains. What I want is someway to be able to access all the elements of a RArray through [], and have some means of recognising the end of the array.

    Regards,
    Abhik

  8. #8
    Registered User
    Join Date
    Nov 2008
    Location
    Mumbai-India
    Posts
    379

    Re: retrieve values from RArray

    Quote Originally Posted by rayabhik View Post
    Hi,

    Is there any way to find out how many elements the RArray contains. What I want is someway to be able to access all the elements of a RArray through [], and have some means of recognising the end of the array.

    Regards,
    Abhik
    Count() gives the no of element present in RArray

    Count()-1 will get last elment and u can access element thru [] operator

Similar Threads

  1. GCCE compile error: ISO C++ forbids declaration of `RAttributeArray' with no type
    By liuxingyu_best in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2008-07-05, 18:07
  2. RArray and Granularity
    By LiTuAu in forum Symbian
    Replies: 5
    Last Post: 2008-04-18, 11:11
  3. How to retrieve values of javax.bluetooth.DataElement
    By ivocalado in forum Mobile Java General
    Replies: 2
    Last Post: 2008-03-03, 11:30
  4. Rarray granular problem
    By lauyk001 in forum Symbian
    Replies: 1
    Last Post: 2005-01-14, 23:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×