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 
00080 struct iDocumentAttributeIterator : public iBase
00081 {
00083   virtual bool HasNext () = 0;
00085   virtual csRef<iDocumentAttribute> Next () = 0;
00086 };
00087 
00088 //===========================================================================
00089 
00090 SCF_VERSION (iDocumentAttribute, 0, 0, 1);
00091 
00107 struct iDocumentAttribute : public iBase
00108 {
00110   virtual const char* GetName () = 0;
00112   virtual const char* GetValue () = 0;
00114   virtual int GetValueAsInt () = 0;
00116   virtual float GetValueAsFloat () = 0;
00118   virtual bool GetValueAsBool () = 0;
00120   virtual void SetName (const char* name) = 0;
00122   virtual void SetValue (const char* value) = 0;
00124   virtual void SetValueAsInt (int v) = 0;
00126   virtual void SetValueAsFloat (float f) = 0;
00127 };
00128 
00129 //===========================================================================
00130 
00131 SCF_VERSION (iDocumentNodeIterator, 0, 0, 1);
00132 
00141 struct iDocumentNodeIterator : public iBase
00142 {
00144   virtual bool HasNext () = 0;
00146   virtual csRef<iDocumentNode> Next () = 0;
00147 };
00148 
00149 //===========================================================================
00150 
00151 SCF_VERSION (iDocumentNode, 0, 4, 1);
00152 
00169 struct iDocumentNode : public iBase
00170 {
00174   virtual csDocumentNodeType GetType () = 0;
00175 
00183   virtual bool Equals (iDocumentNode* other) = 0;
00184 
00197   virtual const char* GetValue () = 0;
00210   virtual void SetValue (const char* value) = 0;
00212   virtual void SetValueAsInt (int value) = 0;
00214   virtual void SetValueAsFloat (float value) = 0;
00215 
00217   virtual csRef<iDocumentNode> GetParent () = 0;
00218 
00219   //---------------------------------------------------------------------
00220   
00225   virtual csRef<iDocumentNodeIterator> GetNodes () = 0;
00230   virtual csRef<iDocumentNodeIterator> GetNodes (const char* value) = 0;
00232   virtual csRef<iDocumentNode> GetNode (const char* value) = 0;
00233 
00235   virtual void RemoveNode (const csRef<iDocumentNode>& child) = 0;
00237   virtual void RemoveNodes () = 0;
00238 
00245   virtual csRef<iDocumentNode> CreateNodeBefore (csDocumentNodeType type,
00246         iDocumentNode* before = 0) = 0;
00247 
00254   virtual const char* GetContentsValue () = 0;
00260   virtual int GetContentsValueAsInt () = 0;
00266   virtual float GetContentsValueAsFloat () = 0;
00267 
00268   //---------------------------------------------------------------------
00269 
00274   virtual csRef<iDocumentAttributeIterator> GetAttributes () = 0;
00276   virtual csRef<iDocumentAttribute> GetAttribute (const char* name) = 0;
00278   virtual const char* GetAttributeValue (const char* name) = 0;
00280   virtual int GetAttributeValueAsInt (const char* name) = 0;
00282   virtual float GetAttributeValueAsFloat (const char* name) = 0;
00287   virtual bool GetAttributeValueAsBool (const char* name,
00288         bool defaultvalue=false) = 0;
00289 
00291   virtual void RemoveAttribute (const csRef<iDocumentAttribute>& attr) = 0;
00293   virtual void RemoveAttributes () = 0;
00294 
00296   virtual void SetAttribute (const char* name, const char* value) = 0;
00298   virtual void SetAttributeAsInt (const char* name, int value) = 0;
00300   virtual void SetAttributeAsFloat (const char* name, float value) = 0;
00301 };
00302 
00303 //===========================================================================
00304 
00305 SCF_VERSION (iDocument, 0, 2, 0);
00306 
00315 struct iDocument : public iBase
00316 {
00318   virtual void Clear () = 0;
00319 
00321   virtual csRef<iDocumentNode> CreateRoot () = 0;
00322 
00324   virtual csRef<iDocumentNode> GetRoot () = 0;
00325 
00332   virtual const char* Parse (iFile* file) = 0;
00333 
00340   virtual const char* Parse (iDataBuffer* buf) = 0;
00341 
00348   virtual const char* Parse (iString* str) = 0;
00349 
00356   virtual const char* Parse (const char* buf) = 0;
00357 
00363   virtual const char* Write (iFile* file) = 0;
00364 
00370   virtual const char* Write (iString* str) = 0;
00371 
00377   virtual const char* Write (iVFS* vfs, const char* filename) = 0;
00378   
00386   virtual int Changeable () = 0;
00387 };
00388 
00389 //===========================================================================
00390 
00391 SCF_VERSION (iDocumentSystem, 0, 0, 1);
00392 
00408 struct iDocumentSystem : public iBase
00409 {
00411   virtual csRef<iDocument> CreateDocument () = 0;
00412 };
00413 
00416 #endif // __CS_IUTIL_DOCUMENT_H__

Generated for Crystal Space by doxygen 1.2.18