25 |
|
|
26 |
|
ostream& operator<<(ostream& output, Host& host) |
27 |
|
{ |
28 |
< |
// |
28 |
> |
output << "<tr>\n"; |
29 |
> |
|
30 |
> |
if (host.host != "") output << "<td>" << host.host << "</td>\n"; |
31 |
> |
if (host.name != "") output << "<td>" << host.name << "</td>\n"; |
32 |
> |
if (host.address != "") output << "<td>" << host.address << "</td>\n"; |
33 |
> |
if (host.platform != "") output << "<td>" << host.platform << "</td>\n"; |
34 |
> |
if (host.since != "") output << "<td>" << host.since << "</td>\n"; |
35 |
> |
|
36 |
> |
output << "</tr>\n"; |
37 |
|
|
38 |
|
return output; |
39 |
|
} |
40 |
|
|
41 |
|
istream& operator>>(istream& input, Host& host) |
42 |
|
{ |
43 |
< |
// |
43 |
> |
bool done = false; |
44 |
> |
|
45 |
> |
do |
46 |
> |
{ |
47 |
> |
switch (input.peek()) |
48 |
> |
{ |
49 |
> |
case 'h': |
50 |
> |
if (host.host != "") |
51 |
> |
{ |
52 |
> |
done = true; |
53 |
> |
|
54 |
> |
continue; |
55 |
> |
} |
56 |
> |
break; |
57 |
> |
case 'n': |
58 |
> |
if (host.name != "") |
59 |
> |
{ |
60 |
> |
done = true; |
61 |
> |
|
62 |
> |
continue; |
63 |
> |
} |
64 |
> |
break; |
65 |
> |
case 'a': |
66 |
> |
if (host.address != "") |
67 |
> |
{ |
68 |
> |
done = true; |
69 |
> |
|
70 |
> |
continue; |
71 |
> |
} |
72 |
> |
break; |
73 |
> |
case 'p': |
74 |
> |
if (host.platform != "") |
75 |
> |
{ |
76 |
> |
done = true; |
77 |
> |
|
78 |
> |
continue; |
79 |
> |
} |
80 |
> |
break; |
81 |
> |
case 's': |
82 |
> |
if (host.since != "") |
83 |
> |
{ |
84 |
> |
done = true; |
85 |
> |
|
86 |
> |
continue; |
87 |
> |
} |
88 |
> |
break; |
89 |
> |
default: |
90 |
> |
done = true; |
91 |
> |
continue; |
92 |
> |
} |
93 |
> |
|
94 |
> |
string name, value; |
95 |
> |
|
96 |
> |
getline(input, name, '='); |
97 |
> |
getline(input, value); |
98 |
> |
|
99 |
> |
if (name == "host") |
100 |
> |
{ |
101 |
> |
host.host = value; |
102 |
> |
} |
103 |
> |
else if (name == "name") |
104 |
> |
{ |
105 |
> |
host.name = value != "" ? value : " "; |
106 |
> |
} |
107 |
> |
else if (name == "address") |
108 |
> |
{ |
109 |
> |
host.address = value; |
110 |
> |
} |
111 |
> |
else if (name == "platform") |
112 |
> |
{ |
113 |
> |
host.platform = value; |
114 |
> |
} |
115 |
> |
else if (name == "since") |
116 |
> |
{ |
117 |
> |
host.setSince(value); |
118 |
> |
} |
119 |
> |
} |
120 |
> |
while (!done && input.good()); |
121 |
|
|
122 |
|
return input; |
123 |
|
} |