diff options
author | pixel <pixel> | 2007-05-09 07:12:33 +0000 |
---|---|---|
committer | pixel <pixel> | 2007-05-09 07:12:33 +0000 |
commit | 6ce9b0beeb0a9c8dee0246f4fae79c6d5c8219af (patch) | |
tree | 2356628a3ecb6cfd6a8b6f4364bc227520ac59bd /lib/Domain.cc | |
parent | 976f094b10a8a95348f02cc5049000228babe7a2 (diff) |
First new bricks of a more global domain system.
Diffstat (limited to 'lib/Domain.cc')
-rw-r--r-- | lib/Domain.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/Domain.cc b/lib/Domain.cc new file mode 100644 index 0000000..8b06bdd --- /dev/null +++ b/lib/Domain.cc @@ -0,0 +1,50 @@ +#include "Domain.h" + +Domain * Domain::head = 0; + +Domain::Domain(const Regex & _pattern) : pattern(_pattern) { + prev = 0; + next = head; + head = this; + next->prev = this; +} + +Domain::~Domain() { + if (head == this) + head = next; + if (next) + next->prev = prev; + if (prev) + prev->next = next; +} + +void Domain::OnTop() { + if (next) + next->prev = prev; + if (prev) + prev->next = next; + + prev = 0; + next = head; + head = this; + next->prev = this; +} + +Domain * Domain::find_domain(const String & url) { + Domain * r = 0; + + if (head) + r = head->find_domain_r(url); + + return r; +} + +Domain * Domain::find_domain_r(const String & url) { + if (pattern.Match(url)) + return this; + + if (next) + return next->find_domain_r(url); + + return 0; +} |