234 |
09 Apr 07 |
peter |
// $Id$ |
234 |
09 Apr 07 |
peter |
2 |
|
234 |
09 Apr 07 |
peter |
3 |
/* |
992 |
17 Dec 09 |
peter |
Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson |
1635 |
30 Mar 23 |
peter |
Copyright (C) 2009, 2010, 2023 Peter Johansson |
992 |
17 Dec 09 |
peter |
6 |
|
687 |
04 Aug 08 |
peter |
This file is part of svndigest, http://dev.thep.lu.se/svndigest |
234 |
09 Apr 07 |
peter |
8 |
|
234 |
09 Apr 07 |
peter |
svndigest is free software; you can redistribute it and/or modify it |
234 |
09 Apr 07 |
peter |
under the terms of the GNU General Public License as published by |
693 |
11 Sep 08 |
jari |
the Free Software Foundation; either version 3 of the License, or |
234 |
09 Apr 07 |
peter |
(at your option) any later version. |
234 |
09 Apr 07 |
peter |
13 |
|
234 |
09 Apr 07 |
peter |
svndigest is distributed in the hope that it will be useful, but |
234 |
09 Apr 07 |
peter |
WITHOUT ANY WARRANTY; without even the implied warranty of |
234 |
09 Apr 07 |
peter |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
234 |
09 Apr 07 |
peter |
General Public License for more details. |
234 |
09 Apr 07 |
peter |
18 |
|
234 |
09 Apr 07 |
peter |
You should have received a copy of the GNU General Public License |
693 |
11 Sep 08 |
jari |
along with svndigest. If not, see <http://www.gnu.org/licenses/>. |
234 |
09 Apr 07 |
peter |
21 |
*/ |
234 |
09 Apr 07 |
peter |
22 |
|
1619 |
12 Mar 23 |
peter |
23 |
#include <config.h> |
1619 |
12 Mar 23 |
peter |
24 |
|
606 |
20 Apr 08 |
peter |
25 |
#include "HtmlBuf.h" |
234 |
09 Apr 07 |
peter |
26 |
|
1155 |
09 Aug 10 |
peter |
27 |
#include "Configuration.h" |
1155 |
09 Aug 10 |
peter |
28 |
|
606 |
20 Apr 08 |
peter |
29 |
#include <cstdio> |
606 |
20 Apr 08 |
peter |
30 |
#include <iostream> |
234 |
09 Apr 07 |
peter |
31 |
#include <string> |
234 |
09 Apr 07 |
peter |
32 |
|
234 |
09 Apr 07 |
peter |
33 |
namespace theplu{ |
234 |
09 Apr 07 |
peter |
34 |
namespace svndigest{ |
234 |
09 Apr 07 |
peter |
35 |
|
606 |
20 Apr 08 |
peter |
36 |
HtmlBuf::HtmlBuf(std::streambuf& buf) |
1513 |
23 Sep 12 |
peter |
37 |
: std::streambuf(), buf_(buf) |
234 |
09 Apr 07 |
peter |
38 |
{ |
991 |
16 Dec 09 |
peter |
39 |
map_['"']=std::string("""); |
234 |
09 Apr 07 |
peter |
40 |
map_['\'']=std::string("\'"); |
234 |
09 Apr 07 |
peter |
41 |
map_['\n']=std::string("<br />"); |
234 |
09 Apr 07 |
peter |
42 |
map_['<']=std::string("<"); |
234 |
09 Apr 07 |
peter |
43 |
map_['>']=std::string(">"); |
234 |
09 Apr 07 |
peter |
44 |
map_['&']=std::string("&"); |
380 |
21 Jun 07 |
jari |
45 |
map_[' ']=std::string(" "); |
1155 |
09 Aug 10 |
peter |
46 |
std::string str; |
1155 |
09 Aug 10 |
peter |
47 |
for (size_t i=0; i<Configuration::instance().tab_size(); ++i) |
1155 |
09 Aug 10 |
peter |
48 |
str += " "; |
1155 |
09 Aug 10 |
peter |
49 |
map_['\t']=str; |
234 |
09 Apr 07 |
peter |
50 |
} |
234 |
09 Apr 07 |
peter |
51 |
|
606 |
20 Apr 08 |
peter |
52 |
HtmlBuf::int_type HtmlBuf::overflow (HtmlBuf::int_type c) |
234 |
09 Apr 07 |
peter |
53 |
{ |
606 |
20 Apr 08 |
peter |
54 |
std::map<char, std::string>::const_iterator i = map_.find(c); |
606 |
20 Apr 08 |
peter |
55 |
if (i==map_.end()) |
606 |
20 Apr 08 |
peter |
56 |
return buf_.sputc(c); |
1513 |
23 Sep 12 |
peter |
// writing |
1513 |
23 Sep 12 |
peter |
58 |
if (buf_.sputn(i->second.c_str(), i->second.size()) == |
606 |
20 Apr 08 |
peter |
59 |
static_cast<std::streamsize>(i->second.size())) |
606 |
20 Apr 08 |
peter |
60 |
return c; |
606 |
20 Apr 08 |
peter |
61 |
return EOF; |
234 |
09 Apr 07 |
peter |
62 |
} |
234 |
09 Apr 07 |
peter |
63 |
|
234 |
09 Apr 07 |
peter |
64 |
}} // end of namespace svndigest and namespace theplu |