iutil/document.h
Go to the documentation of this file.
00001 /* 00002 Crystal Space Document Interface 00003 Copyright (C) 2002 by Jorrit Tyberghein 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_IUTIL_DOCUMENT_H__ 00021 #define __CS_IUTIL_DOCUMENT_H__ 00022 00028 #include "csutil/scf.h" 00029 00030 struct iDocumentNode; 00031 struct iDocumentAttribute; 00032 struct iFile; 00033 struct iDataBuffer; 00034 struct iString; 00035 struct iVFS; 00036 00040 enum csDocumentNodeType 00041 { 00043 CS_NODE_DOCUMENT = 1, 00045 CS_NODE_ELEMENT, 00047 CS_NODE_COMMENT, 00049 CS_NODE_UNKNOWN, 00051 CS_NODE_TEXT, 00053 CS_NODE_DECLARATION 00054 }; 00055 00059 00060 #define CS_CHANGEABLE_NEVER 0 00061 00062 #define CS_CHANGEABLE_NEWROOT 1 00063 00064 #define CS_CHANGEABLE_YES 2 00065 00067 //=========================================================================== 00068 00075 struct iDocumentAttributeIterator : public virtual iBase 00076 { 00077 SCF_INTERFACE(iDocumentAttributeIterator, 2,0,0); 00079 virtual bool HasNext () = 0; 00081 virtual csRef<iDocumentAttribute> Next () = 0; 00082 }; 00083 00084 //=========================================================================== 00085 00086 00099 struct iDocumentAttribute : public virtual iBase 00100 { 00101 SCF_INTERFACE(iDocumentAttribute, 2,0,0); 00103 virtual const char* GetName () = 0; 00105 virtual const char* GetValue () = 0; 00107 virtual int GetValueAsInt () = 0; 00109 virtual float GetValueAsFloat () = 0; 00111 virtual bool GetValueAsBool () = 0; 00113 virtual void SetName (const char* name) = 0; 00115 virtual void SetValue (const char* value) = 0; 00117 virtual void SetValueAsInt (int v) = 0; 00119 virtual void SetValueAsFloat (float f) = 0; 00120 }; 00121 00122 //=========================================================================== 00123 00130 struct iDocumentNodeIterator : public virtual iBase 00131 { 00132 SCF_INTERFACE(iDocumentNodeIterator, 2,0,1); 00134 virtual bool HasNext () = 0; 00136 virtual csRef<iDocumentNode> Next () = 0; 00137 00155 virtual size_t GetNextPosition () = 0; 00160 virtual size_t GetEndPosition () = 0; 00162 }; 00163 00164 //=========================================================================== 00165 00166 00180 struct iDocumentNode : public virtual iBase 00181 { 00182 SCF_INTERFACE(iDocumentNode, 2,0,0); 00186 virtual csDocumentNodeType GetType () = 0; 00187 00196 virtual bool Equals (iDocumentNode* other) = 0; 00197 00208 virtual const char* GetValue () = 0; 00219 virtual void SetValue (const char* value) = 0; 00221 virtual void SetValueAsInt (int value) = 0; 00223 virtual void SetValueAsFloat (float value) = 0; 00224 00226 virtual csRef<iDocumentNode> GetParent () = 0; 00227 00228 //--------------------------------------------------------------------- 00229 00234 virtual csRef<iDocumentNodeIterator> GetNodes () = 0; 00239 virtual csRef<iDocumentNodeIterator> GetNodes (const char* value) = 0; 00241 virtual csRef<iDocumentNode> GetNode (const char* value) = 0; 00242 00244 virtual void RemoveNode (const csRef<iDocumentNode>& child) = 0; 00246 virtual void RemoveNodes (csRef<iDocumentNodeIterator> children) = 0; 00248 virtual void RemoveNodes () = 0; 00249 00256 virtual csRef<iDocumentNode> CreateNodeBefore (csDocumentNodeType type, 00257 iDocumentNode* before = 0) = 0; 00258 00265 virtual const char* GetContentsValue () = 0; 00271 virtual int GetContentsValueAsInt () = 0; 00277 virtual float GetContentsValueAsFloat () = 0; 00278 00279 //--------------------------------------------------------------------- 00280 00285 virtual csRef<iDocumentAttributeIterator> GetAttributes () = 0; 00287 virtual csRef<iDocumentAttribute> GetAttribute (const char* name) = 0; 00289 virtual const char* GetAttributeValue (const char* name) = 0; 00291 virtual int GetAttributeValueAsInt (const char* name) = 0; 00293 virtual float GetAttributeValueAsFloat (const char* name) = 0; 00298 virtual bool GetAttributeValueAsBool (const char* name, 00299 bool defaultvalue=false) = 0; 00300 00302 virtual void RemoveAttribute (const csRef<iDocumentAttribute>& attr) = 0; 00304 virtual void RemoveAttributes () = 0; 00305 00307 virtual void SetAttribute (const char* name, const char* value) = 0; 00309 virtual void SetAttributeAsInt (const char* name, int value) = 0; 00311 virtual void SetAttributeAsFloat (const char* name, float value) = 0; 00312 }; 00313 00314 //=========================================================================== 00315 00316 00323 struct iDocument : public virtual iBase 00324 { 00325 SCF_INTERFACE(iDocument, 2,0,0); 00327 virtual void Clear () = 0; 00328 00330 virtual csRef<iDocumentNode> CreateRoot () = 0; 00331 00336 virtual csRef<iDocumentNode> GetRoot () = 0; 00337 00349 virtual const char* Parse (iFile* file, bool collapse = false) = 0; 00350 00362 virtual const char* Parse (iDataBuffer* buf, bool collapse = false) = 0; 00363 00375 virtual const char* Parse (iString* str, bool collapse = false) = 0; 00376 00388 virtual const char* Parse (const char* buf, bool collapse = false) = 0; 00389 00395 virtual const char* Write (iFile* file) = 0; 00396 00402 virtual const char* Write (iString* str) = 0; 00403 00409 virtual const char* Write (iVFS* vfs, const char* filename) = 0; 00410 00418 virtual int Changeable () = 0; 00419 }; 00420 00421 //=========================================================================== 00422 00423 00437 struct iDocumentSystem : public virtual iBase 00438 { 00439 SCF_INTERFACE(iDocumentSystem, 2,0,0); 00441 virtual csRef<iDocument> CreateDocument () = 0; 00442 }; 00443 00446 #endif // __CS_IUTIL_DOCUMENT_H__
Generated for Crystal Space 1.4.1 by doxygen 1.7.1