|
1 // Copyright (c) 2006-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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @publishedPartner |
|
19 */ |
|
20 |
|
21 #include <mtp/mtpdatatypeconstants.h> |
|
22 #include <mtp/tmtptypeint128.h> |
|
23 |
|
24 /** |
|
25 Default constructor. |
|
26 */ |
|
27 EXPORT_C TMTPTypeInt128::TMTPTypeInt128() |
|
28 { |
|
29 iData.FillZ(iData.MaxLength()); |
|
30 } |
|
31 |
|
32 /** |
|
33 Conversion constructor. |
|
34 */ |
|
35 EXPORT_C TMTPTypeInt128::TMTPTypeInt128(const TPtrC8& aData) : |
|
36 iData(aData) |
|
37 { |
|
38 } |
|
39 |
|
40 /** |
|
41 Sets the data type to the specified value. |
|
42 */ |
|
43 EXPORT_C void TMTPTypeInt128::Set(TInt64 aUpperValue, TUint64 aLowerValue) |
|
44 { |
|
45 memcpy(&iData[KMTPTypeInt128OffsetMS], &aUpperValue, sizeof(aUpperValue)); |
|
46 memcpy(&iData[KMTPTypeInt128OffsetLS], &aLowerValue, sizeof(aLowerValue)); |
|
47 } |
|
48 |
|
49 /** |
|
50 Provides the least significant portion of the data type. |
|
51 @return The least significant 64 bits of the value. |
|
52 */ |
|
53 EXPORT_C TUint64 TMTPTypeInt128::LowerValue() const |
|
54 { |
|
55 // memcpy the data to avoid alignment errors. |
|
56 TInt64 ret; |
|
57 memcpy(&ret, &iData[KMTPTypeInt128OffsetLS], sizeof(ret)); |
|
58 return ret; |
|
59 } |
|
60 |
|
61 /** |
|
62 Provides the most significant portion of type's value. |
|
63 @return The most significant 64 bits of the value. |
|
64 */ |
|
65 EXPORT_C TInt64 TMTPTypeInt128::UpperValue() const |
|
66 { |
|
67 // memcpy the data to avoid alignment errors. |
|
68 TInt64 ret; |
|
69 memcpy(&ret, &iData[KMTPTypeInt128OffsetMS], sizeof(ret)); |
|
70 return ret; |
|
71 } |
|
72 |
|
73 EXPORT_C TInt TMTPTypeInt128::FirstReadChunk(TPtrC8& aChunk) const |
|
74 { |
|
75 aChunk.Set(iData); |
|
76 return KMTPChunkSequenceCompletion; |
|
77 } |
|
78 |
|
79 EXPORT_C TInt TMTPTypeInt128::NextReadChunk(TPtrC8& aChunk) const |
|
80 { |
|
81 aChunk.Set(NULL, 0); |
|
82 return KErrNotReady; |
|
83 } |
|
84 |
|
85 EXPORT_C TInt TMTPTypeInt128::FirstWriteChunk(TPtr8& aChunk) |
|
86 { |
|
87 aChunk.Set(&iData[0], 0, iData.MaxLength()); |
|
88 return KMTPChunkSequenceCompletion; |
|
89 } |
|
90 |
|
91 EXPORT_C TInt TMTPTypeInt128::NextWriteChunk(TPtr8& aChunk) |
|
92 { |
|
93 aChunk.Set(NULL, 0, 0); |
|
94 return KErrNotReady; |
|
95 } |
|
96 |
|
97 EXPORT_C TUint64 TMTPTypeInt128::Size() const |
|
98 { |
|
99 return iData.MaxLength(); |
|
100 } |
|
101 |
|
102 EXPORT_C TUint TMTPTypeInt128::Type() const |
|
103 { |
|
104 return EMTPTypeINT128; |
|
105 } |
|
106 |
|
107 |