|
#ifndef Database_H
#define Database_H
#pragma warning( disable: 4800 )
#include <string>
#include <list>
#include <set>
#include <map>
#include <functional>
#include "stl_ext.h"
#include "CTagsTag.h"
#include "Workspace.h"
namespace CTags {
class Database
{
public:
//typedef std::map<std::string, std::list<CTags::Tag> > TagTable;
//typedef std::multiset<CTags::Tag> TagTable;
typedef std::list<CTags::Tag> TagTable;
private:
std::string mName;
TagTable mTags;
public:
Database() {};
Database(const std::string& name);
Database(const std::list<std::string>& files);
Database(const Workspace& workspace);
template<class QueryType>
TagTable selectTagsWhere(const QueryType &query)
{
TagTable result;
copy_if(mTags.begin(), mTags.end(), std::inserter(result, result.end()), query);
return result;
}
void refreshTagsReferencingFile(const std::string&);
private:
const TagTable& getTags() const { return mTags; }
//TagTable& getTags() { return mTags; }
void createTagFile(const std::list<std::string>&, const std::string&);
void eraseTagsReferencingFile(const std::string&);
TagTable loadTags(const std::string&);
void setupTagTable(const std::list<std::string>&files);
};
template<class QueryType, class ArgumentType>
std::binder2nd<QueryType> make_query(const QueryType &query, const ArgumentType &arg)
{
return std::bind2nd(query, arg);
}
struct TypeIs : public std::binary_function<CTags::Tag, int, bool>
{
const static int ANY_TYPE;
bool operator()(const first_argument_type &tag, second_argument_type type) const
{ return static_cast<bool>(tag.getType() & type); }
};
struct FileIs : public std::binary_function<CTags::Tag, std::string, bool>
{
bool operator()(const first_argument_type &tag, const second_argument_type &file) const
{ return tag.getFile() == file; }
};
struct ScopeOrNameIs : public std::binary_function<CTags::Tag, std::string, bool>
{
bool operator()(const first_argument_type &tag, const second_argument_type &id) const
{ return tag.getScope() == id || tag.getName() == id; }
};
struct ScopeIs : public std::binary_function<CTags::Tag, std::string, bool>
{
bool operator()(const first_argument_type &tag, const second_argument_type &id) const
{ return tag.getScope() == id; }
};
struct FullQualifiedNameIs : public std::binary_function<CTags::Tag, FullQualifiedName, bool>
{
result_type operator()(const first_argument_type &tag, const second_argument_type &fqn) const
{ return tag.getFQN() == fqn; }
};
class DatabaseManager
{
private:
typedef std::map<std::string, smart_ptr<Database> > DBMap;
DBMap mManagedDatabases;
public:
static DatabaseManager& instance();
smart_ptr<Database> getDatabase(const smart_ptr<Workspace> &);
smart_ptr<Database> removeDatabase(const smart_ptr<Workspace> &);
private:
DatabaseManager();
};
} // namespace CTags
#endif
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.