Applied reviewed header(DateTime to Uuid)
[platform/framework/native/appfw.git] / inc / FBaseUtilZipEntry.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                FBaseUtilZipEntry.h
19  * @brief               This is the header file for the %ZipEntry class.
20  *
21  * This header file contains the declarations of the %ZipEntry class.
22  */
23
24 #ifndef _FBASE_UTIL_ZIP_ENTRY_H_
25 #define _FBASE_UTIL_ZIP_ENTRY_H_
26
27 #include <FBaseString.h>
28 #include <FBaseDateTime.h>
29 #include <FBaseUtilTypes.h>
30
31
32
33 namespace Tizen { namespace Base { namespace Utility
34 {
35 /**
36  * @class       ZipEntry
37  * @brief               This class provides methods to access the entries of a zip-archive.
38  *
39  * @since 2.0
40  *
41  * The %ZipEntry class is used for accessing the elements of a zip-archive. Each instance of
42  * %ZipEntry represents a single entry in the zip-archive.
43  * It also stores the information related to that entry, such as name, compressed size,
44  * uncompressed size, compression level, and archive name.
45  *
46  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/base/utility_namespace.htm">Utility</a>.
47  *
48  * The following example demonstrates how to use the %ZipEntry class.
49  *
50  * @code
51  *      #include <FBase.h>
52  *
53  *      using namespace Tizen::App;
54  *      using namespace Tizen::Base;
55  *      using namespace Tizen::Base::Utility;
56  *
57  *      void
58  *      MyClass::FileZipSample(void)
59  *      {
60  *              String str;
61  *              int i = 0, count = 0;
62  *              unsigned long size = 0;
63  *              ZipEntry entry;
64  *
65  *              FileUnzipper unzip;
66  *              String dataPath = App::GetInstance()->GetAppDataPath();
67  *              unzip.Construct(dataPath + L"sample.zip");
68  *
69  *              count = unzip.GetEntryCount();
70  *
71  *              for (i = 0; i < count; i++)
72  *              {
73  *                      // Gets a ZipEntry from the zip-archive
74  *                      unzip.GetEntry(i, entry);
75  *
76  *                      // Gets an entry name associated with the ZipEntry
77  *                      str = entry.GetName();
78  *
79  *                      // Gets the name of the zip file which ZipEntry belongs to
80  *                      str = entry.GetArchiveName();
81  *
82  *                      // Gets the compressed size of ZipEntry
83  *                      size = entry.GetCompressedSize();
84  *              }
85  *
86  *      }
87  * @endcode
88  */
89 class _OSP_EXPORT_ ZipEntry
90         : public Tizen::Base::Object
91 {
92 public:
93         /**
94          * This is the default constructor for this class.
95          *
96          * @since 2.0
97          */
98         ZipEntry(void);
99
100         /**
101          * This destructor overrides Tizen::Base::Object::~Object().
102          *
103          * @since 2.0
104          */
105         virtual ~ZipEntry(void);
106
107         /**
108          * Gets the entry name associated with the zip entry. @n
109          * It can be a file or directory name.
110          *
111          * @since 2.0
112          *
113          * @return              The entry name
114          *
115          */
116         String GetName(void) const;
117
118         /**
119          * Gets the compression level associated with the zip entry.
120          *
121          * @since 2.0
122          *
123          * @return              The compression level associated with the zip entry
124          *
125          */
126         CompressionLevel GetCompressionLevel(void) const;
127
128         /**
129          * Checks whether the zip entry is a file or directory.
130          *
131          * @since 2.0
132          *
133          * @return              @c true if the entry is a directory, @n
134          *                              else @c false
135          */
136         bool IsDirectory(void) const;
137
138         /**
139          * Gets the compressed size of the zip entry.
140          *
141          * @since 2.0
142          *
143          * @return              The compressed size of the zip entry
144          */
145         unsigned long GetCompressedSize(void) const;
146
147         /**
148          * Gets the uncompressed size of the zip entry.
149          *
150          * @since 2.0
151          *
152          * @return              The uncompressed size of the zip entry
153          */
154         unsigned long GetUncompressedSize(void) const;
155
156         /**
157          * Gets the name of the zip file to which %ZipEntry belongs.
158          *
159          * @since 2.0
160          *
161          * @return              The name of the zip file
162          * @remarks     This method returns the name of the zip file that is opened
163          *                              in the FileUnzipper::Construct() method.
164          */
165         String GetArchiveName(void) const;
166
167         /**
168          * Compares the specified instance to the current instance.
169          *
170          * @since 2.0
171          *
172          * @return              @c true if the specified instance equals the current instance, @n
173          *                              else @c false
174          * @param[in]   obj             The object to compare with the current instance
175          * @remarks     This method returns @c true if all the attributes in the instance are same.
176          */
177         virtual bool Equals(const Tizen::Base::Object& obj) const;
178
179         /**
180          * Gets the hash value of the current instance.
181          *
182          * @since 2.0
183          *
184          * @return              The hash value of the current instance
185          */
186         virtual int GetHashCode(void) const;
187
188
189 private:
190         /**
191          * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
192          *
193          * @since 2.0
194          *
195          * @param[in]   entry  The instance of the %ZipEntry class to copy from
196          * @remarks             This constructor is hidden.
197          */
198         ZipEntry(const ZipEntry& entry);
199
200         /**
201          * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
202          *
203          * @since 2.0
204          *
205          * @param[in]   entry   An instance of %ZipEntry
206          * @remarks             This operator is hidden.
207          */
208         ZipEntry& operator =(const ZipEntry& entry);
209
210         void Set(void* unzFile);
211
212
213         String __name;
214         void* __unzFile;
215         CompressionLevel __compressionLevel;
216
217         friend class _FileUnzipperImpl;
218
219         friend class _ZipEntryImpl;
220         class _ZipEntryImpl* __pZipEntryImpl;
221
222 }; // ZipEntry
223
224 }}} // Tizen::Base::Utility
225
226 #endif // _FBASE_UTIL_ZIP_ENTRY_H_