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