|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * Redistribution and use in source and binary forms, with or without |
|
6 * modification, are permitted provided that the following conditions are met: |
|
7 * |
|
8 * - Redistributions of source code must retain the above copyright notice, |
|
9 * this list of conditions and the following disclaimer. |
|
10 * - Redistributions in binary form must reproduce the above copyright notice, |
|
11 * this list of conditions and the following disclaimer in the documentation |
|
12 * and/or other materials provided with the distribution. |
|
13 * - Neither the name of Nokia Corporation nor the names of its contributors |
|
14 * may be used to endorse or promote products derived from this software |
|
15 * without specific prior written permission. |
|
16 * |
|
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
27 * POSSIBILITY OF SUCH DAMAGE. |
|
28 * |
|
29 * Initial Contributors: |
|
30 * Nokia Corporation - initial contribution. |
|
31 * |
|
32 * Contributors: |
|
33 * |
|
34 * Description: |
|
35 * |
|
36 */ |
|
37 |
|
38 using System; |
|
39 using System.Collections.Generic; |
|
40 using System.Text; |
|
41 |
|
42 namespace HeapLib.Cells.Descriptors |
|
43 { |
|
44 public class DescriptorInfo |
|
45 { |
|
46 #region Constructors & destructor |
|
47 internal DescriptorInfo( HeapCell aCell ) |
|
48 : this( aCell, false ) |
|
49 { |
|
50 } |
|
51 |
|
52 internal DescriptorInfo( HeapCell aCell, bool aIsUnicode ) |
|
53 { |
|
54 iCell = aCell; |
|
55 iType = DescriptorType( aCell ); |
|
56 iIsUnicode = aIsUnicode; |
|
57 } |
|
58 #endregion |
|
59 |
|
60 #region API |
|
61 public static HeapCell.TDescriptorType DescriptorType( HeapCell aCell ) |
|
62 { |
|
63 HeapCell.TDescriptorType ret = HeapCell.TDescriptorType.EUnknown; |
|
64 // |
|
65 int type = (int) ( aCell.PossibleVTableAddress >> KDescriptorTypeShiftCount ); |
|
66 if ( type >= (int) HeapCell.TDescriptorType.EBufC && type < (int) HeapCell.TDescriptorType.EUnknown ) |
|
67 { |
|
68 ret = (HeapCell.TDescriptorType) type; |
|
69 } |
|
70 // |
|
71 return ret; |
|
72 } |
|
73 #endregion |
|
74 |
|
75 #region Properties |
|
76 public bool IsUnicode |
|
77 { |
|
78 get { return iIsUnicode; } |
|
79 set { iIsUnicode = value; } |
|
80 } |
|
81 |
|
82 public string Text |
|
83 { |
|
84 get { return iText; } |
|
85 set { iText = value; } |
|
86 } |
|
87 |
|
88 public int Length |
|
89 { |
|
90 get { return iText.Length; } |
|
91 } |
|
92 |
|
93 public HeapCell.TDescriptorType Type |
|
94 { |
|
95 get { return iType; } |
|
96 set |
|
97 { |
|
98 iType = value; |
|
99 } |
|
100 } |
|
101 #endregion |
|
102 |
|
103 #region Internal constants |
|
104 private const int KDescriptorTypeShiftCount = 28; |
|
105 #endregion |
|
106 |
|
107 #region Data members |
|
108 private readonly HeapCell iCell; |
|
109 private bool iIsUnicode = false; |
|
110 private HeapCell.TDescriptorType iType = HeapCell.TDescriptorType.EUnknown; |
|
111 private string iText = string.Empty; |
|
112 #endregion |
|
113 } |
|
114 } |