Fix prevent defect on Text.
[platform/framework/native/appfw.git] / src / text / FTextLatin1Encoding.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                FTextLatin1Encoding.cpp
19  * @brief               This is the implementation file for Latin1 Encoding class.
20  */
21
22 #include <FTextLatin1Encoding.h>
23 #include <FBaseSysLog.h>
24 #include "FText_EncodingImpl.h"
25
26
27 #define ENCODING_NAME L"ISO-8859-1"
28
29 using namespace Tizen::Base;
30
31 namespace Tizen { namespace Text
32 {
33
34
35 Latin1Encoding::Latin1Encoding(void)
36         : __pLatin1EncodingImpl(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 Latin1Encoding::~Latin1Encoding(void)
54 {
55         delete _pEncodingImpl;
56 }
57
58
59 ByteBuffer*
60 Latin1Encoding::GetBytesN(const WcharBuffer& chars) const
61 {
62         return _pEncodingImpl->GetBytesN(chars);
63 }
64
65 ByteBuffer*
66 Latin1Encoding::GetBytesN(const String& str) const
67 {
68         return _pEncodingImpl->GetBytesN(str);
69 }
70
71
72 result
73 Latin1Encoding::GetBytes(const WcharBuffer& chars, int charIndex, int charCount, ByteBuffer& bytes, int byteIndex) const
74 {
75         return _pEncodingImpl->GetBytes(chars, charIndex, charCount, bytes, byteIndex);
76 }
77
78
79 result
80 Latin1Encoding::GetBytes(const String& str, int charIndex, int charCount, ByteBuffer& bytes, int byteIndex) const
81 {
82         return _pEncodingImpl->GetBytes(str, charIndex, charCount, bytes, byteIndex);
83 }
84
85
86 WcharBuffer*
87 Latin1Encoding::GetCharsN(const ByteBuffer& bytes) const
88 {
89         return _pEncodingImpl->GetCharsN(bytes);
90 }
91
92
93 result
94 Latin1Encoding::GetChars(const ByteBuffer& bytes, int byteIndex, int byteCount, WcharBuffer& chars, int charIndex) const
95 {
96         return _pEncodingImpl->GetChars(bytes, byteIndex, byteCount, chars, charIndex);
97 }
98
99
100 result
101 Latin1Encoding::GetString(const ByteBuffer& bytes, String& str) const
102 {
103         return _pEncodingImpl->GetString(bytes, str);
104 }
105
106
107 result
108 Latin1Encoding::GetString(const ByteBuffer& bytes, int byteIndex, int byteCount, String& str) const
109 {
110         return _pEncodingImpl->GetString(bytes, byteIndex, byteCount, str);
111 }
112
113
114 int
115 Latin1Encoding::GetMaxByteCount(int charCount) const
116 {
117         return charCount;
118 }
119
120
121 int
122 Latin1Encoding::GetMaxCharCount(int byteCount) const
123 {
124         return byteCount;
125 }
126
127
128 Encoder*
129 Latin1Encoding::GetEncoderN(void) const
130 {
131         return null;
132 }
133
134
135 Decoder*
136 Latin1Encoding::GetDecoderN(void) const
137 {
138         return null;
139 }
140
141
142 String
143 Latin1Encoding::GetEncodingType(void) const
144 {
145         return String(ENCODING_NAME);
146 }
147
148 } } // Tizen::Text