ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Iffy/Tag.cpp
Revision: 276
Committed: 2004-11-13T00:45:59-08:00 (20 years, 7 months ago) by Douglas Thrift
File size: 1284 byte(s)
Log Message:
Hmm, I should probably check this in.

File Contents

# User Rev Content
1 Douglas Thrift 276 // Iffy
2     //
3     // Douglas Thrift
4     //
5     // $Id$
6    
7     #include "Tag.hpp"
8     #include "Matcher.hpp"
9    
10     #include <cctype>
11    
12     Tag::Tag(const ext::String& segment)
13     {
14     ext::Vector<ext::String> parts(segment.Split(' '));
15    
16     _foreach (ext::Vector<ext::String>, part, parts)
17     {
18     if (part == parts.Begin())
19     {
20     if (part->First() != '/')
21     {
22     type = OPEN;
23     name = lower(*part);
24     }
25     else
26     {
27     type = CLOSE;
28     name = lower(part->Substring(1));
29     }
30     }
31     else
32     {
33     Matcher matcher;
34     ext::String name;
35     ios::String value;
36    
37     if (*part == matcher("^(.*)=\"(.*)\"$"))
38     {
39     name = matcher[1];
40     value = matcher[2];
41     }
42     else if (*part == matcher("^(.*)=\"(.*)$"))
43     {
44     name = matcher[1];
45     value = matcher[2];
46    
47     while (++part != parts.End())
48     {
49     if (*part == matcher("^(.*)\"$"))
50     {
51     value << " " << matcher[1];
52    
53     break;
54     }
55     else value << " " << *part;
56     }
57    
58     if (part == parts.End()) --part;
59     }
60     else if (*part == matcher("^(.*)=(.*)$"))
61     {
62     name = matcher[1];
63     value = matcher[2];
64     }
65    
66     attributes << " " << lower(name) << "=\"" << value << "\"";
67     }
68     }
69     }
70    
71     ext::String Tag::lower(const ext::String& string)
72     {
73     ext::String lower;
74    
75     _foreach (ext::String, atom, string) lower.InsertLast(std::tolower(*atom));
76    
77     return lower;
78     }

Properties

Name Value
svn:eol-style native
svn:keywords Id