sl@0
|
1 |
// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// ///////////////////// TSqlBufRIterator class /////////////////////////////////////////
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
/**
|
sl@0
|
19 |
|
sl@0
|
20 |
Initializes the iterator.
|
sl@0
|
21 |
After the initialization the iterator points to the first flat buffer field - 1.
|
sl@0
|
22 |
|
sl@0
|
23 |
@param aBuf A reference to the buffer which will be iterated.
|
sl@0
|
24 |
*/
|
sl@0
|
25 |
inline void TSqlBufRIterator::Set(const RSqlBufFlat& aBuf)
|
sl@0
|
26 |
{
|
sl@0
|
27 |
iBegin = aBuf.Header();
|
sl@0
|
28 |
iCurrent = iBegin - 1;
|
sl@0
|
29 |
iEnd = iBegin + aBuf.Count();
|
sl@0
|
30 |
}
|
sl@0
|
31 |
|
sl@0
|
32 |
/**
|
sl@0
|
33 |
Moves to the next flat buffer field
|
sl@0
|
34 |
|
sl@0
|
35 |
@return False if there are no more fields to be iterated.
|
sl@0
|
36 |
*/
|
sl@0
|
37 |
inline TBool TSqlBufRIterator::Next()
|
sl@0
|
38 |
{
|
sl@0
|
39 |
return ++iCurrent < iEnd;
|
sl@0
|
40 |
}
|
sl@0
|
41 |
|
sl@0
|
42 |
/**
|
sl@0
|
43 |
Moves to the specified field in the flat buffer.
|
sl@0
|
44 |
|
sl@0
|
45 |
@param aIndex Field index
|
sl@0
|
46 |
*/
|
sl@0
|
47 |
inline void TSqlBufRIterator::MoveTo(TInt aIndex)
|
sl@0
|
48 |
{
|
sl@0
|
49 |
__ASSERT_DEBUG((iBegin + (TUint)aIndex) < iEnd, __SQLPANIC(ESqlPanicBadArgument));
|
sl@0
|
50 |
iCurrent = iBegin + aIndex;
|
sl@0
|
51 |
}
|
sl@0
|
52 |
|
sl@0
|
53 |
/**
|
sl@0
|
54 |
@return True if the current flat buffer field is "Present"
|
sl@0
|
55 |
*/
|
sl@0
|
56 |
inline TBool TSqlBufRIterator::IsPresent() const
|
sl@0
|
57 |
{
|
sl@0
|
58 |
__ASSERT_DEBUG(iCurrent >= iBegin && iCurrent < iEnd, __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
59 |
return iCurrent->iPos > 0;
|
sl@0
|
60 |
}
|
sl@0
|
61 |
|
sl@0
|
62 |
/**
|
sl@0
|
63 |
@return Current flat buffer field type. One of TSqlColumnType enum item values or ESqlText8.
|
sl@0
|
64 |
*/
|
sl@0
|
65 |
inline TInt TSqlBufRIterator::Type() const
|
sl@0
|
66 |
{
|
sl@0
|
67 |
__ASSERT_DEBUG(iCurrent >= iBegin && iCurrent < iEnd, __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
68 |
return iCurrent->Type();
|
sl@0
|
69 |
}
|
sl@0
|
70 |
|
sl@0
|
71 |
/**
|
sl@0
|
72 |
@return Current flat buffer field size
|
sl@0
|
73 |
*/
|
sl@0
|
74 |
inline TInt TSqlBufRIterator::Size() const
|
sl@0
|
75 |
{
|
sl@0
|
76 |
__ASSERT_DEBUG(iCurrent >= iBegin && iCurrent < iEnd, __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
77 |
return Type() == ESqlText ? iCurrent->Size() / sizeof(TUint16) : iCurrent->Size();
|
sl@0
|
78 |
}
|
sl@0
|
79 |
|
sl@0
|
80 |
|
sl@0
|
81 |
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
82 |
//////////////////////// TSqlBufWIterator class //////////////////////////////////
|
sl@0
|
83 |
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
84 |
|
sl@0
|
85 |
/**
|
sl@0
|
86 |
Initializes the iterator.
|
sl@0
|
87 |
After the initialization the iterator points to the first flat buffer field - 1.
|
sl@0
|
88 |
|
sl@0
|
89 |
@param aBuf A reference to the buffer which will be iterated.
|
sl@0
|
90 |
*/
|
sl@0
|
91 |
inline void TSqlBufWIterator::Set(RSqlBufFlat& aBuf)
|
sl@0
|
92 |
{
|
sl@0
|
93 |
iBuf = &aBuf;
|
sl@0
|
94 |
iIndex = -1;
|
sl@0
|
95 |
}
|
sl@0
|
96 |
|
sl@0
|
97 |
/**
|
sl@0
|
98 |
Moves to the next flat buffer field
|
sl@0
|
99 |
|
sl@0
|
100 |
@return False if there are no more fields to be iterated.
|
sl@0
|
101 |
*/
|
sl@0
|
102 |
inline TBool TSqlBufWIterator::Next()
|
sl@0
|
103 |
{
|
sl@0
|
104 |
__ASSERT_DEBUG(iBuf != NULL, __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
105 |
return ++iIndex < iBuf->Count();
|
sl@0
|
106 |
}
|
sl@0
|
107 |
|
sl@0
|
108 |
/**
|
sl@0
|
109 |
Moves to the specified field in the flat buffer.
|
sl@0
|
110 |
|
sl@0
|
111 |
@param aIndex Field index
|
sl@0
|
112 |
*/
|
sl@0
|
113 |
inline void TSqlBufWIterator::MoveTo(TInt aIndex)
|
sl@0
|
114 |
{
|
sl@0
|
115 |
__ASSERT_DEBUG(iBuf != NULL, __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
116 |
__ASSERT_DEBUG((TUint)aIndex < iBuf->Count(), __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
117 |
iIndex = aIndex;
|
sl@0
|
118 |
}
|
sl@0
|
119 |
|
sl@0
|
120 |
/**
|
sl@0
|
121 |
Sets the current flat buffer field to NULL.
|
sl@0
|
122 |
*/
|
sl@0
|
123 |
inline void TSqlBufWIterator::SetNull()
|
sl@0
|
124 |
{
|
sl@0
|
125 |
__ASSERT_DEBUG(iBuf != NULL, __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
126 |
__ASSERT_DEBUG((TUint)iIndex < iBuf->Count(), __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
127 |
(void)iBuf->SetField(iIndex, ESqlNull, NULL, 0);
|
sl@0
|
128 |
}
|
sl@0
|
129 |
|
sl@0
|
130 |
/**
|
sl@0
|
131 |
Sets the current flat buffer field as "Not present".
|
sl@0
|
132 |
|
sl@0
|
133 |
@param aType Field type. One of TSqlColumnType enum item values or ESqlText8.
|
sl@0
|
134 |
@param aLength Field length in bytes
|
sl@0
|
135 |
*/
|
sl@0
|
136 |
inline void TSqlBufWIterator::SetAsNotPresent(TInt aType, TInt aLength)
|
sl@0
|
137 |
{
|
sl@0
|
138 |
__ASSERT_DEBUG(::IsSequenceSqlType(aType), __SQLPANIC(ESqlPanicBadArgument));
|
sl@0
|
139 |
__ASSERT_DEBUG(aLength >= 0, __SQLPANIC(ESqlPanicBadArgument));
|
sl@0
|
140 |
__ASSERT_DEBUG(iBuf != NULL, __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
141 |
__ASSERT_DEBUG((TUint)iIndex < iBuf->Count(), __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
142 |
iBuf->SetField(iIndex, aType, NULL, aType == ESqlText ? aLength * sizeof(TUint16) : aLength);
|
sl@0
|
143 |
}
|
sl@0
|
144 |
|
sl@0
|
145 |
/**
|
sl@0
|
146 |
Initializes current flat buffer field with an integer value.
|
sl@0
|
147 |
|
sl@0
|
148 |
@param aValue An integer value to be set as a field content
|
sl@0
|
149 |
|
sl@0
|
150 |
@return KErrNone, The operation has completed successfully;
|
sl@0
|
151 |
KErrNoMemory, Out of memory condition has occured.
|
sl@0
|
152 |
*/
|
sl@0
|
153 |
inline TInt TSqlBufWIterator::SetInt(TInt aValue)
|
sl@0
|
154 |
{
|
sl@0
|
155 |
__ASSERT_DEBUG(iBuf != NULL, __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
156 |
__ASSERT_DEBUG((TUint)iIndex < iBuf->Count(), __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
157 |
return iBuf->SetField(iIndex, ESqlInt, &aValue, sizeof(TInt));
|
sl@0
|
158 |
}
|
sl@0
|
159 |
|
sl@0
|
160 |
/**
|
sl@0
|
161 |
Initializes current flat buffer field with an 64 bit integer value.
|
sl@0
|
162 |
|
sl@0
|
163 |
@param aValue A 64 bit integer value to be set as a field content
|
sl@0
|
164 |
|
sl@0
|
165 |
@return KErrNone, The operation has completed successfully;
|
sl@0
|
166 |
KErrNoMemory, Out of memory condition has occured.
|
sl@0
|
167 |
*/
|
sl@0
|
168 |
inline TInt TSqlBufWIterator::SetInt64(TInt64 aValue)
|
sl@0
|
169 |
{
|
sl@0
|
170 |
__ASSERT_DEBUG(iBuf != NULL, __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
171 |
__ASSERT_DEBUG((TUint)iIndex < iBuf->Count(), __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
172 |
return iBuf->SetField(iIndex, ESqlInt64, &aValue, sizeof(TInt64));
|
sl@0
|
173 |
}
|
sl@0
|
174 |
|
sl@0
|
175 |
/**
|
sl@0
|
176 |
Initializes current flat buffer field with a real value.
|
sl@0
|
177 |
|
sl@0
|
178 |
@param aValue A real value to be set as a field content
|
sl@0
|
179 |
|
sl@0
|
180 |
@return KErrNone, The operation has completed successfully;
|
sl@0
|
181 |
KErrNoMemory, Out of memory condition has occured.
|
sl@0
|
182 |
*/
|
sl@0
|
183 |
inline TInt TSqlBufWIterator::SetReal(TReal aValue)
|
sl@0
|
184 |
{
|
sl@0
|
185 |
__ASSERT_DEBUG(iBuf != NULL, __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
186 |
__ASSERT_DEBUG((TUint)iIndex < iBuf->Count(), __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
187 |
return iBuf->SetField(iIndex, ESqlReal, &aValue, sizeof(TReal));
|
sl@0
|
188 |
}
|
sl@0
|
189 |
|
sl@0
|
190 |
/**
|
sl@0
|
191 |
Initializes current flat buffer field with a block of binary data.
|
sl@0
|
192 |
|
sl@0
|
193 |
@param aValue An 8 bit descriptor pointing to the block of data to be set as a field content.
|
sl@0
|
194 |
|
sl@0
|
195 |
@return KErrNone, The operation has completed successfully;
|
sl@0
|
196 |
KErrNoMemory, Out of memory condition has occured.
|
sl@0
|
197 |
*/
|
sl@0
|
198 |
inline TInt TSqlBufWIterator::SetBinary(const TDesC8& aValue)
|
sl@0
|
199 |
{
|
sl@0
|
200 |
__ASSERT_DEBUG(iBuf != NULL, __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
201 |
__ASSERT_DEBUG((TUint)iIndex < iBuf->Count(), __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
202 |
return iBuf->SetField(iIndex, ESqlBinary, aValue.Ptr(), aValue.Length());
|
sl@0
|
203 |
}
|
sl@0
|
204 |
|
sl@0
|
205 |
/**
|
sl@0
|
206 |
Initializes current flat buffer field with a block of 16 bit text.
|
sl@0
|
207 |
|
sl@0
|
208 |
@param aValue A 16 bit descriptor pointing to the block of text to be set as a field content.
|
sl@0
|
209 |
|
sl@0
|
210 |
@return KErrNone, The operation has completed successfully;
|
sl@0
|
211 |
KErrNoMemory, Out of memory condition has occured.
|
sl@0
|
212 |
*/
|
sl@0
|
213 |
inline TInt TSqlBufWIterator::SetText(const TDesC16& aValue)
|
sl@0
|
214 |
{
|
sl@0
|
215 |
__ASSERT_DEBUG(iBuf != NULL, __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
216 |
__ASSERT_DEBUG((TUint)iIndex < iBuf->Count(), __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
217 |
return iBuf->SetField(iIndex, ESqlText, aValue.Ptr(), aValue.Length() * sizeof(TUint16));
|
sl@0
|
218 |
}
|
sl@0
|
219 |
|
sl@0
|
220 |
|
sl@0
|
221 |
/**
|
sl@0
|
222 |
Initializes current flat buffer field with a zeroblob of the specified size.
|
sl@0
|
223 |
|
sl@0
|
224 |
@param aSize The size, in bytes, of the zeroblob to be set as the field content.
|
sl@0
|
225 |
|
sl@0
|
226 |
@return KErrNone, The operation has completed successfully;
|
sl@0
|
227 |
KErrNoMemory, Out of memory condition has occured.
|
sl@0
|
228 |
*/
|
sl@0
|
229 |
inline TInt TSqlBufWIterator::SetZeroBlob(TInt aSize)
|
sl@0
|
230 |
{
|
sl@0
|
231 |
__ASSERT_DEBUG(iBuf != NULL, __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
232 |
__ASSERT_DEBUG((TUint)iIndex < iBuf->Count(), __SQLPANIC(ESqlPanicInternalError));
|
sl@0
|
233 |
return iBuf->SetField(iIndex, ESqlZeroBlob, &aSize, sizeof(TInt));
|
sl@0
|
234 |
}
|