Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages
documentcommon.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2005 by Jorrit Tyberghein 00003 (C) 2005 by Frank Richter 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 00024 #ifndef __CS_CSUTIL_DOCUMENTCOMMON_H__ 00025 #define __CS_CSUTIL_DOCUMENTCOMMON_H__ 00026 00027 #include "csextern.h" 00028 #include "iutil/document.h" 00029 00030 #include "csutil/leakguard.h" 00031 00035 class CS_CRYSTALSPACE_EXPORT csEmptyDocumentNodeIterator : 00036 public iDocumentNodeIterator 00037 { 00038 public: 00039 SCF_DECLARE_IBASE; 00040 CS_LEAKGUARD_DECLARE(csEmptyDocumentNodeIterator); 00041 00042 csEmptyDocumentNodeIterator (); 00043 virtual ~csEmptyDocumentNodeIterator (); 00044 00045 virtual bool HasNext () { return false; } 00046 virtual csRef<iDocumentNode> Next () { return 0; } 00047 }; 00048 00052 class CS_CRYSTALSPACE_EXPORT csEmptyDocumentAttributeIterator : 00053 public iDocumentAttributeIterator 00054 { 00055 public: 00056 SCF_DECLARE_IBASE; 00057 CS_LEAKGUARD_DECLARE(csEmptyDocumentAttributeIterator); 00058 00059 csEmptyDocumentAttributeIterator (); 00060 virtual ~csEmptyDocumentAttributeIterator (); 00061 00062 virtual bool HasNext () { return false; } 00063 virtual csRef<iDocumentAttribute> Next () { return 0; } 00064 }; 00065 00069 class CS_CRYSTALSPACE_EXPORT csDocumentNodeCommon : public iDocumentNode 00070 { 00071 public: 00073 00074 virtual void SetValueAsInt (int value); 00075 virtual void SetValueAsFloat (float value); 00077 00079 virtual csRef<iDocumentNodeIterator> GetNodes () 00080 { return csPtr<iDocumentNodeIterator> (new csEmptyDocumentNodeIterator); } 00085 virtual csRef<iDocumentNodeIterator> GetNodes (const char* value); 00087 virtual csRef<iDocumentNode> GetNode (const char* /*value*/) 00088 { return 0; } 00089 00091 00095 virtual const char* GetContentsValue (); 00096 virtual int GetContentsValueAsInt (); 00097 virtual float GetContentsValueAsFloat (); 00099 00101 virtual csRef<iDocumentAttributeIterator> GetAttributes () 00102 { 00103 return csPtr<iDocumentAttributeIterator> 00104 (new csEmptyDocumentAttributeIterator); 00105 } 00106 00108 csRef<iDocumentAttribute> GetAttribute (const char*) { return 0; } 00110 00111 virtual const char* GetAttributeValue (const char* name); 00112 virtual int GetAttributeValueAsInt (const char* name); 00113 virtual float GetAttributeValueAsFloat (const char* name); 00114 virtual bool GetAttributeValueAsBool (const char* name, 00115 bool defaultvalue = false); 00117 00119 00120 virtual void SetAttributeAsInt (const char* name, int value); 00121 virtual void SetAttributeAsFloat (const char* name, float value); 00123 }; 00124 00128 class CS_CRYSTALSPACE_EXPORT csDocumentAttributeCommon : 00129 public iDocumentAttribute 00130 { 00131 public: 00133 00136 virtual int GetValueAsInt (); 00137 virtual float GetValueAsFloat (); 00138 virtual bool GetValueAsBool (); 00140 00142 00143 virtual void SetValueAsInt (int v); 00144 virtual void SetValueAsFloat (float f); 00146 }; 00147 00152 class CS_CRYSTALSPACE_EXPORT csDocumentNodeReadOnly : 00153 public csDocumentNodeCommon 00154 { 00155 public: 00157 00158 virtual void SetValue (const char* /*value*/) {} 00159 virtual void SetValueAsInt (int /*value*/) {} 00160 virtual void SetValueAsFloat (float /*value*/) {} 00161 00162 virtual void RemoveNode (const csRef<iDocumentNode>& /*child*/) {} 00163 virtual void RemoveNodes (csRef<iDocumentNodeIterator> /*children*/) {} 00164 virtual void RemoveNodes () {} 00165 00166 virtual csRef<iDocumentNode> CreateNodeBefore (csDocumentNodeType /*type*/, 00167 iDocumentNode* /*before*/) 00168 { return 0; } 00169 00170 virtual void RemoveAttribute (const csRef<iDocumentAttribute>& /*attr*/) {} 00171 virtual void RemoveAttributes () {} 00172 00173 virtual void SetAttribute (const char* /*name*/, const char* /*value*/) {} 00174 virtual void SetAttributeAsInt (const char* /*name*/, int /*value*/) {} 00175 virtual void SetAttributeAsFloat (const char* /*name*/, float /*value*/) {} 00177 }; 00178 00179 #endif // __CS_CSUTIL_DOCUMENTCOMMON_H__
Generated for Crystal Space by doxygen 1.4.4