2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FTextDecoder.h
20 * @brief This is the header file for the %Decoder class.
22 * This header file contains the declarations of the %Decoder class.
25 #ifndef _FTEXT_DECODER_H_
26 #define _FTEXT_DECODER_H_
28 #include <FBaseObject.h>
29 #include <FBaseTypes.h>
30 #include <FBaseBuffer.h>
32 namespace Tizen { namespace Text
36 * @brief This class is an implementation of the character decoder.
40 * The %Decoder class converts blocks of encoded bytes into blocks of Unicode characters
41 * through successive calls to the GetCharsN() method. This class maintains state consistency information between
42 * successive calls to %GetCharsN(), enabling it to decode a sequence of bytes that span adjacent blocks.
44 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/text/converting_text_data_separate_blocks.htm">Converting Text Data in Separate Blocks</a>.
48 class _OSP_EXPORT_ Decoder
49 : public Tizen::Base::Object
53 * This is the destructor for this class. @n
54 * This destructor overrides Tizen::Base::Object::~Object().
58 virtual ~Decoder(void) { };
61 * Gets the total number of characters that are generated by decoding a range of elements specified in the Tizen::Base::ByteBuffer instance.
65 * @return An error code
66 * @param[in] bytes An instance of Tizen::Base::ByteBuffer to decode
67 * @param[in] byteIndex The index from where decoding begins
68 * @param[in] byteCount The total number of bytes to decode
69 * @param[in] flush Set to @c true to allow this instance to flush its state at the end of the conversion, @n
71 * @param[out] charCount The total number of characters that are generated by decoding the specified Tizen::Base::ByteBuffer instance
72 * @exception E_SUCCESS The method is successful.
73 * @exception E_INVALID_ARG A specified input parameter is invalid, or
74 * the specified @c bytes is empty.
75 * @exception E_OUT_OF_RANGE The value of an argument is outside the valid range defined by the method, or
76 * the length of the specified @c byteIndex or @c byteCount is greater than the length of the specified @c bytes.
77 * @exception E_UNDERFLOW This operation has caused the memory to underflow, or
78 * the sum of the length of the specified @c byteIndex and @c byteCount is greater than the length of the specified @c bytes.
79 * @exception E_INVALID_ENCODING_RANGE The specified string contains code points that are outside the bounds of the character encoding scheme.
80 * @see Encoder::GetByteCount()
82 virtual result GetCharCount(const Tizen::Base::ByteBuffer& bytes,
83 int byteIndex, int byteCount, int& charCount, bool flush = false) const = 0;
86 * Decodes an instance of Tizen::Base::ByteBuffer into an instance of Tizen::Base::WcharBuffer.
90 * @return A pointer to the Tizen::Base::WcharBuffer instance where the resultant decoded data is stored, @n
91 * else @c null if an exception occurs @n
92 * The buffer limit is the position of the last decoded byte plus one in the buffer and the starting position is zero.
93 * @param[in] bytes An instance of Tizen::Base::ByteBuffer to decode
94 * @param[in] flush Set to @c true to allow this instance to flush its state at the end of the conversion, @n
96 * @exception E_SUCCESS The method is successful.
97 * @exception E_OUT_OF_MEMORY The memory is insufficient.
98 * @exception E_INVALID_ARG A specified input parameter is invalid, or
99 * the specified @c bytes is empty.
100 * @exception E_INVALID_ENCODING_RANGE The specified string contains code points that are outside the bounds of the character encoding scheme.
101 * @remarks The specific error code can be accessed using the GetLastResult() method.
102 * @see Encoder::GetBytesN()
104 virtual Tizen::Base::WcharBuffer* GetCharsN(const Tizen::Base::ByteBuffer& bytes, bool flush = false) const = 0;
107 * Decodes an instance of Tizen::Base::ByteBuffer into an instance of Tizen::Base::WcharBuffer as per the specified range.
111 * @return A pointer to the Tizen::Base::WcharBuffer instance where the resultant decoded data is stored, @n
112 * else @c null if an exception occurs @n
113 * The buffer limit is the position of the last decoded byte in the buffer and the starting position is zero.
114 * @param[in] bytes An instance of Tizen::Base::ByteBuffer to decode
115 * @param[in] byteIndex The index from where decoding begins
116 * @param[in] byteCount The total number of bytes to decode
117 * @param[in] flush Set to @c true to allow this instance to flush its state at the end of the conversion, @n
119 * @exception E_SUCCESS The method is successful.
120 * @exception E_OUT_OF_MEMORY The memory is insufficient.
121 * @exception E_INVALID_ARG A specified input parameter is invalid, or
122 * the specified @c bytes is empty.
123 * @exception E_OUT_OF_RANGE The value of an argument is outside the valid range defined by the method, or
124 * the length of the specified @c byteIndex or @c byteCount is greater than the length of the specified @c bytes.
125 * @exception E_UNDERFLOW This operation has caused the memory to underflow, or
126 * the sum of the length of the specified @c byteIndex and @c byteCount is greater than the length of the specified @c bytes.
127 * @exception E_INVALID_ENCODING_RANGE The specified string contains code points that are outside the bounds of the character encoding scheme.
128 * @remarks This method maintains state consistency between conversions.
129 * @remarks The specific error code can be accessed using the GetLastResult() method.
130 * @remarks The pointer to the Tizen::Base::WcharBuffer instance is not terminated by a @c null character.
131 * @see Encoder::GetBytesN()
133 virtual Tizen::Base::WcharBuffer* GetCharsN(const Tizen::Base::ByteBuffer& bytes, int byteIndex, int byteCount,
134 bool flush = false) const = 0;
138 : _pDecoderImpl(null){};
139 friend class _DecoderImpl;
140 class _DecoderImpl* _pDecoderImpl;
144 * The implementation of this copy constructor is intentionally blank and declared as private to
145 * prohibit copying of objects.
147 Decoder(const Decoder& decoder);
150 * The implementation of this copy assignment operator is intentionally blank and declared as private
151 * to prohibit copying of objects.
153 Decoder& operator =(const Decoder& decoder);
158 #endif //_FTEXT_DECODER_H_