- These macros are ugly (especially if you look in the sources ;-), but they
- allow us to define 'template' classes without actually using templates.
- <BR>
- <BR>
- Range checking is performed in debug build for both arrays and objarrays.
- Type checking is done at compile-time. Warning: arrays <I>never</I> shrink,
- they only grow, so loading 10 millions in an array only to delete them 2
- lines below is <I>not</I> recommended. However, it does free memory when
- it's destroyed, so if you destroy array also, it's ok.
- */
-// ----------------------------------------------------------------------------
-
-//@{
- /**
- This macro generates a new array class. It is intended for storage of simple
- types of sizeof()<=sizeof(long) or pointers if sizeof(pointer)<=sizeof(long)
- <BR>
- NB: it has only inline functions => takes no space at all
- <BR>
-
- @memo declare and define array class 'name' containing elements of type 'T'
- */
-#define WX_DEFINE_ARRAY(T, name) \
- typedef T _A##name; \
- _WX_DEFINE_ARRAY(_A##name, name, class)
-
- /**
- This macro does the same as WX_DEFINE_ARRAY except that the array will be
- sorted with the specified compare function.
- */
-#define WX_DEFINE_SORTED_ARRAY(T, name) \
- typedef T _A##name; \
- _WX_DEFINE_SORTED_ARRAY(_A##name, name, class)
-
- /**
- This macro generates a new objarrays class which owns the objects it
- contains, i.e. it will delete them when it is destroyed. An element is of
- type T*, but arguments of type T& are taken (see below!) and T& is
- returned. <BR>
- Don't use this for simple types such as "int" or "long"!
- You _may_ use it for "double" but it's awfully inefficient.
- <BR>
- <BR>
- Note on Add/Insert functions:
- <BR>
- 1) function(T*) gives the object to the array, i.e. it will delete the
- object when it's removed or in the array's dtor
- <BR>
- 2) function(T&) will create a copy of the object and work with it
- <BR>
- <BR>
- Also:
- <BR>
- 1) Remove() will delete the object after removing it from the array
- <BR>
- 2) Detach() just removes the object from the array (returning pointer to it)
- <BR>
- <BR>
- NB1: Base type T should have an accessible copy ctor if Add(T&) is used,
- <BR>
- NB2: Never ever cast a array to it's base type: as dtor is <B>not</B> virtual
- it will provoke memory leaks
- <BR>
- <BR>
- some functions of this class are not inline, so it takes some space to
- define new class from this template.
-
- @memo declare objarray class 'name' containing elements of type 'T'
- */
-#define WX_DECLARE_OBJARRAY(T, name) \
- typedef T _L##name; \
- _WX_DECLARE_OBJARRAY(_L##name, name, class)
-
- /**
- To use an objarray class you must
- <ll>
- <li>#include "dynarray.h"
- <li>WX_DECLARE_OBJARRAY(element_type, list_class_name)
- <li>#include "arrimpl.cpp"
- <li>WX_DEFINE_OBJARRAY(list_class_name) // same as above!
- </ll>
- <BR><BR>
- This is necessary because at the moment of DEFINE_OBJARRAY class
- element_type must be fully defined (i.e. forward declaration is not
- enough), while WX_DECLARE_OBJARRAY may be done anywhere. The separation of
- two allows to break cicrcular dependencies with classes which have member
- variables of objarray type.
-
- @memo define (must include arrimpl.cpp!) objarray class 'name'
- */
-#define WX_DEFINE_OBJARRAY(name) "don't forget to include arrimpl.cpp!"
-//@}
-
-// these macros do the same thing as the WX_XXX ones above, but should be used
-// inside the library for user visible classes because otherwise they wouldn't
-// be visible from outside (when using wxWindows as DLL under Windows)
-#define WX_DEFINE_EXPORTED_ARRAY(T, name) \
- typedef T _A##name; \
- _WX_DEFINE_ARRAY(_A##name, name, class WXDLLEXPORT)
-
-#define WX_DEFINE_SORTED_EXPORTED_ARRAY(T, name) \
- typedef T _A##name; \
- _WX_DEFINE_SORTED_ARRAY(_A##name, name, class WXDLLEXPORT)
-
-#define WX_DECLARE_EXPORTED_OBJARRAY(T, name) \
- typedef T _L##name; \
- _WX_DECLARE_OBJARRAY(_L##name, name, class WXDLLEXPORT)
-
-// ----------------------------------------------------------------------------
-/** @name Some commonly used predefined arrays */
-// ----------------------------------------------------------------------------
-
-//@{
- /** @name ArrayInt */
-WX_DEFINE_EXPORTED_ARRAY(int, wxArrayInt);
- /** @name ArrayLong */
-WX_DEFINE_EXPORTED_ARRAY(long, wxArrayLong);
- /** @name ArrayPtrVoid */
-WX_DEFINE_EXPORTED_ARRAY(void *, wxArrayPtrVoid);
-//@}
-
-//@}
+#define WX_DEFINE_ARRAY(T, name) \
+ WX_DEFINE_TYPEARRAY(T, name, wxBaseArrayPtrVoid)
+#define WX_DEFINE_EXPORTED_ARRAY(T, name) \
+ WX_DEFINE_EXPORTED_TYPEARRAY(T, name, wxBaseArrayPtrVoid)
+#define WX_DEFINE_USER_EXPORTED_ARRAY(T, name, expmode) \
+ WX_DEFINE_TYPEARRAY_WITH_DECL(T, name, wxBaseArrayPtrVoid, expmode)
+
+#define WX_DEFINE_ARRAY_SHORT(T, name) \
+ WX_DEFINE_TYPEARRAY(T, name, wxBaseArrayShort)
+#define WX_DEFINE_EXPORTED_ARRAY_SHORT(T, name) \
+ WX_DEFINE_EXPORTED_TYPEARRAY(T, name, wxBaseArrayShort)
+#define WX_DEFINE_USER_EXPORTED_ARRAY_SHORT(T, name, expmode) \
+ WX_DEFINE_TYPEARRAY_WITH_DECL(T, name, wxBaseArrayShort, expmode)
+
+#define WX_DEFINE_ARRAY_INT(T, name) \
+ WX_DEFINE_TYPEARRAY(T, name, wxBaseArrayInt)
+#define WX_DEFINE_EXPORTED_ARRAY_INT(T, name) \
+ WX_DEFINE_EXPORTED_TYPEARRAY(T, name, wxBaseArrayInt)
+#define WX_DEFINE_USER_EXPORTED_ARRAY_INT(T, name, expmode) \
+ WX_DEFINE_TYPEARRAY_WITH_DECL(T, name, wxBaseArrayInt, expmode)
+
+#define WX_DEFINE_ARRAY_LONG(T, name) \
+ WX_DEFINE_TYPEARRAY(T, name, wxBaseArrayLong)
+#define WX_DEFINE_EXPORTED_ARRAY_LONG(T, name) \
+ WX_DEFINE_EXPORTED_TYPEARRAY(T, name, wxBaseArrayLong)
+#define WX_DEFINE_USER_EXPORTED_ARRAY_LONG(T, name, expmode) \
+ WX_DEFINE_TYPEARRAY_WITH_DECL(T, name, wxBaseArrayLong, expmode)
+
+#define WX_DEFINE_ARRAY_DOUBLE(T, name) \
+ WX_DEFINE_TYPEARRAY(T, name, wxBaseArrayDouble)
+#define WX_DEFINE_EXPORTED_ARRAY_DOUBLE(T, name) \
+ WX_DEFINE_EXPORTED_TYPEARRAY(T, name, wxBaseArrayDouble)
+#define WX_DEFINE_USER_EXPORTED_ARRAY_DOUBLE(T, name, expmode) \
+ WX_DEFINE_TYPEARRAY_WITH_DECL(T, name, wxBaseArrayDouble, expmode)
+
+// ----------------------------------------------------------------------------
+// Convenience macros to define sorted arrays from base arrays
+// ----------------------------------------------------------------------------
+
+#define WX_DEFINE_SORTED_ARRAY(T, name) \
+ WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArrayPtrVoid)
+#define WX_DEFINE_SORTED_EXPORTED_ARRAY(T, name) \
+ WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArrayPtrVoid)
+#define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY(T, name, expmode) \
+ WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayPtrVoid, expmode)
+
+#define WX_DEFINE_SORTED_ARRAY_SHORT(T, name) \
+ WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArrayShort)
+#define WX_DEFINE_SORTED_EXPORTED_ARRAY_SHORT(T, name) \
+ WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArrayShort)
+#define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_SHORT(T, name, expmode) \
+ WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayShort, expmode)
+
+#define WX_DEFINE_SORTED_ARRAY_INT(T, name) \
+ WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArrayInt)
+#define WX_DEFINE_SORTED_EXPORTED_ARRAY_INT(T, name) \
+ WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArrayInt)
+#define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_INT(T, name, expmode) \
+ WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayInt, expmode)
+
+#define WX_DEFINE_SORTED_ARRAY_LONG(T, name) \
+ WX_DEFINE_SORTED_TYPEARRAY(T, name, wxBaseArrayLong)
+#define WX_DEFINE_SORTED_EXPORTED_ARRAY_LONG(T, name) \
+ WX_DEFINE_SORTED_EXPORTED_TYPEARRAY(T, name, wxBaseArrayLong)
+#define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_LONG(T, name, expmode) \
+ WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY(T, name, wxBaseArrayLong, expmode)
+
+// ----------------------------------------------------------------------------
+// Convenience macros to define sorted arrays from base arrays
+// ----------------------------------------------------------------------------
+
+#define WX_DEFINE_SORTED_ARRAY_CMP(T, cmpfunc, name) \
+ WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayPtrVoid)
+#define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP(T, cmpfunc, name) \
+ WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayPtrVoid)
+#define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP(T, cmpfunc, \
+ name, expmode) \
+ WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \
+ wxBaseArrayPtrVoid, expmode)
+
+#define WX_DEFINE_SORTED_ARRAY_CMP_SHORT(T, cmpfunc, name) \
+ WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayShort)
+#define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_SHORT(T, cmpfunc, name) \
+ WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayShort)
+#define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP_SHORT(T, cmpfunc, \
+ name, expmode) \
+ WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \
+ wxBaseArrayShort, expmode)
+
+#define WX_DEFINE_SORTED_ARRAY_CMP_INT(T, cmpfunc, name) \
+ WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayInt)
+#define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_INT(T, cmpfunc, name) \
+ WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayInt)
+#define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP_INT(T, cmpfunc, \
+ name, expmode) \
+ WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \
+ wxBaseArrayInt, expmode)
+
+#define WX_DEFINE_SORTED_ARRAY_CMP_LONG(T, cmpfunc, name) \
+ WX_DEFINE_SORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayLong)
+#define WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_LONG(T, cmpfunc, name) \
+ WX_DEFINE_SORTED_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, wxBaseArrayLong)
+#define WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_CMP_LONG(T, cmpfunc, \
+ name, expmode) \
+ WX_DEFINE_SORTED_USER_EXPORTED_TYPEARRAY_CMP(T, cmpfunc, name, \
+ wxBaseArrayLong, expmode)
+
+// ----------------------------------------------------------------------------
+// Some commonly used predefined arrays
+// ----------------------------------------------------------------------------
+
+WX_DEFINE_USER_EXPORTED_ARRAY_SHORT (short, wxArrayShort, class WXDLLIMPEXP_BASE);
+WX_DEFINE_USER_EXPORTED_ARRAY_INT (int, wxArrayInt, class WXDLLIMPEXP_BASE);
+WX_DEFINE_USER_EXPORTED_ARRAY_LONG (long, wxArrayLong, class WXDLLIMPEXP_BASE);
+WX_DEFINE_USER_EXPORTED_ARRAY (void *, wxArrayPtrVoid, class WXDLLIMPEXP_BASE);