Go to the documentation of this file.00001
00002 #ifndef EPT_DEBTAGS_PKGID_H
00003 #define EPT_DEBTAGS_PKGID_H
00004
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <tagcoll/diskindex/mmap.h>
00029 #include <string>
00030
00031 namespace ept {
00032 namespace debtags {
00033
00040 class PkgId : public tagcoll::diskindex::MMap
00041 {
00042 tagcoll::diskindex::MasterMMap mastermmap;
00043 time_t m_timestamp;
00044
00045 public:
00046 PkgId();
00047 PkgId(const tagcoll::diskindex::MasterMMap& master, size_t idx);
00048 PkgId(const char* buf, int size);
00049
00051 time_t timestamp() const { return m_timestamp; }
00052
00054 size_t size() const { return m_buf ? *(int*)m_buf / sizeof(int) : 0; }
00055
00061 int byName(const std::string& name) const;
00062
00068 std::string byID(int id) const
00069 {
00070 if (id >= 0 || static_cast<unsigned>(id) < size())
00071 return std::string(m_buf + ((int*)m_buf)[id]);
00072 return std::string();
00073 }
00074
00076 int size(int id) const
00077 {
00078 if (id < 0 || (unsigned)id >= size())
00079 return 0;
00080 if ((unsigned)id == size() - 1)
00081 return m_size - ((int*)m_buf)[id] - 1;
00082 else
00083 return ((int*)m_buf)[id + 1] - ((int*)m_buf)[id] - 1;
00084 }
00085 };
00086
00087 }
00088 }
00089
00090
00091 #endif