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 FBaseUtilDeflator.h
20 * @brief This is the header file for the %Deflator class.
22 * This header file contains the declarations of the %Deflator class.
24 #ifndef _FBASE_UTIL_DEFLATOR_H_
25 #define _FBASE_UTIL_DEFLATOR_H_
27 #include <FBaseByteBuffer.h>
28 #include <FBaseUtilTypes.h>
31 namespace Tizen { namespace Base { namespace Utility
35 * @brief This class provides the deflate functionality using zlib.
39 * The %Deflator class provides the deflate functionality using zlib.
41 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/base/utility_namespace.htm">Utility</a>.
43 * The following example demonstrates how to use the %Deflator class.
49 * using namespace Tizen::Base;
50 * using namespace Tizen::Base::Utility;
53 * MyClass::DeflatorSample(ByteBuffer &buf)
55 * ByteBuffer* pBuf1 = null;
56 * ByteBuffer* pBuf2 = null;
57 * ByteBuffer* pBuf3 = null;
59 * // Deflates the buf from the current position to limit of the buf
60 * pBuf1 = Deflator::DeflateN(buf);
63 * // Error case handling...
65 * // pBuf1: Deflated data of buf
67 * // Deflates the buf from the current position to (limit-2) of the buf
68 * pBuf2 = Deflator::DeflateN(buf, (buf.GetLimit()-2));
71 * // Error case handling...
74 * // Deflates the buf from the current position to limit of the buf for BEST_COMPRESSION
75 * pBuf3 = Deflator::DeflateN(buf, BEST_COMPRESSION);
78 * // Error case handling...
89 class _OSP_EXPORT_ Deflator
93 * Deflates the number of bytes from the source byte buffer to the output byte buffer.
97 * @return A pointer to the ByteBuffer instance with the deflated equivalent of the source buffer @n
98 * The buffer's limit is the length of the deflated data, @n
99 * else @c null if an exception occurs.
100 * @param[in] src The buffer to deflate
101 * @param[in] byteCount The number of bytes to deflate from the source buffer
102 * @param[in] level Set to @c BEST_SPEED or @c BEST_COMPRESSION @n
103 * By default, it is set to @c DEFAULT_COMPRESSION.
104 * @exception E_SUCCESS The method is successful.
105 * @exception E_INVALID_ARG A specified input parameter is invalid.
106 * @exception E_SYSTEM A system error has occurred.
107 * @remarks The specific error code can be accessed using the GetLastResult() method.
108 * @see Tizen::Base::Utility::Inflator
110 static ByteBuffer* DeflateN(const ByteBuffer& src, int byteCount, CompressionLevel level = DEFAULT_COMPRESSION);
113 * Deflates data from the source byte buffer to the output byte buffer.
117 * @return A pointer to the ByteBuffer instance with the deflated equivalent of the source buffer @n
118 * The buffer's limit is the length of the deflated data, @n
119 * else @c null if an exception occurs.
120 * @param[in] src The buffer to deflate
121 * @param[in] level Set to @c BEST_SPEED or @c BEST_COMPRESSION @n
122 * By default, it is set to @c DEFAULT_COMPRESSION.
123 * @exception E_SUCCESS The method is successful.
124 * @exception E_INVALID_ARG A specified input parameter is invalid.
125 * @exception E_SYSTEM A system error has occurred.
126 * @remarks The specific error code can be accessed using the GetLastResult() method.
127 * @see Tizen::Base::Utility::Inflator
129 static ByteBuffer* DeflateN(const ByteBuffer& src, CompressionLevel level = DEFAULT_COMPRESSION);
132 static ByteBuffer* __DeflateN(const ByteBuffer& src, int byteCount, CompressionLevel level);
135 * This default constructor is intentionally declared as private because this class cannot be constructed.
140 * This destructor is intentionally declared as private because this class cannot be constructed.
145 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
147 * @param[in] rhs An instance of %Deflator
149 Deflator(const Deflator& rhs);
152 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
154 * @param[in] rhs An instance of %Deflator
156 Deflator& operator =(const Deflator& rhs);
160 }}} // Tizen::Base::Utility
162 #endif // _FBASE_UTIL_DEFLATOR_H_