fixed wrong link
[platform/framework/native/appfw.git] / inc / FBaseUtilDeflator.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file                FBaseUtilDeflator.h
20  * @brief               This is the header file for the %Deflator class.
21  *
22  * This header file contains the declarations of the %Deflator class.
23  */
24 #ifndef _FBASE_UTIL_DEFLATOR_H_
25 #define _FBASE_UTIL_DEFLATOR_H_
26
27 #include <FBaseByteBuffer.h>
28 #include <FBaseUtilTypes.h>
29
30
31 namespace Tizen { namespace Base { namespace Utility
32 {
33 /**
34  * @class       Deflator
35  * @brief       This class provides the deflate functionality using zlib.
36  *
37  * @since 2.0
38  *
39  * The %Deflator class provides the deflate functionality using zlib.
40  *
41  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/base/utility_namespace.htm">Utility</a>.
42  *
43  * The following example demonstrates how to use the %Deflator class.
44  *
45  *      @code
46  *
47  *      #include <FBase.h>
48  *
49  *      using namespace Tizen::Base;
50  *      using namespace Tizen::Base::Utility;
51  *
52  *      void
53  *      MyClass::DeflatorSample(ByteBuffer &buf)
54  *      {
55  *              ByteBuffer* pBuf1 = null;
56  *              ByteBuffer* pBuf2 = null;
57  *              ByteBuffer* pBuf3 = null;
58  *
59  *              // Deflates the buf from the current position to limit of the buf
60  *              pBuf1 = Deflator::DeflateN(buf);
61  *              if (null == pBuf1)
62  *              {
63  *                      // Error case handling...
64  *              }
65  *              // pBuf1: Deflated data of buf
66  *
67  *              // Deflates the buf from the current position to (limit-2) of the buf
68  *              pBuf2 = Deflator::DeflateN(buf, (buf.GetLimit()-2));
69  *              if (null == pBuf2)
70  *              {
71  *                      // Error case handling...
72  *              }
73  *
74  *              // Deflates the buf from the current position to limit of the buf for BEST_COMPRESSION
75  *              pBuf3 = Deflator::DeflateN(buf, BEST_COMPRESSION);
76  *              if (null == pBuf3)
77  *              {
78  *                      // Error case handling...
79  *              }
80  *
81  *
82  *              delete pBuf1;
83  *              delete pBuf2;
84  *              delete pBuf3;
85  *      }
86  *
87  *      @endcode
88  */
89 class _OSP_EXPORT_ Deflator
90 {
91 public:
92         /**
93          * Deflates the number of bytes from the source byte buffer to the output byte buffer.
94          *
95          * @since 2.0
96          *
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
109          */
110         static ByteBuffer* DeflateN(const ByteBuffer& src, int byteCount, CompressionLevel level = DEFAULT_COMPRESSION);
111
112         /**
113          * Deflates data from the source byte buffer to the output byte buffer.
114          *
115          * @since 2.0
116          *
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
128          */
129         static ByteBuffer* DeflateN(const ByteBuffer& src, CompressionLevel level = DEFAULT_COMPRESSION);
130
131 private:
132         static ByteBuffer* __DeflateN(const ByteBuffer& src, int byteCount, CompressionLevel level);
133
134         /**
135          * This default constructor is intentionally declared as private because this class cannot be constructed.
136          */
137         Deflator(void);
138
139         /**
140          * This destructor is intentionally declared as private because this class cannot be constructed.
141          */
142         ~Deflator(void);
143
144         /**
145          * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
146          *
147          * @param[in]   rhs     An instance of %Deflator
148          */
149         Deflator(const Deflator& rhs);
150
151         /**
152          * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
153          *
154          * @param[in]   rhs     An instance of %Deflator
155          */
156         Deflator& operator =(const Deflator& rhs);
157
158 }; // Deflator
159
160 }}} // Tizen::Base::Utility
161
162 #endif // _FBASE_UTIL_DEFLATOR_H_