1 |
// Site Mapper |
2 |
// |
3 |
// Douglas Thrift |
4 |
// |
5 |
// $Id$ |
6 |
|
7 |
#ifndef _SiteMapper_hpp_ |
8 |
#define _SiteMapper_hpp_ |
9 |
|
10 |
#include <cxx/platform.hpp> |
11 |
|
12 |
#ifdef MENES_PRAGMA_ONCE |
13 |
#pragma once |
14 |
#endif |
15 |
|
16 |
#include <api/files.hpp> |
17 |
#include <ios/string.hpp> |
18 |
#include <xml/document.hpp> |
19 |
#include <xml/nodeset.hpp> |
20 |
#include <xml/parse.hpp> |
21 |
#include <xml/textwriter.hpp> |
22 |
|
23 |
#include "Page.hpp" |
24 |
|
25 |
struct LessThan |
26 |
{ |
27 |
_finline static bool Execute(const cse::String &left, const cse::String &right) |
28 |
{ |
29 |
const cse::String::Data &left_(left), &right_(right); |
30 |
int value(ext::Compare(left.Begin(), right.Begin(), left.GetSize() < right.GetSize() ? left.GetSize() : right.GetSize())); |
31 |
|
32 |
if (value < 0) |
33 |
return true; |
34 |
else if (!value) |
35 |
return left.GetSize() < right.GetSize(); |
36 |
else |
37 |
return false; |
38 |
} |
39 |
}; |
40 |
|
41 |
class SiteMapper |
42 |
{ |
43 |
private: |
44 |
cse::String comment; |
45 |
ext::Vector<Page> pages; |
46 |
ext::RedBlackMap<cse::String, ext::RedBlackMap<cse::String, ext::Vector<Page>, LessThan>, LessThan> newPages; |
47 |
void oldMap(const cse::String &siteMap); |
48 |
void oldMap(ext::Vector<Page> &pages, xml::Node* list); |
49 |
void newIndex(const cse::String &siteIndex); |
50 |
bool newIndex(ext::Vector<Page> &pages, Page &page); |
51 |
void newMap(const cse::String &siteMap); |
52 |
void newMap(ext::Vector<Page> &pages, const cse::String &childOf, ext::RedBlackMap<cse::String, ext::Vector<Page>, LessThan> &newPages); |
53 |
public: |
54 |
SiteMapper(const cse::String &siteIndex, const cse::String &siteMap); |
55 |
static cse::String program; |
56 |
static bool debug; |
57 |
}; |
58 |
|
59 |
#endif // _SiteMapper_hpp_ |