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_EncoderImpl.h
19 * @brief This is the header file for the _EncoderImpl class.
22 #ifndef _FTEXT_INTERNAL_ENCODER_IMPL_H_
23 #define _FTEXT_INTERNAL_ENCODER_IMPL_H_
26 #include <unique_ptr.h>
27 #include <FTextEncoder.h>
31 namespace Tizen { namespace Text
42 * This is the destructor for this class.
46 virtual ~_EncoderImpl(void);
48 static _EncoderImpl* GetEncoderN(const Tizen::Base::String& encodingType);
53 * Calculates the number of bytes required to encode a range of characters in the specified WcharBuffer.
56 * @return An error code
57 * @param[in] chars The buffer containing the character array to encode
58 * @param[in] charIndex The starting index of the WcharBuffer to encode
59 * @param[in] charCount The number of characters to encode
60 * @param[in] flush Set to @c true, to allow this instance to flush its state at the end of the conversion @n
62 * @param[out] byteCount The number of bytes required to encode the specified range of characters
63 * @exception E_SUCCESS The method was successful.
64 * @exception E_INVALID_ARG A specified input parameter is invalid. @n
65 * The specified @c chars is empty.
66 * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. @n
67 * The length of the specified @c charIndex or @c charCount is greater than the @n
68 * length of the specified @c chars.
69 * @exception E_UNDERFLOW This operation caused an underflow. @n
70 * The sum of the length of the specified @c charIndex and @c charCount is greater
71 * than the length of the specified @c chars.
72 * @exception E_INVALID_ENCODING_RANGE The specified string contains code points, which are outside the bounds specified @n
73 * by the character encoding scheme.
75 * @see Decoder::GetCharCount()
77 virtual result GetByteCount(const Tizen::Base::WcharBuffer& chars, int charIndex, int charCount, int& byteCount, bool flush = false) const;
80 * Encodes a specified WcharBuffer into a ByteBuffer.
83 * @return A new ByteBuffer where the resulting encoded string is stored @n
84 * @c null, if an exception occurs @n
85 * The buffer's limit is the position of the last encoded byte plus one in the buffer, and the position is zero
86 * @param[in] chars The WcharBuffer to encode
87 * @param[in] flush Set to @c true, to allow this instance to flush its state at the end of the conversion @n
89 * @exception E_SUCCESS The method was successful.
90 * @exception E_OUT_OF_MEMORY Insufficient memory.
91 * @exception E_INVALID_ARG A specified input parameter is invalid. @n
92 * The specified @c chars is empty.
93 * @exception E_INVALID_ENCODING_RANGE The specified string contains code points, which are outside the bounds specified by the character encoding scheme.
94 * @remarks The specific error code can be accessed using the GetLastResult() method.
96 * @see Decoder::GetCharsN()
98 virtual Tizen::Base::ByteBuffer* GetBytesN(const Tizen::Base::WcharBuffer& chars, bool flush = false) const;
101 * Encodes a range of characters from a WcharBuffer into a ByteBuffer.
104 * @return A new ByteBuffer where the resulting encoded string is stored @n
105 * @c null if an exception occurs @n
106 * The buffer's limit is the position of the last encoded byte in the buffer, and the position is zero
107 * @param[in] chars The buffer containing the character array to encode
108 * @param[in] charIndex The starting index of the WcharBuffer to encode
109 * @param[in] charCount The number of characters to encode
110 * @param[in] flush Set to @c true, to allow this instance to flush its state at the end of the conversion @n
111 * @c false, otherwise
112 * @exception E_SUCCESS The method was successful.
113 * @exception E_OUT_OF_MEMORY Insufficient memory.
114 * @exception E_INVALID_ARG A specified input parameter is invalid. @n
115 * The specified @c chars is empty.
116 * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. @n
117 * The length of the specified @c charIndex or @c charCount is greater than the length of the specified @c chars.
118 * @exception E_UNDERFLOW This operation caused an underflow. @n
119 * The sum of the length of the specified @c charIndex and @c charCount is greater than the length of the specified @c chars.
120 * @exception E_INVALID_ENCODING_RANGE The specified string contains code points, which are outside the bounds specified by the character encoding scheme.
121 * @remarks The specific error code can be accessed using the GetLastResult() method.
122 * @remarks The new ByteBuffer isn't terminated by @c null character.
124 * @see Decoder::GetCharsN()
126 virtual Tizen::Base::ByteBuffer* GetBytesN(const Tizen::Base::WcharBuffer& chars, int charIndex, int charCount, bool flush = false) const;
131 result GetBufferSize(const Tizen::Base::WcharBuffer& chars, int& charBufSize) const;
132 result CheckBufferInput(int inBufSize, int inIndex, int inCount) const;
133 result Encode(const wchar_t* pSrc, int srcLength, Tizen::Base::ByteBuffer*& pByteBuffer, int index, bool flush) const;
135 _EncoderImpl(const _EncoderImpl& encoderImpl);
136 _EncoderImpl& operator =(const _EncoderImpl& encoderImpl);
139 std::unique_ptr<_EncodingCore> __pEncoder;
140 Tizen::Base::String __encodingType;
146 #endif //_FTEXT_INTERNAL_ENCODER_IMPL_H_