summaryrefslogtreecommitdiffstats
path: root/src/parsers/parsers.cpp
blob: 8cc67da7b9c9fcb11b712a3a27a3448d8a8a882d (plain)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/***************************************************************************
 *   Copyright (C) 2003 by Sylvain Joyeux                                  *
 *   [email protected]                                                *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

#include "parsers.h"

#include <kuserprofile.h>

#include <kio/slavebase.h>
#include <qhtmlstream.h>
#include <tqregexp.h>

#include <stdlib.h>

namespace Parsers
{
	static void print_czstring(TDEIO::SlaveBase& slave, const char* data, int len)
  {
    TQByteArray nonull;
    nonull.setRawData(data, len);
    slave.data(nonull);
    nonull.resetRawData(data, len);
  }
  void operator << (TDEIO::SlaveBase& slave, const TQCString& string)
  { print_czstring(slave, string.data(), string.size() - 1); }
  void operator << (TDEIO::SlaveBase& slave, const TQString& string)
  { slave << string.utf8(); }
  void operator << (TDEIO::SlaveBase& slave, const char* string)
  { print_czstring(slave, string, strlen(string)); }



  Parser::Parser( ) {}
  Parser::~Parser( ) {}

  void Parser::attribute_begin(TQHtmlStream& stream, const TQString& text)
  {
    stream
      << block("tr") << endl
        << block("td") << param("class") << "attname" << data()
          << text
        << close() << endl
        << block("td");
  }
  void Parser::attribute_end(TQHtmlStream& stream)
  { stream << close() << endl << close(); }

// 	void Parser::operator ( )( TDEIO::SlaveBase * /*slave*/,
//   	const TQString & /*tag*/, const TQString & /*value*/ )
// 	{}

  TQString mangle_version(TQString version)
  { return "version_" + version.replace(TQRegExp("[-:\\.\\+]"), TQString("_")); }

}