Ignore:
Timestamp:
Apr 20, 2008, 5:46:56 AM (13 years ago)
Author:
Peter Johansson
Message:

Fixes ticket:318. Changed HtmlStream? to be inherited from ostream and created a HtmlBuf? (inherited from streambuf) that does the real work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/HtmlStream.cc

    r519 r606  
    2323
    2424#include "HtmlStream.h"
     25#include "HtmlBuf.h"
    2526
    2627#include <string>
     
    3031
    3132  HtmlStream::HtmlStream(std::ostream& os)
    32     : os_(os)
     33    : std::ostream(), hbuf_(*os.rdbuf()), os_(os)
    3334  {
    34     map_['"']=std::string("\"");
    35     map_['\'']=std::string("\'");
    36     map_['\n']=std::string("<br />");
    37     map_['<']=std::string("&lt;");
    38     map_['>']=std::string("&gt;");
    39     map_['&']=std::string("&amp;");
    40     map_[' ']=std::string("&nbsp;");
    41     // This should be configurable, but for now indentation is two spaces.
    42     map_['\t']=std::string("&nbsp;&nbsp;");
    43     map_['å']=std::string("&aring;");
    44     map_['ä']=std::string("&auml;");
    45     map_['ö']=std::string("&ouml;");
    46     map_['Å']=std::string("&Aring;");
    47     map_['Ä']=std::string("&Auml;");
    48     map_['Ö']=std::string("&Ouml;");
    49     map_['é']=std::string("&eacute;");
    50     map_['É']=std::string("&Eacute;");
    51     map_['á']=std::string("&aacute;");
    52     map_['Á']=std::string("&Aacute;");
     35    // setting member variable in base class
     36    rdbuf(&hbuf_);
    5337  }
    5438
     
    5943
    6044
    61   void HtmlStream::print(std::stringstream& ss)
    62   {
    63     char c;
    64     while (true){
    65       ss.get(c);
    66       if (!ss.good())
    67         return;
    68       std::map<char, std::string>::const_iterator i = map_.find(c);
    69       if (i==map_.end())
    70         os_ << c;
    71       else
    72         os_ << i->second;
    73     }
    74   }
    75 
    76  
    7745  std::ostream& HtmlStream::stream(void)
    7846  {
Note: See TracChangeset for help on using the changeset viewer.