1 |
douglas |
676 |
// Url |
2 |
|
|
// |
3 |
|
|
// Douglas Thrift |
4 |
|
|
// |
5 |
|
|
// $Id$ |
6 |
|
|
|
7 |
|
|
#include <cxx/standard.hh> |
8 |
|
|
|
9 |
|
|
#include "Url.hpp" |
10 |
|
|
|
11 |
douglas |
677 |
Url::Url(const cse::String &location, const std::time_t &modified, Frequency frequency, uint8_t priority) : location(location), frequency(frequency), priority(priority) |
12 |
|
|
{ |
13 |
|
|
::gmtime_r(&modified, &this->modified); |
14 |
douglas |
683 |
|
15 |
|
|
_assert (priority < 11); |
16 |
douglas |
677 |
} |
17 |
|
|
|
18 |
douglas |
683 |
Url::Url(const cse::String &location, const std::tm &modified, Frequency frequency = always, uint8_t priority = 5) : location(location), modified(modified), frequency(frequency), priority(priority) |
19 |
|
|
{ |
20 |
|
|
_assert (priority < 11); |
21 |
|
|
} |
22 |
|
|
|
23 |
douglas |
676 |
cse::String Url::GetModified() const |
24 |
|
|
{ |
25 |
|
|
ext::Buffer buffer(22); |
26 |
|
|
|
27 |
douglas |
677 |
size_t size(::strftime(buffer.Begin(), buffer.GetSize(), "%FT%TTZ", &modified)); |
28 |
douglas |
676 |
|
29 |
|
|
buffer.SetSize(size); |
30 |
|
|
|
31 |
|
|
return buffer; |
32 |
|
|
} |
33 |
|
|
|
34 |
|
|
cse::String Url::GetFrequency() const |
35 |
|
|
{ |
36 |
|
|
switch (frequency) |
37 |
|
|
{ |
38 |
|
|
case always: |
39 |
|
|
return _B("always"); |
40 |
|
|
case hourly: |
41 |
|
|
return _B("hourly"); |
42 |
|
|
case daily: |
43 |
|
|
return _B("daily"); |
44 |
|
|
case weekly: |
45 |
|
|
return _B("weekly"); |
46 |
|
|
case monthly: |
47 |
|
|
return _B("monthly"); |
48 |
|
|
case yearly: |
49 |
|
|
return _B("yearly"); |
50 |
|
|
case never: |
51 |
|
|
return _B("never"); |
52 |
|
|
_nodefault |
53 |
|
|
} |
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
cse::String Url::GetPriority() const |
57 |
|
|
{ |
58 |
|
|
_assert (priority < 11); |
59 |
|
|
|
60 |
|
|
switch (priority) |
61 |
|
|
{ |
62 |
|
|
default: |
63 |
|
|
return _S<ios::String>() << _B("0.") << priority; |
64 |
|
|
case 10: |
65 |
|
|
return _B("1.0"); |
66 |
|
|
} |
67 |
|
|
} |