1 /* |
|
2 * Copyright (c) 2009 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: OSN string data header. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef ALFSTRINGDATA_H |
|
19 #define ALFSTRINGDATA_H |
|
20 |
|
21 #include <osn/osntypes.h> |
|
22 |
|
23 #include "stringmacros.h" |
|
24 |
|
25 |
|
26 namespace osncore |
|
27 { |
|
28 |
|
29 class AlfChar; |
|
30 |
|
31 class CAlfString; |
|
32 |
|
33 struct SAlfStringData |
|
34 { |
|
35 // Uses shared null data. |
|
36 SAlfStringData(); |
|
37 |
|
38 // No copy. |
|
39 // SAlfStringData(AlfChar *u, uint l, uint m); |
|
40 // void initialize(AlfChar *u, uint l, uint m); |
|
41 |
|
42 // Copy bytes. |
|
43 // SAlfStringData(const AlfChar *u, uint l); |
|
44 // void initialize(const AlfChar *u, uint l); |
|
45 |
|
46 |
|
47 void initialize(const char *u, int l); |
|
48 |
|
49 |
|
50 ~SAlfStringData(); |
|
51 /* |
|
52 #ifdef QSTRING_DEBUG_ALLOCATIONS |
|
53 void* operator new(size_t s); |
|
54 void operator delete(void*p); |
|
55 #endif |
|
56 */ |
|
57 inline void ref() { refCount++; } |
|
58 inline void deref() { /*if (--refCount == 0 && _isHeapAllocated) delete this;*/ refCount--; } |
|
59 |
|
60 char* ascii(); |
|
61 |
|
62 char *makeAscii(); |
|
63 |
|
64 |
|
65 |
|
66 bool increaseAsciiSize(uint size); |
|
67 |
|
68 // AlfChar *unicode(); |
|
69 // AlfChar *makeUnicode(); |
|
70 |
|
71 |
|
72 // bool isUnicodeInternal() const { return (char *)_unicode == _internalBuffer; } |
|
73 bool isAsciiInternal() const { return _ascii == _internalBuffer; } |
|
74 |
|
75 int refCount; |
|
76 int _length; |
|
77 // mutable AlfChar *_unicode; |
|
78 mutable char *_ascii; |
|
79 int _maxUnicode:30; |
|
80 int _isUnicodeValid:1; |
|
81 int _isHeapAllocated:1; // Fragile, but the only way we can be sure the instance was created with 'new'. |
|
82 int _maxAscii:31; |
|
83 int _isAsciiValid:1; |
|
84 |
|
85 char _internalBuffer[QS_INTERNAL_BUFFER_SIZE]; // Pad out to a (((size + 1) & ~15) + 14) size |
|
86 |
|
87 private: |
|
88 SAlfStringData(const SAlfStringData &); |
|
89 SAlfStringData &operator=(const SAlfStringData &); |
|
90 |
|
91 }; |
|
92 |
|
93 }// osncore |
|
94 #endif |
|