26 #ifndef ais_resources_h 27 #define ais_resources_h 40 #ifndef ais_exceptions_h 41 #include "AISExceptions.h" 49 typedef vector<Resource> ResourceVector;
50 typedef ResourceVector::iterator ResourceVectorIter;
51 typedef ResourceVector::const_iterator ResourceVectorCIter;
77 typedef map<string, ResourceVector> ResourceMap;
78 typedef ResourceMap::iterator ResourceMapIter;
79 typedef ResourceMap::const_iterator ResourceMapCIter;
81 typedef pair<string, ResourceVector> RVPair;
82 typedef vector<RVPair> ResourceRegexps;
83 typedef ResourceRegexps::iterator ResourceRegexpsIter;
84 typedef ResourceRegexps::const_iterator ResourceRegexpsCIter;
93 FindRegexp(
const string &re) : local_re(re)
95 bool operator()(
const RVPair &p)
97 return p.first == local_re;
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;
116 friend class AISResourcesTest;
128 virtual void add_url_resource(
const string &url,
130 virtual void add_url_resource(
const string &url,
const ResourceVector &rv);
132 virtual void add_regexp_resource(
const string ®exp,
134 virtual void add_regexp_resource(
const string ®exp,
135 const ResourceVector &rv);
137 virtual bool has_resource(
const string &primary)
const;
139 virtual ResourceVector get_resource(
const string &primary);
141 virtual void read_database(
const string &database);
143 virtual void write_database(
const string &filename);
148 #endif // ais_resources_h
top level DAP object to house generic methods
int match(const char *s, int len, int pos=0)
Does the pattern match.
ostream & operator<<(ostream &os, const Resource &r)
Associate a rule with an ancillary resource.