Improve speed of category tab title updates
[amule.git] / src / MuleCollection.h
blob9148fc9cc41575adf2991253ede852b5ca4dfe5e
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2007-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2007-2008 Johannes Krampf ( wuischke@amule.org )
6 //
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
9 // respective authors.
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #ifndef __MULECOLLECTION_H__
28 #define __MULECOLLECTION_H__
30 #include <string>
31 #include <vector>
33 #ifndef __MINGW32__
34 #include "Types.h"
35 #endif
37 struct CollectionFile
39 std::string m_fileName;
40 uint64_t m_fileSize;
41 std::string m_fileHash;
43 CollectionFile(
44 const std::string &fileName = "",
45 uint64_t fileSize = 0,
46 const std::string &fileHash = "");
50 class CMuleCollection
52 private:
53 std::vector<CollectionFile> vCollection;
55 public:
56 CMuleCollection();
57 ~CMuleCollection();
59 bool Open(const std::string &File);
60 size_t GetFileCount() const { return vCollection.size(); }
62 std::string GetEd2kLink(size_t index) const;
63 std::string GetFileName(size_t index) const;
64 uint64_t GetFileSize(size_t index) const;
65 std::string GetFileHash(size_t index) const;
67 private:
68 bool OpenBinary(const std::string &File);
69 bool OpenText(const std::string &File);
71 bool AddLink(const std::string &Link);
72 bool AddFile(
73 const std::string &fileName,
74 uint64_t fileSize,
75 const std::string &fileHash);
77 static bool IsValidHash(const std::string &fileHash);
79 template <typename intType>
80 intType ReadInt(std::ifstream& infile);
82 std::string ReadString(std::ifstream& infile, int TagType);
85 #endif // __MULECOLLECTION_H__