1 | // $Id: HtmlStream.cc 235 2007-04-21 13:39:50Z peter $ |
---|
2 | |
---|
3 | /* |
---|
4 | Copyright (C) 2007 Peter Johansson |
---|
5 | |
---|
6 | This file is part of svndigest, http://lev.thep.lu.se/trac/svndigest |
---|
7 | |
---|
8 | svndigest is free software; you can redistribute it and/or modify it |
---|
9 | under the terms of the GNU General Public License as published by |
---|
10 | the Free Software Foundation; either version 2 of the License, or |
---|
11 | (at your option) any later version. |
---|
12 | |
---|
13 | svndigest is distributed in the hope that it will be useful, but |
---|
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
16 | General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with this program; if not, write to the Free Software |
---|
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
---|
21 | 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | #include "HtmlStream.h" |
---|
25 | |
---|
26 | #include <string> |
---|
27 | |
---|
28 | namespace theplu{ |
---|
29 | namespace svndigest{ |
---|
30 | |
---|
31 | HtmlStream::HtmlStream(std::ostream& os) |
---|
32 | : os_(os) |
---|
33 | { |
---|
34 | map_['"']=std::string("\""); |
---|
35 | map_['\'']=std::string("\'"); |
---|
36 | map_['\n']=std::string("<br />"); |
---|
37 | map_['<']=std::string("<"); |
---|
38 | map_['>']=std::string(">"); |
---|
39 | map_['&']=std::string("&"); |
---|
40 | // This should be configurable, but for now indentation is two spaces. |
---|
41 | map_['\t']=std::string(" "); |
---|
42 | map_['å']=std::string("å"); |
---|
43 | map_['ä']=std::string("ä"); |
---|
44 | map_['ö']=std::string("ö"); |
---|
45 | map_['Å']=std::string("Å"); |
---|
46 | map_['Ä']=std::string("Ä"); |
---|
47 | map_['Ö']=std::string("Ö"); |
---|
48 | map_['é']=std::string("é"); |
---|
49 | map_['É']=std::string("É"); |
---|
50 | map_['á']=std::string("á"); |
---|
51 | map_['Á']=std::string("Á"); |
---|
52 | } |
---|
53 | |
---|
54 | |
---|
55 | HtmlStream::~HtmlStream(void) |
---|
56 | { |
---|
57 | } |
---|
58 | |
---|
59 | |
---|
60 | void HtmlStream::print(std::stringstream& ss) |
---|
61 | { |
---|
62 | char c; |
---|
63 | while (true){ |
---|
64 | ss.get(c); |
---|
65 | if (!ss.good()) |
---|
66 | return; |
---|
67 | std::map<char, std::string>::const_iterator i = map_.find(c); |
---|
68 | if (i==map_.end()) |
---|
69 | os_ << c; |
---|
70 | else |
---|
71 | os_ << i->second; |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | }} // end of namespace svndigest and namespace theplu |
---|