libept
debtags.h
Go to the documentation of this file.
1 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t -*-
2 /* @file
3  * @author Enrico Zini (enrico) <enrico@enricozini.org>
4  */
5 
6 /*
7  * libpkg Debtags data provider
8  *
9  * Copyright (C) 2003-2007 Enrico Zini <enrico@debian.org>
10  *
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.
15  *
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24  */
25 
26 #ifndef EPT_DEBTAGS_DEBTAGS_H
27 #define EPT_DEBTAGS_DEBTAGS_H
28 
29 #include <ept/debtags/coll/fast.h>
30 #include <string>
31 
32 namespace ept {
33 namespace debtags {
34 
47 class Debtags : public coll::Fast
48 {
49 protected:
50  // User rc directory to store patches
51  std::string rcdir;
52 
53  // Last modification timestamp of the index
54  time_t m_timestamp;
55 
56  void load(const std::string& pathname);
57 
58 public:
60  typedef std::pair< std::string, std::set<std::string> > value_type;
61 
63  Debtags();
65  Debtags(const std::string& pathname);
66  ~Debtags() {}
67 
69  time_t timestamp() const { return m_timestamp; }
70 
72  bool hasData() const { return m_timestamp != 0; }
73 
74  coll_type& tagdb() { return *this; }
75  const coll_type& tagdb() const { return *this; }
76 
83  static std::string pathname();
84 };
85 
86 }
87 }
88 
89 // vim:set ts=4 sw=4:
90 #endif
sys.h
debtags.h
ept::debtags::Debtags::coll_type
ept::debtags::coll::Fast coll_type
Definition: debtags.h:59
ept::debtags
Definition: fast.cc:29
ept::debtags::Debtags
Access the on-disk Debtags tag database.
Definition: debtags.h:47
ept::debtags::coll::Fast::getAllTags
std::set< std::string > getAllTags() const
Definition: fast.cc:124
ept::debtags::Debtags::timestamp
time_t timestamp() const
Get the timestamp of when the index was last updated.
Definition: debtags.h:69
ept::tests
Definition: tests.cc:23
ept::debtags::coll::Fast::getItemsHavingTags
std::set< std::string > getItemsHavingTags(const std::set< std::string > &tags) const
Get the items which are tagged with at least the tags ‘tags’.
Definition: fast.cc:91
testfile
#define testfile
Definition: debtags-test.cc:12
ept::debtags::Debtags::rcdir
std::string rcdir
Definition: debtags.h:51
EnvOverride
Definition: test.h:16
ept::debtags::coll::Fast::end
const_iterator end() const
Definition: fast.h:52
ept
String functions.
Definition: apt.cc:40
res
set< string > & res
Definition: packagerecord.cc:73
TextFormat.h
ept::debtags::coll::Fast::begin
const_iterator begin() const
Definition: fast.h:51
ept::sys::exists
bool exists(const std::string &file)
Same as access(s, F_OK);.
Definition: sys.cc:148
ept::debtags::Debtags::m_timestamp
time_t m_timestamp
Definition: debtags.h:54
ept::debtags::Debtags::Debtags
Debtags()
Create a Debtags object, reading the system database.
Definition: debtags.cc:42
ept::debtags::Debtags::value_type
std::pair< std::string, std::set< std::string > > value_type
Definition: debtags.h:60
ept::apt::tests
struct ept::apt::AptImplementation tests
ept::tests::actual
Actual< A > actual(const A &actual)
Definition: tests.h:320
ept::debtags::coll::Fast::getTagsOfItem
std::set< std::string > getTagsOfItem(const std::string &item) const
Definition: fast.cc:106
ept::debtags::Debtags::~Debtags
~Debtags()
Definition: debtags.h:66
ept::debtags::Debtags::tagdb
coll_type & tagdb()
Definition: debtags.h:74
test.h
ept::debtags::Debtags::tagdb
const coll_type & tagdb() const
Definition: debtags.h:75
ept::debtags::coll::operators
Definition: operators.h:12
ept::tests::TestCase
Test case collecting several test methods, and self-registering with the singleton instance of TestRe...
Definition: tests.h:614
ept::debtags::coll::Fast
In-memory collection with both item->tags and tag->items mappings.
Definition: fast.h:38
fast.h
std
Definition: packagerecord-test.cc:4
register_tests
void register_tests() override
Definition: debtags-test.cc:4
wassert
#define wassert(...)
Run the given command, raising TestFailed with the appropriate backtrace information if it threw an e...
Definition: tests.h:343
ept::debtags::Debtags::pathname
static std::string pathname()
Return the default pathname for the debtags tags.
Definition: debtags.cc:77
ept::debtags::coll::textformat::parse
void parse(FILE *in, const std::string &pathname, Fast &out)
Definition: TextFormat.cc:168
operators.h
ept::debtags::Debtags::hasData
bool hasData() const
Return true if this data source has data, false if it's empty.
Definition: debtags.h:72
ept::sys::timestamp
time_t timestamp(const std::string &file)
File mtime.
Definition: sys.cc:103
ept::debtags::Debtags::load
void load(const std::string &pathname)
Definition: debtags.cc:57