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