1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/textandlocutils/sortutil/src/SortUtilImpl.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,73 @@
1.4 +/*
1.5 +* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +
1.24 +
1.25 +
1.26 +// INCLUDE FILES
1.27 +#include "SortUtilImpl.h"
1.28 +
1.29 +namespace SortUtilImpl
1.30 + {
1.31 +
1.32 + inline TPtrC StripLeadingWhiteSpace_inline(const TDesC& aText)
1.33 + {
1.34 + const TText* p = aText.Ptr();
1.35 + const TText* const end = p + aText.Length();
1.36 + for (; p != end; ++p)
1.37 + {
1.38 + if (!TChar(*p).IsSpace())
1.39 + {
1.40 + return aText.Mid(p - aText.Ptr());
1.41 + }
1.42 + }
1.43 + // All of aText was whitespace: return empty string
1.44 + return TPtrC();
1.45 + }
1.46 +
1.47 + TPtrC StripLeadingWhiteSpace(const TDesC& aText)
1.48 + {
1.49 + return StripLeadingWhiteSpace_inline(aText);
1.50 + }
1.51 +
1.52 + TPtrC FindNextNonEmptyKey
1.53 + (const MSortKeyArray& aKeys,
1.54 + TSortKeyType aType,
1.55 + TInt& aIndex)
1.56 + {
1.57 + TPtrC result;
1.58 + while (aIndex < aKeys.SortKeyCount())
1.59 + {
1.60 + const TSortKey key(aKeys.SortKeyAt(aIndex));
1.61 + ++aIndex;
1.62 + if (key.Type() == aType)
1.63 + {
1.64 + result.Set(StripLeadingWhiteSpace_inline(key.Text()));
1.65 + if (result.Length() > 0)
1.66 + {
1.67 + return result;
1.68 + }
1.69 + }
1.70 + }
1.71 + return result;
1.72 + }
1.73 +
1.74 + } // namespace SortUtilImpl
1.75 +
1.76 +// End of file