|
1 /* |
|
2 * Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Saves training parameters, which include pronunciation language |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "nssvasctrainingparameters.h" |
|
21 #include "nssvasdbkonsts.h" |
|
22 |
|
23 // ================= MEMBER FUNCTIONS ======================= |
|
24 |
|
25 // --------------------------------------------------------- |
|
26 // CNssTrainingParameters::NewL |
|
27 // Two-phased constructor |
|
28 // --------------------------------------------------------- |
|
29 // |
|
30 EXPORT_C CNssTrainingParameters* CNssTrainingParameters::NewL() |
|
31 { |
|
32 CNssTrainingParameters *me = CNssTrainingParameters::NewLC(); |
|
33 CleanupStack::Pop( me ); |
|
34 return( me ); |
|
35 } |
|
36 |
|
37 // --------------------------------------------------------- |
|
38 // CNssTrainingParameters::NewLC |
|
39 // Two-phased constructor |
|
40 // --------------------------------------------------------- |
|
41 // |
|
42 EXPORT_C CNssTrainingParameters* CNssTrainingParameters::NewLC() |
|
43 { |
|
44 CNssTrainingParameters *me = new (ELeave) CNssTrainingParameters(); |
|
45 CleanupStack::PushL( me ); |
|
46 |
|
47 me->ConstructL(); |
|
48 |
|
49 return( me ); |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------- |
|
53 // CNssTrainingParameters::CNssTrainingParameters |
|
54 // C++ constructor |
|
55 // --------------------------------------------------------- |
|
56 // |
|
57 CNssTrainingParameters::CNssTrainingParameters() |
|
58 : iSeparator(' ') |
|
59 { |
|
60 // Nothing |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------- |
|
64 // CNssTrainingParameters::ConstructL |
|
65 // Second-phase constructor |
|
66 // --------------------------------------------------------- |
|
67 // |
|
68 void CNssTrainingParameters::ConstructL() |
|
69 { |
|
70 iLanguages = new (ELeave) RArray<TLanguage>; |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------- |
|
74 // CNssTrainingParameters::~CNssTrainingParameters |
|
75 // Destructor |
|
76 // --------------------------------------------------------- |
|
77 // |
|
78 EXPORT_C CNssTrainingParameters::~CNssTrainingParameters() |
|
79 { |
|
80 if ( iLanguages ) |
|
81 { |
|
82 iLanguages->Close(); |
|
83 delete iLanguages; |
|
84 } |
|
85 ResetSindeLanguageArray(); |
|
86 |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------- |
|
90 // CNssTrainingParameters::SetLanguages |
|
91 // Sets the language list |
|
92 // --------------------------------------------------------- |
|
93 // |
|
94 EXPORT_C void CNssTrainingParameters::SetLanguages( RArray<TLanguage>* aLanguageArray ) |
|
95 { |
|
96 if ( iLanguages ) |
|
97 { |
|
98 iLanguages->Close(); |
|
99 delete iLanguages; |
|
100 } |
|
101 iLanguages = aLanguageArray; |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------- |
|
105 // CNssTrainingParameters::Languages |
|
106 // Returns the language list |
|
107 // --------------------------------------------------------- |
|
108 // |
|
109 EXPORT_C const RArray<TLanguage>& CNssTrainingParameters::Languages() const |
|
110 { |
|
111 return( *iLanguages ); |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------- |
|
115 // CNssTrainingParameters::SetSeparator |
|
116 // Sets the separator char |
|
117 // --------------------------------------------------------- |
|
118 // |
|
119 EXPORT_C void CNssTrainingParameters::SetSeparator( TChar aSeparator ) |
|
120 { |
|
121 iSeparator = aSeparator; |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------- |
|
125 // CNssTrainingParameters::Separator |
|
126 // Returns the separator char |
|
127 // --------------------------------------------------------- |
|
128 // |
|
129 EXPORT_C TChar CNssTrainingParameters::Separator() const |
|
130 { |
|
131 return( iSeparator ); |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------- |
|
135 // CNssTrainingParameters::SetLanguages |
|
136 // Sets the SINDE language list |
|
137 // --------------------------------------------------------- |
|
138 // |
|
139 EXPORT_C void CNssTrainingParameters::SetSindeLanguages( |
|
140 const RArray<RTrainingLanguageArray>& aLanguageArray ) |
|
141 { |
|
142 ResetSindeLanguageArray(); |
|
143 |
|
144 for ( TInt i = 0; i < aLanguageArray.Count(); i++ ) |
|
145 { |
|
146 const RTrainingLanguageArray& array = aLanguageArray[i]; |
|
147 RTrainingLanguageArray copiedArray; |
|
148 for ( TInt j = 0; j < array.Count(); j++ ) |
|
149 { |
|
150 copiedArray.Append( array[j] ); |
|
151 } |
|
152 iSindeLanguages.Append( copiedArray ); |
|
153 } |
|
154 |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------- |
|
158 // CNssTrainingParameters::Languages |
|
159 // Returns the SINDE language list |
|
160 // --------------------------------------------------------- |
|
161 // |
|
162 EXPORT_C const RArray<RTrainingLanguageArray>& CNssTrainingParameters::SindeLanguagesL() const |
|
163 { |
|
164 if ( iSindeLanguages.Count() == 0 ) |
|
165 { |
|
166 User::Leave( KErrNotFound ); |
|
167 } |
|
168 |
|
169 return iSindeLanguages; |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------- |
|
173 // CNssTrainingParameters::ResetSindeLanguageArray |
|
174 // Resets SINDE language array |
|
175 // --------------------------------------------------------- |
|
176 // |
|
177 void CNssTrainingParameters::ResetSindeLanguageArray() |
|
178 { |
|
179 for ( TInt i = 0; i < iSindeLanguages.Count(); i++ ) |
|
180 { |
|
181 RTrainingLanguageArray& array = iSindeLanguages[i]; |
|
182 array.Close(); |
|
183 } |
|
184 iSindeLanguages.Reset(); |
|
185 iSindeLanguages.Close(); |
|
186 } |
|
187 |
|
188 // End of File |