2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FText_DecoderImpl.h
19 * @brief This is the header file for the _DecoderImpl class.
22 #ifndef _FTEXT_INTERNAL_DECODER_IMPL_H_
23 #define _FTEXT_INTERNAL_DECODER_IMPL_H_
26 #include <unique_ptr.h>
27 #include <FTextDecoder.h>
31 namespace Tizen { namespace Text
42 * This is the destructor for this class.
46 virtual ~_DecoderImpl(void);
48 static _DecoderImpl* GetDecoderN(const Tizen::Base::String& encodingType);
52 * Calculates the number of characters produced by decoding a specified range of elements in a ByteBuffer.
55 * @return An error code
56 * @param[in] bytes The ByteBuffer to decode
57 * @param[in] byteIndex The starting index where decoding begins
58 * @param[in] byteCount The number of bytes to decode
59 * @param[out] charCount The number of characters produced by decoding a range of bytes in the specified ByteBuffer
60 * @param[in] flush Set to @c true, to allow this instance to flush its state at the end of the conversion @n
62 * @exception E_SUCCESS The method was successful.
63 * @exception E_INVALID_ARG A specified input parameter is invalid. @n
64 * The specified @c bytes is empty.
65 * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. @n
66 * The length of the specified @c byteIndex or @c byteCount is greater than the length of the specified @c bytes.
67 * @exception E_UNDERFLOW This operation caused an underflow. @n
68 * The sum of the length of the specified @c byteIndex and @c byteCount is greater than the length of the specified @c bytes.
69 * @exception E_INVALID_ENCODING_RANGE The specified string contains code points, which are outside the bounds specified by the character encoding scheme.
71 * @see Encoder::GetByteCount()
73 virtual result GetCharCount(const Tizen::Base::ByteBuffer& bytes, int byteIndex, int byteCount, int& charCount, bool flush = false) const;
76 * Decodes a ByteBuffer into a WcharBuffer.
79 * @return A new WcharBuffer where the resulting decoded data is stored @n
80 * @c null, if an exception occurs @n
81 * The buffer's limit is the position of the last encoded byte plus one in the buffer, and the position is zero
82 * @param[in] bytes The buffer containing ByteBuffer to decode
83 * @param[in] flush Set to @c true, to allow this instance to flush its state at the end of the conversion @n
85 * @exception E_SUCCESS The method was successful.
86 * @exception E_OUT_OF_MEMORY Insufficient memory.
87 * @exception E_INVALID_ARG A specified input parameter is invalid. @n
88 * The specified @c bytes is empty.
89 * @exception E_INVALID_ENCODING_RANGE The specified string contains code points, which are outside the bounds specified by the character encoding scheme.
90 * @remarks The specific error code can be accessed using the GetLastResult() method.
92 * @see Encoder::GetBytesN()
94 virtual Tizen::Base::WcharBuffer* GetCharsN(const Tizen::Base::ByteBuffer& bytes, bool flush = false) const;
97 * Decodes a range of bytes in a ByteBuffer into a range of characters in a WcharBuffer.
100 * @return A new WcharBuffer where the resulting decoded data is stored @n
101 * @c null, if an exception occurs @n
102 * The buffer's limit is the position of the last encoded byte in the buffer, and the position is zero
103 * @param[in] bytes The buffer containing ByteBuffer to decode
104 * @param[in] byteIndex The starting index where decoding begins
105 * @param[in] byteCount The number of bytes to decode
106 * @param[in] flush Set to @c true, to allow this instance to flush its state at the end of the conversion @n
107 * @c false, otherwise
108 * @exception E_SUCCESS The method was successful.
109 * @exception E_OUT_OF_MEMORY Insufficient memory.
110 * @exception E_INVALID_ARG A specified input parameter is invalid. @n
111 * The specified @c bytes is empty.
112 * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. @n
113 * The length of the specified @c byteIndex or @c byteCount is greater than the length of the specified @c bytes.
114 * @exception E_UNDERFLOW This operation caused an underflow. @n
115 * The sum of the length of the specified @c byteIndex and @c byteCount is greater than the length of the specified @c bytes.
116 * @exception E_INVALID_ENCODING_RANGE The specified string contains code points, which are outside the bounds specified by the character encoding scheme.
117 * @remarks The GetChars() method maintains state consistency between conversions.
118 * @remarks The specific error code can be accessed using the GetLastResult() method.
119 * @remarks The new ByteBuffer isn't terminated by @c null character.
121 * @see Encoder::GetBytesN()
123 virtual Tizen::Base::WcharBuffer* GetCharsN(const Tizen::Base::ByteBuffer& bytes, int byteIndex, int byteCount, bool flush = false) const;
128 result GetBufferSize(const Tizen::Base::ByteBuffer& bytes, int& byteBufSize) const;
129 result CheckBufferInput(int inBufSize, int inIndex, int inCount) const;
130 result Decode(const byte* pSrc, int srcLength, Tizen::Base::WcharBuffer*& pWcharBuffer, int index, bool flush) const;
133 _DecoderImpl(const _DecoderImpl& decoderImpl);
134 _DecoderImpl& operator =(const _DecoderImpl& decoderImpl);
137 std::unique_ptr<_EncodingCore> __pDecoder;
138 Tizen::Base::String __encodingType;
144 #endif //_FTEXT_INTERNAL_DECODER_IMPL_H_