|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // CFindText Test module |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 #include "cfindtext.h" |
|
20 |
|
21 |
|
22 CFindText* CFindText::NewLC |
|
23 (const TDesC& aText) |
|
24 { |
|
25 CFindText* self = new(ELeave) CFindText; |
|
26 CleanupStack::PushL(self); |
|
27 self->ConstructL(aText); |
|
28 return self; |
|
29 } |
|
30 |
|
31 CFindText::~CFindText() |
|
32 { |
|
33 iWords.Close(); |
|
34 delete iText; |
|
35 } |
|
36 |
|
37 TInt CFindText::MdcaCount() const |
|
38 { |
|
39 return iWords.Count(); |
|
40 } |
|
41 |
|
42 TPtrC16 CFindText::MdcaPoint(TInt aIndex) const |
|
43 { |
|
44 return iWords[aIndex]; |
|
45 } |
|
46 |
|
47 void CFindText::ConstructL(const TDesC& aText) |
|
48 { |
|
49 for (TInt beg=0; beg < aText.Length(); ++beg) |
|
50 { |
|
51 // Skip space before next word |
|
52 if (!TChar(aText[beg]).IsSpace()) |
|
53 { |
|
54 // Scan the end of the word |
|
55 TInt end = beg; |
|
56 for (; end < aText.Length() && !TChar(aText[end]).IsSpace(); ++end) |
|
57 { |
|
58 } |
|
59 const TInt len = end-beg; |
|
60 // Append found word to the array |
|
61 User::LeaveIfError(iWords.Append(aText.Mid(beg,len))); |
|
62 // Scan for next word |
|
63 beg = end; |
|
64 } |
|
65 } |
|
66 |
|
67 iText = aText.AllocL(); |
|
68 } |
|
69 |