FXObjectList.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                            O b j e c t   L i s t                              *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXObjectList.h,v 1.31.2.1 2007/01/29 20:22:29 fox Exp $                      *
00023 ********************************************************************************/
00024 #ifndef FXOBJECTLIST_H
00025 #define FXOBJECTLIST_H
00026 
00027 #ifndef FXOBJECT_H
00028 #include "FXObject.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00034 class FXAPI FXObjectList {
00035 protected:
00036   FXObject **ptr;
00037 public:
00038 
00040   FXObjectList();
00041 
00043   FXObjectList(const FXObjectList& orig);
00044 
00046   FXObjectList(FXObject* object);
00047 
00049   FXObjectList(FXObject** objects,FXint n);
00050 
00052   FXObjectList& operator=(const FXObjectList& orig);
00053 
00055   FXint no() const { return *((FXint*)(ptr-1)); }
00056 
00058   void no(FXint num);
00059 
00061   FXObject*& operator[](FXint i){ return ptr[i]; }
00062   FXObject* const& operator[](FXint i) const { return ptr[i]; }
00063 
00065   FXObject*& at(FXint i){ return ptr[i]; }
00066   FXObject* const& at(FXint i) const { return ptr[i]; }
00067 
00069   FXObject** data() const { return ptr; }
00070 
00072   FXObjectList& assign(FXObject* object);
00073 
00075   FXObjectList& assign(FXObject** objects,FXint n);
00076 
00078   FXObjectList& assign(FXObjectList& objects);
00079 
00081   FXObjectList& insert(FXint pos,FXObject* object);
00082 
00084   FXObjectList& insert(FXint pos,FXObject** objects,FXint n);
00085 
00087   FXObjectList& insert(FXint pos,FXObjectList& objects);
00088 
00090   FXObjectList& prepend(FXObject* object);
00091 
00093   FXObjectList& prepend(FXObject** objects,FXint n);
00094 
00096   FXObjectList& prepend(FXObjectList& objects);
00097 
00099   FXObjectList& append(FXObject* object);
00100 
00102   FXObjectList& append(FXObject** objects,FXint n);
00103 
00105   FXObjectList& append(FXObjectList& objects);
00106 
00108   FXObjectList& replace(FXint pos,FXObject* object);
00109 
00111   FXObjectList& replace(FXint pos,FXint m,FXObject** objects,FXint n);
00112 
00114   FXObjectList& replace(FXint pos,FXint m,FXObjectList& objects);
00115 
00117   FXObjectList& erase(FXint pos);
00118 
00120   FXObjectList& erase(FXint pos,FXint n);
00121 
00123   FXObjectList& remove(const FXObject* object);
00124 
00126   FXint find(const FXObject *object,FXint pos=0) const;
00127 
00129   FXint rfind(const FXObject *object,FXint pos=2147483647) const;
00130 
00132   FXObjectList& clear();
00133 
00135   void save(FXStream& store) const;
00136 
00138   void load(FXStream& store);
00139 
00141   virtual ~FXObjectList();
00142   };
00143 
00144 
00146 template<class TYPE>
00147 class FXObjectListOf : public FXObjectList {
00148 public:
00149   FXObjectListOf(){}
00150 
00152   TYPE*& operator[](FXint i){ return (TYPE*&)ptr[i]; }
00153   TYPE *const& operator[](FXint i) const { return (TYPE*const&)ptr[i]; }
00154 
00156   TYPE*& at(FXint i){ return (TYPE*&)ptr[i]; }
00157   TYPE *const& at(FXint i) const { return (TYPE*const&)ptr[i]; }
00158 
00160   TYPE** data() const { return (TYPE**)ptr; }
00161   };
00162 
00163 }
00164 
00165 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:23 2009 for TnFOX by doxygen v1.4.7