diff -r 000000000000 -r bde4ae8d615e os/ossrv/lowlevellibsandfws/apputils/src/BAMATCH.CPP --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os/ossrv/lowlevellibsandfws/apputils/src/BAMATCH.CPP Fri Jun 15 03:10:57 2012 +0200 @@ -0,0 +1,268 @@ +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Started by Brendan, January 1996 +// Descended from HCIMATCH.CPP +// Incremental matcher class +// +// + +#include +#include +#include + + + +EXPORT_C RTextBuf::RTextBuf() + : iPtr(NULL,0), iText(NULL) +/** Default constructor. */ + {} + + +EXPORT_C RTextBuf::~RTextBuf() +/** Destructor. */ + { + Close(); + } + + +EXPORT_C void RTextBuf::SetMaxLengthL(TInt aMaxLength) +/** Sets the maximum length of the text that the object can store. + +Attempts to store text beyond the maximum length cause a panic, as +with descriptors. */ + { + __ASSERT_ALWAYS(aMaxLength>0,Panic(EBafPanicTextBufOutOfRange)); + Close(); + iText=new(ELeave) TText[aMaxLength+1]; + iPtr.Set(iText,0,aMaxLength); + } + +EXPORT_C void RTextBuf::Close() + { + delete [] iText; + iText=NULL; + iPtr.Set(NULL,0,0); + } + +// class RIncrMatcherBase + +EXPORT_C RIncrMatcherBase::~RIncrMatcherBase() +/** Virtual destructor, for reimplementation by derived classes. */ + {} + +TBool RIncrMatcherBase::DoIsMatch(const TDesC& aQuery,TCompareFunc aCompare) const + { + const TDes& des=MatchDes(); + TInt l=des.Length(); + return l>aQuery.Length() ? EFalse : aCompare(aQuery.Ptr(),l,des.Ptr(),l)==0; + } + +TInt RIncrMatcherBase::DoFirstMatchingIndex(TInt& aIndex,const MDesCArray& aDesArray,TCompareFunc aCompare) const + { + TInt noElements=aDesArray.MdcaCount(); + __ASSERT_ALWAYS(aIndex>=0 && aIndex=0) + { + des[l]=0; + des.SetLength(l); + } + } + +EXPORT_C RIncrMatcherPtr::RIncrMatcherPtr() + : iDesPtr(NULL) +/** Default constructor. */ + { + } + +EXPORT_C RIncrMatcherPtr::RIncrMatcherPtr(TDes& aDes) + : iDesPtr(&aDes) +/** Constructor that initialises the object with the text to be matched against. + +@param aDes Text to be matched against */ + { + } + +EXPORT_C RIncrMatcherPtr::~RIncrMatcherPtr() +/** Destructor. */ + { + } + +EXPORT_C TDes& RIncrMatcherPtr::MatchDes() +/** Gets the match text. + +@return Match text */ + { + return(*iDesPtr); + } + +EXPORT_C const TDes& RIncrMatcherPtr::MatchDes() const +/** Gets the match text. + +@return Match text */ + { + return(*iDesPtr); + } + + +EXPORT_C RIncrMatcherTextBuf::RIncrMatcherTextBuf() +/** Default constructor. */ + { + } + +EXPORT_C RIncrMatcherTextBuf::~RIncrMatcherTextBuf() +/** Destructor.*/ + { + } + +EXPORT_C TDes& RIncrMatcherTextBuf::MatchDes() +/** Gets the match text. + +@return Match text */ + { + return(iTextBuf.Text()); + } + +EXPORT_C const TDes& RIncrMatcherTextBuf::MatchDes() const +/** Gets the match text. + +@return Match text */ + { + return(iTextBuf.Text()); + }