CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

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 #include "csutil/ref.h"
00030 
00031 struct iDocumentNode;
00032 struct iDocumentAttribute;
00033 struct iFile;
00034 struct iDataBuffer;
00035 struct iString;
00036 struct iVFS;
00037 
00041 enum csDocumentNodeType
00042 {
00044   CS_NODE_DOCUMENT = 1,
00046   CS_NODE_ELEMENT,
00048   CS_NODE_COMMENT,
00050   CS_NODE_UNKNOWN,
00052   CS_NODE_TEXT,
00054   CS_NODE_DECLARATION
00055 };
00056 
00060 
00061 #define CS_CHANGEABLE_NEVER             0
00062 
00063 #define CS_CHANGEABLE_NEWROOT           1
00064 
00065 #define CS_CHANGEABLE_YES               2
00066 
00068 //===========================================================================
00069 
00070 SCF_VERSION (iDocumentAttributeIterator, 0, 0, 1);
00071 
00075 struct iDocumentAttributeIterator : public iBase
00076 {
00078   virtual bool HasNext () = 0;
00080   virtual csRef<iDocumentAttribute> Next () = 0;
00081 };
00082 
00083 //===========================================================================
00084 
00085 SCF_VERSION (iDocumentAttribute, 0, 0, 1);
00086 
00090 struct iDocumentAttribute : public iBase
00091 {
00093   virtual const char* GetName () = 0;
00095   virtual const char* GetValue () = 0;
00097   virtual int GetValueAsInt () = 0;
00099   virtual float GetValueAsFloat () = 0;
00101   virtual bool GetValueAsBool () = 0;
00103   virtual void SetName (const char* name) = 0;
00105   virtual void SetValue (const char* value) = 0;
00107   virtual void SetValueAsInt (int v) = 0;
00109   virtual void SetValueAsFloat (float f) = 0;
00110 };
00111 
00112 //===========================================================================
00113 
00114 SCF_VERSION (iDocumentNodeIterator, 0, 0, 1);
00115 
00119 struct iDocumentNodeIterator : public iBase
00120 {
00122   virtual bool HasNext () = 0;
00124   virtual csRef<iDocumentNode> Next () = 0;
00125 };
00126 
00127 //===========================================================================
00128 
00129 SCF_VERSION (iDocumentNode, 0, 4, 1);
00130 
00134 struct iDocumentNode : public iBase
00135 {
00139   virtual csDocumentNodeType GetType () = 0;
00140 
00148   virtual bool Equals (iDocumentNode* other) = 0;
00149 
00162   virtual const char* GetValue () = 0;
00175   virtual void SetValue (const char* value) = 0;
00177   virtual void SetValueAsInt (int value) = 0;
00179   virtual void SetValueAsFloat (float value) = 0;
00180 
00182   virtual csRef<iDocumentNode> GetParent () = 0;
00183 
00184   //---------------------------------------------------------------------
00185   
00187   virtual csRef<iDocumentNodeIterator> GetNodes () = 0;
00189   virtual csRef<iDocumentNodeIterator> GetNodes (const char* value) = 0;
00191   virtual csRef<iDocumentNode> GetNode (const char* value) = 0;
00192 
00194   virtual void RemoveNode (const csRef<iDocumentNode>& child) = 0;
00196   virtual void RemoveNodes () = 0;
00197 
00204   virtual csRef<iDocumentNode> CreateNodeBefore (csDocumentNodeType type,
00205         iDocumentNode* before = 0) = 0;
00206 
00213   virtual const char* GetContentsValue () = 0;
00219   virtual int GetContentsValueAsInt () = 0;
00225   virtual float GetContentsValueAsFloat () = 0;
00226 
00227   //---------------------------------------------------------------------
00228 
00230   virtual csRef<iDocumentAttributeIterator> GetAttributes () = 0;
00232   virtual csRef<iDocumentAttribute> GetAttribute (const char* name) = 0;
00234   virtual const char* GetAttributeValue (const char* name) = 0;
00236   virtual int GetAttributeValueAsInt (const char* name) = 0;
00238   virtual float GetAttributeValueAsFloat (const char* name) = 0;
00240   virtual bool GetAttributeValueAsBool (const char* name,bool defaultvalue=false) = 0;
00241 
00243   virtual void RemoveAttribute (const csRef<iDocumentAttribute>& attr) = 0;
00245   virtual void RemoveAttributes () = 0;
00246 
00248   virtual void SetAttribute (const char* name, const char* value) = 0;
00250   virtual void SetAttributeAsInt (const char* name, int value) = 0;
00252   virtual void SetAttributeAsFloat (const char* name, float value) = 0;
00253 };
00254 
00255 //===========================================================================
00256 
00257 SCF_VERSION (iDocument, 0, 2, 0);
00258 
00262 struct iDocument : public iBase
00263 {
00265   virtual void Clear () = 0;
00266 
00268   virtual csRef<iDocumentNode> CreateRoot () = 0;
00269 
00271   virtual csRef<iDocumentNode> GetRoot () = 0;
00272 
00279   virtual const char* Parse (iFile* file) = 0;
00280 
00287   virtual const char* Parse (iDataBuffer* buf) = 0;
00288 
00295   virtual const char* Parse (iString* str) = 0;
00296 
00303   virtual const char* Parse (const char* buf) = 0;
00304 
00310   virtual const char* Write (iFile* file) = 0;
00311 
00317   virtual const char* Write (iString* str) = 0;
00318 
00324   virtual const char* Write (iVFS* vfs, const char* filename) = 0;
00325   
00333   virtual int Changeable () = 0;
00334 };
00335 
00336 //===========================================================================
00337 
00338 SCF_VERSION (iDocumentSystem, 0, 0, 1);
00339 
00343 struct iDocumentSystem : public iBase
00344 {
00346   virtual csRef<iDocument> CreateDocument () = 0;
00347 };
00348 
00351 #endif // __CS_IUTIL_DOCUMENT_H__

Generated for Crystal Space by doxygen 1.2.18