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