moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kvoctrain / kvoctrain / kvt-core / kvt-xml / XmlReader.h
blobb00c5fb52c94965a7bfc27c8540393afed543fa4
1 /* -*- C++ -*-
2 $Id$
4 This file is part of KIllustrator.
5 Copyright (C) 1998 Kai-Uwe Sattler (kus@iti.cs.uni-magdeburg.de)
7 modified for kvoctrain by Ewald Arnold kvoctrain@ewald-arnold.dein April ยด99
8 */
10 #ifndef XmlReader_h_
11 #define XmlReader_h_
13 #include "XmlElement.h"
14 #include "XmlTokenizer.h"
16 class KOXML_ISTREAM;
18 /**
19 * The XMLReader class supports reading elements from a XML stream.
21 * @short A class for reading XML elements from a stream.
22 * @author Kai-Uwe Sattler (kus@iti.cs.uni-magdeburg.de), modifications: Ewald Arnold (kvoctrain@ewald-arnold.de)
23 * @version 2000/07/02
25 class XmlReader {
26 public:
27 /**
28 * Construct a XmlReader instance for the given input stream.
30 * @param is The open input stream.
32 XmlReader (KOXML_ISTREAM& is);
34 /**
35 * Desctructor
37 ~XmlReader ();
39 /**
40 * Check the input stream for a valid XML header.
41 * A header should look like
42 * <pre>
43 * <?xml version="1.0"?>
44 * <!doctype dtype system dtd>
45 * </pre>
46 * where @p dtype and @p dtd are simple strings.
48 * @return @p true if the header conforms to XML, otherwise
49 * @p false.
51 bool validHeader ();
53 /**
54 * Return the document type.
56 * @return The name of the document type.
58 const KOXML_STRING& doctype () const;
60 /**
61 * Return the name of the document type definition.
63 * @return The name of the DTD.
65 const KOXML_STRING& dtd () const;
67 /**
68 * Read a XML element from the stream. If the content is plain text
69 * (no tag), an element with the pseudo ID @p #PCDATA is returned
70 * and the text is available via method getText.
72 * @see #getText
74 * @param elem The XML element which is initialized by the method.
75 * @return @p true for successful reading.
77 bool readElement (XmlElement& elem);
79 /**
80 * Read plain text from the stream.
82 * @return The text as a string.
84 const KOXML_STRING& getText ();
86 /**
87 * Returns current line number
89 * @return The current line number
91 inline int lineNumber() { return tokenizer.lineNumber(); }
93 protected:
94 bool parseEndElement (XmlElement& elem);
95 bool parseElement (const KOXML_STRING& id, XmlElement& elem);
96 bool readAttributes (std::list<XmlAttribute>& attrib_list);
98 private:
99 XmlTokenizer tokenizer;
100 KOXML_STRING s_dtype,
101 s_dtd;
102 KOXML_STRING text;
105 #endif