csutil/documentcommon.h Source File (Crystal Space 2.0 Public API Reference)

| ## Public API Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

csutil/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 "csutil/leakguard.h"
    00029 #include "csutil/scf_implementation.h"
    00030 #include "iutil/document.h"
    00031
    00035 class CS_CRYSTALSPACE_EXPORT csEmptyDocumentNodeIterator :
    00036   public scfImplementation1<csEmptyDocumentNodeIterator, iDocumentNodeIterator>
    00037 {
    00038 public:
    00039   CS_LEAKGUARD_DECLARE(csEmptyDocumentNodeIterator);
    00040
    00041   csEmptyDocumentNodeIterator ();
    00042   virtual ~csEmptyDocumentNodeIterator ();
    00043
    00044   virtual bool HasNext () { return false; }
    00045   virtual csRef<iDocumentNode> Next () { return 0; }
    00046   virtual size_t GetNextPosition () { return 1; }
    00047   virtual size_t GetEndPosition () { return 1; }
    00048 };
    00049
    00053 class CS_CRYSTALSPACE_EXPORT csEmptyDocumentAttributeIterator :
    00054   public scfImplementation1<csEmptyDocumentAttributeIterator, iDocumentAttributeIterator>
    00055 {
    00056 public:
    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 :
    00070   public scfImplementation1<csDocumentNodeCommon, iDocumentNode>
    00071 {
    00072 public:
    00073   csDocumentNodeCommon () : scfImplementationType (this) {}
    00075
    00076   virtual void SetValueAsInt (int value);
    00077   virtual void SetValueAsFloat (float value);
    00079
    00081   virtual csRef<iDocumentNodeIterator> GetNodes ()
    00082   { return csPtr<iDocumentNodeIterator> (new csEmptyDocumentNodeIterator); }
    00087   virtual csRef<iDocumentNodeIterator> GetNodes (const char* value);
    00089   virtual csRef<iDocumentNode> GetNode (const char* /*value*/)
    00090   { return 0; }
    00091
    00093
    00097   virtual const char* GetContentsValue ();
    00098   virtual int GetContentsValueAsInt ();
    00099   virtual float GetContentsValueAsFloat ();
    00101
    00103   virtual csRef<iDocumentAttributeIterator> GetAttributes ()
    00104   {
    00105     return csPtr<iDocumentAttributeIterator>
    00106       (new csEmptyDocumentAttributeIterator);
    00107   }
    00108
    00110   csRef<iDocumentAttribute> GetAttribute (const char*) { return 0; }
    00112
    00113   virtual const char* GetAttributeValue (const char* name, const char* defaultValue = 0);
    00114   virtual int GetAttributeValueAsInt (const char* name, int defaultValue = 0);
    00115   virtual float GetAttributeValueAsFloat (const char* name, float defaultValue = 0.0f);
    00116   virtual bool GetAttributeValueAsBool (const char* name,
    00117     bool defaultValue = false);
    00119
    00121
    00122   virtual void SetAttributeAsInt (const char* name, int value);
    00123   virtual void SetAttributeAsFloat (const char* name, float value);
    00125 };
    00126
    00130 class CS_CRYSTALSPACE_EXPORT csDocumentAttributeCommon :
    00131   public scfImplementation1<csDocumentAttributeCommon, iDocumentAttribute>
    00132 {
    00133 public:
    00134   csDocumentAttributeCommon () : scfImplementationType (this)
    00135   {}
    00137
    00140   virtual int GetValueAsInt ();
    00141   virtual float GetValueAsFloat ();
    00142   virtual bool GetValueAsBool ();
    00144
    00146
    00147   virtual void SetValueAsInt (int v);
    00148   virtual void SetValueAsFloat (float f);
    00150 };
    00151
    00156 class CS_CRYSTALSPACE_EXPORT csDocumentNodeReadOnly :
    00157   public scfImplementationExt0<csDocumentNodeReadOnly, csDocumentNodeCommon>
    00158 {
    00159 public:
    00160   csDocumentNodeReadOnly ()
    00161     : scfImplementationType (this)
    00162   {}
    00164
    00165   virtual void SetValue (const char* /*value*/) {}
    00166   virtual void SetValueAsInt (int /*value*/) {}
    00167   virtual void SetValueAsFloat (float /*value*/) {}
    00168
    00169   virtual void RemoveNode (const csRef<iDocumentNode>& /*child*/) {}
    00170   virtual void RemoveNodes (csRef<iDocumentNodeIterator> /*children*/) {}
    00171   virtual void RemoveNodes () {}
    00172
    00173   virtual csRef<iDocumentNode> CreateNodeBefore (csDocumentNodeType /*type*/,
    00174         iDocumentNode* /*before*/)
    00175   { return 0; }
    00176
    00177   virtual void RemoveAttribute (const csRef<iDocumentAttribute>& /*attr*/) {}
    00178   virtual void RemoveAttributes () {}
    00179
    00180   virtual void SetAttribute (const char* /*name*/, const char* /*value*/) {}
    00181   virtual void SetAttributeAsInt (const char* /*name*/, int /*value*/) {}
    00182   virtual void SetAttributeAsFloat (const char* /*name*/, float /*value*/) {}
    00184 };
    00185
    00186 #endif // __CS_CSUTIL_DOCUMENTCOMMON_H__