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 00062 #define CS_CHANGEABLE_NEWROOT 1 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, 3,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; 00293 virtual const char* GetAttributeValue (const char* name, const char* defaultValue = 0) = 0; 00299 virtual int GetAttributeValueAsInt (const char* name, int defaultValue = 0) = 0; 00305 virtual float GetAttributeValueAsFloat (const char* name, float defaultValue = 0.0f) = 0; 00313 virtual bool GetAttributeValueAsBool (const char* name, 00314 bool defaultValue=false) = 0; 00315 00317 virtual void RemoveAttribute (const csRef<iDocumentAttribute>& attr) = 0; 00319 virtual void RemoveAttributes () = 0; 00320 00322 virtual void SetAttribute (const char* name, const char* value) = 0; 00324 virtual void SetAttributeAsInt (const char* name, int value) = 0; 00326 virtual void SetAttributeAsFloat (const char* name, float value) = 0; 00327 }; 00328 00329 //=========================================================================== 00330 00331 00338 struct iDocument : public virtual iBase 00339 { 00340 SCF_INTERFACE(iDocument, 2,0,0); 00342 virtual void Clear () = 0; 00343 00345 virtual csRef<iDocumentNode> CreateRoot () = 0; 00346 00351 virtual csRef<iDocumentNode> GetRoot () = 0; 00352 00364 virtual const char* Parse (iFile* file, bool collapse = false) = 0; 00365 00377 virtual const char* Parse (iDataBuffer* buf, bool collapse = false) = 0; 00378 00390 virtual const char* Parse (iString* str, bool collapse = false) = 0; 00391 00403 virtual const char* Parse (const char* buf, bool collapse = false) = 0; 00404 00410 virtual const char* Write (iFile* file) = 0; 00411 00417 virtual const char* Write (iString* str) = 0; 00418 00424 virtual const char* Write (iVFS* vfs, const char* filename) = 0; 00425 00433 virtual int Changeable () = 0; 00434 }; 00435 00436 //=========================================================================== 00437 00438 00452 struct iDocumentSystem : public virtual iBase 00453 { 00454 SCF_INTERFACE(iDocumentSystem, 2,0,0); 00456 virtual csRef<iDocument> CreateDocument () = 0; 00457 }; 00458 00461 #endif // __CS_IUTIL_DOCUMENT_H__
Generated for Crystal Space 2.0 by doxygen 1.6.1