Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages
cfgdoc.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2004 by Jorrit Tyberghein 00003 (C) 2004 by Frank Richter 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00020 #ifndef __CS_UTIL_CFGDOC_H__ 00021 #define __CS_UTIL_CFGDOC_H__ 00022 00027 #include "csextern.h" 00028 #include "iutil/cfgfile.h" 00029 #include "iutil/document.h" 00030 #include "csutil/hash.h" 00031 #include "csutil/hashhandlers.h" 00032 00033 class csConfigDocumentIterator; 00034 00039 class CS_CSUTIL_EXPORT csConfigDocument : public iConfigFile 00040 { 00041 friend class csConfigDocumentIterator; 00042 00043 char* filename; 00044 csRef<iDocument> document; 00045 csRef<iVFS> fileVFS; 00046 00047 struct CS_CSUTIL_EXPORT KeyInfo 00048 { 00049 csRef<iDocumentNode> comment; 00050 csRef<iDocumentNode> node; 00051 char* cachedStringValue; 00052 char* cachedComment; 00053 char* originalKey; 00054 00055 KeyInfo () : cachedStringValue(0), cachedComment(0), originalKey(0) {} 00056 KeyInfo (const KeyInfo& other) 00057 { 00058 cachedStringValue = csStrNew (other.cachedStringValue); 00059 cachedComment = csStrNew (other.cachedComment); 00060 originalKey = csStrNew (other.originalKey); 00061 } 00062 ~KeyInfo() 00063 { 00064 delete[] cachedStringValue; 00065 delete[] cachedComment; 00066 delete[] originalKey; 00067 } 00068 }; 00069 csHash<KeyInfo, csStrKey, csConstCharHashKeyHandler> keys; 00070 00071 void ParseDocument (iDocument* doc, bool Merge = false, 00072 bool NewWins = true); 00073 void ParseNode (const char* parent, iDocumentNode* node, 00074 bool NewWins = true); 00075 public: 00076 SCF_DECLARE_IBASE; 00077 00078 csConfigDocument (); 00079 csConfigDocument (const char *Filename, iVFS* = 0); 00080 csConfigDocument (iDocument* doc); 00081 csConfigDocument (iDocumentNode* node); 00082 virtual ~csConfigDocument(); 00083 00084 virtual const char* GetFileName () const; 00085 00086 virtual iVFS* GetVFS () const; 00087 00088 virtual void SetFileName (const char*, iVFS*); 00089 00090 virtual bool Load (const char* iFileName, iVFS* = 0, bool Merge = false, 00091 bool NewWins = true); 00092 bool LoadNode (iDocumentNode* node, bool Merge = false, bool NewWins = true); 00093 00094 virtual bool Save (); 00095 00096 virtual bool Save (const char *iFileName, iVFS* = 0); 00097 00098 virtual void Clear (); 00099 00100 virtual csPtr<iConfigIterator> Enumerate (const char *Subsection = 0); 00101 00102 virtual bool KeyExists (const char *Key) const; 00103 virtual bool SubsectionExists (const char *Subsection) const; 00104 00105 virtual int GetInt (const char *Key, int Def = 0) const; 00106 virtual float GetFloat (const char *Key, float Def = 0.0) const; 00107 virtual const char *GetStr (const char *Key, const char *Def = "") const; 00108 virtual bool GetBool (const char *Key, bool Def = false) const; 00109 virtual const char *GetComment (const char *Key) const; 00110 00111 virtual void SetStr (const char *Key, const char *Val); 00112 virtual void SetInt (const char *Key, int Value); 00113 virtual void SetFloat (const char *Key, float Value); 00114 virtual void SetBool (const char *Key, bool Value); 00115 virtual bool SetComment (const char *Key, const char *Text); 00116 virtual void DeleteKey (const char *Key); 00117 virtual const char *GetEOFComment () const; 00118 virtual void SetEOFComment (const char *Text); 00119 }; 00120 00121 #endif // __CS_UTIL_CFGDOC_H__
Generated for Crystal Space by doxygen 1.3.9.1