Major redesign. All input is handled through XML. Raw input data is first
[gnucomo.git] / src / gcm_input / log_filter.cpp
1
2 /**************************************************************************
3 **  (c) Copyright 2003, Andromeda Technology & Automation
4 ** This is free software; you can redistribute it and/or modify it under the
5 ** terms of the GNU General Public License, see the file COPYING.
6 ***************************************************************************
7 ** MODULE INFORMATION *
8 ***********************
9 **      FILE NAME      : log_filter.cpp
10 **      SYSTEM NAME    : 
11 **      VERSION NUMBER : $Revision: 1.1 $
12 **
13 **  DESCRIPTION      : Implementation of the log_filter class 
14 **
15 **  EXPORTED OBJECTS : 
16 **  LOCAL    OBJECTS : 
17 **  MODULES  USED    :
18 ***************************************************************************
19 **  ADMINISTRATIVE INFORMATION *
20 ********************************
21 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
22 **      CREATION DATE   : Nov 26, 2003
23 **      LAST UPDATE     : Nov 26, 2003
24 **      MODIFICATIONS   : 
25 **************************************************************************/
26
27 /*****************************
28    $Log: log_filter.cpp,v $
29    Revision 1.1  2003-12-04 10:38:09  arjen
30    Major redesign. All input is handled through XML. Raw input data is first
31    transformed into an XML document for further processing.
32    A collection of polymorphic classes handle the transformation of various
33    input formats into XML.
34    Classifying input data is done with a finite improbability calculation.
35
36 *****************************/
37
38 /* static const char *RCSID = "$Id: log_filter.cpp,v 1.1 2003-12-04 10:38:09 arjen Exp $"; */
39
40 #include "log_filter.h"
41
42 extern String XML_Entities(String s);
43
44 /*=========================================================================
45 **  NAME           : constructXML
46 **  SYNOPSIS       : int constructXML(message_buffer &in, strstream &xml)
47 **  PARAMETERS     : 
48 **  RETURN VALUE   : None
49 **
50 **  DESCRIPTION    : Create the body for a Gnucomo XML document. Each line
51 **                   of input from the log file is put in a <raw> XML element.
52 **
53 **  VARS USED      :
54 **  VARS CHANGED   :
55 **  FUNCTIONS USED :
56 **  SEE ALSO       :
57 **  LAST MODIFIED  : Nov 26, 2003
58 **=========================================================================
59 */
60
61 void log_filter::construct_XML(message_buffer &in, std::strstream &xml)
62 {
63    String line;
64
65    scan_email_header(in);
66    construct_header(xml);
67
68    xml << "  <gcmt:data>\n";
69    xml << "    <gcmt:log>\n";
70    while (in >> line)
71    {
72       xml << "    <gcmt:raw>" << XML_Entities(line) << "</gcmt:raw>\n";
73    }
74    xml << "    </gcmt:log>\n";
75    xml << "  </gcmt:data>\n";
76    xml << "</gcmt:message>\n";
77 }
78