source: tags/0.6.8/lib/HtmlStream.cc @ 848

Last change on this file since 848 was 731, checked in by Peter Johansson, 13 years ago

update copyright statements

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