1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
44 |
44 |
45 @param aIndex Field index |
45 @param aIndex Field index |
46 */ |
46 */ |
47 inline void TSqlBufRIterator::MoveTo(TInt aIndex) |
47 inline void TSqlBufRIterator::MoveTo(TInt aIndex) |
48 { |
48 { |
49 __SQLASSERT((iBegin + (TUint)aIndex) < iEnd, ESqlPanicBadArgument); |
49 __ASSERT_DEBUG((iBegin + (TUint)aIndex) < iEnd, __SQLPANIC(ESqlPanicBadArgument)); |
50 iCurrent = iBegin + aIndex; |
50 iCurrent = iBegin + aIndex; |
51 } |
51 } |
52 |
52 |
53 /** |
53 /** |
54 @return True if the current flat buffer field is "Present" |
54 @return True if the current flat buffer field is "Present" |
55 */ |
55 */ |
56 inline TBool TSqlBufRIterator::IsPresent() const |
56 inline TBool TSqlBufRIterator::IsPresent() const |
57 { |
57 { |
58 __SQLASSERT(iCurrent >= iBegin && iCurrent < iEnd, ESqlPanicInternalError); |
58 __ASSERT_DEBUG(iCurrent >= iBegin && iCurrent < iEnd, __SQLPANIC(ESqlPanicInternalError)); |
59 return iCurrent->iPos > 0; |
59 return iCurrent->iPos > 0; |
60 } |
60 } |
61 |
61 |
62 /** |
62 /** |
63 @return Current flat buffer field type. One of TSqlColumnType enum item values or ESqlText8. |
63 @return Current flat buffer field type. One of TSqlColumnType enum item values or ESqlText8. |
64 */ |
64 */ |
65 inline TInt TSqlBufRIterator::Type() const |
65 inline TInt TSqlBufRIterator::Type() const |
66 { |
66 { |
67 __SQLASSERT(iCurrent >= iBegin && iCurrent < iEnd, ESqlPanicInternalError); |
67 __ASSERT_DEBUG(iCurrent >= iBegin && iCurrent < iEnd, __SQLPANIC(ESqlPanicInternalError)); |
68 return iCurrent->Type(); |
68 return iCurrent->Type(); |
69 } |
69 } |
70 |
70 |
71 /** |
71 /** |
72 @return Current flat buffer field size |
72 @return Current flat buffer field size |
73 */ |
73 */ |
74 inline TInt TSqlBufRIterator::Size() const |
74 inline TInt TSqlBufRIterator::Size() const |
75 { |
75 { |
76 __SQLASSERT(iCurrent >= iBegin && iCurrent < iEnd, ESqlPanicInternalError); |
76 __ASSERT_DEBUG(iCurrent >= iBegin && iCurrent < iEnd, __SQLPANIC(ESqlPanicInternalError)); |
77 return Type() == ESqlText ? iCurrent->Size() / sizeof(TUint16) : iCurrent->Size(); |
77 return Type() == ESqlText ? iCurrent->Size() / sizeof(TUint16) : iCurrent->Size(); |
78 } |
78 } |
79 |
79 |
80 |
80 |
81 /////////////////////////////////////////////////////////////////////////////////////////////////////////// |
81 /////////////////////////////////////////////////////////////////////////////////////////////////////////// |
99 |
99 |
100 @return False if there are no more fields to be iterated. |
100 @return False if there are no more fields to be iterated. |
101 */ |
101 */ |
102 inline TBool TSqlBufWIterator::Next() |
102 inline TBool TSqlBufWIterator::Next() |
103 { |
103 { |
104 __SQLASSERT(iBuf != NULL, ESqlPanicInternalError); |
104 __ASSERT_DEBUG(iBuf != NULL, __SQLPANIC(ESqlPanicInternalError)); |
105 return ++iIndex < iBuf->Count(); |
105 return ++iIndex < iBuf->Count(); |
106 } |
106 } |
107 |
107 |
108 /** |
108 /** |
109 Moves to the specified field in the flat buffer. |
109 Moves to the specified field in the flat buffer. |
110 |
110 |
111 @param aIndex Field index |
111 @param aIndex Field index |
112 */ |
112 */ |
113 inline void TSqlBufWIterator::MoveTo(TInt aIndex) |
113 inline void TSqlBufWIterator::MoveTo(TInt aIndex) |
114 { |
114 { |
115 __SQLASSERT(iBuf != NULL, ESqlPanicInternalError); |
115 __ASSERT_DEBUG(iBuf != NULL, __SQLPANIC(ESqlPanicInternalError)); |
116 __SQLASSERT((TUint)aIndex < iBuf->Count(), ESqlPanicInternalError); |
116 __ASSERT_DEBUG((TUint)aIndex < iBuf->Count(), __SQLPANIC(ESqlPanicInternalError)); |
117 iIndex = aIndex; |
117 iIndex = aIndex; |
118 } |
118 } |
119 |
119 |
120 /** |
120 /** |
121 Sets the current flat buffer field to NULL. |
121 Sets the current flat buffer field to NULL. |
122 */ |
122 */ |
123 inline void TSqlBufWIterator::SetNull() |
123 inline void TSqlBufWIterator::SetNull() |
124 { |
124 { |
125 __SQLASSERT(iBuf != NULL, ESqlPanicInternalError); |
125 __ASSERT_DEBUG(iBuf != NULL, __SQLPANIC(ESqlPanicInternalError)); |
126 __SQLASSERT((TUint)iIndex < iBuf->Count(), ESqlPanicInternalError); |
126 __ASSERT_DEBUG((TUint)iIndex < iBuf->Count(), __SQLPANIC(ESqlPanicInternalError)); |
127 (void)iBuf->SetField(iIndex, ESqlNull, NULL, 0); |
127 (void)iBuf->SetField(iIndex, ESqlNull, NULL, 0); |
128 } |
128 } |
129 |
129 |
130 /** |
130 /** |
131 Sets the current flat buffer field as "Not present". |
131 Sets the current flat buffer field as "Not present". |
133 @param aType Field type. One of TSqlColumnType enum item values or ESqlText8. |
133 @param aType Field type. One of TSqlColumnType enum item values or ESqlText8. |
134 @param aLength Field length in bytes |
134 @param aLength Field length in bytes |
135 */ |
135 */ |
136 inline void TSqlBufWIterator::SetAsNotPresent(TInt aType, TInt aLength) |
136 inline void TSqlBufWIterator::SetAsNotPresent(TInt aType, TInt aLength) |
137 { |
137 { |
138 __SQLASSERT(::IsSequenceSqlType(aType), ESqlPanicBadArgument); |
138 __ASSERT_DEBUG(::IsSequenceSqlType(aType), __SQLPANIC(ESqlPanicBadArgument)); |
139 __SQLASSERT(aLength >= 0, ESqlPanicBadArgument); |
139 __ASSERT_DEBUG(aLength >= 0, __SQLPANIC(ESqlPanicBadArgument)); |
140 __SQLASSERT(iBuf != NULL, ESqlPanicInternalError); |
140 __ASSERT_DEBUG(iBuf != NULL, __SQLPANIC(ESqlPanicInternalError)); |
141 __SQLASSERT((TUint)iIndex < iBuf->Count(), ESqlPanicInternalError); |
141 __ASSERT_DEBUG((TUint)iIndex < iBuf->Count(), __SQLPANIC(ESqlPanicInternalError)); |
142 iBuf->SetField(iIndex, aType, NULL, aType == ESqlText ? aLength * sizeof(TUint16) : aLength); |
142 iBuf->SetField(iIndex, aType, NULL, aType == ESqlText ? aLength * sizeof(TUint16) : aLength); |
143 } |
143 } |
144 |
144 |
145 /** |
145 /** |
146 Initializes current flat buffer field with an integer value. |
146 Initializes current flat buffer field with an integer value. |
150 @return KErrNone, The operation has completed successfully; |
150 @return KErrNone, The operation has completed successfully; |
151 KErrNoMemory, Out of memory condition has occured. |
151 KErrNoMemory, Out of memory condition has occured. |
152 */ |
152 */ |
153 inline TInt TSqlBufWIterator::SetInt(TInt aValue) |
153 inline TInt TSqlBufWIterator::SetInt(TInt aValue) |
154 { |
154 { |
155 __SQLASSERT(iBuf != NULL, ESqlPanicInternalError); |
155 __ASSERT_DEBUG(iBuf != NULL, __SQLPANIC(ESqlPanicInternalError)); |
156 __SQLASSERT((TUint)iIndex < iBuf->Count(), ESqlPanicInternalError); |
156 __ASSERT_DEBUG((TUint)iIndex < iBuf->Count(), __SQLPANIC(ESqlPanicInternalError)); |
157 return iBuf->SetField(iIndex, ESqlInt, &aValue, sizeof(TInt)); |
157 return iBuf->SetField(iIndex, ESqlInt, &aValue, sizeof(TInt)); |
158 } |
158 } |
159 |
159 |
160 /** |
160 /** |
161 Initializes current flat buffer field with an 64 bit integer value. |
161 Initializes current flat buffer field with an 64 bit integer value. |
165 @return KErrNone, The operation has completed successfully; |
165 @return KErrNone, The operation has completed successfully; |
166 KErrNoMemory, Out of memory condition has occured. |
166 KErrNoMemory, Out of memory condition has occured. |
167 */ |
167 */ |
168 inline TInt TSqlBufWIterator::SetInt64(TInt64 aValue) |
168 inline TInt TSqlBufWIterator::SetInt64(TInt64 aValue) |
169 { |
169 { |
170 __SQLASSERT(iBuf != NULL, ESqlPanicInternalError); |
170 __ASSERT_DEBUG(iBuf != NULL, __SQLPANIC(ESqlPanicInternalError)); |
171 __SQLASSERT((TUint)iIndex < iBuf->Count(), ESqlPanicInternalError); |
171 __ASSERT_DEBUG((TUint)iIndex < iBuf->Count(), __SQLPANIC(ESqlPanicInternalError)); |
172 return iBuf->SetField(iIndex, ESqlInt64, &aValue, sizeof(TInt64)); |
172 return iBuf->SetField(iIndex, ESqlInt64, &aValue, sizeof(TInt64)); |
173 } |
173 } |
174 |
174 |
175 /** |
175 /** |
176 Initializes current flat buffer field with a real value. |
176 Initializes current flat buffer field with a real value. |
180 @return KErrNone, The operation has completed successfully; |
180 @return KErrNone, The operation has completed successfully; |
181 KErrNoMemory, Out of memory condition has occured. |
181 KErrNoMemory, Out of memory condition has occured. |
182 */ |
182 */ |
183 inline TInt TSqlBufWIterator::SetReal(TReal aValue) |
183 inline TInt TSqlBufWIterator::SetReal(TReal aValue) |
184 { |
184 { |
185 __SQLASSERT(iBuf != NULL, ESqlPanicInternalError); |
185 __ASSERT_DEBUG(iBuf != NULL, __SQLPANIC(ESqlPanicInternalError)); |
186 __SQLASSERT((TUint)iIndex < iBuf->Count(), ESqlPanicInternalError); |
186 __ASSERT_DEBUG((TUint)iIndex < iBuf->Count(), __SQLPANIC(ESqlPanicInternalError)); |
187 return iBuf->SetField(iIndex, ESqlReal, &aValue, sizeof(TReal)); |
187 return iBuf->SetField(iIndex, ESqlReal, &aValue, sizeof(TReal)); |
188 } |
188 } |
189 |
189 |
190 /** |
190 /** |
191 Initializes current flat buffer field with a block of binary data. |
191 Initializes current flat buffer field with a block of binary data. |
195 @return KErrNone, The operation has completed successfully; |
195 @return KErrNone, The operation has completed successfully; |
196 KErrNoMemory, Out of memory condition has occured. |
196 KErrNoMemory, Out of memory condition has occured. |
197 */ |
197 */ |
198 inline TInt TSqlBufWIterator::SetBinary(const TDesC8& aValue) |
198 inline TInt TSqlBufWIterator::SetBinary(const TDesC8& aValue) |
199 { |
199 { |
200 __SQLASSERT(iBuf != NULL, ESqlPanicInternalError); |
200 __ASSERT_DEBUG(iBuf != NULL, __SQLPANIC(ESqlPanicInternalError)); |
201 __SQLASSERT((TUint)iIndex < iBuf->Count(), ESqlPanicInternalError); |
201 __ASSERT_DEBUG((TUint)iIndex < iBuf->Count(), __SQLPANIC(ESqlPanicInternalError)); |
202 return iBuf->SetField(iIndex, ESqlBinary, aValue.Ptr(), aValue.Length()); |
202 return iBuf->SetField(iIndex, ESqlBinary, aValue.Ptr(), aValue.Length()); |
203 } |
203 } |
204 |
204 |
205 /** |
205 /** |
206 Initializes current flat buffer field with a block of 16 bit text. |
206 Initializes current flat buffer field with a block of 16 bit text. |
210 @return KErrNone, The operation has completed successfully; |
210 @return KErrNone, The operation has completed successfully; |
211 KErrNoMemory, Out of memory condition has occured. |
211 KErrNoMemory, Out of memory condition has occured. |
212 */ |
212 */ |
213 inline TInt TSqlBufWIterator::SetText(const TDesC16& aValue) |
213 inline TInt TSqlBufWIterator::SetText(const TDesC16& aValue) |
214 { |
214 { |
215 __SQLASSERT(iBuf != NULL, ESqlPanicInternalError); |
215 __ASSERT_DEBUG(iBuf != NULL, __SQLPANIC(ESqlPanicInternalError)); |
216 __SQLASSERT((TUint)iIndex < iBuf->Count(), ESqlPanicInternalError); |
216 __ASSERT_DEBUG((TUint)iIndex < iBuf->Count(), __SQLPANIC(ESqlPanicInternalError)); |
217 return iBuf->SetField(iIndex, ESqlText, aValue.Ptr(), aValue.Length() * sizeof(TUint16)); |
217 return iBuf->SetField(iIndex, ESqlText, aValue.Ptr(), aValue.Length() * sizeof(TUint16)); |
218 } |
218 } |
219 |
219 |
220 |
220 |
221 /** |
221 /** |
226 @return KErrNone, The operation has completed successfully; |
226 @return KErrNone, The operation has completed successfully; |
227 KErrNoMemory, Out of memory condition has occured. |
227 KErrNoMemory, Out of memory condition has occured. |
228 */ |
228 */ |
229 inline TInt TSqlBufWIterator::SetZeroBlob(TInt aSize) |
229 inline TInt TSqlBufWIterator::SetZeroBlob(TInt aSize) |
230 { |
230 { |
231 __SQLASSERT(iBuf != NULL, ESqlPanicInternalError); |
231 __ASSERT_DEBUG(iBuf != NULL, __SQLPANIC(ESqlPanicInternalError)); |
232 __SQLASSERT((TUint)iIndex < iBuf->Count(), ESqlPanicInternalError); |
232 __ASSERT_DEBUG((TUint)iIndex < iBuf->Count(), __SQLPANIC(ESqlPanicInternalError)); |
233 return iBuf->SetField(iIndex, ESqlZeroBlob, &aSize, sizeof(TInt)); |
233 return iBuf->SetField(iIndex, ESqlZeroBlob, &aSize, sizeof(TInt)); |
234 } |
234 } |