File: htmlescostream.cpp

package info (click to toggle)
tntnet 1.5.3-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,004 kB
  • ctags: 2,381
  • sloc: cpp: 13,553; sh: 8,997; ansic: 1,604; makefile: 573; sql: 10
file content (28 lines) | stat: -rw-r--r-- 615 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "tnt/htmlescostream.h"

namespace tnt
{
  std::streambuf::int_type HtmlEscStreamBuf::overflow(std::streambuf::int_type ch)
  {
    switch (ch)
    {
      case '<': return sink->sputn("&lt;", 4);
      case '>': return sink->sputn("&gt;", 4);
      case '&': return sink->sputn("&amp;", 5);
      case '"': return sink->sputn("&quot;", 6);
      case '\'': return sink->sputn("&#39;", 5);
      default: return sink->sputc(ch);
    }
  }

  std::streambuf::int_type HtmlEscStreamBuf::underflow()
  {
    return traits_type::eof();
  }

  int HtmlEscStreamBuf::sync()
  {
    return sink->pubsync();
  }

}