source: trunk/lib/HtmlBuf.cc @ 687

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

Merged patch release 0.6.6 to trunk. Delta 0.6.6 - 0.6.5

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.1 KB
RevLine 
[234]1// $Id: HtmlBuf.cc 687 2008-08-04 19:37:10Z peter $
2
3/*
[380]4  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
[606]5  Copyright (C) 2008 Peter Johansson
[234]6
[687]7  This file is part of svndigest, http://dev.thep.lu.se/svndigest
[234]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
[606]25#include "HtmlBuf.h"
[234]26
[606]27#include <cstdio>
28#include <iostream>
[234]29#include <string>
30
31namespace theplu{
32namespace svndigest{
33
[606]34  HtmlBuf::HtmlBuf(std::streambuf& buf)
35    : std::streambuf(), buf_(buf) 
[234]36  {
37    map_['"']=std::string("\"");
38    map_['\'']=std::string("\'");
39    map_['\n']=std::string("<br />");
40    map_['<']=std::string("&lt;");
41    map_['>']=std::string("&gt;");
42    map_['&']=std::string("&amp;");
[380]43    map_[' ']=std::string("&nbsp;");
[234]44    // This should be configurable, but for now indentation is two spaces.
45    map_['\t']=std::string("&nbsp;&nbsp;");
46    map_['å']=std::string("&aring;");
47    map_['ä']=std::string("&auml;");
48    map_['ö']=std::string("&ouml;");
49    map_['Å']=std::string("&Aring;");
50    map_['Ä']=std::string("&Auml;");
51    map_['Ö']=std::string("&Ouml;");
52    map_['é']=std::string("&eacute;");
53    map_['É']=std::string("&Eacute;");
54    map_['á']=std::string("&aacute;");
55    map_['Á']=std::string("&Aacute;");
56  }
57
[606]58  HtmlBuf::int_type HtmlBuf::overflow (HtmlBuf::int_type c)
[234]59  {
[606]60    std::map<char, std::string>::const_iterator i = map_.find(c);
61    if (i==map_.end())
62      return buf_.sputc(c);
63    // writing
64    if (buf_.sputn(i->second.c_str(), i->second.size()) == 
65        static_cast<std::streamsize>(i->second.size()))
66      return c;
67    return EOF;
[234]68  }
69
70}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.