• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

spl/xml/XmlNodeList.h

00001 /*
00002  *   This file is part of the Standard Portable Library (SPL).
00003  *
00004  *   SPL is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   SPL is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with SPL.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 #ifndef _xmlnodelist_h
00018 #define _xmlnodelist_h
00019 
00020 #include <spl/Debug.h>
00021 #include <spl/String.h>
00022 #include <spl/collection/Vector.h>
00023 #include <spl/xml/XmlNode.h>
00024 
00030 class XmlNodeList;
00031 typedef RefCountPtr<XmlNodeList> XmlNodeListPtr;
00032 typedef WeakReference<XmlNodeList, XmlNodeListPtr> XmlNodeListRef;
00033 
00034 REGISTER_TYPEOF( 522, XmlNodeListPtr );
00035 REGISTER_TYPEOF( 524, XmlNodeListRef );
00036 
00040 class XmlNodeList : public IMemoryValidate
00041 {
00042 protected:
00043         Vector<XmlNodePtr> m_nodes;
00044         
00045         friend class XmlElement;
00046 
00047 public:
00048         XmlNodeList();
00049         virtual ~XmlNodeList();
00050 
00051         inline int Count() const 
00052         { 
00053                 return m_nodes.Count(); 
00054         }
00055         
00056         inline XmlNodePtr Item(int idx) const
00057         {
00058                 return m_nodes.ElementAt(idx);
00059         }
00060 
00061         void Clear();
00062         
00063         inline void Add(XmlNodePtr node)
00064         {
00065                 m_nodes.Add(node);
00066         }
00067         
00068         inline void Add(const XmlNodeList& list)
00069         {
00070                 m_nodes.AddRange(list.m_nodes);
00071         }
00072         
00073         inline Vector<XmlNodePtr>::Iterator Begin()
00074         {
00075                 return m_nodes.Begin();
00076         }
00077 
00078 #ifdef DEBUG
00079         virtual void ValidateMem() const;
00080         virtual void CheckMem() const;
00081 #endif
00082 };
00083 
00084 REGISTER_TYPEOF( 527, XmlNodeList );
00085 
00088 #endif