OmniEvents
PersistNode.h
Go to the documentation of this file.
1// Package : omniEvents
2// PersistNode.h Created : 2004/04/29
3// Author : Alex Tingle
4//
5// Copyright (C) 2004 Alex Tingle.
6//
7// This file is part of the omniEvents application.
8//
9// omniEvents is free software; you can redistribute it and/or
10// modify it under the terms of the GNU Lesser General Public
11// License as published by the Free Software Foundation; either
12// version 2.1 of the License, or (at your option) any later version.
13//
14// omniEvents is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17// Lesser General Public License for more details.
18//
19// You should have received a copy of the GNU Lesser General Public
20// License along with this library; if not, write to the Free Software
21// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22//
23
24#ifndef OMNIEVENTS__PERSIST_NODE_H
25#define OMNIEVENTS__PERSIST_NODE_H
26
27#ifdef HAVE_CONFIG_H
28# include "config.h"
29#endif
30
31#include <string>
32#include <map>
33
34#ifdef HAVE_IOSTREAM
35# include <iostream>
36#else
37# include <iostream.h>
38#endif
39
40#ifdef HAVE_STD_IOSTREAM
41using namespace std;
42#endif
43
44namespace OmniEvents {
45
46class PersistNode;
47
49{
50public:
52 PersistNode(istream& is);
53 ~PersistNode();
54 void output(ostream& os,string name) const;
55
56public: // Construction
57 inline bool readnode(istream& is);
58 inline bool readtoken(istream& is, string& tok);
59 PersistNode* addnode(const string& name);
60 void delnode(const string& name);
61 void addattr(const string& keyvalue);
62 void addattr(const string& key,long value);
63
64public: // Accessors
65 bool hasAttr(const string& key) const;
66 string attrString(const string& key, const string& fallback="") const;
67 long attrLong( const string& key, long fallback=0 ) const;
68 PersistNode* child(const string& key) const;
69
70public: // Members
71 map<string,PersistNode*> _child;
72 map<string,string> _attr;
73
74 friend class omniEventsLog;
75};
76
77}; // end namespace OmniEvents
78
79#endif // OMNIEVENTS__PERSIST_NODE_H
void output(ostream &os, string name) const
bool readtoken(istream &is, string &tok)
map< string, PersistNode * > _child
Definition PersistNode.h:71
bool hasAttr(const string &key) const
map< string, string > _attr
Definition PersistNode.h:72
~PersistNode()
Free node and all its children.
string attrString(const string &key, const string &fallback="") const
void delnode(const string &name)
PersistNode * addnode(const string &name)
bool readnode(istream &is)
long attrLong(const string &key, long fallback=0) const
PersistNode()
Create an empty node.
Definition PersistNode.h:51
PersistNode * child(const string &key) const
void addattr(const string &keyvalue)