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