OmniEvents
|
00001 // Package : omniEvents 00002 // PersistNode.h Created : 2004/04/29 00003 // Author : Alex Tingle 00004 // 00005 // Copyright (C) 2004 Alex Tingle. 00006 // 00007 // This file is part of the omniEvents application. 00008 // 00009 // omniEvents is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU Lesser General Public 00011 // License as published by the Free Software Foundation; either 00012 // version 2.1 of the License, or (at your option) any later version. 00013 // 00014 // omniEvents is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 // Lesser General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU Lesser General Public 00020 // License along with this library; if not, write to the Free Software 00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 // 00023 00024 #ifndef OMNIEVENTS__PERSIST_NODE_H 00025 #define OMNIEVENTS__PERSIST_NODE_H 00026 00027 #ifdef HAVE_CONFIG_H 00028 # include "config.h" 00029 #endif 00030 00031 #include <string> 00032 #include <map> 00033 00034 #ifdef HAVE_IOSTREAM 00035 # include <iostream> 00036 #else 00037 # include <iostream.h> 00038 #endif 00039 00040 #ifdef HAVE_STD_IOSTREAM 00041 using namespace std; 00042 #endif 00043 00044 namespace OmniEvents { 00045 00046 class PersistNode; 00047 00048 class PersistNode 00049 { 00050 public: 00051 PersistNode(){} 00052 PersistNode(istream& is); 00053 ~PersistNode(); 00054 void output(ostream& os,string name) const; 00055 00056 public: // Construction 00057 inline bool readnode(istream& is); 00058 inline bool readtoken(istream& is, string& tok); 00059 PersistNode* addnode(const string& name); 00060 void delnode(const string& name); 00061 void addattr(const string& keyvalue); 00062 void addattr(const string& key,long value); 00063 00064 public: // Accessors 00065 bool hasAttr(const string& key) const; 00066 string attrString(const string& key, const string& fallback="") const; 00067 long attrLong( const string& key, long fallback=0 ) const; 00068 PersistNode* child(const string& key) const; 00069 00070 public: // Members 00071 map<string,PersistNode*> _child; 00072 map<string,string> _attr; 00073 00074 friend class omniEventsLog; 00075 }; 00076 00077 }; // end namespace OmniEvents 00078 00079 #endif // OMNIEVENTS__PERSIST_NODE_H