|
1 /* |
|
2 * Copyright (c) 2002-2007 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: Provides functions to read and write from/to long text columns. |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <s32buf.h> |
|
21 #include "EPos_PosLmLongTextColHandler.h" |
|
22 |
|
23 // ================= MEMBER FUNCTIONS ======================= |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // ----------------------------------------------------------------------------- |
|
27 // |
|
28 EXPORT_C void PosLmLongTextColHandler::ReadFromLongTextColumnL( |
|
29 TDes& aLongText, |
|
30 RDbRowSet& aView, |
|
31 TDbColNo aCol) |
|
32 { |
|
33 aLongText.Zero(); |
|
34 |
|
35 RDbColReadStream readStream; |
|
36 readStream.OpenLC(aView, aCol); |
|
37 readStream.ReadL(aLongText, readStream.Source()->SizeL() / 2); |
|
38 // Size is in bytes and not characters. Assume 16-bit environment. |
|
39 readStream.Close(); // This close call cannot be removed. |
|
40 |
|
41 CleanupStack::PopAndDestroy(&readStream); |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 EXPORT_C void PosLmLongTextColHandler::WriteToLongTextColumnL( |
|
48 const TDesC& aLongText, |
|
49 RDbRowSet& aView, |
|
50 TDbColNo aCol) |
|
51 { |
|
52 RDbColWriteStream writeStream; |
|
53 writeStream.OpenLC(aView, aCol); |
|
54 writeStream.WriteL(aLongText); |
|
55 writeStream.Close(); // This close call cannot be removed. |
|
56 |
|
57 CleanupStack::PopAndDestroy(&writeStream); |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 EXPORT_C HBufC* PosLmLongTextColHandler::ReadFromLongTextColumnLC( |
|
64 RDbRowSet& aView, |
|
65 TDbColNo aCol ) |
|
66 { |
|
67 TInt len = aView.ColLength( aCol ); |
|
68 if ( len > 0 ) |
|
69 { |
|
70 HBufC* text = HBufC::NewLC( len ); |
|
71 TPtr ptr = text->Des(); |
|
72 |
|
73 RDbColReadStream readStream; |
|
74 readStream.OpenL( aView, aCol ); |
|
75 CleanupClosePushL( readStream ); |
|
76 readStream.ReadL( ptr, len ); |
|
77 CleanupStack::PopAndDestroy( &readStream ); |
|
78 |
|
79 return text; |
|
80 } |
|
81 else |
|
82 { |
|
83 return KNullDesC().AllocLC(); |
|
84 } |
|
85 } |
|
86 |