26#ifndef ais_resources_h
27#define ais_resources_h
40#ifndef ais_exceptions_h
75 typedef map<string, ResourceVector> ResourceMap;
76 typedef ResourceMap::iterator ResourceMapIter;
77 typedef ResourceMap::const_iterator ResourceMapCIter;
79 typedef pair<string, ResourceVector> RVPair;
80 typedef vector<RVPair> ResourceRegexps;
81 typedef ResourceRegexps::iterator ResourceRegexpsIter;
82 typedef ResourceRegexps::const_iterator ResourceRegexpsCIter;
90 struct FindRegexp :
public binary_function<RVPair, string, bool>
93 FindRegexp(
const string &re) : local_re(re)
95 bool operator()(
const RVPair &p)
97 return p.first == local_re;
104 struct MatchRegexp :
public binary_function<RVPair, string, bool>
107 MatchRegexp(
const string &url) : candidate(url)
109 bool operator()(
const RVPair &p)
111 Regex r(p.first.c_str());
112 return r.
match(candidate.c_str(), candidate.length()) != -1;
virtual void write_database(const string &filename)
virtual ResourceVector get_resource(const string &primary)
friend class AISResourcesTest
friend ostream & operator<<(ostream &os, const AISResources &ais_res)
virtual bool has_resource(const string &primary) const
virtual void read_database(const string &database)
virtual void add_regexp_resource(const string ®exp, const Resource &ancillary)
virtual void add_url_resource(const string &url, const Resource &ancillary)
Regular expression matching.
int match(const char *s, int len, int pos=0) const
Does the pattern match.
Associate a rule with an ancillary resource.
top level DAP object to house generic methods
vector< Resource > ResourceVector
ResourceVector::const_iterator ResourceVectorCIter
ResourceVector::iterator ResourceVectorIter