CrystalSpace

Public API Reference

Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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 
00069 SCF_VERSION (iDocumentAttributeIterator, 0, 0, 1);
00070 
00079 struct iDocumentAttributeIterator : public iBase
00080 {
00082   virtual bool HasNext () = 0;
00084   virtual csRef<iDocumentAttribute> Next () = 0;
00085 };
00086 
00087 //===========================================================================
00088 
00089 SCF_VERSION (iDocumentAttribute, 0, 0, 1);
00090 
00106 struct iDocumentAttribute : public iBase
00107 {
00109   virtual const char* GetName () = 0;
00111   virtual const char* GetValue () = 0;
00113   virtual int GetValueAsInt () = 0;
00115   virtual float GetValueAsFloat () = 0;
00117   virtual bool GetValueAsBool () = 0;
00119   virtual void SetName (const char* name) = 0;
00121   virtual void SetValue (const char* value) = 0;
00123   virtual void SetValueAsInt (int v) = 0;
00125   virtual void SetValueAsFloat (float f) = 0;
00126 };
00127 
00128 //===========================================================================
00129 
00130 SCF_VERSION (iDocumentNodeIterator, 0, 0, 1);
00131 
00140 struct iDocumentNodeIterator : public virtual iBase
00141 {
00143   virtual bool HasNext () = 0;
00145   virtual csRef<iDocumentNode> Next () = 0;
00146 };
00147 
00148 //===========================================================================
00149 
00150 SCF_VERSION (iDocumentNode, 0, 4, 1);
00151 
00168 struct iDocumentNode : public iBase
00169 {
00173   virtual csDocumentNodeType GetType () = 0;
00174 
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 (csRef<iDocumentNodeIterator> children) = 0;
00239   virtual void RemoveNodes () = 0;
00240 
00247   virtual csRef<iDocumentNode> CreateNodeBefore (csDocumentNodeType type,
00248         iDocumentNode* before = 0) = 0;
00249 
00256   virtual const char* GetContentsValue () = 0;
00262   virtual int GetContentsValueAsInt () = 0;
00268   virtual float GetContentsValueAsFloat () = 0;
00269 
00270   //---------------------------------------------------------------------
00271 
00276   virtual csRef<iDocumentAttributeIterator> GetAttributes () = 0;
00278   virtual csRef<iDocumentAttribute> GetAttribute (const char* name) = 0;
00280   virtual const char* GetAttributeValue (const char* name) = 0;
00282   virtual int GetAttributeValueAsInt (const char* name) = 0;
00284   virtual float GetAttributeValueAsFloat (const char* name) = 0;
00289   virtual bool GetAttributeValueAsBool (const char* name,
00290         bool defaultvalue=false) = 0;
00291 
00293   virtual void RemoveAttribute (const csRef<iDocumentAttribute>& attr) = 0;
00295   virtual void RemoveAttributes () = 0;
00296 
00298   virtual void SetAttribute (const char* name, const char* value) = 0;
00300   virtual void SetAttributeAsInt (const char* name, int value) = 0;
00302   virtual void SetAttributeAsFloat (const char* name, float value) = 0;
00303 };
00304 
00305 //===========================================================================
00306 
00307 SCF_VERSION (iDocument, 0, 2, 0);
00308 
00317 struct iDocument : public iBase
00318 {
00320   virtual void Clear () = 0;
00321 
00323   virtual csRef<iDocumentNode> CreateRoot () = 0;
00324 
00326   virtual csRef<iDocumentNode> GetRoot () = 0;
00327 
00339   virtual const char* Parse (iFile* file, bool collapse = false) = 0;
00340 
00352   virtual const char* Parse (iDataBuffer* buf, bool collapse = false) = 0;
00353 
00365   virtual const char* Parse (iString* str, bool collapse = false) = 0;
00366 
00378   virtual const char* Parse (const char* buf, bool collapse = false) = 0;
00379 
00385   virtual const char* Write (iFile* file) = 0;
00386 
00392   virtual const char* Write (iString* str) = 0;
00393 
00399   virtual const char* Write (iVFS* vfs, const char* filename) = 0;
00400   
00408   virtual int Changeable () = 0;
00409 };
00410 
00411 //===========================================================================
00412 
00413 SCF_VERSION (iDocumentSystem, 0, 0, 1);
00414 
00431 struct iDocumentSystem : public virtual iBase
00432 {
00434   virtual csRef<iDocument> CreateDocument () = 0;
00435 };
00436 
00439 #endif // __CS_IUTIL_DOCUMENT_H__

Generated for Crystal Space by doxygen 1.4.4