diff -r 000000000000 -r bde4ae8d615e os/textandloc/textandlocutils/sortutil/src/SortUtilImpl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os/textandloc/textandlocutils/sortutil/src/SortUtilImpl.cpp Fri Jun 15 03:10:57 2012 +0200 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "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: +* +*/ + + + + + + +// INCLUDE FILES +#include "SortUtilImpl.h" + +namespace SortUtilImpl + { + + inline TPtrC StripLeadingWhiteSpace_inline(const TDesC& aText) + { + const TText* p = aText.Ptr(); + const TText* const end = p + aText.Length(); + for (; p != end; ++p) + { + if (!TChar(*p).IsSpace()) + { + return aText.Mid(p - aText.Ptr()); + } + } + // All of aText was whitespace: return empty string + return TPtrC(); + } + + TPtrC StripLeadingWhiteSpace(const TDesC& aText) + { + return StripLeadingWhiteSpace_inline(aText); + } + + TPtrC FindNextNonEmptyKey + (const MSortKeyArray& aKeys, + TSortKeyType aType, + TInt& aIndex) + { + TPtrC result; + while (aIndex < aKeys.SortKeyCount()) + { + const TSortKey key(aKeys.SortKeyAt(aIndex)); + ++aIndex; + if (key.Type() == aType) + { + result.Set(StripLeadingWhiteSpace_inline(key.Text())); + if (result.Length() > 0) + { + return result; + } + } + } + return result; + } + + } // namespace SortUtilImpl + +// End of file