PageRenderTime 14ms CodeModel.GetById 1ms app.highlight 9ms RepoModel.GetById 2ms app.codeStats 0ms

/strigi-0.7.7/libstreamanalyzer/lib/xmlparser/xmlstream.h

#
C++ Header | 89 lines | 40 code | 7 blank | 42 comment | 0 complexity | af88992bcc4baad51804d841c97c289f MD5 | raw file
Possible License(s): LGPL-2.0
 1/* This file is part of Strigi Desktop Search
 2 *
 3 * Copyright (C) 2006 Jos van den Oever <jos@vandenoever.info>
 4 *
 5 * This library is free software; you can redistribute it and/or
 6 * modify it under the terms of the GNU Library General Public
 7 * License as published by the Free Software Foundation; either
 8 * version 2 of the License, or (at your option) any later version.
 9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB.  If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20#ifndef XMLSTREAM_H
21#define XMLSTREAM_H
22
23#include <string>
24#include <map>
25#include <list>
26// Although ostream isn't used *here*, other generated code
27// which #includes this file does use std::ostream (while
28// it doesn't #include <ostream> itself) so pull the header
29// in here.
30#include <ostream>
31
32class SimpleNode;
33class XMLStream {
34private:
35    class Private;
36    Private* p;
37public:
38    XMLStream(const std::string& xml);
39    ~XMLStream();
40    void setFromAttribute(bool&, const char*);
41    void setFromAttribute(int&, const char*);
42    void setFromAttribute(std::string&, const char*);
43    const std::string& getTagName() const;
44    /**
45     * The node at which the XMLStream is currently positioned.
46     **/
47    const SimpleNode& currentNode() const;
48    /**
49     * Moves the XMLStream to the first visible child of the current node, and
50     * returns the new node. If the current node has no visible children,
51     * returns null, and retains the current node.
52     **/
53    const SimpleNode* firstChild() const;
54    /**
55     * Moves the XMLStream to the next sibling of the current node, and
56     * returns the new node. If the current node has no visible next sibling,
57     * returns null, and retains the current node.
58     **/
59    const SimpleNode* nextSibling() const;
60    /**
61     * Moves to and returns the closest visible ancestor node of the current
62     * node. If the search for parentNode attempts to step upward from the
63     * XMLStream's root node, or if it fails to find a visible ancestor node,
64     * this method retains the current position and returns null.
65     **/
66    const SimpleNode* parentNode() const;
67};
68
69XMLStream& operator>>(XMLStream& in, bool& e);
70XMLStream& operator>>(XMLStream& in, int& e);
71XMLStream& operator>>(XMLStream& in, std::string& e);
72
73class SimpleNode {
74friend class SimpleNodeParser;
75private:
76    SimpleNode() :parent(0), next(0) {}
77public:
78    const SimpleNode* parent;
79    const SimpleNode* next;
80    std::string tagname;
81    std::map<std::string, std::string> atts;
82    std::list<SimpleNode> nodes;
83    std::string text;
84
85    SimpleNode(const std::string& xml);
86};
87
88
89#endif