renamed wx/ptr_shrd.h to wx/sharedptr.h; split wx/ptr_scpd.h in wx/scopedptr.h and wx/scopedarray.h; extracted common parts into new wx/checkeddelete.h
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58634 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -318,6 +318,7 @@ ALL_BASE_HEADERS = \
|
|||||||
wx/buffer.h \
|
wx/buffer.h \
|
||||||
wx/build.h \
|
wx/build.h \
|
||||||
wx/chartype.h \
|
wx/chartype.h \
|
||||||
|
wx/checkeddelete.h \
|
||||||
wx/chkconf.h \
|
wx/chkconf.h \
|
||||||
wx/clntdata.h \
|
wx/clntdata.h \
|
||||||
wx/cmdargs.h \
|
wx/cmdargs.h \
|
||||||
@@ -391,7 +392,10 @@ ALL_BASE_HEADERS = \
|
|||||||
wx/ptr_shrd.h \
|
wx/ptr_shrd.h \
|
||||||
wx/recguard.h \
|
wx/recguard.h \
|
||||||
wx/regex.h \
|
wx/regex.h \
|
||||||
|
wx/scopedarray.h \
|
||||||
|
wx/scopedptr.h \
|
||||||
wx/scopeguard.h \
|
wx/scopeguard.h \
|
||||||
|
wx/sharedptr.h \
|
||||||
wx/snglinst.h \
|
wx/snglinst.h \
|
||||||
wx/sstream.h \
|
wx/sstream.h \
|
||||||
wx/stack.h \
|
wx/stack.h \
|
||||||
@@ -471,6 +475,7 @@ ALL_PORTS_BASE_HEADERS = \
|
|||||||
wx/buffer.h \
|
wx/buffer.h \
|
||||||
wx/build.h \
|
wx/build.h \
|
||||||
wx/chartype.h \
|
wx/chartype.h \
|
||||||
|
wx/checkeddelete.h \
|
||||||
wx/chkconf.h \
|
wx/chkconf.h \
|
||||||
wx/clntdata.h \
|
wx/clntdata.h \
|
||||||
wx/cmdargs.h \
|
wx/cmdargs.h \
|
||||||
@@ -544,7 +549,10 @@ ALL_PORTS_BASE_HEADERS = \
|
|||||||
wx/ptr_shrd.h \
|
wx/ptr_shrd.h \
|
||||||
wx/recguard.h \
|
wx/recguard.h \
|
||||||
wx/regex.h \
|
wx/regex.h \
|
||||||
|
wx/scopedarray.h \
|
||||||
|
wx/scopedptr.h \
|
||||||
wx/scopeguard.h \
|
wx/scopeguard.h \
|
||||||
|
wx/sharedptr.h \
|
||||||
wx/snglinst.h \
|
wx/snglinst.h \
|
||||||
wx/sstream.h \
|
wx/sstream.h \
|
||||||
wx/stack.h \
|
wx/stack.h \
|
||||||
|
@@ -399,6 +399,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
|
|||||||
wx/buffer.h
|
wx/buffer.h
|
||||||
wx/build.h
|
wx/build.h
|
||||||
wx/chartype.h
|
wx/chartype.h
|
||||||
|
wx/checkeddelete.h
|
||||||
wx/chkconf.h
|
wx/chkconf.h
|
||||||
wx/clntdata.h
|
wx/clntdata.h
|
||||||
wx/cmdargs.h
|
wx/cmdargs.h
|
||||||
@@ -472,7 +473,10 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
|
|||||||
wx/ptr_shrd.h
|
wx/ptr_shrd.h
|
||||||
wx/recguard.h
|
wx/recguard.h
|
||||||
wx/regex.h
|
wx/regex.h
|
||||||
|
wx/scopedarray.h
|
||||||
|
wx/scopedptr.h
|
||||||
wx/scopeguard.h
|
wx/scopeguard.h
|
||||||
|
wx/sharedptr.h
|
||||||
wx/snglinst.h
|
wx/snglinst.h
|
||||||
wx/sstream.h
|
wx/sstream.h
|
||||||
wx/stack.h
|
wx/stack.h
|
||||||
|
@@ -1071,6 +1071,10 @@ SOURCE=..\..\include\wx\chartype.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\include\wx\checkeddelete.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\include\wx\chkconf.h
|
SOURCE=..\..\include\wx\chkconf.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
@@ -1371,10 +1375,22 @@ SOURCE=..\..\include\wx\regex.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\include\wx\scopedarray.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\include\wx\scopedptr.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\include\wx\scopeguard.h
|
SOURCE=..\..\include\wx\scopeguard.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\include\wx\sharedptr.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\include\wx\snglinst.h
|
SOURCE=..\..\include\wx\snglinst.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@@ -1221,6 +1221,9 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\wx\chartype.h">
|
RelativePath="..\..\include\wx\chartype.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\include\wx\checkeddelete.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\wx\chkconf.h">
|
RelativePath="..\..\include\wx\chkconf.h">
|
||||||
</File>
|
</File>
|
||||||
@@ -1446,9 +1449,18 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\wx\regex.h">
|
RelativePath="..\..\include\wx\regex.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\include\wx\scopedarray.h">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\include\wx\scopedptr.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\wx\scopeguard.h">
|
RelativePath="..\..\include\wx\scopeguard.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\include\wx\sharedptr.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\wx\snglinst.h">
|
RelativePath="..\..\include\wx\snglinst.h">
|
||||||
</File>
|
</File>
|
||||||
|
@@ -1651,6 +1651,10 @@
|
|||||||
RelativePath="..\..\include\wx\chartype.h"
|
RelativePath="..\..\include\wx\chartype.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\include\wx\checkeddelete.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\wx\chkconf.h"
|
RelativePath="..\..\include\wx\chkconf.h"
|
||||||
>
|
>
|
||||||
@@ -1951,10 +1955,22 @@
|
|||||||
RelativePath="..\..\include\wx\regex.h"
|
RelativePath="..\..\include\wx\regex.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\include\wx\scopedarray.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\include\wx\scopedptr.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\wx\scopeguard.h"
|
RelativePath="..\..\include\wx\scopeguard.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\include\wx\sharedptr.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\wx\snglinst.h"
|
RelativePath="..\..\include\wx\snglinst.h"
|
||||||
>
|
>
|
||||||
|
@@ -1647,6 +1647,10 @@
|
|||||||
RelativePath="..\..\include\wx\chartype.h"
|
RelativePath="..\..\include\wx\chartype.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\include\wx\checkeddelete.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\wx\chkconf.h"
|
RelativePath="..\..\include\wx\chkconf.h"
|
||||||
>
|
>
|
||||||
@@ -1947,10 +1951,22 @@
|
|||||||
RelativePath="..\..\include\wx\regex.h"
|
RelativePath="..\..\include\wx\regex.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\include\wx\scopedarray.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\include\wx\scopedptr.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\wx\scopeguard.h"
|
RelativePath="..\..\include\wx\scopeguard.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\include\wx\sharedptr.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\wx\snglinst.h"
|
RelativePath="..\..\include\wx\snglinst.h"
|
||||||
>
|
>
|
||||||
|
@@ -320,7 +320,9 @@ All:
|
|||||||
Linnakangas).
|
Linnakangas).
|
||||||
- wxVariant::Unshare allows exclusive allocation of data that must be shared,
|
- wxVariant::Unshare allows exclusive allocation of data that must be shared,
|
||||||
if the wxVariantData::Clone function is implemented.
|
if the wxVariantData::Clone function is implemented.
|
||||||
- Added wxWeakRef<T>, wxScopedPtr<T>, wxScopedArray<T>, wxSharedPtr<T> templates.
|
- Added wxWeakRef<T>, wxScopedPtr<T>, wxScopedArray<T>, wxSharedPtr<T> templates
|
||||||
|
and renamed old wx/ptr_{scpd,shrd}.h headers to wx/scoped{ptr,array}.h and
|
||||||
|
wx/sharedptr.h (but old headers are still provided for compatibility).
|
||||||
- Added wxVector<T> class templates
|
- Added wxVector<T> class templates
|
||||||
- Added wxON_BLOCK_EXIT_SET() and wxON_BLOCK_EXIT_NULL() to wx/scopeguard.h.
|
- Added wxON_BLOCK_EXIT_SET() and wxON_BLOCK_EXIT_NULL() to wx/scopeguard.h.
|
||||||
- Added wxEvtHandler::QueueEvent() replacing AddPendingEvent() and
|
- Added wxEvtHandler::QueueEvent() replacing AddPendingEvent() and
|
||||||
|
54
include/wx/checkeddelete.h
Normal file
54
include/wx/checkeddelete.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: wx/checkeddelete.h
|
||||||
|
// Purpose: wxCHECKED_DELETE() macro
|
||||||
|
// Author: Vadim Zeitlin
|
||||||
|
// Created: 2009-02-03
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) 2002-2009 wxWidgets dev team
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _WX_CHECKEDDELETE_H_
|
||||||
|
#define _WX_CHECKEDDELETE_H_
|
||||||
|
|
||||||
|
// TODO: provide wxCheckedDelete[Array]() template functions too
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxCHECKED_DELETE and wxCHECKED_DELETE_ARRAY macros
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/*
|
||||||
|
checked deleters are used to make sure that the type being deleted is really
|
||||||
|
a complete type.: otherwise sizeof() would result in a compile-time error
|
||||||
|
|
||||||
|
do { ... } while ( 0 ) construct is used to have an anonymous scope
|
||||||
|
(otherwise we could have name clashes between different "complete"s) but
|
||||||
|
still force a semicolon after the macro
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __WATCOMC__
|
||||||
|
#define wxFOR_ONCE(name) for(int name=0; name<1; name++)
|
||||||
|
#define wxPRE_NO_WARNING_SCOPE(name) wxFOR_ONCE(wxMAKE_UNIQUE_NAME(name))
|
||||||
|
#define wxPOST_NO_WARNING_SCOPE(name)
|
||||||
|
#else
|
||||||
|
#define wxPRE_NO_WARNING_SCOPE(name) do
|
||||||
|
#define wxPOST_NO_WARNING_SCOPE(name) while ( wxFalse )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define wxCHECKED_DELETE(ptr) \
|
||||||
|
wxPRE_NO_WARNING_SCOPE(scope_var1) \
|
||||||
|
{ \
|
||||||
|
typedef char complete[sizeof(*ptr)]; \
|
||||||
|
delete ptr; \
|
||||||
|
} wxPOST_NO_WARNING_SCOPE(scope_var1)
|
||||||
|
|
||||||
|
#define wxCHECKED_DELETE_ARRAY(ptr) \
|
||||||
|
wxPRE_NO_WARNING_SCOPE(scope_var2) \
|
||||||
|
{ \
|
||||||
|
typedef char complete[sizeof(*ptr)]; \
|
||||||
|
delete [] ptr; \
|
||||||
|
} wxPOST_NO_WARNING_SCOPE(scope_var2)
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _WX_CHECKEDDELETE_H_
|
||||||
|
|
@@ -791,7 +791,6 @@ public:
|
|||||||
// For drag operations
|
// For drag operations
|
||||||
void SetDataObject( wxDataObject *obj ) { m_dataObject = obj; }
|
void SetDataObject( wxDataObject *obj ) { m_dataObject = obj; }
|
||||||
wxDataObject *GetDataObject() const { return m_dataObject; }
|
wxDataObject *GetDataObject() const { return m_dataObject; }
|
||||||
#endif // wxUSE_DRAG_AND_DROP
|
|
||||||
|
|
||||||
// For drop operations
|
// For drop operations
|
||||||
void SetDataFormat( const wxDataFormat &format ) { m_dataFormat = format; }
|
void SetDataFormat( const wxDataFormat &format ) { m_dataFormat = format; }
|
||||||
@@ -800,6 +799,7 @@ public:
|
|||||||
size_t GetDataSize() const { return m_dataSize; }
|
size_t GetDataSize() const { return m_dataSize; }
|
||||||
void SetDataBuffer( void* buf ) { m_dataBuffer = buf;}
|
void SetDataBuffer( void* buf ) { m_dataBuffer = buf;}
|
||||||
void *GetDataBuffer() const { return m_dataBuffer; }
|
void *GetDataBuffer() const { return m_dataBuffer; }
|
||||||
|
#endif // wxUSE_DRAG_AND_DROP
|
||||||
|
|
||||||
virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); }
|
virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); }
|
||||||
|
|
||||||
|
120
include/wx/scopedarray.h
Normal file
120
include/wx/scopedarray.h
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: wx/scopedarray.h
|
||||||
|
// Purpose: scoped smart pointer class
|
||||||
|
// Author: Vadim Zeitlin
|
||||||
|
// Created: 2009-02-03
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) Jesse Lovelace and original Boost authors (see below)
|
||||||
|
// (c) 2009 Vadim Zeitlin
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _WX_SCOPED_ARRAY_H_
|
||||||
|
#define _WX_SCOPED_ARRAY_H_
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#include "wx/checkeddelete.h"
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxScopedArray: A scoped array
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class wxScopedArray
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef T element_type;
|
||||||
|
|
||||||
|
wxEXPLICIT wxScopedArray(T * array = NULL) : m_array(array) { }
|
||||||
|
|
||||||
|
~wxScopedArray() { delete [] m_array; }
|
||||||
|
|
||||||
|
// test for pointer validity: defining conversion to unspecified_bool_type
|
||||||
|
// and not more obvious bool to avoid implicit conversions to integer types
|
||||||
|
typedef T *(wxScopedArray<T>::*unspecified_bool_type)() const;
|
||||||
|
operator unspecified_bool_type() const
|
||||||
|
{
|
||||||
|
return m_array ? &wxScopedArray<T>::get : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset(T *array = NULL)
|
||||||
|
{
|
||||||
|
if ( array != m_array )
|
||||||
|
{
|
||||||
|
delete m_array;
|
||||||
|
m_array = array;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
T& operator[](size_t n) const { return m_array[n]; }
|
||||||
|
|
||||||
|
T *get() const { return m_array; }
|
||||||
|
|
||||||
|
void swap(wxScopedArray &other)
|
||||||
|
{
|
||||||
|
T * const tmp = other.m_array;
|
||||||
|
other.m_array = m_array;
|
||||||
|
m_array = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
T *m_array;
|
||||||
|
|
||||||
|
DECLARE_NO_COPY_TEMPLATE_CLASS(wxScopedArray, T)
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// old macro based implementation
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// the same but for arrays instead of simple pointers
|
||||||
|
#define wxDECLARE_SCOPED_ARRAY(T, name)\
|
||||||
|
class name \
|
||||||
|
{ \
|
||||||
|
private: \
|
||||||
|
T * m_ptr; \
|
||||||
|
name(name const &); \
|
||||||
|
name & operator=(name const &); \
|
||||||
|
\
|
||||||
|
public: \
|
||||||
|
wxEXPLICIT name(T * p = NULL) : m_ptr(p) \
|
||||||
|
{} \
|
||||||
|
\
|
||||||
|
~name(); \
|
||||||
|
void reset(T * p = NULL); \
|
||||||
|
\
|
||||||
|
T & operator[](long int i) const\
|
||||||
|
{ \
|
||||||
|
wxASSERT(m_ptr != NULL); \
|
||||||
|
wxASSERT(i >= 0); \
|
||||||
|
return m_ptr[i]; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
T * get() const \
|
||||||
|
{ \
|
||||||
|
return m_ptr; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
void swap(name & ot) \
|
||||||
|
{ \
|
||||||
|
T * tmp = ot.m_ptr; \
|
||||||
|
ot.m_ptr = m_ptr; \
|
||||||
|
m_ptr = tmp; \
|
||||||
|
} \
|
||||||
|
};
|
||||||
|
|
||||||
|
#define wxDEFINE_SCOPED_ARRAY(T, name) \
|
||||||
|
name::~name() \
|
||||||
|
{ \
|
||||||
|
wxCHECKED_DELETE_ARRAY(m_ptr); \
|
||||||
|
} \
|
||||||
|
void name::reset(T * p){ \
|
||||||
|
if (m_ptr != p) \
|
||||||
|
{ \
|
||||||
|
wxCHECKED_DELETE_ARRAY(m_ptr); \
|
||||||
|
m_ptr = p; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // _WX_SCOPED_ARRAY_H_
|
||||||
|
|
@@ -1,8 +1,7 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: wx/ptr_scpd.h
|
// Name: wx/scopedptr.h
|
||||||
// Purpose: scoped smart pointer class
|
// Purpose: scoped smart pointer class
|
||||||
// Author: Jesse Lovelace <jllovela@eos.ncsu.edu>
|
// Author: Jesse Lovelace <jllovela@eos.ncsu.edu>
|
||||||
// Modified by: Vadim Zeitlin to add template wxScopedArray
|
|
||||||
// Created: 06/01/02
|
// Created: 06/01/02
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Jesse Lovelace and original Boost authors (see below)
|
// Copyright: (c) Jesse Lovelace and original Boost authors (see below)
|
||||||
@@ -26,10 +25,11 @@
|
|||||||
// See http://www.boost.org/libs/smart_ptr/scoped_ptr.htm for documentation.
|
// See http://www.boost.org/libs/smart_ptr/scoped_ptr.htm for documentation.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef __WX_SCOPED_POINTER__
|
#ifndef _WX_SCOPED_PTR_H_
|
||||||
#define __WX_SCOPED_POINTER__
|
#define _WX_SCOPED_PTR_H_
|
||||||
|
|
||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
|
#include "wx/checkeddelete.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxScopedPtr: A scoped pointer
|
// wxScopedPtr: A scoped pointer
|
||||||
@@ -99,90 +99,10 @@ private:
|
|||||||
DECLARE_NO_COPY_TEMPLATE_CLASS(wxScopedPtr, T)
|
DECLARE_NO_COPY_TEMPLATE_CLASS(wxScopedPtr, T)
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// wxScopedArray: A scoped array
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
class wxScopedArray
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef T element_type;
|
|
||||||
|
|
||||||
wxEXPLICIT wxScopedArray(T * array = NULL) : m_array(array) { }
|
|
||||||
|
|
||||||
~wxScopedArray() { delete [] m_array; }
|
|
||||||
|
|
||||||
// test for pointer validity: defining conversion to unspecified_bool_type
|
|
||||||
// and not more obvious bool to avoid implicit conversions to integer types
|
|
||||||
typedef T *(wxScopedArray<T>::*unspecified_bool_type)() const;
|
|
||||||
operator unspecified_bool_type() const
|
|
||||||
{
|
|
||||||
return m_array ? &wxScopedArray<T>::get : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset(T *array = NULL)
|
|
||||||
{
|
|
||||||
if ( array != m_array )
|
|
||||||
{
|
|
||||||
delete m_array;
|
|
||||||
m_array = array;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
T& operator[](size_t n) const { return m_array[n]; }
|
|
||||||
|
|
||||||
T *get() const { return m_array; }
|
|
||||||
|
|
||||||
void swap(wxScopedArray &other)
|
|
||||||
{
|
|
||||||
T * const tmp = other.m_array;
|
|
||||||
other.m_array = m_array;
|
|
||||||
m_array = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
T *m_array;
|
|
||||||
|
|
||||||
DECLARE_NO_COPY_TEMPLATE_CLASS(wxScopedArray, T)
|
|
||||||
};
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// old macro based implementation
|
// old macro based implementation
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/*
|
|
||||||
checked deleters are used to make sure that the type being deleted is really
|
|
||||||
a complete type.: otherwise sizeof() would result in a compile-time error
|
|
||||||
|
|
||||||
do { ... } while ( 0 ) construct is used to have an anonymous scope
|
|
||||||
(otherwise we could have name clashes between different "complete"s) but
|
|
||||||
still force a semicolon after the macro
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __WATCOMC__
|
|
||||||
#define wxFOR_ONCE(name) for(int name=0; name<1; name++)
|
|
||||||
#define wxPRE_NO_WARNING_SCOPE(name) wxFOR_ONCE(wxMAKE_UNIQUE_NAME(name))
|
|
||||||
#define wxPOST_NO_WARNING_SCOPE(name)
|
|
||||||
#else
|
|
||||||
#define wxPRE_NO_WARNING_SCOPE(name) do
|
|
||||||
#define wxPOST_NO_WARNING_SCOPE(name) while ( wxFalse )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define wxCHECKED_DELETE(ptr) \
|
|
||||||
wxPRE_NO_WARNING_SCOPE(scope_var1) \
|
|
||||||
{ \
|
|
||||||
typedef char complete[sizeof(*ptr)]; \
|
|
||||||
delete ptr; \
|
|
||||||
} wxPOST_NO_WARNING_SCOPE(scope_var1)
|
|
||||||
|
|
||||||
#define wxCHECKED_DELETE_ARRAY(ptr) \
|
|
||||||
wxPRE_NO_WARNING_SCOPE(scope_var2) \
|
|
||||||
{ \
|
|
||||||
typedef char complete[sizeof(*ptr)]; \
|
|
||||||
delete [] ptr; \
|
|
||||||
} wxPOST_NO_WARNING_SCOPE(scope_var2)
|
|
||||||
|
|
||||||
/* The type being used *must* be complete at the time
|
/* The type being used *must* be complete at the time
|
||||||
that wxDEFINE_SCOPED_* is called or a compiler error will result.
|
that wxDEFINE_SCOPED_* is called or a compiler error will result.
|
||||||
This is because the class checks for the completeness of the type
|
This is because the class checks for the completeness of the type
|
||||||
@@ -257,55 +177,6 @@ name::~name() \
|
|||||||
wxDECLARE_SCOPED_PTR(T, T ## Ptr) \
|
wxDECLARE_SCOPED_PTR(T, T ## Ptr) \
|
||||||
wxDEFINE_SCOPED_PTR(T, T ## Ptr)
|
wxDEFINE_SCOPED_PTR(T, T ## Ptr)
|
||||||
|
|
||||||
// the same but for arrays instead of simple pointers
|
|
||||||
#define wxDECLARE_SCOPED_ARRAY(T, name)\
|
|
||||||
class name \
|
|
||||||
{ \
|
|
||||||
private: \
|
|
||||||
T * m_ptr; \
|
|
||||||
name(name const &); \
|
|
||||||
name & operator=(name const &); \
|
|
||||||
\
|
|
||||||
public: \
|
|
||||||
wxEXPLICIT name(T * p = NULL) : m_ptr(p) \
|
|
||||||
{} \
|
|
||||||
\
|
|
||||||
~name(); \
|
|
||||||
void reset(T * p = NULL); \
|
|
||||||
\
|
|
||||||
T & operator[](long int i) const\
|
|
||||||
{ \
|
|
||||||
wxASSERT(m_ptr != NULL); \
|
|
||||||
wxASSERT(i >= 0); \
|
|
||||||
return m_ptr[i]; \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
T * get() const \
|
|
||||||
{ \
|
|
||||||
return m_ptr; \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
void swap(name & ot) \
|
|
||||||
{ \
|
|
||||||
T * tmp = ot.m_ptr; \
|
|
||||||
ot.m_ptr = m_ptr; \
|
|
||||||
m_ptr = tmp; \
|
|
||||||
} \
|
|
||||||
};
|
|
||||||
|
|
||||||
#define wxDEFINE_SCOPED_ARRAY(T, name) \
|
|
||||||
name::~name() \
|
|
||||||
{ \
|
|
||||||
wxCHECKED_DELETE_ARRAY(m_ptr); \
|
|
||||||
} \
|
|
||||||
void name::reset(T * p){ \
|
|
||||||
if (m_ptr != p) \
|
|
||||||
{ \
|
|
||||||
wxCHECKED_DELETE_ARRAY(m_ptr); \
|
|
||||||
m_ptr = p; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// "Tied" scoped pointer: same as normal one but also sets the value of
|
// "Tied" scoped pointer: same as normal one but also sets the value of
|
||||||
// some other variable to the pointer value
|
// some other variable to the pointer value
|
||||||
@@ -333,5 +204,5 @@ void name::reset(T * p){ \
|
|||||||
T *m_pOld; \
|
T *m_pOld; \
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __WX_SCOPED_POINTER__
|
#endif // _WX_SCOPED_PTR_H_
|
||||||
|
|
@@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: wx/ptr_shrd.h
|
// Name: wx/sharedptr.h
|
||||||
// Purpose: Shared pointer based on the counted_ptr<> template, which
|
// Purpose: Shared pointer based on the counted_ptr<> template, which
|
||||||
// is in the public domain
|
// is in the public domain
|
||||||
// Author: Robert Roebling, Yonat Sharon
|
// Author: Robert Roebling, Yonat Sharon
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef _WX_SHARED_PTRH__
|
#ifndef _WX_SHAREDPTR_H_
|
||||||
#define _WX_SHARED_PTRH__
|
#define _WX_SHAREDPTR_H_
|
||||||
|
|
||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
#include "wx/atomic.h"
|
#include "wx/atomic.h"
|
||||||
@@ -138,6 +138,4 @@ bool operator != (wxSharedPtr<T> const &a, wxSharedPtr<U> const &b )
|
|||||||
return a.get() != b.get();
|
return a.get() != b.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // _WX_SHAREDPTR_H_
|
||||||
|
|
||||||
#endif // _WX_SHARED_PTRH__
|
|
172
interface/wx/scopedarray.h
Normal file
172
interface/wx/scopedarray.h
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: wx/scopedarray.h
|
||||||
|
// Purpose: interface of wxScopedArray
|
||||||
|
// Author: wxWidgets team
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Licence: wxWindows license
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
@class wxScopedArray
|
||||||
|
|
||||||
|
This is a simple scoped smart pointer array implementation that is similar to
|
||||||
|
the Boost smart pointers (see http://www.boost.org/) but rewritten to
|
||||||
|
use macros instead.
|
||||||
|
|
||||||
|
@b Example:
|
||||||
|
|
||||||
|
Below is an example of using a wxWidgets scoped smart pointer and pointer array.
|
||||||
|
|
||||||
|
@code
|
||||||
|
class MyClass { ... };
|
||||||
|
|
||||||
|
// declare a smart pointer to a MyClass called wxMyClassPtr
|
||||||
|
wxDECLARE_SCOPED_PTR(MyClass, wxMyClassPtr)
|
||||||
|
// declare a smart pointer to an array of chars
|
||||||
|
wxDECLARE_SCOPED_ARRAY(char, wxCharArray)
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
// define the first pointer class, must be complete
|
||||||
|
wxDEFINE_SCOPED_PTR(MyClass, wxMyClassPtr)
|
||||||
|
// define the second pointer class
|
||||||
|
wxDEFINE_SCOPED_ARRAY(char, wxCharArray)
|
||||||
|
|
||||||
|
// create an object with a new pointer to MyClass
|
||||||
|
wxMyClassPtr theObj(new MyClass());
|
||||||
|
// reset the pointer (deletes the previous one)
|
||||||
|
theObj.reset(new MyClass());
|
||||||
|
|
||||||
|
// access the pointer
|
||||||
|
theObj->MyFunc();
|
||||||
|
|
||||||
|
// create an object with a new array of chars
|
||||||
|
wxCharArray theCharObj(new char[100]);
|
||||||
|
|
||||||
|
// access the array
|
||||||
|
theCharObj[0] = "!";
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
<b>Declaring new smart pointer types:</b>
|
||||||
|
@code
|
||||||
|
wxDECLAR_SCOPED_ARRAY( TYPE, // type of the values
|
||||||
|
CLASSNAME ); // name of the class
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
A smart pointer holds a pointer to an object (which must be complete when
|
||||||
|
wxDEFINE_SCOPED_ARRAY() is called).
|
||||||
|
|
||||||
|
The memory used by the object is deleted when the smart pointer goes out of
|
||||||
|
scope. The first argument of the macro is the pointer type, the second is the
|
||||||
|
name of the new smart pointer class being created. Below we will use wxScopedArray
|
||||||
|
to represent the scoped pointer array class, but the user may create the class with
|
||||||
|
any legal name.
|
||||||
|
|
||||||
|
@library{wxbase}
|
||||||
|
@category{smartpointers}
|
||||||
|
|
||||||
|
@see wxScopedPtr
|
||||||
|
*/
|
||||||
|
class wxScopedArray
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
Creates the smart pointer with the given pointer or none if @NULL. On
|
||||||
|
compilers that support it, this uses the explicit keyword.
|
||||||
|
*/
|
||||||
|
wxScopedArray(type* T = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
This operator gets the pointer stored in the smart pointer or returns @NULL if
|
||||||
|
there is none.
|
||||||
|
*/
|
||||||
|
const T* get();
|
||||||
|
|
||||||
|
/**
|
||||||
|
This operator acts like the standard [] indexing operator for C++ arrays. The
|
||||||
|
function does not do bounds checking.
|
||||||
|
*/
|
||||||
|
const T& operator [](long int i);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Deletes the currently held pointer and sets it to 'p' or to @NULL if no
|
||||||
|
arguments are specified. This function does check to make sure that the
|
||||||
|
pointer you are assigning is not the same pointer that is already stored.
|
||||||
|
*/
|
||||||
|
reset(T* p = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Swap the pointer inside the smart pointer with @a ot. The pointer being swapped
|
||||||
|
must be of the same type (hence the same class name).
|
||||||
|
*/
|
||||||
|
swap(wxScopedArray& ot);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
A scoped array template class.
|
||||||
|
|
||||||
|
This class is similar to boost scoped_array class:
|
||||||
|
http://www.boost.org/doc/libs/1_37_0/libs/smart_ptr/scoped_array.htm
|
||||||
|
|
||||||
|
Notice that objects of this class intentionally cannot be copied.
|
||||||
|
|
||||||
|
@library{wxbase}
|
||||||
|
@category{smartpointers}
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
class wxScopedArray
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/// The type of the array elements.
|
||||||
|
typedef T element_type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Constructor takes ownership of the given array.
|
||||||
|
|
||||||
|
If @a array is @NULL, reset() must presumably be called later.
|
||||||
|
|
||||||
|
@param array
|
||||||
|
An array allocated using @c new[] or @NULL.
|
||||||
|
*/
|
||||||
|
explicit wxScopedArray(T * array = NULL);
|
||||||
|
|
||||||
|
/// Destructor destroy the array.
|
||||||
|
~wxScopedArray();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Conversion to a boolean expression (in a variant which is not
|
||||||
|
convertible to anything but a boolean expression).
|
||||||
|
|
||||||
|
If this class contains a valid array it will return @true, if it contains
|
||||||
|
a @NULL pointer it will return @false.
|
||||||
|
*/
|
||||||
|
operator unspecified_bool_type() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Change the array pointer stored.
|
||||||
|
|
||||||
|
The previously stored array is deleted.
|
||||||
|
|
||||||
|
@param array
|
||||||
|
An array allocated using @c new[] or @NULL.
|
||||||
|
*/
|
||||||
|
void reset(T *array = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return the n-th element of the array.
|
||||||
|
|
||||||
|
Must not be called if the array has no valid pointer.
|
||||||
|
*/
|
||||||
|
T& operator[](size_t n) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return the array pointer.
|
||||||
|
|
||||||
|
The returned pointer may be @NULL. It must not be deleted by the
|
||||||
|
caller, call @c reset(NULL) instead.
|
||||||
|
*/
|
||||||
|
T *get() const;
|
||||||
|
|
||||||
|
/// Swaps the contents of this array with another one.
|
||||||
|
void swap(wxScopedArray &other);
|
||||||
|
};
|
@@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: ptr_scpd.h
|
// Name: wx/scopedptr.h
|
||||||
// Purpose: interface of wxScopedPtr
|
// Purpose: interface of wxScopedPtr
|
||||||
// Author: wxWidgets team
|
// Author: wxWidgets team
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
@@ -152,106 +152,6 @@ public:
|
|||||||
swap(wxScopedPtr& other);
|
swap(wxScopedPtr& other);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
@class wxScopedArray
|
|
||||||
|
|
||||||
This is a simple scoped smart pointer array implementation that is similar to
|
|
||||||
the Boost smart pointers (see http://www.boost.org/) but rewritten to
|
|
||||||
use macros instead.
|
|
||||||
|
|
||||||
@b Example:
|
|
||||||
|
|
||||||
Below is an example of using a wxWidgets scoped smart pointer and pointer array.
|
|
||||||
|
|
||||||
@code
|
|
||||||
class MyClass { ... };
|
|
||||||
|
|
||||||
// declare a smart pointer to a MyClass called wxMyClassPtr
|
|
||||||
wxDECLARE_SCOPED_PTR(MyClass, wxMyClassPtr)
|
|
||||||
// declare a smart pointer to an array of chars
|
|
||||||
wxDECLARE_SCOPED_ARRAY(char, wxCharArray)
|
|
||||||
|
|
||||||
...
|
|
||||||
|
|
||||||
// define the first pointer class, must be complete
|
|
||||||
wxDEFINE_SCOPED_PTR(MyClass, wxMyClassPtr)
|
|
||||||
// define the second pointer class
|
|
||||||
wxDEFINE_SCOPED_ARRAY(char, wxCharArray)
|
|
||||||
|
|
||||||
// create an object with a new pointer to MyClass
|
|
||||||
wxMyClassPtr theObj(new MyClass());
|
|
||||||
// reset the pointer (deletes the previous one)
|
|
||||||
theObj.reset(new MyClass());
|
|
||||||
|
|
||||||
// access the pointer
|
|
||||||
theObj->MyFunc();
|
|
||||||
|
|
||||||
// create an object with a new array of chars
|
|
||||||
wxCharArray theCharObj(new char[100]);
|
|
||||||
|
|
||||||
// access the array
|
|
||||||
theCharObj[0] = "!";
|
|
||||||
@endcode
|
|
||||||
|
|
||||||
<b>Declaring new smart pointer types:</b>
|
|
||||||
@code
|
|
||||||
wxDECLAR_SCOPED_ARRAY( TYPE, // type of the values
|
|
||||||
CLASSNAME ); // name of the class
|
|
||||||
@endcode
|
|
||||||
|
|
||||||
A smart pointer holds a pointer to an object (which must be complete when
|
|
||||||
wxDEFINE_SCOPED_ARRAY() is called).
|
|
||||||
|
|
||||||
The memory used by the object is deleted when the smart pointer goes out of
|
|
||||||
scope. The first argument of the macro is the pointer type, the second is the
|
|
||||||
name of the new smart pointer class being created. Below we will use wxScopedArray
|
|
||||||
to represent the scoped pointer array class, but the user may create the class with
|
|
||||||
any legal name.
|
|
||||||
|
|
||||||
@library{wxbase}
|
|
||||||
@category{smartpointers}
|
|
||||||
|
|
||||||
@see wxScopedPtr
|
|
||||||
*/
|
|
||||||
class wxScopedArray
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
Creates the smart pointer with the given pointer or none if @NULL. On
|
|
||||||
compilers that support it, this uses the explicit keyword.
|
|
||||||
*/
|
|
||||||
wxScopedArray(type* T = NULL);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This operator gets the pointer stored in the smart pointer or returns @NULL if
|
|
||||||
there is none.
|
|
||||||
*/
|
|
||||||
const T* get();
|
|
||||||
|
|
||||||
/**
|
|
||||||
This operator acts like the standard [] indexing operator for C++ arrays. The
|
|
||||||
function does not do bounds checking.
|
|
||||||
*/
|
|
||||||
const T& operator [](long int i);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Deletes the currently held pointer and sets it to 'p' or to @NULL if no
|
|
||||||
arguments are specified. This function does check to make sure that the
|
|
||||||
pointer you are assigning is not the same pointer that is already stored.
|
|
||||||
*/
|
|
||||||
reset(T* p = NULL);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Swap the pointer inside the smart pointer with @a ot. The pointer being swapped
|
|
||||||
must be of the same type (hence the same class name).
|
|
||||||
*/
|
|
||||||
swap(wxScopedPtr& ot);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class wxScopedTiedPtr
|
@class wxScopedTiedPtr
|
||||||
|
|
||||||
@@ -289,7 +189,6 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
A scoped pointer template class.
|
A scoped pointer template class.
|
||||||
|
|
||||||
It is the template version of the old-style @ref wxScopedPtr "scoped pointer macros".
|
It is the template version of the old-style @ref wxScopedPtr "scoped pointer macros".
|
||||||
@@ -368,71 +267,3 @@ public:
|
|||||||
void swap(wxScopedPtr<T>& ot);
|
void swap(wxScopedPtr<T>& ot);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
A scoped array template class.
|
|
||||||
|
|
||||||
This class is similar to boost scoped_array class:
|
|
||||||
http://www.boost.org/doc/libs/1_37_0/libs/smart_ptr/scoped_array.htm
|
|
||||||
|
|
||||||
Notice that objects of this class intentionally cannot be copied.
|
|
||||||
|
|
||||||
@library{wxbase}
|
|
||||||
@category{smartpointers}
|
|
||||||
*/
|
|
||||||
template <class T>
|
|
||||||
class wxScopedArray
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// The type of the array elements.
|
|
||||||
typedef T element_type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructor takes ownership of the given array.
|
|
||||||
|
|
||||||
If @a array is @NULL, reset() must presumably be called later.
|
|
||||||
|
|
||||||
@param array
|
|
||||||
An array allocated using @c new[] or @NULL.
|
|
||||||
*/
|
|
||||||
explicit wxScopedArray(T * array = NULL);
|
|
||||||
|
|
||||||
/// Destructor destroy the array.
|
|
||||||
~wxScopedArray();
|
|
||||||
|
|
||||||
/**
|
|
||||||
Conversion to a boolean expression (in a variant which is not
|
|
||||||
convertible to anything but a boolean expression).
|
|
||||||
|
|
||||||
If this class contains a valid array it will return @true, if it contains
|
|
||||||
a @NULL pointer it will return @false.
|
|
||||||
*/
|
|
||||||
operator unspecified_bool_type() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Change the array pointer stored.
|
|
||||||
|
|
||||||
The previously stored array is deleted.
|
|
||||||
|
|
||||||
@param array
|
|
||||||
An array allocated using @c new[] or @NULL.
|
|
||||||
*/
|
|
||||||
void reset(T *array = NULL);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Return the n-th element of the array.
|
|
||||||
|
|
||||||
Must not be called if the array has no valid pointer.
|
|
||||||
*/
|
|
||||||
T& operator[](size_t n) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Return the array pointer.
|
|
||||||
|
|
||||||
The returned pointer may be @NULL. It must not be deleted by the
|
|
||||||
caller, call @c reset(NULL) instead.
|
|
||||||
*/
|
|
||||||
T *get() const;
|
|
||||||
|
|
||||||
/// Swaps the contents of this array with another one.
|
|
||||||
void swap(wxScopedArray &other);
|
|
||||||
};
|
|
@@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: ptr_shrd.h
|
// Name: sharedptr.h
|
||||||
// Purpose: interface of wxSharedPtr<T>
|
// Purpose: interface of wxSharedPtr<T>
|
||||||
// Author: wxWidgets team
|
// Author: wxWidgets team
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
@@ -7,17 +7,16 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
A smart pointer with non-intrusive reference counting.
|
||||||
|
|
||||||
A smart pointer with non-intrusive reference counting. It is modeled after
|
It is modeled after @c boost::shared_ptr<> and can be used with STL
|
||||||
@c boost::shared_ptr<> and can be used with STL containers and wxVector<T> -
|
containers and wxVector<T> unlike @c std::auto_ptr<> and wxScopedPtr<T>.
|
||||||
unlike @c std::auto_ptr<> and wxScopedPtr<T>.
|
|
||||||
|
|
||||||
@library{wxbase}
|
@library{wxbase}
|
||||||
@category{smartpointers}
|
@category{smartpointers}
|
||||||
|
|
||||||
@see wxScopedPtr<T>, wxWeakRef<T>, wxObjectDataPtr<T>
|
@see wxScopedPtr<T>, wxWeakRef<T>, wxObjectDataPtr<T>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class wxSharedPtr<T>
|
class wxSharedPtr<T>
|
||||||
{
|
{
|
||||||
@@ -47,7 +46,7 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Conversion to a boolean expression (in a variant which is not
|
Conversion to a boolean expression (in a variant which is not
|
||||||
convertable to anything but a boolean expression).
|
convertible to anything but a boolean expression).
|
||||||
|
|
||||||
If this class contains a valid pointer it will return @true, if it contains
|
If this class contains a valid pointer it will return @true, if it contains
|
||||||
a @NULL pointer it will return @false.
|
a @NULL pointer it will return @false.
|
@@ -42,7 +42,7 @@
|
|||||||
#include "wx/evtloop.h"
|
#include "wx/evtloop.h"
|
||||||
#include "wx/filename.h"
|
#include "wx/filename.h"
|
||||||
#include "wx/msgout.h"
|
#include "wx/msgout.h"
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/scopedptr.h"
|
||||||
#include "wx/tokenzr.h"
|
#include "wx/tokenzr.h"
|
||||||
#include "wx/thread.h"
|
#include "wx/thread.h"
|
||||||
|
|
||||||
|
@@ -58,7 +58,8 @@
|
|||||||
#include "wx/filename.h"
|
#include "wx/filename.h"
|
||||||
#include "wx/stdpaths.h"
|
#include "wx/stdpaths.h"
|
||||||
#include "wx/vector.h"
|
#include "wx/vector.h"
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/scopedarray.h"
|
||||||
|
#include "wx/scopedptr.h"
|
||||||
|
|
||||||
#if wxUSE_STD_IOSTREAM
|
#if wxUSE_STD_IOSTREAM
|
||||||
#include "wx/ioswrap.h"
|
#include "wx/ioswrap.h"
|
||||||
|
@@ -47,7 +47,7 @@
|
|||||||
#include "wx/thread.h"
|
#include "wx/thread.h"
|
||||||
|
|
||||||
#if wxUSE_BASE
|
#if wxUSE_BASE
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/scopedptr.h"
|
||||||
|
|
||||||
wxDECLARE_SCOPED_PTR(wxEvent, wxEventPtr)
|
wxDECLARE_SCOPED_PTR(wxEvent, wxEventPtr)
|
||||||
wxDEFINE_SCOPED_PTR(wxEvent, wxEventPtr)
|
wxDEFINE_SCOPED_PTR(wxEvent, wxEventPtr)
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/scopedptr.h"
|
||||||
|
|
||||||
wxDEFINE_SCOPED_PTR_TYPE(wxFSFile)
|
wxDEFINE_SCOPED_PTR_TYPE(wxFSFile)
|
||||||
wxDEFINE_SCOPED_PTR_TYPE(wxInputStream)
|
wxDEFINE_SCOPED_PTR_TYPE(wxInputStream)
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "wx/gifdecod.h"
|
#include "wx/gifdecod.h"
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/scopedptr.h"
|
||||||
#include "wx/scopeguard.h"
|
#include "wx/scopeguard.h"
|
||||||
|
|
||||||
|
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
#include "wx/init.h"
|
#include "wx/init.h"
|
||||||
#include "wx/thread.h"
|
#include "wx/thread.h"
|
||||||
|
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/scopedptr.h"
|
||||||
#include "wx/except.h"
|
#include "wx/except.h"
|
||||||
|
|
||||||
#if defined(__WXMSW__) && defined(__WXDEBUG__)
|
#if defined(__WXMSW__) && defined(__WXDEBUG__)
|
||||||
|
@@ -66,7 +66,7 @@
|
|||||||
#include "wx/tokenzr.h"
|
#include "wx/tokenzr.h"
|
||||||
#include "wx/fontmap.h"
|
#include "wx/fontmap.h"
|
||||||
#include "wx/encconv.h"
|
#include "wx/encconv.h"
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/scopedptr.h"
|
||||||
#include "wx/apptrait.h"
|
#include "wx/apptrait.h"
|
||||||
#include "wx/stdpaths.h"
|
#include "wx/stdpaths.h"
|
||||||
#include "wx/hashset.h"
|
#include "wx/hashset.h"
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
#include "wx/apptrait.h"
|
#include "wx/apptrait.h"
|
||||||
#include "wx/renderer.h"
|
#include "wx/renderer.h"
|
||||||
|
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/scopedptr.h"
|
||||||
|
|
||||||
#if wxUSE_DYNLIB_CLASS
|
#if wxUSE_DYNLIB_CLASS
|
||||||
#include "wx/dynlib.h"
|
#include "wx/dynlib.h"
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include "wx/buffer.h"
|
#include "wx/buffer.h"
|
||||||
#include "wx/datetime.h"
|
#include "wx/datetime.h"
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/scopedptr.h"
|
||||||
#include "wx/filename.h"
|
#include "wx/filename.h"
|
||||||
#include "wx/thread.h"
|
#include "wx/thread.h"
|
||||||
|
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
#include "wx/datstrm.h"
|
#include "wx/datstrm.h"
|
||||||
#include "wx/zstream.h"
|
#include "wx/zstream.h"
|
||||||
#include "wx/mstream.h"
|
#include "wx/mstream.h"
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/scopedptr.h"
|
||||||
#include "wx/wfstream.h"
|
#include "wx/wfstream.h"
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
|
|
||||||
|
@@ -29,13 +29,12 @@
|
|||||||
#include "wx/dataobj.h"
|
#include "wx/dataobj.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/scopedarray.h"
|
||||||
#include "wx/scopeguard.h"
|
#include "wx/scopeguard.h"
|
||||||
|
|
||||||
#include "wx/gtk/private.h"
|
#include "wx/gtk/private.h"
|
||||||
|
|
||||||
wxDECLARE_SCOPED_ARRAY(wxDataFormat, wxDataFormatArray)
|
typedef wxScopedArray<wxDataFormat> wxDataFormatArray;
|
||||||
wxDEFINE_SCOPED_ARRAY(wxDataFormat, wxDataFormatArray)
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// data
|
// data
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include "wx/evtloop.h"
|
#include "wx/evtloop.h"
|
||||||
|
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/scopedptr.h"
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
@@ -32,7 +32,9 @@
|
|||||||
#include "wx/dataobj.h"
|
#include "wx/dataobj.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/scopedarray.h"
|
||||||
|
|
||||||
|
typedef wxScopedArray<wxDataFormat> wxDataFormatScopedArray;
|
||||||
|
|
||||||
#ifdef __VMS__
|
#ifdef __VMS__
|
||||||
#pragma message disable nosimpint
|
#pragma message disable nosimpint
|
||||||
@@ -233,9 +235,6 @@ bool wxClipboard::SetData( wxDataObject *data )
|
|||||||
return AddData( data );
|
return AddData( data );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDECLARE_SCOPED_ARRAY( wxDataFormat, wxDataFormatScopedArray )
|
|
||||||
wxDEFINE_SCOPED_ARRAY( wxDataFormat, wxDataFormatScopedArray )
|
|
||||||
|
|
||||||
#if wxCHECK_LESSTIF()
|
#if wxCHECK_LESSTIF()
|
||||||
void wxClipboardCallback( Widget xwidget, int* data_id,
|
void wxClipboardCallback( Widget xwidget, int* data_id,
|
||||||
int* priv, int* WXUNUSED(reason) )
|
int* priv, int* WXUNUSED(reason) )
|
||||||
|
@@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
#include "wx/msw/private.h"
|
#include "wx/msw/private.h"
|
||||||
#include "wx/evtloop.h"
|
#include "wx/evtloop.h"
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/scopedptr.h"
|
||||||
|
|
||||||
#if defined(__SMARTPHONE__) && defined(__WXWINCE__)
|
#if defined(__SMARTPHONE__) && defined(__WXWINCE__)
|
||||||
#include "wx/msw/wince/resources.h"
|
#include "wx/msw/wince/resources.h"
|
||||||
|
@@ -34,7 +34,6 @@
|
|||||||
#include "wx/evtloop.h"
|
#include "wx/evtloop.h"
|
||||||
#include "wx/thread.h"
|
#include "wx/thread.h"
|
||||||
#include "wx/except.h"
|
#include "wx/except.h"
|
||||||
#include "wx/ptr_scpd.h"
|
|
||||||
#include "wx/msw/private.h"
|
#include "wx/msw/private.h"
|
||||||
|
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
|
@@ -39,7 +39,7 @@
|
|||||||
#include "wx/ownerdrw.h"
|
#include "wx/ownerdrw.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/scopedarray.h"
|
||||||
|
|
||||||
#include "wx/msw/private.h"
|
#include "wx/msw/private.h"
|
||||||
#include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly"
|
#include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly"
|
||||||
|
@@ -46,7 +46,7 @@
|
|||||||
#include "wx/artprov.h"
|
#include "wx/artprov.h"
|
||||||
#include "wx/sysopt.h"
|
#include "wx/sysopt.h"
|
||||||
#include "wx/dcclient.h"
|
#include "wx/dcclient.h"
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/scopedarray.h"
|
||||||
|
|
||||||
#include "wx/msw/private.h"
|
#include "wx/msw/private.h"
|
||||||
#include "wx/msw/dc.h"
|
#include "wx/msw/dc.h"
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include "wx/os2/private.h"
|
#include "wx/os2/private.h"
|
||||||
#include "wx/evtloop.h"
|
#include "wx/evtloop.h"
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/scopedptr.h"
|
||||||
|
|
||||||
#define wxDIALOG_DEFAULT_X 300
|
#define wxDIALOG_DEFAULT_X 300
|
||||||
#define wxDIALOG_DEFAULT_Y 300
|
#define wxDIALOG_DEFAULT_Y 300
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#include "wx/evtloop.h"
|
#include "wx/evtloop.h"
|
||||||
#include "wx/tooltip.h"
|
#include "wx/tooltip.h"
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/scopedptr.h"
|
||||||
|
|
||||||
#include "wx/os2/private.h"
|
#include "wx/os2/private.h"
|
||||||
#include "wx/os2/private/timer.h" // for wxTimerProc
|
#include "wx/os2/private/timer.h" // for wxTimerProc
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/evtloop.h"
|
#include "wx/evtloop.h"
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/scopedptr.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxWin macros
|
// wxWin macros
|
||||||
|
@@ -33,7 +33,6 @@
|
|||||||
|
|
||||||
#include "wx/tooltip.h"
|
#include "wx/tooltip.h"
|
||||||
#include "wx/except.h"
|
#include "wx/except.h"
|
||||||
#include "wx/ptr_scpd.h"
|
|
||||||
|
|
||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
#include "wx/thread.h"
|
#include "wx/thread.h"
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
#include "wx/datstrm.h"
|
#include "wx/datstrm.h"
|
||||||
#include "wx/zstream.h"
|
#include "wx/zstream.h"
|
||||||
#include "wx/strconv.h"
|
#include "wx/strconv.h"
|
||||||
#include "wx/ptr_scpd.h"
|
#include "wx/scopedptr.h"
|
||||||
|
|
||||||
#include "expat.h" // from Expat
|
#include "expat.h" // from Expat
|
||||||
|
|
||||||
|
@@ -217,6 +217,7 @@ wx/beforestd.h
|
|||||||
wx/buffer.h
|
wx/buffer.h
|
||||||
wx/build.h
|
wx/build.h
|
||||||
wx/chartype.h
|
wx/chartype.h
|
||||||
|
wx/checkeddelete.h
|
||||||
wx/chkconf.h
|
wx/chkconf.h
|
||||||
wx/clntdata.h
|
wx/clntdata.h
|
||||||
wx/cmdargs.h
|
wx/cmdargs.h
|
||||||
@@ -290,7 +291,10 @@ wx/ptr_scpd.h
|
|||||||
wx/ptr_shrd.h
|
wx/ptr_shrd.h
|
||||||
wx/recguard.h
|
wx/recguard.h
|
||||||
wx/regex.h
|
wx/regex.h
|
||||||
|
wx/scopedarray.h
|
||||||
|
wx/scopedptr.h
|
||||||
wx/scopeguard.h
|
wx/scopeguard.h
|
||||||
|
wx/sharedptr.h
|
||||||
wx/snglinst.h
|
wx/snglinst.h
|
||||||
wx/sstream.h
|
wx/sstream.h
|
||||||
wx/stack.h
|
wx/stack.h
|
||||||
@@ -341,8 +345,6 @@ wx/meta/convertible.h
|
|||||||
wx/meta/if.h
|
wx/meta/if.h
|
||||||
wx/meta/int2type.h
|
wx/meta/int2type.h
|
||||||
wx/meta/movable.h
|
wx/meta/movable.h
|
||||||
wx/private/fdiodispatcher.h
|
|
||||||
wx/private/selectdispatcher.h
|
|
||||||
wx/unix/app.h
|
wx/unix/app.h
|
||||||
wx/unix/apptbase.h
|
wx/unix/apptbase.h
|
||||||
wx/unix/apptrait.h
|
wx/unix/apptrait.h
|
||||||
|
@@ -122,6 +122,7 @@ wx/beforestd.h
|
|||||||
wx/buffer.h
|
wx/buffer.h
|
||||||
wx/build.h
|
wx/build.h
|
||||||
wx/chartype.h
|
wx/chartype.h
|
||||||
|
wx/checkeddelete.h
|
||||||
wx/chkconf.h
|
wx/chkconf.h
|
||||||
wx/clntdata.h
|
wx/clntdata.h
|
||||||
wx/cmdargs.h
|
wx/cmdargs.h
|
||||||
@@ -195,7 +196,10 @@ wx/ptr_scpd.h
|
|||||||
wx/ptr_shrd.h
|
wx/ptr_shrd.h
|
||||||
wx/recguard.h
|
wx/recguard.h
|
||||||
wx/regex.h
|
wx/regex.h
|
||||||
|
wx/scopedarray.h
|
||||||
|
wx/scopedptr.h
|
||||||
wx/scopeguard.h
|
wx/scopeguard.h
|
||||||
|
wx/sharedptr.h
|
||||||
wx/snglinst.h
|
wx/snglinst.h
|
||||||
wx/sstream.h
|
wx/sstream.h
|
||||||
wx/stack.h
|
wx/stack.h
|
||||||
@@ -246,8 +250,6 @@ wx/meta/convertible.h
|
|||||||
wx/meta/if.h
|
wx/meta/if.h
|
||||||
wx/meta/int2type.h
|
wx/meta/int2type.h
|
||||||
wx/meta/movable.h
|
wx/meta/movable.h
|
||||||
wx/private/fdiodispatcher.h
|
|
||||||
wx/private/selectdispatcher.h
|
|
||||||
wx/unix/app.h
|
wx/unix/app.h
|
||||||
wx/unix/apptbase.h
|
wx/unix/apptbase.h
|
||||||
wx/unix/apptrait.h
|
wx/unix/apptrait.h
|
||||||
|
@@ -146,6 +146,7 @@ wx/beforestd.h
|
|||||||
wx/buffer.h
|
wx/buffer.h
|
||||||
wx/build.h
|
wx/build.h
|
||||||
wx/chartype.h
|
wx/chartype.h
|
||||||
|
wx/checkeddelete.h
|
||||||
wx/chkconf.h
|
wx/chkconf.h
|
||||||
wx/clntdata.h
|
wx/clntdata.h
|
||||||
wx/cmdargs.h
|
wx/cmdargs.h
|
||||||
@@ -219,7 +220,10 @@ wx/ptr_scpd.h
|
|||||||
wx/ptr_shrd.h
|
wx/ptr_shrd.h
|
||||||
wx/recguard.h
|
wx/recguard.h
|
||||||
wx/regex.h
|
wx/regex.h
|
||||||
|
wx/scopedarray.h
|
||||||
|
wx/scopedptr.h
|
||||||
wx/scopeguard.h
|
wx/scopeguard.h
|
||||||
|
wx/sharedptr.h
|
||||||
wx/snglinst.h
|
wx/snglinst.h
|
||||||
wx/sstream.h
|
wx/sstream.h
|
||||||
wx/stack.h
|
wx/stack.h
|
||||||
@@ -270,8 +274,6 @@ wx/meta/convertible.h
|
|||||||
wx/meta/if.h
|
wx/meta/if.h
|
||||||
wx/meta/int2type.h
|
wx/meta/int2type.h
|
||||||
wx/meta/movable.h
|
wx/meta/movable.h
|
||||||
wx/private/fdiodispatcher.h
|
|
||||||
wx/private/selectdispatcher.h
|
|
||||||
wx/unix/app.h
|
wx/unix/app.h
|
||||||
wx/unix/apptbase.h
|
wx/unix/apptbase.h
|
||||||
wx/unix/apptrait.h
|
wx/unix/apptrait.h
|
||||||
|
Reference in New Issue
Block a user