CrystalSpace

Public API Reference

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

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 void SetName (const char* name) = 0;
00103   virtual void SetValue (const char* value) = 0;
00105   virtual void SetValueAsInt (int v) = 0;
00107   virtual void SetValueAsFloat (float f) = 0;
00108 };
00109 
00110 //===========================================================================
00111 
00112 SCF_VERSION (iDocumentNodeIterator, 0, 0, 1);
00113 
00117 struct iDocumentNodeIterator : public iBase
00118 {
00120   virtual bool HasNext () = 0;
00122   virtual csRef<iDocumentNode> Next () = 0;
00123 };
00124 
00125 //===========================================================================
00126 
00127 SCF_VERSION (iDocumentNode, 0, 4, 1);
00128 
00132 struct iDocumentNode : public iBase
00133 {
00137   virtual csDocumentNodeType GetType () = 0;
00138 
00146   virtual bool Equals (iDocumentNode* other) = 0;
00147 
00160   virtual const char* GetValue () = 0;
00173   virtual void SetValue (const char* value) = 0;
00175   virtual void SetValueAsInt (int value) = 0;
00177   virtual void SetValueAsFloat (float value) = 0;
00178 
00180   virtual csRef<iDocumentNode> GetParent () = 0;
00181 
00182   //---------------------------------------------------------------------
00183   
00185   virtual csRef<iDocumentNodeIterator> GetNodes () = 0;
00187   virtual csRef<iDocumentNodeIterator> GetNodes (const char* value) = 0;
00189   virtual csRef<iDocumentNode> GetNode (const char* value) = 0;
00190 
00192   virtual void RemoveNode (const csRef<iDocumentNode>& child) = 0;
00194   virtual void RemoveNodes () = 0;
00195 
00202   virtual csRef<iDocumentNode> CreateNodeBefore (csDocumentNodeType type,
00203         iDocumentNode* before = NULL) = 0;
00204 
00209   virtual const char* GetContentsValue () = 0;
00215   virtual int GetContentsValueAsInt () = 0;
00221   virtual float GetContentsValueAsFloat () = 0;
00222 
00223   //---------------------------------------------------------------------
00224 
00226   virtual csRef<iDocumentAttributeIterator> GetAttributes () = 0;
00228   virtual csRef<iDocumentAttribute> GetAttribute (const char* name) = 0;
00230   virtual const char* GetAttributeValue (const char* name) = 0;
00232   virtual int GetAttributeValueAsInt (const char* name) = 0;
00234   virtual float GetAttributeValueAsFloat (const char* name) = 0;
00235 
00237   virtual void RemoveAttribute (const csRef<iDocumentAttribute>& attr) = 0;
00239   virtual void RemoveAttributes () = 0;
00240 
00242   virtual void SetAttribute (const char* name, const char* value) = 0;
00244   virtual void SetAttributeAsInt (const char* name, int value) = 0;
00246   virtual void SetAttributeAsFloat (const char* name, float value) = 0;
00247 };
00248 
00249 //===========================================================================
00250 
00251 SCF_VERSION (iDocument, 0, 2, 0);
00252 
00256 struct iDocument : public iBase
00257 {
00259   virtual void Clear () = 0;
00260 
00262   virtual csRef<iDocumentNode> CreateRoot () = 0;
00263 
00265   virtual csRef<iDocumentNode> GetRoot () = 0;
00266 
00273   virtual const char* Parse (iFile* file) = 0;
00274 
00281   virtual const char* Parse (iDataBuffer* buf) = 0;
00282 
00289   virtual const char* Parse (iString* str) = 0;
00290 
00297   virtual const char* Parse (const char* buf) = 0;
00298 
00304   virtual const char* Write (iFile* file) = 0;
00305 
00311   virtual const char* Write (iString* str) = 0;
00312 
00318   virtual const char* Write (iVFS* vfs, const char* filename) = 0;
00319   
00327   virtual int Changeable () = 0;
00328 };
00329 
00330 //===========================================================================
00331 
00332 SCF_VERSION (iDocumentSystem, 0, 0, 1);
00333 
00337 struct iDocumentSystem : public iBase
00338 {
00340   virtual csRef<iDocument> CreateDocument () = 0;
00341 };
00342 
00345 #endif // __CS_IUTIL_DOCUMENT_H__

Generated for Crystal Space by doxygen 1.2.14