Merge "Remove the memory leak on osp-security-service" into tizen_2.2
[platform/framework/native/appfw.git] / inc / FTextDecoder.h
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                FTextDecoder.h
19  * @brief               This is the header file for the %Decoder class.
20  *
21  * This header file contains the declarations of the %Decoder class.
22  */
23
24 #ifndef _FTEXT_DECODER_H_
25 #define _FTEXT_DECODER_H_
26
27 #include <FBaseObject.h>
28 #include <FBaseTypes.h>
29 #include <FBaseBuffer.h>
30
31 namespace Tizen { namespace Text
32 {
33 /**
34  * @class       Decoder
35  * @brief       This class is an implementation of the character decoder.
36  *
37  * @since       2.0
38  *
39  * The %Decoder class converts blocks of encoded bytes into blocks of Unicode characters
40  * through successive calls to the GetCharsN() method. This class maintains state consistency information between
41  * successive calls to %GetCharsN() and enables it to decode a sequence of bytes that span adjacent blocks.
42  *
43  * 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>.
44  *
45  */
46
47 class _OSP_EXPORT_ Decoder
48         : public Tizen::Base::Object
49 {
50 public:
51         /**
52          * This is the destructor for this class. @n
53          * This destructor overrides Tizen::Base::Object::~Object().
54          *
55          * @since       2.0
56          */
57         virtual ~Decoder(void) { };
58
59         /**
60          * Gets the total number of characters that are generated by decoding a range of elements specified in the Tizen::Base::ByteBuffer instance.
61          *
62          * @since                       2.0
63          *
64          * @return              An error code
65          * @param[in]   bytes                                    An instance of Tizen::Base::ByteBuffer to decode
66          * @param[in]   byteIndex                                The index from where the decoding begins
67          * @param[in]   byteCount                                The total number of bytes to decode
68          * @param[in]   flush                                    Set to @c true to allow this instance to flush its state at the end of the conversion, @n
69          *                                                                               else @c false
70          * @param[out]  charCount                                The total number of characters that are generated by decoding the specified Tizen::Base::ByteBuffer instance
71          * @exception   E_SUCCESS                The method is successful.
72          * @exception   E_INVALID_ARG            Either of the following conditions has occurred:
73          *                                                                               - A specified input parameter is invalid.
74          *                                                                               - The specified @c bytes is empty.
75          * @exception   E_OUT_OF_RANGE           Either of the following conditions has occurred:
76          *                                                                               - A specified input parameter is outside the valid range defined by the method.
77          *                                                                               - The length of the specified @c byteIndex or @c byteCount is greater than the length of the specified @c bytes.
78          * @exception   E_UNDERFLOW              Either of the following conditions has occurred:
79          *                                                                               - This operation has caused the memory to underflow.
80          *                                                                               - The sum of the length of the specified @c byteIndex and @c byteCount is greater than the length of the specified @c bytes.
81          * @exception   E_INVALID_ENCODING_RANGE The specified string contains code points that are outside the bounds of the character encoding scheme.
82          * @see         Encoder::GetByteCount()
83          */
84         virtual result GetCharCount(const Tizen::Base::ByteBuffer& bytes,
85                 int byteIndex, int byteCount, int& charCount, bool flush = false) const = 0;
86
87         /**
88          * Decodes an instance of Tizen::Base::ByteBuffer into an instance of Tizen::Base::WcharBuffer.
89          *
90          * @since                       2.0
91          *
92          * @return              A pointer to the Tizen::Base::WcharBuffer instance where the resultant decoded data is stored, @n
93          *                              else @c null if an exception occurs @n
94          *                              The buffer limit is the position of the last decoded byte plus one in the buffer and the starting position is zero.
95          * @param[in]   bytes                                    An instance of Tizen::Base::ByteBuffer to decode
96          * @param[in]   flush                                    Set to @c true to allow this instance to flush its state at the end of the conversion, @n
97          *                                                                               else @c false
98          * @exception   E_SUCCESS                The method is successful.
99          * @exception   E_OUT_OF_MEMORY          The memory is insufficient.
100          * @exception   E_INVALID_ARG            Either of the following conditions has occurred:
101          *                                                                               - A specified input parameter is invalid.
102          *                                                                               - The specified @c bytes is empty.
103          * @exception   E_INVALID_ENCODING_RANGE The specified string contains code points that are outside the bounds of the character encoding scheme.
104          * @remarks             The specific error code can be accessed using the GetLastResult() method.
105          * @see                 Encoder::GetBytesN()
106          */
107         virtual Tizen::Base::WcharBuffer* GetCharsN(const Tizen::Base::ByteBuffer& bytes, bool flush = false) const = 0;
108
109         /**
110          * Decodes an instance of Tizen::Base::ByteBuffer into an instance of Tizen::Base::WcharBuffer as per the specified range.
111          *
112          * @since                       2.0
113          *
114          * @return              A pointer to the Tizen::Base::WcharBuffer instance where the resultant decoded data is stored, @n
115          *                              else @c null if an exception occurs @n
116          *                              The buffer limit is the position of the last decoded byte in the buffer and the starting position is zero.
117          * @param[in]   bytes                                   An instance of Tizen::Base::ByteBuffer to decode
118          * @param[in]   byteIndex                               The index from where the decoding begins
119          * @param[in]   byteCount                               The total number of bytes to decode
120          * @param[in]   flush                                   Set to @c true to allow this instance to flush its state at the end of the conversion, @n
121          *                                                                              else @c false
122          * @exception   E_SUCCESS               The method is successful.
123          * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
124          * @exception   E_INVALID_ARG           Either of the following conditions has occurred:
125          *                                                                              - A specified input parameter is invalid.
126          *                                                                              - The specified @c bytes is empty.
127          * @exception   E_OUT_OF_RANGE          Either of the following conditions has occurred:
128          *                                                                              - A specified input parameter is outside the valid range defined by the method.
129          *                                                                              - The length of the specified @c byteIndex or @c byteCount is greater than the length of the specified @c bytes.
130          * @exception   E_UNDERFLOW                 Either of the following conditions has occurred:
131          *                                                                              - This operation has caused the memory to underflow.
132          *                                                                              - The sum of the length of the specified @c byteIndex and @c byteCount is greater than the length of the specified @c bytes.
133          * @exception   E_INVALID_ENCODING_RANGE The specified string contains code points that are outside the bounds of the character encoding scheme.
134          * @remarks     
135          *                              - This method maintains state consistency between conversions.
136          *                              - The specific error code can be accessed using the GetLastResult() method.
137          *                              - The pointer to the Tizen::Base::WcharBuffer instance is not terminated by a @c null character.
138          * @see                 Encoder::GetBytesN()
139          */
140         virtual Tizen::Base::WcharBuffer* GetCharsN(const Tizen::Base::ByteBuffer& bytes, int byteIndex, int byteCount,
141                 bool flush = false) const = 0;
142
143 protected:
144         Decoder(void)
145                 : _pDecoderImpl(null){};
146         friend class _DecoderImpl;
147         class _DecoderImpl* _pDecoderImpl;
148
149 private:
150         /**
151          * The implementation of this copy constructor is intentionally blank and declared as private to
152          * prohibit copying of objects.
153          */
154         Decoder(const Decoder& decoder);
155
156         /**
157          * The implementation of this copy assignment operator is intentionally blank and declared as private
158          * to prohibit copying of objects.
159          */
160         Decoder& operator =(const Decoder& decoder);
161
162 };
163
164 } } // Tizen::Text
165 #endif //_FTEXT_DECODER_H_