×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Jan 2012
    Posts
    139

    [moved] Getting items from CDesCArrayFlat

    Hello All,
    I have Two array(CDesCArrayFlat).
    Value and Item
    Which contains data like...
    in Value(False, True,False,False,False,True)
    and in Item(a,b,c,d,e)
    Now I want to show only True value of data from Item.
    Kindly help me.
    Thanks.
    Nishant

  2. #2
    Regular Contributor
    Join Date
    Jan 2012
    Posts
    139

    Re: Getting items from CDesCArrayFlat

    Right Now I am using like this
    TBuf<5>string;
    string.copy(_L("True"));
    if(Value->Find(string,i))
    {
    ibuf.Copy(_L("\t"));
    ibuf.Append(Item->MdcaPoint(i));
    ibuf.Append(_L("\t\t"));
    copyArray->AppendL(ibuf);
    }
    iItemList->Model()->SetItemTextArray(copyArray);

  3. #3
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,043

    Re: Getting items from CDesCArrayFlat

    If both arrays contain same number of items then you can run a for loop for Value array till its count & inside it search for "True" element , if found on a index then fetch corresponding value from Item array at the same index.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,698

    Re: Getting items from CDesCArrayFlat

    You should not post Symbian C++ questions into 'General Discussions', while you already know the Symbian C++ boards well.

    For the question: it is possible to provide your own array implementation. The last line in the code
    Code:
    iItemList->Model()->SetItemTextArray(copyArray);
    expects a generic array interface to be passed, the method is declared as
    Code:
    void SetItemTextArray (MDesCArray *aItemTextArray)
    and MDesCArray is something what you can implement too:
    Quote Originally Posted by bamdesca.h, comments removed
    Code:
    class MDesC16Array
        {
    public:
        virtual ~MDesC16Array() {}
        virtual TInt MdcaCount() const =0;
        virtual TPtrC16 MdcaPoint(TInt aIndex) const =0;
        };
    it is a class which has to know how many elements it has, and has to be able to return its elements by their index.
    Having your Value-Item notation as iValues-iItems
    Code:
    class CCustomItemTextArray : public CBase, public MDesCArray
    {
        ~CCustomItemTextArray();
        TInt MdcaCount() const;
        TPtrC16 MdcaPoint(TInt aIndex) const;
        ...
        CDesCArray *iItems;
        RArray<TBool> iValues;
    };
    implementation
    Code:
    CCustomItemTextArray::~CCustomItemTextArray()
    {
        delete iItems;
        iValues.Close();
    }
    
    
    TInt CCustomItemTextArray::MdcaCount() const
    {
        TInt count=0;
        for(TInt i=0;i<iValues.Count();i++)
            if(iValues[i])count++;
        return count;
    }
    
    TPtrC16 CCustomItemTextArray::MdcaPoint(TInt aIndex) const
    {
        for(TInt i=0;i<iValues.Count();i++)
        {
            if(iValues[i])
            {
                if(aIndex==0) return (*iItems)[i];
                aIndex--
            }
        }
        // User::Panic can be used here
        return KNullDesC(); // something must be returned, otherwise compiler warnings/errors come
    }
    EDIT: if iValues has to be text too, then "if(iValues[i])" (2 occasions) becomes "if((*iValues)[i].CompareF(KTrueText)==0)", where KTrueText is "_LIT(KTrueText,"True");"

Similar Threads

  1. Replies: 2
    Last Post: 2009-02-26, 08:13
  2. Replies: 1
    Last Post: 2009-01-08, 12:16
  3. [moved] sending many items trough socket
    By xchewy in forum Symbian Networking & Messaging (Closed)
    Replies: 4
    Last Post: 2008-06-23, 18:51
  4. CDesCArrayFlat && RFs
    By white.coder in forum Symbian
    Replies: 10
    Last Post: 2007-08-16, 03:29
  5. getting items from CDesCArrayFlat ???
    By chishti.hameed in forum Symbian
    Replies: 3
    Last Post: 2005-06-13, 06:43

Posting Permissions

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