26#ifndef ais_resources_h
27#define ais_resources_h
40#ifndef ais_exceptions_h
41#include "AISExceptions.h"
49typedef vector<Resource> ResourceVector;
50typedef ResourceVector::iterator ResourceVectorIter;
51typedef 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;
92 struct FindRegexp :
public binary_function<RVPair, string, bool>
95 FindRegexp(
const string &re) : local_re(re)
97 bool operator()(
const RVPair &p)
99 return p.first == local_re;
106 struct MatchRegexp :
public binary_function<RVPair, string, bool>
109 MatchRegexp(
const string &url) : candidate(url)
111 bool operator()(
const RVPair &p)
113 Regex r(p.first.c_str());
114 return r.
match(candidate.c_str(), candidate.length()) != -1;
119 friend class AISResourcesTest;
132 const Resource &ancillary);
136 const Resource &ancillary);
138 const ResourceVector &rv);
142 virtual ResourceVector
get_resource(
const string &primary);
virtual void write_database(const string &filename)
virtual ResourceVector get_resource(const string &primary)
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.
top level DAP object to house generic methods