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 FBaseUtilDeflator.h
19 * @brief This is the header file for the %Deflator class.
21 * This header file contains the declarations of the %Deflator class.
23 #ifndef _FBASE_UTIL_DEFLATOR_H_
24 #define _FBASE_UTIL_DEFLATOR_H_
26 #include <FBaseByteBuffer.h>
27 #include <FBaseUtilTypes.h>
30 namespace Tizen { namespace Base { namespace Utility
34 * @brief This class provides the deflate functionality using zlib.
38 * The %Deflator class provides the deflate functionality using zlib.
40 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/base/utility_namespace.htm">Utility</a>.
42 * The following example demonstrates how to use the %Deflator class.
48 * using namespace Tizen::Base;
49 * using namespace Tizen::Base::Utility;
52 * MyClass::DeflatorSample(ByteBuffer &buf)
54 * ByteBuffer* pBuf1 = null;
55 * ByteBuffer* pBuf2 = null;
56 * ByteBuffer* pBuf3 = null;
58 * // Deflates the buf from the current position to limit of the buf
59 * pBuf1 = Deflator::DeflateN(buf);
62 * // Error case handling...
64 * // pBuf1: Deflated data of buf
66 * // Deflates the buf from the current position to (limit-2) of the buf
67 * pBuf2 = Deflator::DeflateN(buf, (buf.GetLimit()-2));
70 * // Error case handling...
73 * // Deflates the buf from the current position to limit of the buf for BEST_COMPRESSION
74 * pBuf3 = Deflator::DeflateN(buf, BEST_COMPRESSION);
77 * // Error case handling...
88 class _OSP_EXPORT_ Deflator
92 * Deflates the number of bytes from the source byte buffer to the output byte buffer.
96 * @return A pointer to the ByteBuffer instance with the deflated equivalent of the source buffer @n
97 * The buffer's limit is the length of the deflated data, @n
98 * else @c null if an exception occurs.
99 * @param[in] src The buffer to deflate
100 * @param[in] byteCount The number of bytes to deflate from the source buffer
101 * @param[in] level Set to @c BEST_SPEED or @c BEST_COMPRESSION @n
102 * By default, it is set to @c DEFAULT_COMPRESSION.
103 * @exception E_SUCCESS The method is successful.
104 * @exception E_INVALID_ARG A specified input parameter is invalid.
105 * @exception E_SYSTEM A system error has occurred.
106 * @remarks The specific error code can be accessed using the GetLastResult() method.
107 * @see Tizen::Base::Utility::Inflator
109 static ByteBuffer* DeflateN(const ByteBuffer& src, int byteCount, CompressionLevel level = DEFAULT_COMPRESSION);
112 * Deflates data from the source byte buffer to the output byte buffer.
116 * @return A pointer to the ByteBuffer instance with the deflated equivalent of the source buffer @n
117 * The buffer's limit is the length of the deflated data, @n
118 * else @c null if an exception occurs.
119 * @param[in] src The buffer to deflate
120 * @param[in] level Set to @c BEST_SPEED or @c BEST_COMPRESSION @n
121 * By default, it is set to @c DEFAULT_COMPRESSION.
122 * @exception E_SUCCESS The method is successful.
123 * @exception E_INVALID_ARG A specified input parameter is invalid.
124 * @exception E_SYSTEM A system error has occurred.
125 * @remarks The specific error code can be accessed using the GetLastResult() method.
126 * @see Tizen::Base::Utility::Inflator
128 static ByteBuffer* DeflateN(const ByteBuffer& src, CompressionLevel level = DEFAULT_COMPRESSION);
131 static ByteBuffer* __DeflateN(const ByteBuffer& src, int byteCount, CompressionLevel level);
134 * This default constructor is intentionally declared as private because this class cannot be constructed.
139 * This destructor is intentionally declared as private because this class cannot be constructed.
144 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
146 * @param[in] rhs An instance of %Deflator
148 Deflator(const Deflator& rhs);
151 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
153 * @param[in] rhs An instance of %Deflator
155 Deflator& operator =(const Deflator& rhs);
159 }}} // Tizen::Base::Utility
161 #endif // _FBASE_UTIL_DEFLATOR_H_