textdocvisitor.cpp 3.17 KB
Newer Older
dimitri's avatar
dimitri committed
1 2
/******************************************************************************
 *
dimitri's avatar
dimitri committed
3
 * 
dimitri's avatar
dimitri committed
4 5
 *
 *
dimitri's avatar
dimitri committed
6
 * Copyright (C) 1997-2010 by Dimitri van Heesch.
dimitri's avatar
dimitri committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation under the terms of the GNU General Public License is hereby 
 * granted. No representations are made about the suitability of this software 
 * for any purpose. It is provided "as is" without express or implied warranty.
 * See the GNU General Public License for more details.
 *
 * Documents produced by Doxygen are derivative works derived from the
 * input used in their production; they are not affected by this license.
 *
 */

#include <qdir.h>
#include "textdocvisitor.h"
#include "message.h"

//-------------------------------------------------------------------------

void TextDocVisitor::visit(DocSymbol *s)
{
  switch(s->symbol())
  {
    case DocSymbol::BSlash:  m_t << "\\"; break;
    case DocSymbol::At:      m_t << "@"; break;
    case DocSymbol::Less:    m_t << "&lt;"; break;
    case DocSymbol::Greater: m_t << "&gt;"; break;
    case DocSymbol::Amp:     m_t << "&amp;"; break;
    case DocSymbol::Dollar:  m_t << "$"; break;
    case DocSymbol::Hash:    m_t << "#"; break;
dimitri's avatar
dimitri committed
36
    case DocSymbol::DoubleColon: m_t << "::"; break;
dimitri's avatar
dimitri committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
    case DocSymbol::Percent: m_t << "%"; break;
    case DocSymbol::Copy:    m_t << "&copy;"; break;
    case DocSymbol::Tm:      m_t << "&tm;"; break;
    case DocSymbol::Reg:     m_t << "&reg;"; break;
    case DocSymbol::Apos:    m_t << "'"; break;
    case DocSymbol::Quot:    m_t << "\""; break;
    case DocSymbol::Lsquo:   m_t << "&lsquo;"; break;
    case DocSymbol::Rsquo:   m_t << "&rsquo;"; break;
    case DocSymbol::Ldquo:   m_t << "&ldquo;"; break;
    case DocSymbol::Rdquo:   m_t << "&rdquo;"; break;
    case DocSymbol::Ndash:   m_t << "&ndash;"; break;
    case DocSymbol::Mdash:   m_t << "&mdash;"; break;
    case DocSymbol::Uml:     m_t << "&" << s->letter() << "uml;"; break;
    case DocSymbol::Acute:   m_t << "&" << s->letter() << "acute;"; break;
    case DocSymbol::Grave:   m_t << "&" << s->letter() << "grave;"; break;
    case DocSymbol::Circ:    m_t << "&" << s->letter() << "circ;"; break;
    case DocSymbol::Slash:   m_t << "&" << s->letter() << "slash;"; break;
    case DocSymbol::Tilde:   m_t << "&" << s->letter() << "tilde;"; break;
    case DocSymbol::Szlig:   m_t << "&szlig;"; break;
    case DocSymbol::Cedil:   m_t << "&" << s->letter() << "cedil;"; break;
    case DocSymbol::Ring:    m_t << "&" << s->letter() << "ring;"; break;
    case DocSymbol::Nbsp:    m_t << "&nbsp;"; break;
dimitri's avatar
dimitri committed
59 60
    case DocSymbol::Aelig:   m_t << "&aelig;"; break;
    case DocSymbol::AElig:   m_t << "&AElig;"; break;
dimitri's avatar
dimitri committed
61
    default:
dimitri's avatar
dimitri committed
62
                             err("error: unknown symbol found\n");
dimitri's avatar
dimitri committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76
  }
}


void TextDocVisitor::filter(const char *str)
{ 
  if (str==0) return;
  const char *p=str;
  char c;
  while (*p)
  {
    c=*p++;
    switch(c)
    {
dimitri's avatar
dimitri committed
77 78
      case '\n':  m_t << " ";      break;
      case '"':   m_t << "&quot;"; break;
dimitri's avatar
dimitri committed
79
      case '\'':  m_t << "&#39;";  break;
dimitri's avatar
dimitri committed
80 81 82 83
      case '<':   m_t << "&lt;";   break;
      case '>':   m_t << "&gt;";   break;
      case '&':   m_t << "&amp;";  break;
      default:    m_t << c;
dimitri's avatar
dimitri committed
84 85 86 87
    }
  }
}