## Public API Reference

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

- 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 };
    00047
    00051 class CS_CRYSTALSPACE_EXPORT csEmptyDocumentAttributeIterator :
    00052   public scfImplementation1<csEmptyDocumentAttributeIterator, iDocumentAttributeIterator>
    00053 {
    00054 public:
    00055   CS_LEAKGUARD_DECLARE(csEmptyDocumentAttributeIterator);
    00056
    00057   csEmptyDocumentAttributeIterator ();
    00058   virtual ~csEmptyDocumentAttributeIterator ();
    00059
    00060   virtual bool HasNext () { return false; }
    00061   virtual csRef<iDocumentAttribute> Next () { return 0; }
    00062 };
    00063
    00067 class CS_CRYSTALSPACE_EXPORT csDocumentNodeCommon :
    00068   public scfImplementation1<csDocumentNodeCommon, iDocumentNode>
    00069 {
    00070 public:
    00071   csDocumentNodeCommon () : scfImplementationType (this) {}
    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 scfImplementation1<csDocumentAttributeCommon, iDocumentAttribute>
    00130 {
    00131 public:
    00132   csDocumentAttributeCommon () : scfImplementationType (this)
    00133   {}
    00135
    00138   virtual int GetValueAsInt ();
    00139   virtual float GetValueAsFloat ();
    00140   virtual bool GetValueAsBool ();
    00142
    00144
    00145   virtual void SetValueAsInt (int v);
    00146   virtual void SetValueAsFloat (float f);
    00148 };
    00149
    00154 class CS_CRYSTALSPACE_EXPORT csDocumentNodeReadOnly :
    00155   public scfImplementationExt0<csDocumentNodeReadOnly, csDocumentNodeCommon>
    00156 {
    00157 public:
    00158   csDocumentNodeReadOnly ()
    00159     : scfImplementationType (this)
    00160   {}
    00162
    00163   virtual void SetValue (const char* /*value*/) {}
    00164   virtual void SetValueAsInt (int /*value*/) {}
    00165   virtual void SetValueAsFloat (float /*value*/) {}
    00166
    00167   virtual void RemoveNode (const csRef<iDocumentNode>& /*child*/) {}
    00168   virtual void RemoveNodes (csRef<iDocumentNodeIterator> /*children*/) {}
    00169   virtual void RemoveNodes () {}
    00170
    00171   virtual csRef<iDocumentNode> CreateNodeBefore (csDocumentNodeType /*type*/,
    00172         iDocumentNode* /*before*/)
    00173   { return 0; }
    00174
    00175   virtual void RemoveAttribute (const csRef<iDocumentAttribute>& /*attr*/) {}
    00176   virtual void RemoveAttributes () {}
    00177
    00178   virtual void SetAttribute (const char* /*name*/, const char* /*value*/) {}
    00179   virtual void SetAttributeAsInt (const char* /*name*/, int /*value*/) {}
    00180   virtual void SetAttributeAsFloat (const char* /*name*/, float /*value*/) {}
    00182 };
    00183
    00184 #endif // __CS_CSUTIL_DOCUMENTCOMMON_H__