sync with tizen_2.0
[platform/framework/native/appfw.git] / src / text / FTextGsmEncoding.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FTextGsmEncoding.cpp
20  * @brief               This is the implementation file for GSM Encoding class.
21  */
22
23 #include <FTextGsmEncoding.h>
24 #include <FBaseSysLog.h>
25 #include "FText_EncodingImpl.h"
26
27
28 #define ENCODING_NAME L"GSM"
29
30 using namespace Tizen::Base;
31
32 namespace Tizen { namespace Text
33 {
34
35 GsmEncoding::GsmEncoding(void)
36         : __pGsmEncodingImpl(null)
37 {
38         _pEncodingImpl = new (std::nothrow) _EncodingImpl;
39         if (_pEncodingImpl)
40         {
41                 result r = _pEncodingImpl->Construct(ENCODING_NAME);
42                 if (IsFailed(r))
43                 {
44                         delete _pEncodingImpl;
45                         _pEncodingImpl = null;
46                 }
47         }
48
49         SysAssert(_pEncodingImpl);
50 }
51
52
53 GsmEncoding::~GsmEncoding(void)
54 {
55         delete _pEncodingImpl;
56 }
57
58
59 result
60 GsmEncoding::GetByteCount(const String& str, int& byteCount) const
61 {
62         return _pEncodingImpl->GetByteCount(str, byteCount);
63 }
64
65
66 result
67 GsmEncoding::GetByteCount(const WcharBuffer& chars, int& byteCount) const
68 {
69         return _pEncodingImpl->GetByteCount(chars, byteCount);
70 }
71
72
73 result
74 GsmEncoding::GetByteCount(const WcharBuffer& chars, int charIndex, int charCount, int& byteCount) const
75 {
76         return _pEncodingImpl->GetByteCount(chars, charIndex, charCount, byteCount);
77 }
78
79
80 ByteBuffer*
81 GsmEncoding::GetBytesN(const WcharBuffer& chars) const
82 {
83         return _pEncodingImpl->GetBytesN(chars);
84 }
85
86
87 ByteBuffer*
88 GsmEncoding::GetBytesN(const String& str) const
89 {
90         return _pEncodingImpl->GetBytesN(str);
91 }
92
93
94 result
95 GsmEncoding::GetBytes(const WcharBuffer& chars, int charIndex, int charCount, ByteBuffer& bytes, int byteIndex) const
96 {
97         return _pEncodingImpl->GetBytes(chars, charIndex, charCount, bytes, byteIndex);
98 }
99
100
101 result
102 GsmEncoding::GetBytes(const String& str, int charIndex, int charCount, ByteBuffer& bytes, int byteIndex) const
103 {
104         return _pEncodingImpl->GetBytes(str, charIndex, charCount, bytes, byteIndex);
105 }
106
107
108 result
109 GsmEncoding::GetCharCount(const ByteBuffer& bytes, int& charCount) const
110 {
111         return _pEncodingImpl->GetCharCount(bytes, charCount);
112 }
113
114
115 result
116 GsmEncoding::GetCharCount(const ByteBuffer& bytes, int byteIndex, int byteCount, int& charCount) const
117 {
118         return _pEncodingImpl->GetCharCount(bytes, byteIndex, byteCount, charCount);
119 }
120
121
122 WcharBuffer*
123 GsmEncoding::GetCharsN(const ByteBuffer& bytes) const
124 {
125         return _pEncodingImpl->GetCharsN(bytes);
126 }
127
128
129 result
130 GsmEncoding::GetChars(const ByteBuffer& bytes, int byteIndex, int byteCount, WcharBuffer& chars, int charIndex) const
131 {
132         return _pEncodingImpl->GetChars(bytes, byteIndex, byteCount, chars, charIndex);
133 }
134
135
136 result
137 GsmEncoding::GetString(const ByteBuffer& bytes, String& str) const
138 {
139         return GetString(bytes, bytes.GetPosition(), bytes.GetRemaining(), str);
140 }
141
142
143 result
144 GsmEncoding::GetString(const ByteBuffer& bytes, int index, int count, String& str) const
145 {
146         return _pEncodingImpl->GetString(bytes, index, count, str);
147 }
148
149
150 int
151 GsmEncoding::GetMaxByteCount(int charCount) const
152 {
153         return charCount * 2;
154 }
155
156
157 int
158 GsmEncoding::GetMaxCharCount(int byteCount) const
159 {
160         return byteCount;
161 }
162
163
164 Encoder*
165 GsmEncoding::GetEncoderN(void) const
166 {
167         return null;
168 }
169
170
171 Decoder*
172 GsmEncoding::GetDecoderN(void) const
173 {
174         return null;
175 }
176
177
178 String
179 GsmEncoding::GetEncodingType(void) const
180 {
181         return String(ENCODING_NAME);
182 }
183
184 } } // Tizen::Text