ARC SDK
URLMap.h
1 // -*- indent-tabs-mode: nil -*-
2 
3 #ifndef __ARC_URLMAP_H__
4 #define __ARC_URLMAP_H__
5 
6 #include <list>
7 
8 #include <arc/URL.h>
9 #include <arc/Logger.h>
10 
11 namespace Arc {
12 
14 
22  class URLMap {
23  private:
24  class map_entry {
25  public:
26  URL initial;
27  URL replacement;
28  URL access;
29  map_entry() {}
30  map_entry(const URL& templ, const URL& repl, const URL& accs = URL())
31  : initial(templ),
32  replacement(repl),
33  access(accs) {}
34  };
35  std::list<map_entry> entries;
36  static Logger logger;
37  public:
39  URLMap();
40  ~URLMap();
42 
52  bool map(URL& url) const;
54 
59  bool local(const URL& url) const;
61 
69  void add(const URL& templ, const URL& repl, const URL& accs = URL());
71  operator bool() const { return entries.size() != 0; };
73  bool operator!() const { return entries.size() == 0; };
74  };
75 
76 } // namespace Arc
77 
78 #endif // __ARC_URLMAP_H__
Arc namespace contains all core ARC classes.
Definition: ArcConfig.h:11
bool map(URL &url) const
Map a URL if possible.
A logger class.
Definition: Logger.h:493
void add(const URL &templ, const URL &repl, const URL &accs=URL())
Add an entry to the URLMap.
bool local(const URL &url) const
Check if a mapping exists for a URL.
Class to represent general URLs.
Definition: URL.h:88
URLMap allows mapping certain patterns of URLs to other URLs.
Definition: URLMap.h:22
bool operator!() const
Returns true if the URLMap is empty.
Definition: URLMap.h:73
URLMap()
Construct an empty URLMap.