123
This commit is contained in:
490
STLPORT/stlport/stl/debug/_debug.c
Normal file
490
STLPORT/stlport/stl/debug/_debug.c
Normal file
@@ -0,0 +1,490 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
# ifndef _STLP_DEBUG_C
|
||||
# define _STLP_DEBUG_C
|
||||
|
||||
#if defined ( _STLP_DEBUG )
|
||||
|
||||
# ifdef _STLP_THREADS
|
||||
# ifndef _STLP_NEED_MUTABLE
|
||||
# define _STLP_ACQUIRE_LOCK(_Lock) _Lock._M_acquire_lock();
|
||||
# define _STLP_RELEASE_LOCK(_Lock) _Lock._M_release_lock();
|
||||
# else
|
||||
# define _STLP_ACQUIRE_LOCK(_Lock) ((_STLP_mutex&)_Lock)._M_acquire_lock();
|
||||
# define _STLP_RELEASE_LOCK(_Lock) ((_STLP_mutex&)_Lock)._M_release_lock();
|
||||
# endif /* _STLP_NEED_MUTABLE */
|
||||
# else
|
||||
# define _STLP_ACQUIRE_LOCK(_Lock)
|
||||
# define _STLP_RELEASE_LOCK(_Lock)
|
||||
# endif /* _STLP_THREADS */
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
//==========================================================
|
||||
// global non-inline functions
|
||||
//==========================================================
|
||||
|
||||
// [ i1, i2)
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL
|
||||
__in_range_aux(const _Iterator& __it, const _Iterator& __first,
|
||||
const _Iterator& __last, const random_access_iterator_tag &) {
|
||||
return ( __it >= __first &&
|
||||
__it < __last);
|
||||
}
|
||||
|
||||
template <class _Iterator1, class _Iterator>
|
||||
# if defined (_STLP_MSVC) && (_STLP_MSVC >= 1100)
|
||||
inline bool _STLP_CALL __in_range_aux(_Iterator1 __it, const _Iterator& __first,
|
||||
# else
|
||||
inline bool _STLP_CALL __in_range_aux(const _Iterator1& __it, const _Iterator& __first,
|
||||
# endif
|
||||
const _Iterator& __last, const forward_iterator_tag &) {
|
||||
_Iterator1 __i(__first);
|
||||
for (; __i != __last && __i != __it; ++__i);
|
||||
return (__i!=__last);
|
||||
}
|
||||
|
||||
# if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
|
||||
template <class _Iterator1, class _Iterator>
|
||||
inline bool _STLP_CALL
|
||||
__in_range_aux(const _Iterator1& __it, const _Iterator& __first,
|
||||
const _Iterator& __last, const bidirectional_iterator_tag &) {
|
||||
_Iterator1 __i(__first);
|
||||
for (; __i != __last && __i != __it; ++__i);
|
||||
return (__i !=__last);
|
||||
}
|
||||
# endif
|
||||
|
||||
template <class _Iterator>
|
||||
bool _STLP_CALL __check_range(const _Iterator& __first, const _Iterator& __last) {
|
||||
_STLP_VERBOSE_RETURN(__valid_range(__first,__last), _StlMsg_INVALID_RANGE )
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
bool _STLP_CALL __check_range(const _Iterator& __it,
|
||||
const _Iterator& __start, const _Iterator& __finish) {
|
||||
_STLP_VERBOSE_RETURN(__in_range(__it,__start, __finish),
|
||||
_StlMsg_NOT_IN_RANGE_1)
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
bool _STLP_CALL __check_range(const _Iterator& __first, const _Iterator& __last,
|
||||
const _Iterator& __start, const _Iterator& __finish) {
|
||||
_STLP_VERBOSE_RETURN(__in_range(__first, __last, __start, __finish),
|
||||
_StlMsg_NOT_IN_RANGE_2)
|
||||
return true;
|
||||
}
|
||||
|
||||
//===============================================================
|
||||
|
||||
template <class _Iterator>
|
||||
void _STLP_CALL __invalidate_range(const __owned_list* __base,
|
||||
const _Iterator& __first,
|
||||
const _Iterator& __last)
|
||||
{
|
||||
typedef _Iterator* _Safe_iterator_ptr;
|
||||
typedef __owned_link _L_type;
|
||||
_STLP_ACQUIRE_LOCK(__base->_M_lock)
|
||||
_L_type* __pos;
|
||||
_L_type* __prev;
|
||||
|
||||
for (__prev = (_L_type*)&__base->_M_node, __pos= (_L_type*)__prev->_M_next;
|
||||
__pos!=0;) {
|
||||
if ((!(&__first == (_Iterator*)__pos || &__last == (_Iterator*)__pos))
|
||||
&& __in_range_aux(
|
||||
*(_Iterator*)__pos,
|
||||
__first,
|
||||
__last,
|
||||
_STLP_ITERATOR_CATEGORY(__first, _Iterator))) {
|
||||
__pos->_M_owner = 0;
|
||||
__pos = (_L_type*) (__prev->_M_next = __pos->_M_next);
|
||||
}
|
||||
else {
|
||||
__prev = __pos;
|
||||
__pos=(_L_type*)__pos->_M_next;
|
||||
}
|
||||
}
|
||||
_STLP_RELEASE_LOCK(__base->_M_lock)
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
void _STLP_CALL __invalidate_iterator(const __owned_list* __base,
|
||||
const _Iterator& __it)
|
||||
{
|
||||
typedef __owned_link _L_type;
|
||||
_L_type* __position, *__prev;
|
||||
_STLP_ACQUIRE_LOCK(__base->_M_lock)
|
||||
for (__prev = (_L_type*)&__base->_M_node, __position = (_L_type*)__prev->_M_next;
|
||||
__position!= 0;) {
|
||||
// this requires safe iterators to be derived from __owned_link
|
||||
if ((__position != (_L_type*)&__it) && *((_Iterator*)__position)==__it) {
|
||||
__position->_M_owner = 0;
|
||||
__position = (_L_type*) (__prev->_M_next = __position->_M_next);
|
||||
}
|
||||
else {
|
||||
__prev = __position;
|
||||
__position=(_L_type*)__position->_M_next;
|
||||
}
|
||||
}
|
||||
_STLP_RELEASE_LOCK(__base->_M_lock)
|
||||
}
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
# endif /* _STLP_DEBUG */
|
||||
|
||||
# if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION)
|
||||
|
||||
// dwa 12/26/99 -- for abort
|
||||
# if defined (_STLP_USE_NEW_C_HEADERS)
|
||||
# include <cstdlib>
|
||||
# else
|
||||
# include <stdlib.h>
|
||||
# endif
|
||||
|
||||
# if defined (_STLP_WIN32)
|
||||
# include <stl/_threads.h>
|
||||
# endif
|
||||
|
||||
//==========================================================
|
||||
// .c section
|
||||
// owned_list non-inline methods and global functions
|
||||
//==========================================================
|
||||
|
||||
#if defined ( _STLP_ASSERTIONS )
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
# ifndef _STLP_STRING_LITERAL
|
||||
# define _STLP_STRING_LITERAL(__x) __x
|
||||
# endif
|
||||
|
||||
# ifdef _STLP_WINCE
|
||||
# define _STLP_PERCENT_S "%hs"
|
||||
# else
|
||||
# define _STLP_PERCENT_S "%s"
|
||||
# endif
|
||||
|
||||
# define _STLP_MESSAGE_TABLE_BODY = { \
|
||||
_STLP_STRING_LITERAL("\n" _STLP_PERCENT_S "(%d): STL error: %s\n"), \
|
||||
_STLP_STRING_LITERAL(_STLP_PERCENT_S "(%d): STL assertion failure : " _STLP_PERCENT_S "\n" _STLP_ASSERT_MSG_TRAILER), \
|
||||
_STLP_STRING_LITERAL("\n" _STLP_PERCENT_S "(%d): STL error : " _STLP_PERCENT_S "\n" _STLP_PERCENT_S "(%d): STL assertion failure: " _STLP_PERCENT_S " \n" _STLP_ASSERT_MSG_TRAILER), \
|
||||
_STLP_STRING_LITERAL("Invalid argument to operation (see operation documentation)"), \
|
||||
_STLP_STRING_LITERAL("Taking an iterator out of destroyed (or otherwise corrupted) container"), \
|
||||
_STLP_STRING_LITERAL("Trying to extract an object out from empty container"),\
|
||||
_STLP_STRING_LITERAL("Past-the-end iterator could not be erased"), \
|
||||
_STLP_STRING_LITERAL("Index out of bounds"), \
|
||||
_STLP_STRING_LITERAL("Container doesn't own the iterator"), \
|
||||
_STLP_STRING_LITERAL("Uninitialized or invalidated (by mutating operation) iterator used"), \
|
||||
_STLP_STRING_LITERAL("Uninitialized or invalidated (by mutating operation) lefthand iterator in expression"), \
|
||||
_STLP_STRING_LITERAL("Uninitialized or invalidated (by mutating operation) righthand iterator in expression"), \
|
||||
_STLP_STRING_LITERAL("Iterators used in expression are from different owners"), \
|
||||
_STLP_STRING_LITERAL("Iterator could not be dereferenced (past-the-end ?)"), \
|
||||
_STLP_STRING_LITERAL("Range [first,last) is invalid"), \
|
||||
_STLP_STRING_LITERAL("Iterator is not in range [first,last)"), \
|
||||
_STLP_STRING_LITERAL("Range [first,last) is not in range [start,finish)"), \
|
||||
_STLP_STRING_LITERAL("The advance would produce invalid iterator"), \
|
||||
_STLP_STRING_LITERAL("Iterator is singular (advanced beyond the bounds ?)"), \
|
||||
_STLP_STRING_LITERAL("Memory block deallocated twice"), \
|
||||
_STLP_STRING_LITERAL("Deallocating a block that was never allocated"), \
|
||||
_STLP_STRING_LITERAL("Deallocating a memory block allocated for another type"), \
|
||||
_STLP_STRING_LITERAL("Size of block passed to deallocate() doesn't match block size"), \
|
||||
_STLP_STRING_LITERAL("Pointer underrun - safety margin at front of memory block overwritten"), \
|
||||
_STLP_STRING_LITERAL("Pointer overrrun - safety margin at back of memory block overwritten"), \
|
||||
_STLP_STRING_LITERAL("Attempt to dereference null pointer returned by auto_ptr::get()"), \
|
||||
_STLP_STRING_LITERAL("Unknown problem") \
|
||||
}
|
||||
|
||||
# if ( _STLP_STATIC_TEMPLATE_DATA > 0 )
|
||||
template <class _Dummy>
|
||||
const char* __stl_debug_engine<_Dummy>::_Message_table[_StlMsg_MAX] _STLP_MESSAGE_TABLE_BODY;
|
||||
|
||||
# else
|
||||
__DECLARE_INSTANCE(const char*, __stl_debug_engine<bool>::_Message_table[_StlMsg_MAX],
|
||||
_STLP_MESSAGE_TABLE_BODY);
|
||||
|
||||
# endif
|
||||
|
||||
# undef _STLP_STRING_LITERAL
|
||||
# undef _STLP_PERCENT_S
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
// abort()
|
||||
# include <cstdlib>
|
||||
|
||||
# if !defined( _STLP_DEBUG_MESSAGE )
|
||||
|
||||
# include <cstdarg>
|
||||
# include <cstdio>
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Message(const char * __format_str, ...)
|
||||
{
|
||||
STLPORT_CSTD::va_list __args;
|
||||
va_start( __args, __format_str );
|
||||
|
||||
# if defined (_STLP_WINCE)
|
||||
TCHAR __buffer[512];
|
||||
int _convert = strlen(__format_str) + 1;
|
||||
LPWSTR _lpw = (LPWSTR)alloca(_convert*sizeof(wchar_t));
|
||||
_lpw[0] = '\0';
|
||||
MultiByteToWideChar(GetACP(), 0, __format_str, -1, _lpw, _convert);
|
||||
wvsprintf(__buffer, _lpw, __args);
|
||||
// wvsprintf(__buffer, __format_str, __args);
|
||||
_STLP_WINCE_TRACE(__buffer);
|
||||
# elif defined (_STLP_WIN32) && ( defined(_STLP_MSVC) || defined (__ICL) || defined (__BORLANDC__))
|
||||
char __buffer [4096];
|
||||
_vsnprintf(__buffer, sizeof(__buffer) / sizeof(char),
|
||||
__format_str, __args);
|
||||
OutputDebugStringA(__buffer);
|
||||
# elif defined (__amigaos__)
|
||||
STLPORT_CSTD::vfprintf(stderr, __format_str, (char *)__args);
|
||||
# else
|
||||
STLPORT_CSTD::vfprintf(stderr, __format_str, __args);
|
||||
# endif /* WINCE */
|
||||
|
||||
# ifdef _STLP_DEBUG_MESSAGE_POST
|
||||
_STLP_DEBUG_MESSAGE_POST
|
||||
# endif
|
||||
|
||||
va_end(__args);
|
||||
|
||||
}
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
# endif /* _STLP_DEBUG_MESSAGE */
|
||||
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_IndexedError(int __error_ind, const char* __f, int __l)
|
||||
{
|
||||
__stl_debug_message(_Message_table[_StlFormat_ERROR_RETURN],
|
||||
__f, __l, _Message_table[__error_ind]);
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_VerboseAssert(const char* __expr, int __error_ind, const char* __f, int __l)
|
||||
{
|
||||
__stl_debug_message(_Message_table[_StlFormat_VERBOSE_ASSERTION_FAILURE],
|
||||
__f, __l, _Message_table[__error_ind], __f, __l, __expr);
|
||||
__stl_debug_terminate();
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Assert(const char* __expr, const char* __f, int __l)
|
||||
{
|
||||
__stl_debug_message(_Message_table[_StlFormat_ASSERTION_FAILURE],__f, __l, __expr);
|
||||
__stl_debug_terminate();
|
||||
}
|
||||
|
||||
// if exceptions are present, sends unique exception
|
||||
// if not, calls abort() to terminate
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Terminate()
|
||||
{
|
||||
# ifdef _STLP_USE_NAMESPACES
|
||||
using namespace _STLP_STD;
|
||||
# endif
|
||||
# if defined (_STLP_USE_EXCEPTIONS) && ! defined (_STLP_NO_DEBUG_EXCEPTIONS)
|
||||
throw __stl_debug_exception();
|
||||
# else
|
||||
_STLP_ABORT();
|
||||
# endif
|
||||
}
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
# endif /* _STLP_ASSERTIONS */
|
||||
|
||||
#ifdef _STLP_DEBUG
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
//==========================================================
|
||||
// owned_list non-inline methods
|
||||
//==========================================================
|
||||
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Invalidate_all(__owned_list* __l) {
|
||||
_STLP_ACQUIRE_LOCK(__l->_M_lock);
|
||||
_Stamp_all(__l, 0);
|
||||
__l->_M_node._M_next =0;
|
||||
_STLP_RELEASE_LOCK(__l->_M_lock);
|
||||
}
|
||||
|
||||
// boris : this is unasafe routine; should be used from within critical section only !
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Stamp_all(__owned_list* __l, __owned_list* __o) {
|
||||
// crucial
|
||||
if (__l->_M_node._M_owner) {
|
||||
for (__owned_link* __position = (__owned_link*)__l->_M_node._M_next;
|
||||
__position != 0; __position= (__owned_link*)__position->_M_next) {
|
||||
_STLP_ASSERT(__position->_Owner()== __l)
|
||||
__position->_M_owner=__o;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Verify(const __owned_list* __l) {
|
||||
_STLP_ACQUIRE_LOCK(__l->_M_lock);
|
||||
if (__l) {
|
||||
_STLP_ASSERT(__l->_M_node._Owner() != 0)
|
||||
for (__owned_link* __position = (__owned_link*)__l->_M_node._M_next;
|
||||
__position != 0; __position= (__owned_link*)__position->_M_next) {
|
||||
_STLP_ASSERT(__position->_Owner()== __l)
|
||||
}
|
||||
}
|
||||
_STLP_RELEASE_LOCK(__l->_M_lock);
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Swap_owners(__owned_list& __x, __owned_list& __y) {
|
||||
|
||||
// according to the standard : --no swap() function invalidates any references,
|
||||
// pointers, or iterators referring to the elements of the containers being swapped.
|
||||
|
||||
__owned_link* __tmp;
|
||||
|
||||
// boris : there is a deadlock potential situation here if we lock two containers sequentially.
|
||||
// As user is supposed to provide its own synchronization around swap() ( it is unsafe to do any container/iterator access
|
||||
// in parallel with swap()), we just do not use any locking at all -- that behaviour is closer to non-debug version
|
||||
|
||||
__tmp = __x._M_node._M_next;
|
||||
|
||||
_Stamp_all(&__x, &__y);
|
||||
_Stamp_all(&__y, &__x);
|
||||
|
||||
__x._M_node._M_next = __y._M_node._M_next;
|
||||
__y._M_node._M_next = __tmp;
|
||||
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_M_detach(__owned_list* __l, __owned_link* __c_node) {
|
||||
if (__l != 0) {
|
||||
|
||||
_STLP_VERBOSE_ASSERT(__l->_Owner()!=0, _StlMsg_INVALID_CONTAINER)
|
||||
|
||||
_STLP_ACQUIRE_LOCK(__l->_M_lock)
|
||||
// boris : re-test the condition in case someone else already deleted us
|
||||
if(__c_node->_M_owner != 0) {
|
||||
__owned_link* __prev, *__next;
|
||||
|
||||
for (__prev = &__l->_M_node; (__next = __prev->_M_next) != __c_node;
|
||||
__prev = __next) {
|
||||
_STLP_ASSERT(__next && __next->_Owner() == __l)
|
||||
}
|
||||
|
||||
__prev->_M_next = __c_node->_M_next;
|
||||
__c_node->_M_owner=0;
|
||||
}
|
||||
_STLP_RELEASE_LOCK(__l->_M_lock)
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_M_attach(__owned_list* __l, __owned_link* __c_node) {
|
||||
if (__l ==0) {
|
||||
(__c_node)->_M_owner = 0;
|
||||
} else {
|
||||
_STLP_VERBOSE_ASSERT(__l->_Owner()!=0, _StlMsg_INVALID_CONTAINER)
|
||||
_STLP_ACQUIRE_LOCK(__l->_M_lock)
|
||||
__c_node->_M_owner = __l;
|
||||
__c_node->_M_next = __l->_M_node._M_next;
|
||||
__l->_M_node._M_next = __c_node;
|
||||
_STLP_RELEASE_LOCK(__l->_M_lock)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class _Dummy>
|
||||
void* _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Get_container_ptr(const __owned_link* __l) {
|
||||
const __owned_list* __owner = __l->_Owner();
|
||||
_STLP_VERBOSE_RETURN_0(__owner != 0, _StlMsg_INVALID_ITERATOR)
|
||||
void* __ret = __CONST_CAST(void*,__owner->_Owner());
|
||||
_STLP_VERBOSE_RETURN_0(__ret !=0, _StlMsg_INVALID_CONTAINER)
|
||||
return __ret;
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
bool _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Check_same_owner( const __owned_link& __i1,
|
||||
const __owned_link& __i2)
|
||||
{
|
||||
_STLP_VERBOSE_RETURN(__i1._Valid(), _StlMsg_INVALID_LEFTHAND_ITERATOR)
|
||||
_STLP_VERBOSE_RETURN(__i2._Valid(), _StlMsg_INVALID_RIGHTHAND_ITERATOR)
|
||||
_STLP_VERBOSE_RETURN((__i1._Owner()==__i2._Owner()), _StlMsg_DIFFERENT_OWNERS)
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
bool _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Check_same_owner_or_null( const __owned_link& __i1,
|
||||
const __owned_link& __i2)
|
||||
{
|
||||
_STLP_VERBOSE_RETURN(__i1._Owner()==__i2._Owner(), _StlMsg_DIFFERENT_OWNERS)
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
bool _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Check_if_owner( const __owned_list * __l, const __owned_link& __it)
|
||||
{
|
||||
const __owned_list* __owner_ptr = __it._Owner();
|
||||
_STLP_VERBOSE_RETURN(__owner_ptr!=0, _StlMsg_INVALID_ITERATOR)
|
||||
_STLP_VERBOSE_RETURN(__l==__owner_ptr, _StlMsg_NOT_OWNER)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_DEBUG */
|
||||
|
||||
#endif /* if defined (EXPOSE_GLOBALS_IMPLEMENTATION) */
|
||||
|
||||
#endif /* header guard */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
426
STLPORT/stlport/stl/debug/_debug.h
Normal file
426
STLPORT/stlport/stl/debug/_debug.h
Normal file
@@ -0,0 +1,426 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_DEBUG_H
|
||||
# define _STLP_DEBUG_H
|
||||
|
||||
# if defined (_STLP_ASSERTIONS) || defined (_STLP_DEBUG)
|
||||
|
||||
#ifndef _STLP_CONFIG_H
|
||||
# include <stl/_config.h>
|
||||
#endif
|
||||
|
||||
# if !defined (_STLP_EXTRA_OPERATORS_FOR_DEBUG) && \
|
||||
( defined (_STLP_BASE_MATCH_BUG) || (defined (_STLP_MSVC) && _STLP_MSVC < 1100 ) )
|
||||
# define _STLP_EXTRA_OPERATORS_FOR_DEBUG
|
||||
# endif
|
||||
|
||||
# if !defined(_STLP_FILE__)
|
||||
# define _STLP_FILE__ __FILE__
|
||||
# endif
|
||||
|
||||
enum {
|
||||
_StlFormat_ERROR_RETURN,
|
||||
_StlFormat_ASSERTION_FAILURE,
|
||||
_StlFormat_VERBOSE_ASSERTION_FAILURE,
|
||||
_StlMsg_INVALID_ARGUMENT,
|
||||
_StlMsg_INVALID_CONTAINER,
|
||||
_StlMsg_EMPTY_CONTAINER,
|
||||
_StlMsg_ERASE_PAST_THE_END,
|
||||
_StlMsg_OUT_OF_BOUNDS,
|
||||
_StlMsg_NOT_OWNER,
|
||||
_StlMsg_INVALID_ITERATOR,
|
||||
_StlMsg_INVALID_LEFTHAND_ITERATOR,
|
||||
_StlMsg_INVALID_RIGHTHAND_ITERATOR,
|
||||
_StlMsg_DIFFERENT_OWNERS ,
|
||||
_StlMsg_NOT_DEREFERENCEABLE ,
|
||||
_StlMsg_INVALID_RANGE ,
|
||||
_StlMsg_NOT_IN_RANGE_1 ,
|
||||
_StlMsg_NOT_IN_RANGE_2 ,
|
||||
_StlMsg_INVALID_ADVANCE ,
|
||||
_StlMsg_SINGULAR_ITERATOR ,
|
||||
// debug alloc messages
|
||||
_StlMsg_DBA_DELETED_TWICE ,
|
||||
_StlMsg_DBA_NEVER_ALLOCATED ,
|
||||
_StlMsg_DBA_TYPE_MISMATCH ,
|
||||
_StlMsg_DBA_SIZE_MISMATCH ,
|
||||
_StlMsg_DBA_UNDERRUN ,
|
||||
_StlMsg_DBA_OVERRUN ,
|
||||
// auto_ptr messages
|
||||
_StlMsg_AUTO_PTR_NULL ,
|
||||
_StlMsg_UNKNOWN
|
||||
/* _StlMsg_MAX */
|
||||
};
|
||||
|
||||
/* have to hardcode that ;() */
|
||||
# define _StlMsg_MAX 27
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
// This class is unique (not inherited from exception),
|
||||
// to disallow catch in anything but (...)
|
||||
struct __stl_debug_exception {
|
||||
// no members
|
||||
};
|
||||
|
||||
class _STLP_CLASS_DECLSPEC __owned_link;
|
||||
class _STLP_CLASS_DECLSPEC __owned_list;
|
||||
|
||||
template <class _Dummy>
|
||||
struct __stl_debug_engine {
|
||||
|
||||
// Basic routine to report any debug message
|
||||
// Use _STLP_DEBUG_MESSAGE to override
|
||||
static void _STLP_CALL _Message(const char * format_str, ...);
|
||||
|
||||
// Micsellanous function to report indexed error message
|
||||
static void _STLP_CALL _IndexedError(int __ind, const char* __f, int __l);
|
||||
|
||||
// Basic assertion report mechanism.
|
||||
// Reports failed assertion via __stl_debug_message and calls _Terminate
|
||||
// if _STLP_DEBUG_TERMINATE is specified, calls __stl_debug_terminate instead
|
||||
static void _STLP_CALL _Assert(const char* __expr, const char* __f, int __l);
|
||||
|
||||
// The same, with additional diagnostics
|
||||
static void _STLP_CALL _VerboseAssert(const char* __expr, int __error_ind, const char* __f, int __l);
|
||||
|
||||
// If exceptions are present, sends unique exception
|
||||
// If not, calls _STLP_ABORT() to terminate
|
||||
// Use _STLP_DEBUG_TERMINATE to override
|
||||
static void _STLP_CALL _Terminate();
|
||||
|
||||
# ifdef _STLP_DEBUG
|
||||
|
||||
// owned_list/link delegate non-inline functions here
|
||||
|
||||
static bool _STLP_CALL _Check_same_owner( const __owned_link& __i1,
|
||||
const __owned_link& __i2);
|
||||
static bool _STLP_CALL _Check_same_owner_or_null( const __owned_link& __i1,
|
||||
const __owned_link& __i2);
|
||||
static bool _STLP_CALL _Check_if_owner( const __owned_list*, const __owned_link&);
|
||||
|
||||
static void _STLP_CALL _Verify(const __owned_list*);
|
||||
|
||||
static void _STLP_CALL _Swap_owners(__owned_list&, __owned_list& /*, bool __swap_roots */ );
|
||||
|
||||
static void _STLP_CALL _Invalidate_all(__owned_list*);
|
||||
|
||||
static void _STLP_CALL _Stamp_all(__owned_list*, __owned_list*);
|
||||
|
||||
static void _STLP_CALL _M_detach(__owned_list*, __owned_link*);
|
||||
|
||||
static void _STLP_CALL _M_attach(__owned_list*, __owned_link*);
|
||||
|
||||
// accessor : check and get pointer to the container
|
||||
static void* _STLP_CALL _Get_container_ptr(const __owned_link*);
|
||||
# endif /* _STLP_DEBUG */
|
||||
|
||||
// debug messages and formats
|
||||
_STLP_STATIC_MEMBER_DECLSPEC static const char* _Message_table[_StlMsg_MAX];
|
||||
};
|
||||
|
||||
|
||||
# if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE struct _STLP_CLASS_DECLSPEC __stl_debug_engine<bool>;
|
||||
# endif /* _STLP_USE_TEMPLATE_EXPORT */
|
||||
|
||||
typedef __stl_debug_engine<bool> __stl_debugger;
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
# ifndef _STLP_ASSERT
|
||||
# define _STLP_ASSERT(expr) \
|
||||
if (!(expr)) {STLPORT::__stl_debugger::_Assert( # expr, _STLP_FILE__, __LINE__);}
|
||||
# endif
|
||||
|
||||
# endif /* _STLP_ASSERTIONS || _STLP_DEBUG */
|
||||
|
||||
|
||||
// this section is for _STLP_DEBUG only
|
||||
#if defined ( _STLP_DEBUG )
|
||||
|
||||
# ifndef _STLP_VERBOSE_ASSERT
|
||||
// fbp : new form not requiring ";"
|
||||
# define _STLP_VERBOSE_ASSERT(expr,__diag_num) \
|
||||
if (!(expr)) { STLPORT::__stl_debugger::_VerboseAssert\
|
||||
( # expr, __diag_num, _STLP_FILE__, __LINE__ ); \
|
||||
}
|
||||
# endif
|
||||
|
||||
# define _STLP_DEBUG_CHECK(expr) _STLP_ASSERT(expr)
|
||||
# define _STLP_DEBUG_DO(expr) expr;
|
||||
|
||||
# ifndef _STLP_VERBOSE_RETURN
|
||||
# define _STLP_VERBOSE_RETURN(__expr,__diag_num) if (!(__expr)) { \
|
||||
__stl_debugger::_IndexedError(__diag_num, __FILE__ , __LINE__); \
|
||||
return false; }
|
||||
# endif
|
||||
|
||||
# ifndef _STLP_VERBOSE_RETURN_0
|
||||
# define _STLP_VERBOSE_RETURN_0(__expr,__diag_num) if (!(__expr)) { \
|
||||
__stl_debugger::_IndexedError(__diag_num, __FILE__ , __LINE__); \
|
||||
return 0; }
|
||||
# endif
|
||||
|
||||
#if ! defined (_STLP_INTERNAL_THREADS_H)
|
||||
# include <stl/_threads.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ITERATOR_BASE_H
|
||||
# include <stl/_iterator_base.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
//=============================================================
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL __valid_range(const _Iterator& __i1 ,const _Iterator& __i2,
|
||||
const random_access_iterator_tag&) {
|
||||
return (__i1< __i2) || (__i1 == __i2);
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL __valid_range(const _Iterator& __i1 ,const _Iterator& __i2,
|
||||
const bidirectional_iterator_tag&) {
|
||||
// check if comparable
|
||||
bool __dummy(__i1==__i2);
|
||||
return (__dummy==__dummy);
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL __valid_range(const _Iterator& __i1 ,const _Iterator& __i2, const forward_iterator_tag&) {
|
||||
// check if comparable
|
||||
bool __dummy(__i1==__i2);
|
||||
return (__dummy==__dummy);
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL __valid_range(const _Iterator&,const _Iterator&, const input_iterator_tag&) {
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL __valid_range(const _Iterator&,const _Iterator&, const output_iterator_tag&) {
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL __valid_range(const _Iterator& __i1, const _Iterator& __i2) {
|
||||
return __valid_range(__i1,__i2,_STLP_ITERATOR_CATEGORY(__i1, _Iterator));
|
||||
}
|
||||
|
||||
// Note : that means in range [i1, i2].
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL __in_range(const _Iterator& _It, const _Iterator& __i1,
|
||||
const _Iterator& __i2) {
|
||||
return __valid_range(__i1,_It,_STLP_ITERATOR_CATEGORY(__i1, _Iterator)) &&
|
||||
__valid_range(_It,__i2,_STLP_ITERATOR_CATEGORY(_It, _Iterator));
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL __in_range(const _Iterator& __first, const _Iterator& __last,
|
||||
const _Iterator& __start, const _Iterator& __finish) {
|
||||
return __valid_range(__first,__last,_STLP_ITERATOR_CATEGORY(__first, _Iterator)) &&
|
||||
__valid_range(__start,__first,_STLP_ITERATOR_CATEGORY(__first, _Iterator)) &&
|
||||
__valid_range(__last,__finish,_STLP_ITERATOR_CATEGORY(__last, _Iterator));
|
||||
}
|
||||
|
||||
//==========================================================
|
||||
|
||||
|
||||
class _STLP_CLASS_DECLSPEC __owned_link {
|
||||
public:
|
||||
|
||||
__owned_link() : _M_owner(0) {}
|
||||
__owned_link(const __owned_list* __c) : _M_owner(0), _M_next(0) {
|
||||
__stl_debugger::_M_attach(__CONST_CAST(__owned_list*,__c), this);
|
||||
}
|
||||
__owned_link(const __owned_link& __rhs): _M_owner(0) {
|
||||
__stl_debugger::_M_attach(__CONST_CAST(__owned_list*,__rhs._M_owner), this);
|
||||
}
|
||||
__owned_link& operator=(const __owned_link& __rhs) {
|
||||
__owned_list* __new_owner = __CONST_CAST(__owned_list*,__rhs._M_owner);
|
||||
__owned_list* __old_owner = _M_owner;
|
||||
if ( __old_owner != __new_owner ) {
|
||||
__stl_debugger::_M_detach(__old_owner, this);
|
||||
__stl_debugger::_M_attach(__new_owner, this);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
~__owned_link() {
|
||||
__stl_debugger::_M_detach(_M_owner, this);
|
||||
_Invalidate();
|
||||
}
|
||||
|
||||
const __owned_list* _Owner() const {
|
||||
return _M_owner;
|
||||
}
|
||||
__owned_list* _Owner() {
|
||||
return _M_owner;
|
||||
}
|
||||
void _Set_owner(const __owned_list* __o) {
|
||||
_M_owner= __CONST_CAST(__owned_list*,__o);
|
||||
}
|
||||
bool _Valid() const {
|
||||
return _M_owner !=0;
|
||||
}
|
||||
|
||||
void _Invalidate() { _M_owner=0; _M_next = 0; }
|
||||
void _Link_to_self() { _M_next= 0; }
|
||||
|
||||
__owned_link* _Next() { return _M_next; }
|
||||
const __owned_link* _Next() const { return _M_next; }
|
||||
|
||||
public:
|
||||
__owned_list* _M_owner;
|
||||
__owned_link* _M_next;
|
||||
};
|
||||
|
||||
|
||||
class _STLP_CLASS_DECLSPEC __owned_list {
|
||||
public:
|
||||
__owned_list(const void* __o) {
|
||||
// fprintf(stderr, "__owned_list(): %p\n",(void*)this);
|
||||
_M_node._M_owner = __CONST_CAST(__owned_list*, __REINTERPRET_CAST(const __owned_list*,__o));
|
||||
_M_node._M_next=0;
|
||||
}
|
||||
~__owned_list() {
|
||||
// fprintf(stderr, "~__owned_list(): %p\n",(void*)this);
|
||||
_Invalidate_all();
|
||||
// that prevents detach
|
||||
_M_node._Invalidate();
|
||||
}
|
||||
const void* _Owner() const {
|
||||
return (const void*)_M_node._M_owner;
|
||||
}
|
||||
void* _Owner() {
|
||||
return (void*)_M_node._M_owner;
|
||||
}
|
||||
bool _Valid() const {
|
||||
return _M_node._M_owner!=0;
|
||||
}
|
||||
void _Invalidate() { _M_node._M_owner=0; }
|
||||
|
||||
__owned_link* _First() { return _M_node._Next(); }
|
||||
__owned_link* _Last() { return 0 ; }
|
||||
|
||||
const __owned_link* _First() const { return (__owned_link*)_M_node._M_next; }
|
||||
const __owned_link* _Last() const { return 0 ;}
|
||||
|
||||
void _Verify() const {
|
||||
__stl_debugger::_Verify(this);
|
||||
}
|
||||
|
||||
void _Swap_owners(__owned_list& __y) {
|
||||
__stl_debugger::_Swap_owners(*this, __y);
|
||||
}
|
||||
|
||||
void _Invalidate_all() {
|
||||
__stl_debugger::_Invalidate_all(this);
|
||||
}
|
||||
|
||||
mutable __owned_link _M_node;
|
||||
mutable _STLP_mutex _M_lock;
|
||||
|
||||
private:
|
||||
// should never be called, should be left undefined,
|
||||
// but some compilers complain about it ;(
|
||||
__owned_list(const __owned_list&){}
|
||||
void operator=(const __owned_list&) {}
|
||||
|
||||
friend class __owned_link;
|
||||
friend struct __stl_debug_engine<bool>;
|
||||
};
|
||||
|
||||
|
||||
//==========================================================
|
||||
|
||||
// forward declaratioins
|
||||
|
||||
template <class _Iterator>
|
||||
bool _STLP_CALL __check_range(const _Iterator&, const _Iterator&);
|
||||
template <class _Iterator>
|
||||
bool _STLP_CALL __check_range(const _Iterator&,
|
||||
const _Iterator&, const _Iterator&);
|
||||
template <class _Iterator>
|
||||
bool _STLP_CALL __check_range(const _Iterator&, const _Iterator& ,
|
||||
const _Iterator&, const _Iterator& );
|
||||
|
||||
template <class _Iterator>
|
||||
void _STLP_CALL __invalidate_range(const __owned_list* __base,
|
||||
const _Iterator& __first,
|
||||
const _Iterator& __last);
|
||||
|
||||
template <class _Iterator>
|
||||
void _STLP_CALL __invalidate_iterator(const __owned_list* __base,
|
||||
const _Iterator& __it);
|
||||
|
||||
//============================================================
|
||||
|
||||
inline bool _STLP_CALL
|
||||
__check_same_owner( const __owned_link& __i1, const __owned_link& __i2) {
|
||||
return __stl_debugger::_Check_same_owner(__i1,__i2);
|
||||
}
|
||||
inline bool _STLP_CALL
|
||||
__check_same_owner_or_null( const __owned_link& __i1, const __owned_link& __i2) {
|
||||
return __stl_debugger::_Check_same_owner_or_null(__i1,__i2);
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL __check_if_owner( const __owned_list* __owner,
|
||||
const _Iterator& __it) {
|
||||
return __stl_debugger::_Check_if_owner(__owner, (const __owned_link&)__it);
|
||||
}
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
# endif /* _STLP_DEBUG */
|
||||
|
||||
#if defined ( _STLP_ASSERTIONS )
|
||||
|
||||
# ifndef _STLP_ASSERT_MSG_TRAILER
|
||||
# define _STLP_ASSERT_MSG_TRAILER
|
||||
# endif
|
||||
|
||||
// dwa 12/30/98 - if _STLP_DEBUG_MESSAGE is defined, the user can supply own definition.
|
||||
# if !defined( _STLP_DEBUG_MESSAGE )
|
||||
# define __stl_debug_message __stl_debugger::_Message
|
||||
# else
|
||||
extern void __stl_debug_message(const char * format_str, ...);
|
||||
# endif
|
||||
|
||||
// fbp: if _STLP_DEBUG_TERMINATE is defined, the user can supply own definition.
|
||||
# if !defined( _STLP_DEBUG_TERMINATE )
|
||||
# define __stl_debug_terminate __stl_debugger::_Terminate
|
||||
# else
|
||||
extern void __stl_debug_terminate(void);
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
# if !defined (_STLP_LINK_TIME_INSTANTIATION)
|
||||
# include <stl/debug/_debug.c>
|
||||
# endif
|
||||
|
||||
#endif /* DEBUG_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
281
STLPORT/stlport/stl/debug/_deque.h
Normal file
281
STLPORT/stlport/stl/debug/_deque.h
Normal file
@@ -0,0 +1,281 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_DBG_DEQUE_H
|
||||
#define _STLP_INTERNAL_DBG_DEQUE_H
|
||||
|
||||
#include <stl/debug/_iterator.h>
|
||||
|
||||
# if !defined (_STLP_USE_WRAPPER_FOR_ALLOC_PARAM) && !defined (_STLP_NO_DEFAULT_NON_TYPE_PARAM)
|
||||
# undef _DBG_deque
|
||||
# define _DBG_deque deque
|
||||
# endif
|
||||
|
||||
# define _DEQUE_WRAPPER _DBG_deque<_Tp,_Alloc>
|
||||
|
||||
# define _STLP_DEQUE_SUPER __WORKAROUND_DBG_RENAME(deque) <_Tp,_Alloc>
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
# ifdef _STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _Tp* value_type(const _DBG_iter_base< _STLP_DEQUE_SUPER >&) {
|
||||
return (_Tp*)0;
|
||||
}
|
||||
template <class _Tp, class _Alloc>
|
||||
inline random_access_iterator_tag iterator_category(const _DBG_iter_base< _STLP_DEQUE_SUPER >&) {
|
||||
return random_access_iterator_tag();
|
||||
}
|
||||
# endif
|
||||
|
||||
template <class _Tp, _STLP_DBG_ALLOCATOR_SELECT(_Tp) >
|
||||
class _DBG_deque : public _STLP_DEQUE_SUPER {
|
||||
|
||||
typedef _DBG_deque<_Tp,_Alloc> _Self;
|
||||
typedef _STLP_DEQUE_SUPER _Base;
|
||||
|
||||
public: // Basic types
|
||||
|
||||
__IMPORT_CONTAINER_TYPEDEFS(_Base)
|
||||
|
||||
public: // Iterators
|
||||
typedef _DBG_iter< _STLP_DEQUE_SUPER, _Nonconst_traits<value_type> > iterator;
|
||||
typedef _DBG_iter< _STLP_DEQUE_SUPER, _Const_traits<value_type> > const_iterator;
|
||||
|
||||
_STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
|
||||
|
||||
protected:
|
||||
__owned_list _M_iter_list;
|
||||
void _Invalidate_iterator(const iterator& __it) {
|
||||
__invalidate_iterator(&_M_iter_list,__it);
|
||||
}
|
||||
void _Invalidate_all() {
|
||||
_M_iter_list._Invalidate_all();
|
||||
}
|
||||
|
||||
public: // Basic accessors
|
||||
iterator begin() { return iterator(&_M_iter_list, this->_M_start); }
|
||||
iterator end() { return iterator(&_M_iter_list, this->_M_finish); }
|
||||
const_iterator begin() const {
|
||||
return const_iterator(&_M_iter_list, this->_M_start);
|
||||
}
|
||||
const_iterator end() const {
|
||||
return const_iterator(&_M_iter_list, this->_M_finish);
|
||||
}
|
||||
|
||||
reverse_iterator rbegin() { return reverse_iterator(end()); }
|
||||
reverse_iterator rend() { return reverse_iterator(begin()); }
|
||||
const_reverse_iterator rbegin() const
|
||||
{ return const_reverse_iterator(end()); }
|
||||
const_reverse_iterator rend() const
|
||||
{ return const_reverse_iterator(begin()); }
|
||||
|
||||
reference operator[](size_type __n)
|
||||
{ return begin()[difference_type(__n)]; }
|
||||
const_reference operator[](size_type __n) const
|
||||
{ return begin()[difference_type(__n)]; }
|
||||
|
||||
reference front() { return *begin(); }
|
||||
reference back() {
|
||||
iterator __tmp = end();
|
||||
--__tmp;
|
||||
return *__tmp;
|
||||
}
|
||||
const_reference front() const { return *begin(); }
|
||||
const_reference back() const {
|
||||
const_iterator __tmp = end();
|
||||
--__tmp;
|
||||
return *__tmp;
|
||||
}
|
||||
|
||||
public: // Constructor, destructor.
|
||||
|
||||
const _Base* _Get_base() const { return (const _Base*)this; }
|
||||
|
||||
explicit _DBG_deque(const allocator_type& __a = allocator_type()) :
|
||||
_STLP_DEQUE_SUPER(__a), _M_iter_list(_Get_base()) {}
|
||||
_DBG_deque(const _Self& __x) : _STLP_DEQUE_SUPER(__x), _M_iter_list(_Get_base()) {}
|
||||
_DBG_deque(size_type __n, const value_type& __value,
|
||||
const allocator_type& __a = allocator_type()) :
|
||||
_STLP_DEQUE_SUPER(__n, __value, __a), _M_iter_list(_Get_base()) {}
|
||||
explicit _DBG_deque(size_type __n) : _STLP_DEQUE_SUPER(__n), _M_iter_list(_Get_base()) {}
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
template <class _InputIterator>
|
||||
_DBG_deque(_InputIterator __first, _InputIterator __last,
|
||||
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) :
|
||||
_STLP_DEQUE_SUPER(__first, __last, __a) , _M_iter_list(_Get_base()) {}
|
||||
# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
|
||||
template <class _InputIterator>
|
||||
_DBG_deque(_InputIterator __first, _InputIterator __last):
|
||||
_STLP_DEQUE_SUPER(__first, __last, allocator_type()) , _M_iter_list(_Get_base()) {}
|
||||
# endif
|
||||
#else /* _STLP_MEMBER_TEMPLATES */
|
||||
_DBG_deque(const value_type* __first, const value_type* __last,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _STLP_DEQUE_SUPER(__first, __last, __a), _M_iter_list(_Get_base()) {}
|
||||
|
||||
_DBG_deque(const_iterator __first, const_iterator __last,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _STLP_DEQUE_SUPER(__first._M_iterator, __last._M_iterator, __a),
|
||||
_M_iter_list(_Get_base()) {}
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
_Self& operator= (const _Self& __x) {
|
||||
_Invalidate_all();
|
||||
(_Base&)*this = (const _Base&)__x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(_Self& __x) {
|
||||
_M_iter_list._Swap_owners(__x._M_iter_list);
|
||||
_Base::swap(__x);
|
||||
}
|
||||
|
||||
public:
|
||||
void assign(size_type __n, const _Tp& __val) {
|
||||
_Base::assign(__n, __val);
|
||||
}
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
|
||||
template <class _InputIterator>
|
||||
void assign(_InputIterator __first, _InputIterator __last) {
|
||||
_Base::assign(__first, __last);
|
||||
}
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
public: // push_* and pop_*
|
||||
|
||||
void push_back(const value_type& __t) {
|
||||
_Invalidate_all();
|
||||
_Base::push_back(__t);
|
||||
}
|
||||
|
||||
void push_back() {
|
||||
_Invalidate_all();
|
||||
_Base::push_back();
|
||||
}
|
||||
|
||||
void push_front(const value_type& __t) {
|
||||
_Invalidate_all();
|
||||
_Base::push_front(__t);
|
||||
}
|
||||
|
||||
void push_front() {
|
||||
_Base::push_front();
|
||||
_Invalidate_all();
|
||||
}
|
||||
|
||||
|
||||
void pop_back() {
|
||||
_Invalidate_iterator(end());
|
||||
_Base::pop_back();
|
||||
}
|
||||
|
||||
void pop_front() {
|
||||
_Invalidate_iterator(begin());
|
||||
_Base::pop_front();
|
||||
}
|
||||
|
||||
public: // Insert
|
||||
|
||||
iterator insert(iterator __position, const value_type& __x) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
|
||||
// fbp : invalidation !
|
||||
return iterator(&_M_iter_list, _Base::insert(__position._M_iterator, __x));
|
||||
}
|
||||
|
||||
iterator insert(iterator __position) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
|
||||
// fbp : invalidation !
|
||||
return iterator(&_M_iter_list, _Base::insert(__position._M_iterator));
|
||||
}
|
||||
|
||||
void insert(iterator __position, size_type __n, const value_type& __x) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
|
||||
// fbp : invalidation !
|
||||
_Base::insert(__position._M_iterator, __n, __x);
|
||||
}
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
template <class _InputIterator>
|
||||
void insert(iterator __position, _InputIterator __first, _InputIterator __last) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
|
||||
// fbp : invalidation !
|
||||
_Base::insert(__position._M_iterator, __first, __last);
|
||||
}
|
||||
#else /* _STLP_MEMBER_TEMPLATES */
|
||||
void insert(iterator __position,
|
||||
const value_type* __first, const value_type* __last) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
|
||||
_Base::insert(__position._M_iterator, __first, __last);
|
||||
}
|
||||
void insert(iterator __position,
|
||||
const_iterator __first, const_iterator __last) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
|
||||
_Base::insert(__position._M_iterator, __first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
public: // Erase
|
||||
iterator erase(iterator __pos) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __pos) && (__pos != end()))
|
||||
return iterator (&_M_iter_list, _Base::erase(__pos._M_iterator));
|
||||
}
|
||||
|
||||
iterator erase(iterator __first, iterator __last) {
|
||||
_STLP_DEBUG_CHECK(__first >= begin() && __last <= end())
|
||||
return iterator (&_M_iter_list, _Base::erase(__first._M_iterator, __last._M_iterator));
|
||||
}
|
||||
|
||||
void clear() {
|
||||
_Invalidate_all();
|
||||
_Base::clear();
|
||||
}
|
||||
};
|
||||
|
||||
#define _STLP_TEMPLATE_HEADER template <class _Tp, class _Alloc>
|
||||
#define _STLP_TEMPLATE_CONTAINER _DBG_deque<_Tp, _Alloc>
|
||||
#define _STLP_TEMPLATE_CONTAINER_BASE _STLP_DEQUE_SUPER
|
||||
#include <stl/debug/_relops_cont.h>
|
||||
#undef _STLP_TEMPLATE_CONTAINER_BASE
|
||||
#undef _STLP_TEMPLATE_CONTAINER
|
||||
#undef _STLP_TEMPLATE_HEADER
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
# undef _DBG_deque
|
||||
# undef _STLP_DEQUE_SUPER
|
||||
|
||||
#endif /* _STLP_INTERNAL_DEQUE_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
261
STLPORT/stlport/stl/debug/_hashtable.h
Normal file
261
STLPORT/stlport/stl/debug/_hashtable.h
Normal file
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_DBG_HASHTABLE_H
|
||||
#define _STLP_INTERNAL_DBG_HASHTABLE_H
|
||||
|
||||
// Hashtable class, used to implement the hashed associative containers
|
||||
// hash_set, hash_map, hash_multiset, and hash_multimap.
|
||||
|
||||
# include <stl/debug/_iterator.h>
|
||||
|
||||
# undef hashtable
|
||||
# undef _DBG_hashtable
|
||||
# define _DBG_hashtable hashtable
|
||||
|
||||
# define _STLP_DBG_HT_SUPER \
|
||||
__WORKAROUND_DBG_RENAME(hashtable) <_Val, _Key, _HF, _ExK, _EqK, _All>
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
# ifdef _STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _ExK, class _EqK, class _All>
|
||||
inline _Val*
|
||||
value_type(const _DBG_iter_base< _STLP_DBG_HT_SUPER >&) {
|
||||
return (_Val*)0;
|
||||
}
|
||||
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _ExK, class _EqK, class _All>
|
||||
inline forward_iterator_tag
|
||||
iterator_category(const _DBG_iter_base< _STLP_DBG_HT_SUPER >&) {
|
||||
return forward_iterator_tag();
|
||||
}
|
||||
# endif
|
||||
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _ExK, class _EqK, class _All>
|
||||
class _DBG_hashtable : public _STLP_DBG_HT_SUPER {
|
||||
typedef _DBG_hashtable<_Val, _Key, _HF, _ExK, _EqK, _All> _Self;
|
||||
typedef _STLP_DBG_HT_SUPER _Base;
|
||||
|
||||
public:
|
||||
typedef _Key key_type;
|
||||
typedef _HF hasher;
|
||||
typedef _EqK key_equal;
|
||||
|
||||
__IMPORT_CONTAINER_TYPEDEFS(_Base)
|
||||
|
||||
public:
|
||||
typedef _DBG_iter<_Base, _Nonconst_traits<value_type> > iterator;
|
||||
typedef _DBG_iter<_Base, _Const_traits<value_type> > const_iterator;
|
||||
typedef typename _Base::iterator _Base_iterator;
|
||||
typedef typename _Base::const_iterator _Base_const_iterator;
|
||||
|
||||
protected:
|
||||
void _Invalidate_all() {_M_iter_list._Invalidate_all();}
|
||||
|
||||
void _Invalidate_iterator(const const_iterator& __it) {
|
||||
__invalidate_iterator(&_M_iter_list,__it);
|
||||
}
|
||||
void _Invalidate_iterators(const const_iterator& __first, const const_iterator& __last) {
|
||||
const_iterator __cur = __first;
|
||||
while (__cur != __last) __invalidate_iterator(&_M_iter_list, __cur++);
|
||||
}
|
||||
|
||||
const _Base* _Get_base() const { return (const _Base*)this; }
|
||||
_Base* _Get_base() { return (_Base*)this; }
|
||||
|
||||
public:
|
||||
_DBG_hashtable(size_type __n,
|
||||
const _HF& __hf,
|
||||
const _EqK& __eql,
|
||||
const _ExK& __ext,
|
||||
const allocator_type& __a = allocator_type()):
|
||||
_STLP_DBG_HT_SUPER(__n, __hf, __eql, __ext, __a),
|
||||
_M_iter_list(_Get_base()) {}
|
||||
|
||||
_DBG_hashtable(size_type __n,
|
||||
const _HF& __hf,
|
||||
const _EqK& __eql,
|
||||
const allocator_type& __a = allocator_type()):
|
||||
|
||||
_STLP_DBG_HT_SUPER(__n, __hf, __eql, __a),
|
||||
_M_iter_list(_Get_base()) {}
|
||||
|
||||
_DBG_hashtable(const _Self& __ht):
|
||||
_STLP_DBG_HT_SUPER(__ht),
|
||||
_M_iter_list(_Get_base()) {}
|
||||
|
||||
_Self& operator= (const _Self& __ht) {
|
||||
_Invalidate_all();
|
||||
_Base::operator=(__ht);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(_Self& __ht)
|
||||
{
|
||||
_M_iter_list._Swap_owners(__ht._M_iter_list);
|
||||
_Base::swap(__ht);
|
||||
}
|
||||
|
||||
iterator begin() { return iterator(&_M_iter_list, _Base::begin()); }
|
||||
iterator end() { return iterator(&_M_iter_list, _Base::end()); }
|
||||
|
||||
const_iterator begin() const { return const_iterator(&_M_iter_list, _Base::begin()); }
|
||||
const_iterator end() const { return const_iterator(&_M_iter_list, _Base::end()); }
|
||||
|
||||
pair<iterator, bool> insert_unique(const value_type& __obj)
|
||||
{
|
||||
pair < _Base_iterator, bool> __res =
|
||||
_Base::insert_unique(__obj);
|
||||
return pair<iterator, bool> ( iterator(&_M_iter_list, __res.first), __res.second);
|
||||
}
|
||||
|
||||
iterator insert_equal(const value_type& __obj) {
|
||||
return iterator(&_M_iter_list, _Base::insert_equal(__obj));
|
||||
}
|
||||
|
||||
pair<iterator, bool> insert_unique_noresize(const value_type& __obj) {
|
||||
pair < _Base_iterator, bool> __res =
|
||||
_Base::insert_unique_noresize(__obj);
|
||||
return pair<iterator, bool> ( iterator(&_M_iter_list, __res.first), __res.second);
|
||||
}
|
||||
|
||||
iterator insert_equal_noresize(const value_type& __obj) {
|
||||
return iterator(&_M_iter_list, _Base::insert_equal_noresize(__obj));
|
||||
}
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
template <class _InputIterator>
|
||||
void insert_unique(_InputIterator __f, _InputIterator __l) {
|
||||
_Base::insert_unique(__f, __l);
|
||||
}
|
||||
|
||||
template <class _InputIterator>
|
||||
void insert_equal(_InputIterator __f, _InputIterator __l){
|
||||
_Base::insert_equal(__f, __l);
|
||||
}
|
||||
|
||||
#else /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
void insert_unique(const value_type* __f, const value_type* __l) {
|
||||
_Base::insert_unique(__f, __l);
|
||||
}
|
||||
|
||||
void insert_equal(const value_type* __f, const value_type* __l) {
|
||||
_Base::insert_equal(__f, __l);
|
||||
}
|
||||
|
||||
void insert_unique(const_iterator __f, const_iterator __l) {
|
||||
_Base::insert_unique(__f._M_iterator, __l._M_iterator);
|
||||
}
|
||||
|
||||
void insert_equal(const_iterator __f, const_iterator __l) {
|
||||
_Base::insert_equal(__f._M_iterator, __l._M_iterator);
|
||||
}
|
||||
#endif /*_STLP_MEMBER_TEMPLATES */
|
||||
|
||||
iterator find(const key_type& __key) {
|
||||
return iterator(&_M_iter_list, _Base::find(__key));
|
||||
}
|
||||
|
||||
const_iterator find(const key_type& __key) const {
|
||||
return const_iterator(&_M_iter_list, _Base::find(__key));
|
||||
}
|
||||
|
||||
pair<iterator, iterator>
|
||||
equal_range(const key_type& __key) {
|
||||
pair < _Base_iterator, _Base_iterator > __res =
|
||||
_Base::equal_range(__key);
|
||||
return pair<iterator,iterator> (iterator(&_M_iter_list,__res.first),
|
||||
iterator(&_M_iter_list,__res.second));
|
||||
}
|
||||
|
||||
pair<const_iterator, const_iterator>
|
||||
equal_range(const key_type& __key) const {
|
||||
pair < _Base_const_iterator, _Base_const_iterator > __res =
|
||||
_Base::equal_range(__key);
|
||||
return pair<const_iterator,const_iterator> (const_iterator(&_M_iter_list,__res.first),
|
||||
const_iterator(&_M_iter_list,__res.second));
|
||||
}
|
||||
|
||||
size_type erase(const key_type& __key) {
|
||||
pair<const_iterator, const_iterator> __p = equal_range(__key);
|
||||
size_type __n = distance(__p.first, __p.second);
|
||||
_Invalidate_iterators(__p.first, __p.second);
|
||||
_Base::erase(__p.first._M_iterator, __p.second._M_iterator);
|
||||
return __n;
|
||||
}
|
||||
|
||||
void erase(const const_iterator& __it) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __it))
|
||||
_STLP_DEBUG_CHECK(_Dereferenceable(__it))
|
||||
_Invalidate_iterator(__it);
|
||||
_Base::erase(__it._M_iterator);
|
||||
}
|
||||
void erase(const_iterator __first, const_iterator __last) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __first)&&
|
||||
__check_if_owner(&_M_iter_list, __last))
|
||||
_Invalidate_iterators(__first, __last);
|
||||
_Base::erase(__first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
void resize(size_type __num_elements_hint) {
|
||||
_Base::resize(__num_elements_hint);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
_Invalidate_all();
|
||||
_Base::clear();
|
||||
}
|
||||
|
||||
private:
|
||||
__owned_list _M_iter_list;
|
||||
|
||||
};
|
||||
|
||||
#define _STLP_TEMPLATE_HEADER template <class _Val, class _Key, class _HF, class _ExK, class _EqK, class _All>
|
||||
#define _STLP_TEMPLATE_CONTAINER _DBG_hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>
|
||||
#define _STLP_TEMPLATE_CONTAINER_BASE hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>
|
||||
#include <stl/debug/_relops_hash_cont.h>
|
||||
#undef _STLP_TEMPLATE_CONTAINER_BASE
|
||||
#undef _STLP_TEMPLATE_CONTAINER
|
||||
#undef _STLP_TEMPLATE_HEADER
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
# undef hashtable
|
||||
|
||||
#endif /* _STLP_INTERNAL_HASHTABLE_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
|
||||
394
STLPORT/stlport/stl/debug/_iterator.h
Normal file
394
STLPORT/stlport/stl/debug/_iterator.h
Normal file
@@ -0,0 +1,394 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_DBG_ITERATOR_H
|
||||
# define _STLP_DBG_ITERATOR_H
|
||||
|
||||
# include <stl/_pair.h>
|
||||
# include <stl/_alloc.h>
|
||||
|
||||
# define _STLP_DBG_ALLOCATOR_SELECT( _Tp ) _STLP_DEFAULT_ALLOCATOR_SELECT( _Tp )
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
//============================================================
|
||||
|
||||
template <class _Iterator>
|
||||
void _Decrement(_Iterator& __it, const bidirectional_iterator_tag &) {
|
||||
--__it;
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
void _Decrement(_Iterator& __it, const random_access_iterator_tag &) {
|
||||
--__it;
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
void _Decrement(_Iterator& __it, const forward_iterator_tag &) {
|
||||
_STLP_ASSERT(0)
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
void _Advance(_Iterator&, ptrdiff_t, const forward_iterator_tag &) {
|
||||
_STLP_ASSERT(0)
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
void _Advance(_Iterator& __it, ptrdiff_t, const bidirectional_iterator_tag &) {
|
||||
_STLP_ASSERT(0)
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
void _Advance(_Iterator& __it, ptrdiff_t __n, const random_access_iterator_tag &) {
|
||||
__it += __n;
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
ptrdiff_t _DBG_distance(const _Iterator& __x, const _Iterator& __y, const random_access_iterator_tag &) {
|
||||
return __x - __y;
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
ptrdiff_t _DBG_distance(const _Iterator&, const _Iterator&, const forward_iterator_tag &) {
|
||||
_STLP_ASSERT(0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
ptrdiff_t _DBG_distance(const _Iterator&, const _Iterator&, const bidirectional_iterator_tag &) {
|
||||
_STLP_ASSERT(0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
bool _CompareIt(const _Iterator&, const _Iterator&, const forward_iterator_tag &) {
|
||||
_STLP_ASSERT(0)
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
bool _CompareIt(const _Iterator&, const _Iterator&, const bidirectional_iterator_tag &) {
|
||||
_STLP_ASSERT(0)
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
bool _CompareIt(const _Iterator& __x, const _Iterator& __y, const random_access_iterator_tag &) {
|
||||
return __x < __y;
|
||||
}
|
||||
|
||||
|
||||
template <class _Iterator>
|
||||
bool _Dereferenceable(_Iterator __it) {
|
||||
return (__it._Get_container_ptr() !=0) && !(__it._M_iterator == (__it._Get_container_ptr())->end());
|
||||
}
|
||||
|
||||
|
||||
template <class _Iterator>
|
||||
bool _Incrementable(const _Iterator& __it, ptrdiff_t __n, const forward_iterator_tag &) {
|
||||
return (__n == 1) && _Dereferenceable(__it);
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
bool _Incrementable(const _Iterator& __it, ptrdiff_t __n, const bidirectional_iterator_tag &) {
|
||||
typedef typename _Iterator::_Container_type __container_type;
|
||||
__container_type* __c = __it._Get_container_ptr();
|
||||
return (__c!=0) && ((__n == 1 && __it._M_iterator != __c->end() ) ||
|
||||
(__n == -1 && __it._M_iterator != __c->begin()));
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
bool _Incrementable(const _Iterator& __it, ptrdiff_t __n, const random_access_iterator_tag &) {
|
||||
typedef typename _Iterator::_Container_type __container_type;
|
||||
__container_type* __c = __it._Get_container_ptr();
|
||||
if (!__c) return false;
|
||||
ptrdiff_t __new_pos = (__it._M_iterator - __c->begin()) + __n;
|
||||
return (__new_pos >=0) && (__STATIC_CAST(typename __container_type::size_type,__new_pos) <=__c->size());
|
||||
}
|
||||
|
||||
|
||||
template <class _Container>
|
||||
struct _DBG_iter_base : public __owned_link {
|
||||
public:
|
||||
typedef typename _Container::value_type value_type;
|
||||
typedef typename _Container::reference reference;
|
||||
typedef typename _Container::pointer pointer;
|
||||
typedef ptrdiff_t difference_type;
|
||||
//private:
|
||||
typedef typename _Container::iterator _Nonconst_iterator;
|
||||
typedef typename _Container::const_iterator _Const_iterator;
|
||||
typedef _Container _Container_type;
|
||||
|
||||
# ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
|
||||
typedef typename iterator_traits<_Const_iterator>::iterator_category _Iterator_category;
|
||||
# else
|
||||
typedef typename _Container::_Iterator_category _Iterator_category;
|
||||
# endif
|
||||
typedef _Iterator_category iterator_category;
|
||||
|
||||
_DBG_iter_base() : __owned_link(0) {}
|
||||
_DBG_iter_base(const __owned_list* __c, const _Const_iterator& __it) :
|
||||
# ifdef __HP_aCC
|
||||
__owned_link(__c), _M_iterator(*__REINTERPRET_CAST(const _Nonconst_iterator *, &__it)) {}
|
||||
# else
|
||||
__owned_link(__c), _M_iterator(*(const _Nonconst_iterator*)&__it) {}
|
||||
# endif
|
||||
_Container* _Get_container_ptr() const {
|
||||
return (_Container*)__stl_debugger::_Get_container_ptr(this);
|
||||
}
|
||||
|
||||
void __increment() {
|
||||
_STLP_DEBUG_CHECK(_Incrementable(*this,1,_Iterator_category()))
|
||||
++_M_iterator;
|
||||
}
|
||||
|
||||
void __decrement() {
|
||||
_STLP_DEBUG_CHECK(_Incrementable(*this,-1,_Iterator_category()))
|
||||
_Decrement(_M_iterator, _Iterator_category());
|
||||
}
|
||||
|
||||
void __advance(difference_type __n) {
|
||||
_STLP_DEBUG_CHECK(_Incrementable(*this,__n, _Iterator_category()))
|
||||
_Advance(_M_iterator,__n, _Iterator_category());
|
||||
}
|
||||
|
||||
// protected:
|
||||
_Nonconst_iterator _M_iterator;
|
||||
};
|
||||
|
||||
template <class _Container>
|
||||
ptrdiff_t operator-(const _DBG_iter_base<_Container>& __x,
|
||||
const _DBG_iter_base<_Container>& __y ) {
|
||||
typedef typename _DBG_iter_base<_Container>::_Iterator_category _Iterator_category;
|
||||
_STLP_DEBUG_CHECK(__check_same_owner(__x, __y))
|
||||
return _DBG_distance(__x._M_iterator,__y._M_iterator, _Iterator_category());
|
||||
}
|
||||
|
||||
template <class _Container, class _Traits>
|
||||
struct _DBG_iter_mid : public _DBG_iter_base<_Container>
|
||||
{
|
||||
typedef _DBG_iter_mid<_Container, typename _Traits::_Non_const_traits> _Nonconst_self;
|
||||
typedef typename _Container::iterator _Nonconst_iterator;
|
||||
typedef typename _Container::const_iterator _Const_iterator;
|
||||
|
||||
_DBG_iter_mid() {}
|
||||
|
||||
explicit _DBG_iter_mid(const _Nonconst_self& __it) :
|
||||
_DBG_iter_base<_Container>(__it) {}
|
||||
|
||||
_DBG_iter_mid(const __owned_list* __c, const _Const_iterator& __it) :
|
||||
_DBG_iter_base<_Container>(__c, __it) {}
|
||||
};
|
||||
|
||||
template <class _Container, class _Traits>
|
||||
struct _DBG_iter : public _DBG_iter_mid<_Container, _Traits> {
|
||||
typedef _DBG_iter_base<_Container> _Base;
|
||||
public:
|
||||
typedef typename _Base::value_type value_type;
|
||||
typedef typename _Base::difference_type difference_type;
|
||||
typedef typename _Traits::reference reference;
|
||||
typedef typename _Traits::pointer pointer;
|
||||
|
||||
private:
|
||||
typedef typename _Base::_Nonconst_iterator _Nonconst_iterator;
|
||||
typedef typename _Base::_Const_iterator _Const_iterator;
|
||||
|
||||
typedef _DBG_iter<_Container, _Traits> _Self;
|
||||
typedef _DBG_iter_mid<_Container, typename _Traits::_Non_const_traits> _Nonconst_mid;
|
||||
|
||||
public:
|
||||
|
||||
# ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
|
||||
typedef typename _Base::iterator_category iterator_category;
|
||||
# endif
|
||||
typedef typename _Base::_Iterator_category _Iterator_category;
|
||||
|
||||
public:
|
||||
_DBG_iter() {}
|
||||
// boris : real type of iter would be nice
|
||||
_DBG_iter(const __owned_list* __c, const _Const_iterator& __it) :
|
||||
_DBG_iter_mid<_Container, _Traits>(__c, __it) {}
|
||||
|
||||
// This allows conversions from iterator to const_iterator without being
|
||||
// redundant with the copy constructor below.
|
||||
_DBG_iter(const _Nonconst_mid& __rhs) :
|
||||
_DBG_iter_mid<_Container, _Traits>(__rhs) {}
|
||||
|
||||
_DBG_iter(const _Self& __rhs) :
|
||||
_DBG_iter_mid<_Container, _Traits>(__rhs) {}
|
||||
|
||||
// This allows conversions from iterator to const_iterator without being
|
||||
// redundant with the copy assignment operator below.
|
||||
_Self& operator=(const _Nonconst_mid& __rhs)
|
||||
{
|
||||
(_Base&)*this = __rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator=(const _Self& __rhs)
|
||||
{
|
||||
(_Base&)*this = __rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
reference operator*() const {
|
||||
_STLP_DEBUG_CHECK(_Dereferenceable(*this))
|
||||
return *this->_M_iterator;
|
||||
}
|
||||
|
||||
_STLP_DEFINE_ARROW_OPERATOR
|
||||
|
||||
_Self& operator++() {
|
||||
this->__increment();
|
||||
return *this;
|
||||
}
|
||||
_Self operator++(int) {
|
||||
_Self __tmp = *this;
|
||||
this->__increment();
|
||||
return __tmp;
|
||||
}
|
||||
_Self& operator--() {
|
||||
this->__decrement();
|
||||
return *this;
|
||||
}
|
||||
_Self operator--(int) {
|
||||
_Self __tmp = *this;
|
||||
this->__decrement();
|
||||
return __tmp;
|
||||
}
|
||||
|
||||
_Self& operator+=(difference_type __n) {
|
||||
this->__advance(__n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator-=(difference_type __n) {
|
||||
this->__advance(-__n);
|
||||
return *this;
|
||||
}
|
||||
_Self operator+(difference_type __n) const {
|
||||
_Self __tmp(*this);
|
||||
__tmp.__advance(__n);
|
||||
return __tmp;
|
||||
}
|
||||
_Self operator-(difference_type __n) const {
|
||||
_Self __tmp(*this);
|
||||
__tmp.__advance(-__n);
|
||||
return __tmp;
|
||||
}
|
||||
reference operator[](difference_type __n) const { return *(*this + __n); }
|
||||
};
|
||||
|
||||
template <class _Container>
|
||||
inline bool
|
||||
operator==(const _DBG_iter_base<_Container>& __x, const _DBG_iter_base<_Container>& __y) {
|
||||
_STLP_DEBUG_CHECK(__check_same_owner_or_null(__x, __y))
|
||||
return __x._M_iterator==__y._M_iterator;
|
||||
}
|
||||
|
||||
template <class _Container>
|
||||
inline bool
|
||||
operator<(const _DBG_iter_base<_Container>& __x, const _DBG_iter_base<_Container>& __y) {
|
||||
_STLP_DEBUG_CHECK(__check_same_owner_or_null(__x, __y))
|
||||
typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category;
|
||||
return _CompareIt(__x._M_iterator , __y._M_iterator, _Category());
|
||||
}
|
||||
|
||||
template <class _Container>
|
||||
inline bool
|
||||
operator>(const _DBG_iter_base<_Container>& __x,
|
||||
const _DBG_iter_base<_Container>& __y) {
|
||||
typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category;
|
||||
return _CompareIt(__y._M_iterator , __x._M_iterator, _Category());
|
||||
}
|
||||
|
||||
template <class _Container>
|
||||
inline bool
|
||||
operator>=(const _DBG_iter_base<_Container>& __x, const _DBG_iter_base<_Container>& __y) {
|
||||
_STLP_DEBUG_CHECK(__check_same_owner_or_null(__x, __y))
|
||||
typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category;
|
||||
return !_CompareIt(__x._M_iterator , __y._M_iterator, _Category());
|
||||
}
|
||||
|
||||
template <class _Container>
|
||||
inline bool
|
||||
operator<=(const _DBG_iter_base<_Container>& __x,
|
||||
const _DBG_iter_base<_Container>& __y) {
|
||||
typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category;
|
||||
return !_CompareIt(__y._M_iterator , __x._M_iterator, _Category());
|
||||
}
|
||||
|
||||
template <class _Container>
|
||||
inline bool
|
||||
operator!=(const _DBG_iter_base<_Container>& __x,
|
||||
const _DBG_iter_base<_Container>& __y) {
|
||||
_STLP_DEBUG_CHECK(__check_same_owner_or_null(__x, __y))
|
||||
return __x._M_iterator != __y._M_iterator;
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
|
||||
template <class _Container, class _Traits>
|
||||
inline _DBG_iter<_Container, _Traits>
|
||||
operator+(ptrdiff_t __n, const _DBG_iter<_Container, _Traits>& __it) {
|
||||
_DBG_iter<_Container, _Traits> __tmp(__it);
|
||||
return __tmp += __n;
|
||||
}
|
||||
|
||||
|
||||
# ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
|
||||
# if defined (_STLP_NESTED_TYPE_PARAM_BUG) \
|
||||
|| ( defined (__SUNPRO_CC) && __SUNPRO_CC < 0x600) \
|
||||
|| ( defined (_STLP_MSVC) && (_STLP_MSVC < 1100) )
|
||||
# define _STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS 1
|
||||
# endif
|
||||
|
||||
template <class _Container>
|
||||
inline ptrdiff_t*
|
||||
distance_type(const _DBG_iter_base<_Container>&) { return (ptrdiff_t*) 0; }
|
||||
|
||||
# if !defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
|
||||
template <class _Container>
|
||||
inline _STLP_TYPENAME_ON_RETURN_TYPE _DBG_iter_base<_Container>::value_type*
|
||||
value_type(const _DBG_iter_base<_Container>&) {
|
||||
typedef typename _DBG_iter_base<_Container>::value_type _Val;
|
||||
return (_Val*)0;
|
||||
}
|
||||
|
||||
template <class _Container>
|
||||
inline _STLP_TYPENAME_ON_RETURN_TYPE _DBG_iter_base<_Container>::_Iterator_category
|
||||
iterator_category(const _DBG_iter_base<_Container>&) {
|
||||
typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category;
|
||||
return _Category();
|
||||
}
|
||||
# endif
|
||||
|
||||
# endif /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */
|
||||
|
||||
# define _Get_iter(__x) __x
|
||||
# define _Debug_iter(__x, __y) __y
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* INTERNAL_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
318
STLPORT/stlport/stl/debug/_list.h
Normal file
318
STLPORT/stlport/stl/debug/_list.h
Normal file
@@ -0,0 +1,318 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_DBG_LIST_H
|
||||
#define _STLP_INTERNAL_DBG_LIST_H
|
||||
|
||||
#include <stl/debug/_iterator.h>
|
||||
|
||||
# ifndef _STLP_USE_WRAPPER_FOR_ALLOC_PARAM
|
||||
# undef _DBG_list
|
||||
# define _DBG_list list
|
||||
# endif
|
||||
|
||||
# define _STLP_DBG_LIST_BASE \
|
||||
__WORKAROUND_DBG_RENAME(list) <_Tp, _Alloc>
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
# ifdef _STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _Tp*
|
||||
value_type(const _DBG_iter_base< _STLP_DBG_LIST_BASE >&) {
|
||||
return (_Tp*)0;
|
||||
}
|
||||
template <class _Tp, class _Alloc>
|
||||
inline bidirectional_iterator_tag
|
||||
iterator_category(const _DBG_iter_base< _STLP_DBG_LIST_BASE >&) {
|
||||
return bidirectional_iterator_tag();
|
||||
}
|
||||
# endif
|
||||
|
||||
template <class _Tp, _STLP_DEFAULT_ALLOCATOR_SELECT(_Tp) >
|
||||
class _DBG_list : public _STLP_DBG_LIST_BASE {
|
||||
|
||||
typedef _STLP_DBG_LIST_BASE _Base;
|
||||
typedef _DBG_list<_Tp, _Alloc> _Self;
|
||||
|
||||
public:
|
||||
__IMPORT_CONTAINER_TYPEDEFS(_Base)
|
||||
|
||||
public:
|
||||
typedef _DBG_iter<_Base, _Nonconst_traits<value_type> > iterator;
|
||||
typedef _DBG_iter<_Base, _Const_traits<value_type> > const_iterator;
|
||||
|
||||
_STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS;
|
||||
|
||||
protected:
|
||||
mutable __owned_list _M_iter_list;
|
||||
void _Invalidate_all() { _M_iter_list._Invalidate_all();}
|
||||
|
||||
public:
|
||||
const _Base* _Get_base() const { return (const _Base*)this; }
|
||||
_Base* _Get_base() { return (_Base*)this; }
|
||||
explicit _DBG_list(const allocator_type& __a = allocator_type()) :
|
||||
_STLP_DBG_LIST_BASE(__a), _M_iter_list(_Get_base()) {}
|
||||
_DBG_list(size_type __n, const _Tp& __value,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _STLP_DBG_LIST_BASE(__n, __value, __a), _M_iter_list(_Get_base()) {}
|
||||
explicit _DBG_list(size_type __n)
|
||||
: _STLP_DBG_LIST_BASE(__n), _M_iter_list(_Get_base()) {}
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
|
||||
// We don't need any dispatching tricks here, because insert does all of
|
||||
// that anyway.
|
||||
# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
|
||||
template <class _InputIterator>
|
||||
_DBG_list(_InputIterator __first, _InputIterator __last)
|
||||
: _STLP_DBG_LIST_BASE(__first, __last, allocator_type()), _M_iter_list(_Get_base()) {}
|
||||
# endif
|
||||
template <class _InputIterator>
|
||||
_DBG_list(_InputIterator __first, _InputIterator __last,
|
||||
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
|
||||
: _STLP_DBG_LIST_BASE(__first, __last, __a), _M_iter_list(_Get_base()) {}
|
||||
#else /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
_DBG_list(const _Tp* __first, const _Tp* __last,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _STLP_DBG_LIST_BASE(__first, __last, __a), _M_iter_list(_Get_base()) {}
|
||||
_DBG_list(const_iterator __first, const_iterator __last,
|
||||
const allocator_type& __a = allocator_type()):
|
||||
_STLP_DBG_LIST_BASE(__first._M_iterator, __last._M_iterator, __a),
|
||||
_M_iter_list(_Get_base()) {}
|
||||
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
_DBG_list(const _Self& __x) :
|
||||
_STLP_DBG_LIST_BASE(__x) , _M_iter_list(_Get_base()) {}
|
||||
|
||||
_Self& operator=(const _Self& __x) {
|
||||
_Invalidate_all();
|
||||
_Base::operator=((const _Base&)__x);
|
||||
return *this;
|
||||
}
|
||||
|
||||
public:
|
||||
iterator begin() { return iterator(&_M_iter_list, _Base::begin()); }
|
||||
const_iterator begin() const { return const_iterator(&_M_iter_list, _Base::begin()); }
|
||||
|
||||
iterator end() { return iterator(&_M_iter_list, _Base::end()); }
|
||||
const_iterator end() const { return const_iterator(&_M_iter_list, _Base::end()); }
|
||||
|
||||
reverse_iterator rbegin() { return reverse_iterator(end()); }
|
||||
reverse_iterator rend() { return reverse_iterator(begin()); }
|
||||
|
||||
const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
|
||||
const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
|
||||
|
||||
// those are here to enforce checking
|
||||
reference front() { return *begin(); }
|
||||
const_reference front() const { return *begin(); }
|
||||
reference back() { return *(--end()); }
|
||||
const_reference back() const { return *(--end()); }
|
||||
|
||||
void swap(_Self& __x) {
|
||||
_M_iter_list._Swap_owners(__x._M_iter_list);
|
||||
_Base::swap(__x);
|
||||
}
|
||||
|
||||
iterator insert(iterator __position, const _Tp& __x) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__position))
|
||||
return iterator(&_M_iter_list,_Base::insert(__position._M_iterator, __x) );
|
||||
}
|
||||
|
||||
# ifndef _STLP_NO_ANACHRONISMS
|
||||
iterator insert(iterator __position) { return insert(__position, _Tp()); }
|
||||
# endif
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
|
||||
template <class _InputIterator>
|
||||
void insert(iterator __position, _InputIterator __first, _InputIterator __last) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__position))
|
||||
_Base::insert(__position._M_iterator, __first, __last);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void insert(iterator __position, const _Tp* __first, const _Tp* __last) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__position))
|
||||
_Base::insert(__position._M_iterator, __first, __last);
|
||||
}
|
||||
|
||||
void insert(iterator __position,
|
||||
const_iterator __first, const_iterator __last) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__position))
|
||||
_Base::insert(__position._M_iterator, __first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
void insert(iterator __position, size_type __n, const _Tp& __x) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__position))
|
||||
_Base::insert(__position._M_iterator, __n, __x);
|
||||
}
|
||||
|
||||
void pop_back() {
|
||||
_STLP_VERBOSE_ASSERT(!this->empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
__invalidate_iterator(&_M_iter_list,end());
|
||||
_Base::pop_back();
|
||||
}
|
||||
|
||||
void pop_front() {
|
||||
_STLP_VERBOSE_ASSERT(!this->empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
__invalidate_iterator(&_M_iter_list,begin());
|
||||
_Base::pop_front();
|
||||
}
|
||||
|
||||
iterator erase(iterator __position) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__position))
|
||||
_STLP_VERBOSE_ASSERT(__position._M_iterator._M_node!=this->_M_node._M_data,
|
||||
_StlMsg_ERASE_PAST_THE_END)
|
||||
// fbp : CHECK !!!
|
||||
__invalidate_iterator(&_M_iter_list, __position);
|
||||
return iterator(&_M_iter_list,_Base::erase(__position._M_iterator));
|
||||
}
|
||||
iterator erase(iterator __first, iterator __last) {
|
||||
while (__first != __last)
|
||||
erase(__first++);
|
||||
return __last;
|
||||
}
|
||||
|
||||
void resize(size_type __new_size, const _Tp& __x) {
|
||||
typename _Base::iterator __i = _Base::begin();
|
||||
size_type __len = 0;
|
||||
for ( ; __i != _Base::end() && __len < __new_size; ++__i, ++__len);
|
||||
|
||||
if (__len == __new_size)
|
||||
erase(iterator(&_M_iter_list,__i), end());
|
||||
else // __i == end()
|
||||
_Base::insert(_Base::end(), __new_size - __len, __x);
|
||||
}
|
||||
|
||||
void resize(size_type __new_size) { this->resize(__new_size, _Tp()); }
|
||||
|
||||
void remove(const _Tp& __value) {
|
||||
typename _Base::iterator __first = _Base::begin();
|
||||
typename _Base::iterator __last = _Base::end();
|
||||
while (__first != __last) {
|
||||
typename _Base::iterator __next = __first;
|
||||
++__next;
|
||||
if (__value == *__first) erase(iterator(&_M_iter_list,__first));
|
||||
__first = __next;
|
||||
}
|
||||
}
|
||||
|
||||
void clear() {
|
||||
_Invalidate_all();
|
||||
_Base::clear();
|
||||
}
|
||||
|
||||
public:
|
||||
void splice(iterator __position, _Self& __x) {
|
||||
_STLP_VERBOSE_ASSERT(&__x!=this, _StlMsg_INVALID_ARGUMENT)
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__position))
|
||||
_Base::splice(__position._M_iterator, __x);
|
||||
__x._Invalidate_all();
|
||||
}
|
||||
|
||||
void splice(iterator __position, _Self& __x, iterator __i) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__position) &&
|
||||
__check_if_owner(&__x._M_iter_list ,__i))
|
||||
_STLP_DEBUG_CHECK(_Dereferenceable(__i))
|
||||
// fbp : CHECK !!!
|
||||
// __invalidate_iterator(&__x._M_iter_list, __i);
|
||||
_Base::splice(__position._M_iterator, __x, __i._M_iterator);
|
||||
}
|
||||
|
||||
void splice(iterator __position, _Self& __x, iterator __first, iterator __last) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
|
||||
_STLP_VERBOSE_ASSERT(__first._Owner()==&__x._M_iter_list && __last._Owner()==&__x._M_iter_list,
|
||||
_StlMsg_NOT_OWNER)
|
||||
_Base::splice(__position._M_iterator, __x, __first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
|
||||
void merge(_Self& __x) {
|
||||
__x._Invalidate_all();
|
||||
_Base::merge(__x);
|
||||
}
|
||||
void reverse() {
|
||||
_Invalidate_all();
|
||||
_Base::reverse();
|
||||
}
|
||||
void unique() {
|
||||
_Invalidate_all();
|
||||
_Base::unique();
|
||||
}
|
||||
void sort() {
|
||||
_Invalidate_all();
|
||||
_Base::sort();
|
||||
}
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
|
||||
template <class _Predicate> void remove_if(_Predicate __pred) {
|
||||
_Base::remove_if(__pred);
|
||||
}
|
||||
template <class _BinaryPredicate>
|
||||
void unique(_BinaryPredicate __binary_pred) {
|
||||
_Base::unique(__binary_pred);
|
||||
}
|
||||
template <class _StrictWeakOrdering>
|
||||
void merge(_Self& __x,
|
||||
_StrictWeakOrdering __comp) {
|
||||
__x._Invalidate_all();
|
||||
_Base::merge(__x, __comp);
|
||||
}
|
||||
|
||||
template <class _StrictWeakOrdering>
|
||||
void sort(_StrictWeakOrdering __comp) {
|
||||
_Invalidate_all();
|
||||
_Base::sort(__comp);
|
||||
}
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
};
|
||||
|
||||
#define _STLP_TEMPLATE_HEADER template <class _Tp, class _Alloc>
|
||||
#define _STLP_TEMPLATE_CONTAINER _DBG_list<_Tp,_Alloc>
|
||||
#define _STLP_TEMPLATE_CONTAINER_BASE _STLP_DBG_LIST_BASE
|
||||
#include <stl/debug/_relops_cont.h>
|
||||
#undef _STLP_TEMPLATE_CONTAINER_BASE
|
||||
#undef _STLP_TEMPLATE_CONTAINER
|
||||
#undef _STLP_TEMPLATE_HEADER
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_LIST_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
41
STLPORT/stlport/stl/debug/_relops_cont.h
Normal file
41
STLPORT/stlport/stl/debug/_relops_cont.h
Normal file
@@ -0,0 +1,41 @@
|
||||
// This is an implementation file which
|
||||
// is intended to be included multiple times with different _STLP_ASSOCIATIVE_CONTAINER
|
||||
// setting
|
||||
|
||||
#ifdef _STLP_EXTRA_OPERATORS_FOR_DEBUG
|
||||
|
||||
_STLP_TEMPLATE_HEADER
|
||||
inline bool _STLP_CALL
|
||||
operator==(const _STLP_TEMPLATE_CONTAINER& __x, const _STLP_TEMPLATE_CONTAINER& __y)
|
||||
{
|
||||
return (const _STLP_TEMPLATE_CONTAINER_BASE&)__x == (const _STLP_TEMPLATE_CONTAINER_BASE&)__y;
|
||||
}
|
||||
|
||||
_STLP_TEMPLATE_HEADER
|
||||
inline bool _STLP_CALL
|
||||
operator<(const _STLP_TEMPLATE_CONTAINER& __x, const _STLP_TEMPLATE_CONTAINER& __y)
|
||||
{
|
||||
return (const _STLP_TEMPLATE_CONTAINER_BASE&)__x < (const _STLP_TEMPLATE_CONTAINER_BASE&)__y;
|
||||
}
|
||||
|
||||
_STLP_RELOPS_OPERATORS( _STLP_TEMPLATE_HEADER , _STLP_TEMPLATE_CONTAINER )
|
||||
|
||||
#endif /* _STLP_EXTRA_OPERATORS_FOR_DEBUG */
|
||||
|
||||
#ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER
|
||||
|
||||
_STLP_TEMPLATE_HEADER
|
||||
inline void _STLP_CALL swap(_STLP_TEMPLATE_CONTAINER& __x, _STLP_TEMPLATE_CONTAINER& __y)
|
||||
{
|
||||
__x.swap(__y);
|
||||
}
|
||||
|
||||
#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */
|
||||
|
||||
#if 0 /* def _STLP_CLASS_PARTIAL_SPECIALIZATION */
|
||||
|
||||
_STLP_TEMPLATE_HEADER
|
||||
struct __type_traits<_STLP_STD::_STLP_TEMPLATE_CONTAINER > : __type_traits_aux<0, 1>
|
||||
{};
|
||||
|
||||
#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
|
||||
34
STLPORT/stlport/stl/debug/_relops_hash_cont.h
Normal file
34
STLPORT/stlport/stl/debug/_relops_hash_cont.h
Normal file
@@ -0,0 +1,34 @@
|
||||
// This is an implementation file which
|
||||
// is intended to be included multiple times with different _STLP_ASSOCIATIVE_CONTAINER
|
||||
// setting
|
||||
|
||||
#ifdef _STLP_EXTRA_OPERATORS_FOR_DEBUG
|
||||
_STLP_TEMPLATE_HEADER
|
||||
inline bool _STLP_CALL
|
||||
operator==(const _STLP_TEMPLATE_CONTAINER& __hm1, const _STLP_TEMPLATE_CONTAINER& __hm2)
|
||||
{
|
||||
return _STLP_TEMPLATE_CONTAINER_BASE::_M_equal(__hm1, __hm2);
|
||||
}
|
||||
|
||||
#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
|
||||
|
||||
_STLP_TEMPLATE_HEADER
|
||||
inline bool _STLP_CALL
|
||||
operator!=(const _STLP_TEMPLATE_CONTAINER& __hm1, const _STLP_TEMPLATE_CONTAINER& __hm2) {
|
||||
return !(__hm1 == __hm2);
|
||||
}
|
||||
|
||||
#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
|
||||
|
||||
#endif /* _STLP_EXTRA_OPERATORS_FOR_DEBUG */
|
||||
|
||||
#ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER
|
||||
|
||||
_STLP_TEMPLATE_HEADER
|
||||
inline void _STLP_CALL
|
||||
swap(_STLP_TEMPLATE_CONTAINER& __hm1, _STLP_TEMPLATE_CONTAINER& __hm2)
|
||||
{
|
||||
__hm1.swap(__hm2);
|
||||
}
|
||||
|
||||
#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */
|
||||
399
STLPORT/stlport/stl/debug/_slist.h
Normal file
399
STLPORT/stlport/stl/debug/_slist.h
Normal file
@@ -0,0 +1,399 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_DBG_SLIST_H
|
||||
#define _STLP_INTERNAL_DBG_SLIST_H
|
||||
|
||||
#include <stl/debug/_iterator.h>
|
||||
|
||||
# ifndef _STLP_USE_WRAPPER_FOR_ALLOC_PARAM
|
||||
# undef _DBG_slist
|
||||
# define _DBG_slist slist
|
||||
# endif
|
||||
|
||||
# define _STLP_DBG_SLIST_BASE __WORKAROUND_DBG_RENAME(slist) <_Tp, _Alloc>
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
# ifdef _STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _Tp*
|
||||
value_type(const _DBG_iter_base< _STLP_DBG_SLIST_BASE >&) {
|
||||
return (_Tp*)0;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline forward_iterator_tag
|
||||
iterator_category(const _DBG_iter_base< _STLP_DBG_SLIST_BASE >&) {
|
||||
return forward_iterator_tag();
|
||||
}
|
||||
# endif
|
||||
|
||||
template <class _Tp, _STLP_DEFAULT_ALLOCATOR_SELECT(_Tp) >
|
||||
class _DBG_slist : public _STLP_DBG_SLIST_BASE
|
||||
{
|
||||
private:
|
||||
typedef _STLP_DBG_SLIST_BASE _Base;
|
||||
typedef _DBG_slist<_Tp,_Alloc> _Self;
|
||||
|
||||
public:
|
||||
|
||||
__IMPORT_CONTAINER_TYPEDEFS(_Base)
|
||||
|
||||
typedef _DBG_iter<_Base, _Nonconst_traits<value_type> > iterator;
|
||||
typedef _DBG_iter<_Base, _Const_traits<value_type> > const_iterator;
|
||||
|
||||
protected:
|
||||
friend class __owned_link;
|
||||
mutable __owned_list _M_iter_list;
|
||||
void _Invalidate_all() { _M_iter_list._Invalidate_all();}
|
||||
void _Invalidate_iterator(const iterator& __it) {__invalidate_iterator(&_M_iter_list, __it); }
|
||||
|
||||
public:
|
||||
const _Base* _Get_base() const { return (const _Base*)this; }
|
||||
_Base* _Get_base() { return (_Base*)this; }
|
||||
|
||||
public:
|
||||
|
||||
explicit _DBG_slist(const allocator_type& __a = allocator_type()) :
|
||||
_STLP_DBG_SLIST_BASE(__a) , _M_iter_list(_Get_base()) {}
|
||||
|
||||
_DBG_slist(size_type __n, const value_type& __x,
|
||||
const allocator_type& __a = allocator_type()) :
|
||||
_STLP_DBG_SLIST_BASE(__n, __x, __a), _M_iter_list(_Get_base()) {}
|
||||
|
||||
explicit _DBG_slist(size_type __n) : _STLP_DBG_SLIST_BASE(__n) , _M_iter_list(_Get_base()) {}
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
// We don't need any dispatching tricks here, because _M_insert_after_range
|
||||
// already does them.
|
||||
# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
|
||||
template <class _InputIterator>
|
||||
_DBG_slist(_InputIterator __first, _InputIterator __last) :
|
||||
_STLP_DBG_SLIST_BASE(__first, __last, allocator_type()), _M_iter_list(_Get_base()) {}
|
||||
# endif
|
||||
template <class _InputIterator>
|
||||
_DBG_slist(_InputIterator __first, _InputIterator __last,
|
||||
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) :
|
||||
_STLP_DBG_SLIST_BASE(__first, __last, __a), _M_iter_list(_Get_base()) {}
|
||||
|
||||
#else /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
_DBG_slist(const_iterator __first, const_iterator __last,
|
||||
const allocator_type& __a = allocator_type() ) :
|
||||
_STLP_DBG_SLIST_BASE(__first._M_iterator, __last._M_iterator, __a),
|
||||
_M_iter_list(_Get_base()) {}
|
||||
|
||||
_DBG_slist(const value_type* __first, const value_type* __last,
|
||||
const allocator_type& __a = allocator_type()) :
|
||||
_STLP_DBG_SLIST_BASE(__first, __last, __a), _M_iter_list(_Get_base()) {}
|
||||
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
_DBG_slist(const _Self& __x) : _STLP_DBG_SLIST_BASE(__x), _M_iter_list(_Get_base()) {}
|
||||
|
||||
_Self& operator= (const _Self& __x) {
|
||||
_Invalidate_all();
|
||||
(_Base&)*this = (const _Base&)__x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
~_DBG_slist() {}
|
||||
|
||||
public:
|
||||
void assign(size_type __n, const _Tp& __val) {
|
||||
// fbp :check invalidation here !
|
||||
_Base::assign(__n, __val);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
iterator before_begin() { return iterator(&_M_iter_list, _Base::before_begin()); }
|
||||
const_iterator before_begin() const
|
||||
{ return const_iterator(&_M_iter_list, _Base::before_begin()); }
|
||||
|
||||
iterator begin() { return iterator(&_M_iter_list, _Base::begin()); }
|
||||
const_iterator begin() const
|
||||
{ return const_iterator(&_M_iter_list,_Base::begin());}
|
||||
|
||||
iterator end() { return iterator(&_M_iter_list, _Base::end()); }
|
||||
const_iterator end() const { return const_iterator(&_M_iter_list, _Base::end()); }
|
||||
|
||||
void swap(_Self& __x) {
|
||||
_M_iter_list._Swap_owners(__x._M_iter_list);
|
||||
_Base::swap(__x);
|
||||
}
|
||||
|
||||
public:
|
||||
// fbp : checks here !
|
||||
reference front() {
|
||||
_STLP_VERBOSE_ASSERT(!this->empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
return _Base::front();
|
||||
}
|
||||
const_reference front() const {
|
||||
_STLP_VERBOSE_ASSERT(!this->empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
return _Base::front();
|
||||
}
|
||||
void pop_front() {
|
||||
_STLP_VERBOSE_ASSERT(!this->empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
_Base::pop_front();
|
||||
}
|
||||
iterator previous(const_iterator __pos) {
|
||||
return iterator(&_M_iter_list,_Base::previous(__pos._M_iterator));
|
||||
}
|
||||
const_iterator previous(const_iterator __pos) const {
|
||||
return const_iterator(&_M_iter_list,_Base::previous(__pos._M_iterator));
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
iterator insert_after(iterator __pos, const value_type& __x) {
|
||||
return iterator(&_M_iter_list,_Base::insert_after(__pos._M_iterator, __x));
|
||||
}
|
||||
|
||||
iterator insert_after(iterator __pos) {
|
||||
return iterator(&_M_iter_list,_Base::insert_after(__pos._M_iterator));
|
||||
}
|
||||
|
||||
void insert_after(iterator __pos, size_type __n, const value_type& __x) {
|
||||
_Base::insert_after(__pos._M_iterator, __n, __x);
|
||||
}
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
|
||||
template <class _InputIterator>
|
||||
void assign(_InputIterator __first, _InputIterator __last) {
|
||||
// fbp :check invalidation here !
|
||||
_Base::assign(__first, __last);
|
||||
}
|
||||
|
||||
// We don't need any dispatching tricks here, because _M_insert_after_range
|
||||
// already does them.
|
||||
template <class _InIter>
|
||||
void insert_after(iterator __pos, _InIter __first, _InIter __last) {
|
||||
_Base::insert_after(__pos._M_iterator, __first, __last);
|
||||
}
|
||||
|
||||
// We don't need any dispatching tricks here, because _M_insert_after_range
|
||||
// already does them.
|
||||
template <class _InIter>
|
||||
void insert(iterator __pos, _InIter __first, _InIter __last) {
|
||||
_Base::insert(__pos._M_iterator, __first, __last);
|
||||
|
||||
}
|
||||
|
||||
#else /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
void insert_after(iterator __pos,
|
||||
const_iterator __first, const_iterator __last) {
|
||||
_Base::insert_after(__pos._M_iterator, __first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
void insert_after(iterator __pos,
|
||||
const value_type* __first, const value_type* __last) {
|
||||
_Base::insert_after(__pos._M_iterator, __first, __last);
|
||||
}
|
||||
|
||||
void insert(iterator __pos, const_iterator __first, const_iterator __last) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos))
|
||||
_Base::insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
void insert(iterator __pos, const value_type* __first,
|
||||
const value_type* __last) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos))
|
||||
_Base::insert(__pos._M_iterator, __first, __last);
|
||||
}
|
||||
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
iterator insert(iterator __pos, const value_type& __x) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos))
|
||||
return iterator(&_M_iter_list, _Base::insert(__pos._M_iterator, __x));
|
||||
}
|
||||
|
||||
iterator insert(iterator __pos) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos))
|
||||
return iterator(&_M_iter_list, _Base::insert(__pos._M_iterator));
|
||||
}
|
||||
|
||||
void insert(iterator __pos, size_type __n, const value_type& __x) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos))
|
||||
_Base::insert(__pos._M_iterator, __n, __x);
|
||||
}
|
||||
|
||||
public:
|
||||
iterator erase_after(iterator __pos) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos))
|
||||
return iterator(&_M_iter_list, _Base::erase_after(__pos._M_iterator));
|
||||
}
|
||||
iterator erase_after(iterator __before_first, iterator __last) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__before_first))
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__last))
|
||||
return iterator(&_M_iter_list,
|
||||
_Base::erase_after(__before_first._M_iterator, __last._M_iterator));
|
||||
}
|
||||
|
||||
iterator erase(iterator __pos) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos))
|
||||
return iterator(&_M_iter_list, _Base::erase(__pos._M_iterator));
|
||||
}
|
||||
iterator erase(iterator __first, iterator __last) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__first))
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__last))
|
||||
return iterator(&_M_iter_list,
|
||||
_Base::erase(__first._M_iterator, __last._M_iterator));
|
||||
}
|
||||
|
||||
void resize(size_type __new_size, const _Tp& __x) {
|
||||
_Base::resize(__new_size, __x);
|
||||
}
|
||||
void resize(size_type new_size) { resize(new_size, _Tp()); }
|
||||
|
||||
void clear() {
|
||||
_Invalidate_all();
|
||||
_Base::clear();
|
||||
}
|
||||
|
||||
public:
|
||||
// Moves the range [__before_first + 1, __before_last + 1) to *this,
|
||||
// inserting it immediately after __pos. This is constant time.
|
||||
void splice_after(iterator __pos,
|
||||
iterator __before_first, iterator __before_last)
|
||||
{
|
||||
if (__before_first != __before_last) {
|
||||
_Base::splice_after(__pos._M_iterator,
|
||||
__before_first._M_iterator, __before_last._M_iterator);
|
||||
__before_first++;
|
||||
__before_last++;
|
||||
__invalidate_range(__before_first._Owner(),
|
||||
__before_first, __before_last);
|
||||
}
|
||||
}
|
||||
|
||||
// Moves the element that follows __prev to *this, inserting it immediately
|
||||
// after __pos. This is constant time.
|
||||
void splice_after(iterator __pos, iterator __prev)
|
||||
{
|
||||
_Base::splice_after(__pos._M_iterator, __prev._M_iterator);
|
||||
__invalidate_iterator(__prev._Owner(), ++__prev);
|
||||
}
|
||||
|
||||
// Removes all of the elements from the list __x to *this, inserting
|
||||
// them immediately after __pos. __x must not be *this. Complexity:
|
||||
// linear in __x.size().
|
||||
void splice_after(iterator __pos, _Self& __x)
|
||||
{
|
||||
_Base::splice_after(__pos._M_iterator, (_Base&)__x);
|
||||
__x._Invalidate_all();
|
||||
}
|
||||
|
||||
// Linear in distance(begin(), __pos), and linear in __x.size().
|
||||
void splice(iterator __pos, _Self& __x) {
|
||||
_STLP_VERBOSE_ASSERT(!(&__x==this), _StlMsg_INVALID_ARGUMENT)
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos))
|
||||
_Base::splice(__pos._M_iterator, (_Base&)__x);
|
||||
__x._Invalidate_all();
|
||||
}
|
||||
|
||||
// Linear in distance(begin(), __pos), and in distance(__x.begin(), __i).
|
||||
void splice(iterator __pos, _Self& __x, iterator __i) {
|
||||
_STLP_VERBOSE_ASSERT(&__x!=this, _StlMsg_INVALID_ARGUMENT)
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos) &&
|
||||
__check_if_owner(&__x._M_iter_list ,__i))
|
||||
_Base::splice(__pos._M_iterator, (_Base&)__x, __i._M_iterator);
|
||||
__x._Invalidate_iterator(__i);
|
||||
}
|
||||
|
||||
// Linear in distance(begin(), __pos), in distance(__x.begin(), __first),
|
||||
// and in distance(__first, __last).
|
||||
void splice(iterator __pos, _Self& __x, iterator __first, iterator __last)
|
||||
{
|
||||
_STLP_VERBOSE_ASSERT(&__x!=this, _StlMsg_INVALID_ARGUMENT)
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos))
|
||||
if (__first != __last)
|
||||
_Base::splice(__pos._M_iterator, (_Base&)__x, __first._M_iterator, __last._M_iterator);
|
||||
__invalidate_range(&__x._M_iter_list, __first, __last);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
void remove(const _Tp& __val) {
|
||||
_Base::remove(__val);
|
||||
// __x._Invalidate_all();
|
||||
}
|
||||
void unique() {
|
||||
_Base::unique();
|
||||
}
|
||||
void merge(_Self& __x) {
|
||||
_Base::merge((_Base&)__x);
|
||||
__x._Invalidate_all();
|
||||
}
|
||||
void sort() {
|
||||
_Invalidate_all();
|
||||
_Base::sort();
|
||||
}
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
|
||||
template <class _Predicate>
|
||||
void remove_if(_Predicate __pred) {
|
||||
_Base::remove_if(__pred);
|
||||
}
|
||||
|
||||
template <class _BinaryPredicate>
|
||||
void unique(_BinaryPredicate __pred) {
|
||||
_Base::unique(__pred);
|
||||
}
|
||||
|
||||
template <class _StrictWeakOrdering>
|
||||
void merge(_Self& __x, _StrictWeakOrdering __ord) {
|
||||
_Base::merge((_Base&)__x, __ord);
|
||||
__x._Invalidate_all();
|
||||
}
|
||||
|
||||
template <class _StrictWeakOrdering>
|
||||
void sort(_StrictWeakOrdering __comp) {
|
||||
_Invalidate_all();
|
||||
_Base::sort(__comp);
|
||||
}
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
};
|
||||
|
||||
#define _STLP_TEMPLATE_HEADER template <class _Tp, class _Alloc>
|
||||
#define _STLP_TEMPLATE_CONTAINER _DBG_slist<_Tp,_Alloc>
|
||||
#define _STLP_TEMPLATE_CONTAINER_BASE _STLP_DBG_SLIST_BASE
|
||||
#include <stl/debug/_relops_cont.h>
|
||||
#undef _STLP_TEMPLATE_CONTAINER_BASE
|
||||
#undef _STLP_TEMPLATE_CONTAINER
|
||||
#undef _STLP_TEMPLATE_HEADER
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_DBG_SLIST_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
772
STLPORT/stlport/stl/debug/_string.h
Normal file
772
STLPORT/stlport/stl/debug/_string.h
Normal file
@@ -0,0 +1,772 @@
|
||||
/*
|
||||
* Copyright (c) 1997-1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_DBG_STRING_H
|
||||
#define _STLP_DBG_STRING_H
|
||||
|
||||
#include <stl/debug/_iterator.h>
|
||||
|
||||
# define _STLP_DBG_STRING_BASE _Nondebug_string <_CharT, _Traits, _Alloc>
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
# ifdef _STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS
|
||||
template <class _CharT,class _Traits, class _Alloc>
|
||||
inline _CharT*
|
||||
value_type(const _DBG_iter_base< _STLP_DBG_STRING_BASE >&) {
|
||||
return (_CharT*)0;
|
||||
}
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline random_access_iterator_tag
|
||||
iterator_category(const _DBG_iter_base< _STLP_DBG_STRING_BASE >&) {
|
||||
return random_access_iterator_tag();
|
||||
}
|
||||
# endif
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
class basic_string : public _STLP_DBG_STRING_BASE {
|
||||
private:
|
||||
typedef _STLP_DBG_STRING_BASE _Base;
|
||||
typedef basic_string<_CharT, _Traits, _Alloc> _Self;
|
||||
protected:
|
||||
mutable __owned_list _M_iter_list;
|
||||
public:
|
||||
__IMPORT_CONTAINER_TYPEDEFS(_Base)
|
||||
typedef _DBG_iter<_Base, _Nonconst_traits<value_type> > iterator;
|
||||
typedef _DBG_iter<_Base, _Const_traits<value_type> > const_iterator;
|
||||
_STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
|
||||
# ifdef _STLP_USE_NATIVE_STRING
|
||||
// this typedef is being used for conversions
|
||||
typedef _STLP_VENDOR_STD::basic_string<_CharT,_Traits,
|
||||
_STLP_VENDOR_STD::allocator<_CharT> > __std_string;
|
||||
# endif
|
||||
public: // Constructor, destructor, assignment.
|
||||
typedef typename _Base::_Reserve_t _Reserve_t;
|
||||
|
||||
const _Base* _Get_base() const { return (const _Base*)this; }
|
||||
_Base* _Get_base() { return (_Base*)this; }
|
||||
|
||||
basic_string() :_STLP_DBG_STRING_BASE(), _M_iter_list(_Get_base()) {}
|
||||
|
||||
explicit basic_string(const allocator_type& __a):
|
||||
_STLP_DBG_STRING_BASE(__a), _M_iter_list(_Get_base()) {}
|
||||
|
||||
basic_string(_Reserve_t __r, size_t __n,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _STLP_DBG_STRING_BASE(__r, __n, __a), _M_iter_list(_Get_base()) {}
|
||||
|
||||
basic_string(const _Self& __s):
|
||||
_STLP_DBG_STRING_BASE(__s), _M_iter_list(_Get_base()) {}
|
||||
|
||||
basic_string(const _Self& __s, size_type __pos, size_type __n = _Base::npos,
|
||||
const allocator_type& __a = allocator_type()):
|
||||
_STLP_DBG_STRING_BASE(__s, __pos, __n, __a), _M_iter_list(_Get_base()) {}
|
||||
|
||||
basic_string(const _CharT* __s, size_type __n,
|
||||
const allocator_type& __a = allocator_type()):
|
||||
_STLP_DBG_STRING_BASE(__s, __n, __a), _M_iter_list(_Get_base()) {}
|
||||
|
||||
basic_string(const _CharT* __s,
|
||||
const allocator_type& __a = allocator_type()):
|
||||
_STLP_DBG_STRING_BASE(__s, __a), _M_iter_list(_Get_base()) {}
|
||||
|
||||
basic_string(size_type __n, _CharT __c,
|
||||
const allocator_type& __a = allocator_type()):
|
||||
_STLP_DBG_STRING_BASE(__n, __c, __a), _M_iter_list(_Get_base()) {}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES) && !(defined(__MRC__)||(defined(__SC__) && !defined(__DMC__)))
|
||||
# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
|
||||
template <class _InputIterator>
|
||||
basic_string(_InputIterator __f, _InputIterator __l):
|
||||
_STLP_DBG_STRING_BASE(__f, __l), _M_iter_list(_Get_base()) {}
|
||||
# endif
|
||||
template <class _InputIterator>
|
||||
basic_string(_InputIterator __f, _InputIterator __l,
|
||||
const allocator_type & __a _STLP_ALLOCATOR_TYPE_DFL):
|
||||
_STLP_DBG_STRING_BASE(__f, __l, __a), _M_iter_list(_Get_base()) {}
|
||||
#else /* _STLP_MEMBER_TEMPLATES */
|
||||
basic_string(const_iterator __f, const_iterator __l,
|
||||
const allocator_type & __a = allocator_type()):
|
||||
_STLP_DBG_STRING_BASE(__f._M_iterator, __l._M_iterator, __a),
|
||||
_M_iter_list(_Get_base()) {}
|
||||
|
||||
basic_string(const _CharT* __f, const _CharT* __l,
|
||||
const allocator_type& __a = allocator_type()):
|
||||
_STLP_DBG_STRING_BASE(__f, __l, __a), _M_iter_list(_Get_base()) {}
|
||||
#endif
|
||||
|
||||
# ifdef _STLP_USE_NATIVE_STRING
|
||||
// these conversion operations still needed for
|
||||
// strstream, etc.
|
||||
basic_string (const __std_string& __x)
|
||||
: _STLP_DBG_STRING_BASE(__x.begin(), __x.end()), _M_iter_list(_Get_base()) {}
|
||||
operator __std_string() const { return __std_string(this->data()); }
|
||||
# endif
|
||||
|
||||
// constructor from non-debug version
|
||||
basic_string (const _Base& __x)
|
||||
: _STLP_DBG_STRING_BASE(__x), _M_iter_list(_Get_base()) {}
|
||||
|
||||
_Self& operator=(const _Self& __s) {
|
||||
_Base::operator=(__s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator=(const _CharT* __s) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_Base::operator=(__s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator=(_CharT __c) {
|
||||
_Base::operator=(__c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
public: // Iterators.
|
||||
|
||||
iterator begin() { return iterator(&_M_iter_list, this->_M_start); }
|
||||
const_iterator begin() const { return const_iterator(&_M_iter_list,this->_M_start); }
|
||||
iterator end() { return iterator(&_M_iter_list,this->_M_finish); }
|
||||
const_iterator end() const { return const_iterator(&_M_iter_list,this->_M_finish); }
|
||||
void _M_deallocate_block() {
|
||||
_M_iter_list._Invalidate_all();
|
||||
_Base::_M_deallocate_block();
|
||||
}
|
||||
|
||||
reverse_iterator rbegin()
|
||||
{ return reverse_iterator(iterator(&_M_iter_list,this->_M_finish)); }
|
||||
reverse_iterator rend()
|
||||
{ return reverse_iterator(iterator(&_M_iter_list,this->_M_start)); }
|
||||
const_reverse_iterator rbegin() const
|
||||
{ return const_reverse_iterator(const_iterator(&_M_iter_list,this->_M_finish)); }
|
||||
const_reverse_iterator rend() const
|
||||
{ return const_reverse_iterator(const_iterator(&_M_iter_list,this->_M_start)); }
|
||||
|
||||
public: // Size, capacity, etc.
|
||||
|
||||
void resize(size_type __n, _CharT __c) {
|
||||
_Base::resize(__n, __c);
|
||||
}
|
||||
void resize(size_type __n) { resize(__n, this->_M_null()); }
|
||||
|
||||
void reserve(size_type __s= 0) {
|
||||
_Base::reserve(__s);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
_M_iter_list._Invalidate_all();
|
||||
_Base::clear();
|
||||
}
|
||||
|
||||
public: // Element access.
|
||||
|
||||
const_reference operator[](size_type __n) const
|
||||
{ return *(begin() + __n); }
|
||||
reference operator[](size_type __n)
|
||||
{ return *(begin() + __n); }
|
||||
|
||||
const_reference at(size_type __n) const {
|
||||
if (__n >= this->size())
|
||||
this->_M_throw_out_of_range();
|
||||
return *(begin() + __n);
|
||||
}
|
||||
|
||||
reference at(size_type __n) {
|
||||
if (__n >= this->size())
|
||||
this->_M_throw_out_of_range();
|
||||
return *(begin() + __n);
|
||||
}
|
||||
|
||||
public: // Append, operator+=, push_back.
|
||||
|
||||
_Self& operator+=(const _Self& __s) { return append(__s); }
|
||||
_Self& operator+=(const _CharT* __s) { _STLP_FIX_LITERAL_BUG(__s) return append(__s); }
|
||||
_Self& operator+=(_CharT __c) { push_back(__c); return *this; }
|
||||
|
||||
_Self& append(const _Self& __s) { return append(__s._M_start, __s._M_finish); }
|
||||
|
||||
_Self& append(const _Self& __s,
|
||||
size_type __pos, size_type __n)
|
||||
{
|
||||
_Base::append(__s, __pos, __n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& append(const _CharT* __s, size_type __n)
|
||||
{ _STLP_FIX_LITERAL_BUG(__s) return append(__s, __s+__n); }
|
||||
|
||||
_Self& append(const _CharT* __s)
|
||||
{ _STLP_FIX_LITERAL_BUG(__s) return append(__s, __s + _Traits::length(__s)); }
|
||||
|
||||
_Self& append(size_type __n, _CharT __c){
|
||||
_Base::append(__n, __c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
|
||||
// Check to see if _InputIterator is an integer type. If so, then
|
||||
// it can't be an iterator.
|
||||
template <class _InputIter>
|
||||
_Self& append(_InputIter __first, _InputIter __last) {
|
||||
_Base::append(__first, __last);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef _STLP_MSVC
|
||||
// specialization for append
|
||||
template <>
|
||||
inline _Self& append(iterator __f, iterator __l) {
|
||||
_STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
|
||||
__check_range(__f, __l);
|
||||
_Base::append(__f._M_iterator, __l._M_iterator);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
#else /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
_Self& append(const _CharT* __first, const _CharT* __last) {
|
||||
_Base::append(__first, __last);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& append(const_iterator __first, const_iterator __last) {
|
||||
_Base::append(__first._M_iterator, __last._M_iterator);
|
||||
return *this;
|
||||
}
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
void push_back(_CharT __c) {
|
||||
_Base::push_back(__c);
|
||||
}
|
||||
|
||||
void pop_back() {
|
||||
__invalidate_iterator(&_M_iter_list,end());
|
||||
_Base::pop_back();
|
||||
}
|
||||
|
||||
|
||||
public: // Assign
|
||||
|
||||
_Self& assign(const _Self& __s) {
|
||||
_Base::assign(__s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& assign(const _Self& __s,
|
||||
size_type __pos, size_type __n) {
|
||||
_Base::assign(__s, __pos, __n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& assign(const _CharT* __s, size_type __n)
|
||||
{ _STLP_FIX_LITERAL_BUG(__s) return assign(__s, __s + __n); }
|
||||
|
||||
_Self& assign(const _CharT* __s)
|
||||
{ _STLP_FIX_LITERAL_BUG(__s) return assign(__s, __s + _Traits::length(__s)); }
|
||||
|
||||
_Self& assign(size_type __n, _CharT __c) {
|
||||
_Base::assign(__n, __c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
template <class _InputIter>
|
||||
inline _Self& assign(_InputIter __first, _InputIter __last) {
|
||||
_STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
|
||||
__check_range(__first, __last);
|
||||
_Base::assign(__first, __last);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef _STLP_MSVC
|
||||
// partial specialization for assign
|
||||
template <>
|
||||
inline _Self& assign(iterator __f, iterator __l) {
|
||||
_STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
|
||||
__check_range(__f, __l);
|
||||
_Base::assign(__f._M_iterator, __l._M_iterator);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
_Self& assign(const _CharT* __f, const _CharT* __l) {
|
||||
_STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
|
||||
__check_range(__f, __l);
|
||||
_Base::assign(__f, __l);
|
||||
return *this;
|
||||
}
|
||||
_Self& assign(const_iterator __f, const_iterator __l) {
|
||||
|
||||
_Base::assign(__f._M_iterator, __l._M_iterator);
|
||||
return *this;
|
||||
}
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
public: // Insert
|
||||
|
||||
_Self& insert(size_type __pos, const _Self& __s) {
|
||||
_Base::insert(__pos, __s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& insert(size_type __pos, const _Self& __s,
|
||||
size_type __beg, size_type __n) {
|
||||
_Base::insert(__pos, __s, __beg, __n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& insert(size_type __pos, const _CharT* __s, size_type __n) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_Base::insert(__pos, __s, __n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& insert(size_type __pos, const _CharT* __s) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_Base::insert(__pos, __s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& insert(size_type __pos, size_type __n, _CharT __c) {
|
||||
_Base::insert(__pos, __n, __c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
iterator insert(iterator __p, _CharT __c) {
|
||||
_STLP_FIX_LITERAL_BUG(__p)
|
||||
__check_if_owner(&_M_iter_list,__p);
|
||||
return iterator(&_M_iter_list,_Base::insert(__p._M_iterator, __c));
|
||||
}
|
||||
|
||||
void insert(iterator __p, size_t __n, _CharT __c) {
|
||||
__check_if_owner(&_M_iter_list,__p);
|
||||
_Base::insert(__p._M_iterator, __n, __c);
|
||||
}
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
template <class _InputIter>
|
||||
void insert(iterator __p, _InputIter __first, _InputIter __last) {
|
||||
__check_if_owner(&_M_iter_list,__p);
|
||||
__check_range(__first,__last);
|
||||
_Base::insert(__p._M_iterator, __first, __last);
|
||||
}
|
||||
#else /* _STLP_MEMBER_TEMPLATES */
|
||||
void insert(iterator __p, const _CharT* __first, const _CharT* __last) {
|
||||
_STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
|
||||
__check_if_owner(&_M_iter_list,__p);
|
||||
__check_range(__first,__last);
|
||||
_Base::insert(__p._M_iterator, __first, __last);
|
||||
}
|
||||
void insert(iterator __p, const_iterator __first, const_iterator __last) {
|
||||
__check_range(__first,__last);
|
||||
_Base::insert(__p._M_iterator, __first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
public: // Erase.
|
||||
_Self& erase(size_type __pos = 0, size_type __n = _Base::npos) {
|
||||
_Base::erase(__pos, __n);
|
||||
return *this;
|
||||
}
|
||||
iterator erase(iterator __position) {
|
||||
__check_if_owner(&_M_iter_list, __position);
|
||||
__invalidate_iterator(&_M_iter_list,end());
|
||||
return iterator(&_M_iter_list, _Base::erase(__position._M_iterator));
|
||||
}
|
||||
iterator erase(iterator __first, iterator __last) {
|
||||
__check_range(__first, __last)&&__check_if_owner(&_M_iter_list,__first);
|
||||
if (__first != __last) {
|
||||
__invalidate_range(&_M_iter_list, __last, end());
|
||||
}
|
||||
return iterator(&_M_iter_list, _Base::erase(__first._M_iterator, __last._M_iterator));
|
||||
}
|
||||
|
||||
public: // Substring.
|
||||
_Self substr(size_type __pos = 0, size_type __n = _Base::npos) const {
|
||||
if (__pos > this->size())
|
||||
this->_M_throw_out_of_range();
|
||||
return _Self(this->begin() + __pos,
|
||||
this->begin() + __pos + min(__n, this->size() - __pos),
|
||||
allocator_type());
|
||||
}
|
||||
public: // Replace. (Conceptually equivalent
|
||||
// to erase followed by insert.)
|
||||
_Self& replace(size_type __pos, size_type __n,
|
||||
const _Self& __s) {
|
||||
_Base::replace(__pos, __n, __s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& replace(size_type __pos1, size_type __n1,
|
||||
const _Self& __s,
|
||||
size_type __pos2, size_type __n2) {
|
||||
_Base::replace(__pos1, __n1, (const _Base&)__s, __pos2, __n2);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& replace(size_type __pos, size_type __n1,
|
||||
const _CharT* __s, size_type __n2) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_Base::replace(__pos, __n1, __s, __n2);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& replace(size_type __pos, size_type __n1,
|
||||
const _CharT* __s) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_Base::replace(__pos, __n1, __s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& replace(size_type __pos, size_type __n1,
|
||||
size_type __n2, _CharT __c) {
|
||||
_Base::replace(__pos, __n1, __n2, __c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& replace(iterator __first, iterator __last,
|
||||
const _Self& __s) {
|
||||
__check_if_owner(&_M_iter_list,__first);
|
||||
__check_range(__first, __last);
|
||||
_Base::replace(__first._M_iterator, __last._M_iterator,__s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& replace(iterator __first, iterator __last,
|
||||
const _CharT* __s, size_type __n) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
__check_if_owner(&_M_iter_list,__first);
|
||||
__check_range(__first, __last);
|
||||
_Base::replace(__first._M_iterator, __last._M_iterator,__s, __n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& replace(iterator __first, iterator __last,
|
||||
const _CharT* __s) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
__check_if_owner(&_M_iter_list,__first);
|
||||
__check_range(__first, __last);
|
||||
_Base::replace(__first._M_iterator, __last._M_iterator,__s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& replace(iterator __first, iterator __last,
|
||||
size_type __n, _CharT __c) {
|
||||
__check_if_owner(&_M_iter_list,__first);
|
||||
__check_range(__first, __last);
|
||||
_Base::replace(__first._M_iterator, __last._M_iterator, __n, __c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
template <class _InputIter>
|
||||
_Self& replace(iterator __first, iterator __last,
|
||||
_InputIter __f, _InputIter __l) {
|
||||
__check_if_owner(&_M_iter_list, __first);
|
||||
__check_range(__first, __last);
|
||||
__check_range(__f, __l);
|
||||
_Base::replace(__first._M_iterator, __last._M_iterator, __f, __l);
|
||||
return *this;
|
||||
}
|
||||
#else /* _STLP_MEMBER_TEMPLATES */
|
||||
_Self& replace(iterator __first, iterator __last,
|
||||
const _CharT* __f, const _CharT* __l) {
|
||||
__check_if_owner(&_M_iter_list, __first);
|
||||
__check_range(__first, __last);
|
||||
__check_range(__f, __l);
|
||||
_Base::replace(__first._M_iterator, __last._M_iterator, __f, __l);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& replace(iterator __first, iterator __last,
|
||||
const_iterator __f, const_iterator __l) {
|
||||
__check_if_owner(&_M_iter_list, __first);
|
||||
__check_range(__first, __last);
|
||||
__check_range(__f, __l);
|
||||
_Base::replace(__first._M_iterator, __last._M_iterator,
|
||||
__f._M_iterator, __l._M_iterator);
|
||||
return *this;
|
||||
}
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
public: // Other modifier member functions.
|
||||
|
||||
void swap(_Self& __s) {
|
||||
_M_iter_list._Swap_owners(__s._M_iter_list);
|
||||
_Base::swap(__s);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// This is a hook to instantiate STLport exports in a designated DLL
|
||||
# if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT template class _STLP_CLASS_DECLSPEC basic_string<char, char_traits<char>, allocator<char> >;
|
||||
# if defined (_STLP_HAS_WCHAR_T)
|
||||
_STLP_EXPORT template class _STLP_CLASS_DECLSPEC basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >;
|
||||
# endif
|
||||
# endif /* _STLP_USE_TEMPLATE_EXPORT */
|
||||
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Non-member functions.
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
|
||||
operator+(const basic_string<_CharT,_Traits,_Alloc>& __s,
|
||||
const basic_string<_CharT,_Traits,_Alloc>& __y)
|
||||
{
|
||||
return basic_string<_CharT,_Traits,_Alloc>(*__s._Get_base() + *__y._Get_base());
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
|
||||
operator+(const _CharT* __s,
|
||||
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
return basic_string<_CharT,_Traits,_Alloc>(__s + *__y._Get_base());
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
|
||||
operator+(_CharT __c,
|
||||
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
||||
return basic_string<_CharT,_Traits,_Alloc>(__c + *__y._Get_base());
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
|
||||
operator+(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
||||
const _CharT* __s) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
return basic_string<_CharT,_Traits,_Alloc>(*__x._Get_base()+ __s);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
|
||||
operator+(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
||||
const _CharT __c) {
|
||||
return basic_string<_CharT,_Traits,_Alloc>(*__x._Get_base() + __c);
|
||||
}
|
||||
|
||||
#ifdef _STLP_EXTRA_OPERATORS_FOR_DEBUG
|
||||
|
||||
// Operator== and operator!=
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline bool _STLP_CALL
|
||||
operator==(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
||||
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
||||
return (*__x._Get_base() == *__y._Get_base());
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline bool _STLP_CALL
|
||||
operator==(const _CharT* __s,
|
||||
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
return (__s == *__y._Get_base());
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline bool _STLP_CALL
|
||||
operator==(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
||||
const _CharT* __s) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
return (*__x._Get_base() == __s);
|
||||
}
|
||||
|
||||
// Operator< (and also >, <=, and >=).
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline bool _STLP_CALL
|
||||
operator<(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
||||
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
||||
return (*__x._Get_base() < *__y._Get_base());
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline bool _STLP_CALL
|
||||
operator<(const _CharT* __s,
|
||||
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
return (__s < *__y._Get_base());
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline bool _STLP_CALL
|
||||
operator<(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
||||
const _CharT* __s) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
return (*__x._Get_base() < __s);
|
||||
}
|
||||
|
||||
#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline bool _STLP_CALL
|
||||
operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
||||
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
||||
return !(__x == __y);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline bool _STLP_CALL
|
||||
operator>(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
||||
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
||||
return __y < __x;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline bool _STLP_CALL
|
||||
operator<=(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
||||
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
||||
return !(__y < __x);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline bool _STLP_CALL
|
||||
operator>=(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
||||
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
||||
return !(__x < __y);
|
||||
}
|
||||
|
||||
#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline bool _STLP_CALL
|
||||
operator!=(const _CharT* __s,
|
||||
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
return !(__s == __y);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline bool _STLP_CALL
|
||||
operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
||||
const _CharT* __s) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
return !(__x == __s);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline bool _STLP_CALL
|
||||
operator>(const _CharT* __s,
|
||||
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
return __y < __s;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline bool _STLP_CALL
|
||||
operator>(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
||||
const _CharT* __s) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
return __s < __x;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline bool _STLP_CALL
|
||||
operator<=(const _CharT* __s,
|
||||
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
return !(__y < __s);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline bool _STLP_CALL
|
||||
operator<=(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
||||
const _CharT* __s) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
return !(__s < __x);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline bool _STLP_CALL
|
||||
operator>=(const _CharT* __s,
|
||||
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
return !(__s < __y);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline bool _STLP_CALL
|
||||
operator>=(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
||||
const _CharT* __s) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
return !(__x < __s);
|
||||
}
|
||||
#endif /* if 0 */
|
||||
|
||||
// Swap.
|
||||
#ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline void swap(basic_string<_CharT,_Traits,_Alloc>& __x,
|
||||
basic_string<_CharT,_Traits,_Alloc>& __y) {
|
||||
__x.swap(__y);
|
||||
}
|
||||
#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */
|
||||
|
||||
// I/O.
|
||||
|
||||
#ifdef _STLP_EXTRA_OPERATORS_FOR_DEBUG
|
||||
#if defined (_STLP_USE_NEW_IOSTREAMS) && ! defined (_STLP_OWN_IOSTREAMS)
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
basic_ostream<_CharT, _Traits>& _STLP_CALL
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os,
|
||||
const basic_string<_CharT,_Traits,_Alloc>& __s) {
|
||||
return __os << *__s._Get_base();
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
basic_istream<_CharT, _Traits>& _STLP_CALL
|
||||
operator>>(basic_istream<_CharT, _Traits>& __is,
|
||||
basic_string<_CharT,_Traits,_Alloc>& __s) {
|
||||
return __is >> *__s._Get_base();
|
||||
}
|
||||
|
||||
#elif ! defined ( _STLP_USE_NO_IOSTREAMS )
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
ostream& _STLP_CALL operator<<(ostream& __os,
|
||||
const basic_string<_CharT,_Traits,_Alloc>& __s) {
|
||||
return __os << *__s._Get_base();
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
istream& _STLP_CALL operator>>(istream& __is, basic_string<_CharT,_Traits,_Alloc>& __s) {
|
||||
return __is >> *__s._Get_base();
|
||||
}
|
||||
|
||||
#endif /* _STLP_USE_NEW_IOSTREAMS */
|
||||
#endif /* if _STLP_EXTRA_OPERATORS_FOR_DEBUG */
|
||||
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_DBG_STRING */
|
||||
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
249
STLPORT/stlport/stl/debug/_tree.h
Normal file
249
STLPORT/stlport/stl/debug/_tree.h
Normal file
@@ -0,0 +1,249 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_DBG_TREE_H
|
||||
#define _STLP_INTERNAL_DBG_TREE_H
|
||||
|
||||
#include <stl/debug/_iterator.h>
|
||||
#include <stl/_function.h>
|
||||
#include <stl/_alloc.h>
|
||||
|
||||
# undef _DBG_Rb_tree
|
||||
# define _DBG_Rb_tree _Rb_tree
|
||||
|
||||
# define _STLP_DBG_TREE_SUPER __WORKAROUND_DBG_RENAME(Rb_tree) <_Key, _Value, _KeyOfValue, _Compare, _Alloc>
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
# ifdef _STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS
|
||||
template <class _Key, class _Value, class _KeyOfValue, class _Compare, class _Alloc >
|
||||
inline _Value*
|
||||
value_type(const _DBG_iter_base< _STLP_DBG_TREE_SUPER >&) {
|
||||
return (_Value*)0;
|
||||
}
|
||||
template <class _Key, class _Value, class _KeyOfValue, class _Compare, class _Alloc >
|
||||
inline bidirectional_iterator_tag
|
||||
iterator_category(const _DBG_iter_base< _STLP_DBG_TREE_SUPER >&) {
|
||||
return bidirectional_iterator_tag();
|
||||
}
|
||||
# endif
|
||||
|
||||
template <class _Key, class _Value, class _KeyOfValue, class _Compare,
|
||||
_STLP_DBG_ALLOCATOR_SELECT(_Value) >
|
||||
class _DBG_Rb_tree : public _STLP_DBG_TREE_SUPER {
|
||||
typedef _STLP_DBG_TREE_SUPER _Base;
|
||||
typedef _DBG_Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc> _Self;
|
||||
protected:
|
||||
friend class __owned_link;
|
||||
mutable __owned_list _M_iter_list;
|
||||
|
||||
public:
|
||||
__IMPORT_CONTAINER_TYPEDEFS(_Base)
|
||||
typedef typename _Base::key_type key_type;
|
||||
|
||||
typedef _DBG_iter<_Base, _Nonconst_traits<value_type> > iterator;
|
||||
typedef _DBG_iter<_Base, _Const_traits<value_type> > const_iterator;
|
||||
|
||||
_STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS;
|
||||
|
||||
protected:
|
||||
|
||||
//typedef typename _Base::key_param_type key_param_type;
|
||||
//typedef typename _Base::val_param_type val_param_type;
|
||||
|
||||
void _Invalidate_all() {_M_iter_list._Invalidate_all();}
|
||||
|
||||
void _Invalidate_iterator(const iterator& __it) {
|
||||
__invalidate_iterator(&_M_iter_list,__it);
|
||||
}
|
||||
void _Invalidate_iterators(const iterator& __first, const iterator& __last) {
|
||||
iterator __cur = __first;
|
||||
while (__cur != __last) __invalidate_iterator(&_M_iter_list, __cur++);
|
||||
}
|
||||
|
||||
const _Base* _Get_base() const { return (const _Base*)this; }
|
||||
_Base* _Get_base() { return (_Base*)this; }
|
||||
|
||||
public:
|
||||
_DBG_Rb_tree() : _STLP_DBG_TREE_SUPER(),
|
||||
_M_iter_list(_Get_base()) {}
|
||||
_DBG_Rb_tree(const _Compare& __comp) :
|
||||
_STLP_DBG_TREE_SUPER(__comp), _M_iter_list(_Get_base()) {}
|
||||
_DBG_Rb_tree(const _Compare& __comp, const allocator_type& __a):
|
||||
_STLP_DBG_TREE_SUPER(__comp, __a), _M_iter_list(_Get_base()) {}
|
||||
_DBG_Rb_tree(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x):
|
||||
_STLP_DBG_TREE_SUPER(__x), _M_iter_list(_Get_base()) {}
|
||||
~_DBG_Rb_tree() { _Invalidate_all(); }
|
||||
|
||||
_Self& operator=(const _Self& __x) {
|
||||
_Invalidate_all();
|
||||
(_Base&)*this = (const _Base&)__x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
iterator begin() { return iterator(&_M_iter_list,_Base::begin()); }
|
||||
const_iterator begin() const { return const_iterator(&_M_iter_list, _Base::begin()); }
|
||||
iterator end() { return iterator(&_M_iter_list, _Base::end()); }
|
||||
const_iterator end() const { return const_iterator(&_M_iter_list,_Base::end()); }
|
||||
|
||||
public:
|
||||
reverse_iterator rbegin() { return reverse_iterator(end()); }
|
||||
const_reverse_iterator rbegin() const {
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
reverse_iterator rend() { return reverse_iterator(begin()); }
|
||||
const_reverse_iterator rend() const {
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
void swap(_Self& __t) {
|
||||
_Base::swap(__t);
|
||||
_M_iter_list._Swap_owners(__t._M_iter_list);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
iterator find(const key_type& __x) {
|
||||
return iterator(&_M_iter_list, _Base::find(__x));
|
||||
}
|
||||
const_iterator find(const key_type& __x) const {
|
||||
return const_iterator(&_M_iter_list, _Base::find(__x));
|
||||
}
|
||||
|
||||
iterator lower_bound(const key_type& __x) {
|
||||
return iterator(&_M_iter_list, _Base::lower_bound(__x));
|
||||
}
|
||||
const_iterator lower_bound(const key_type& __x) const {
|
||||
return const_iterator(&_M_iter_list, _Base::lower_bound(__x));
|
||||
}
|
||||
|
||||
iterator upper_bound(const key_type& __x) {
|
||||
return iterator(&_M_iter_list, _Base::upper_bound(__x));
|
||||
}
|
||||
const_iterator upper_bound(const key_type& __x) const {
|
||||
return const_iterator(&_M_iter_list, _Base::upper_bound(__x));
|
||||
}
|
||||
|
||||
pair<iterator,iterator> equal_range(const key_type& __x) {
|
||||
return pair<iterator, iterator>(iterator(&_M_iter_list, _Base::lower_bound(__x)),
|
||||
iterator(&_M_iter_list, _Base::upper_bound(__x)));
|
||||
}
|
||||
pair<const_iterator, const_iterator> equal_range(const key_type& __x) const {
|
||||
return pair<const_iterator,const_iterator>(const_iterator(&_M_iter_list, _Base::lower_bound(__x)),
|
||||
const_iterator(&_M_iter_list, _Base::upper_bound(__x)));
|
||||
}
|
||||
|
||||
pair<iterator,bool> insert_unique(const value_type& __x) {
|
||||
_STLP_STD::pair<_STLP_HEADER_TYPENAME _Base::iterator, bool> __res = _Base::insert_unique(__x);
|
||||
return pair<iterator,bool>( iterator(&_M_iter_list, __res.first), __res.second ) ;
|
||||
}
|
||||
iterator insert_equal(const value_type& __x) {
|
||||
return iterator(&_M_iter_list, _Base::insert_equal(__x));
|
||||
}
|
||||
|
||||
iterator insert_unique(iterator __position, const value_type& __x) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__position))
|
||||
return iterator(&_M_iter_list, _Base::insert_unique(__position._M_iterator, __x));
|
||||
}
|
||||
iterator insert_equal(iterator __position, const value_type& __x) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__position))
|
||||
return iterator(&_M_iter_list, _Base::insert_equal(__position._M_iterator, __x));
|
||||
}
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
template<class _II>
|
||||
void insert_equal(_II __first, _II __last) {
|
||||
_Base::insert_equal(__first, __last);
|
||||
}
|
||||
template<class _II>
|
||||
void insert_unique(_II __first, _II __last) {
|
||||
_Base::insert_unique(__first, __last);
|
||||
}
|
||||
#else /* _STLP_MEMBER_TEMPLATES */
|
||||
void insert_unique(const_iterator __first, const_iterator __last) {
|
||||
_Base::insert_unique(__first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
void insert_unique(const value_type* __first, const value_type* __last) {
|
||||
_Base::insert_unique(__first, __last);
|
||||
}
|
||||
void insert_equal(const_iterator __first, const_iterator __last) {
|
||||
_Base::insert_equal(__first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
void insert_equal(const value_type* __first, const value_type* __last) {
|
||||
_Base::insert_equal(__first, __last);
|
||||
}
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
void erase(iterator __position) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__position))
|
||||
_STLP_DEBUG_CHECK(_Dereferenceable(__position))
|
||||
_Invalidate_iterator(__position);
|
||||
_Base::erase(__position._M_iterator);
|
||||
}
|
||||
size_type erase(const key_type& __x) {
|
||||
pair<iterator,iterator> __p = equal_range(__x);
|
||||
size_type __n = _STLP_STD::distance(__p.first, __p.second);
|
||||
_Invalidate_iterators(__p.first, __p.second);
|
||||
_Base::erase(__p.first._M_iterator, __p.second._M_iterator);
|
||||
return __n;
|
||||
}
|
||||
|
||||
void erase(iterator __first, iterator __last) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __first)&&
|
||||
__check_if_owner(&_M_iter_list, __last))
|
||||
_Invalidate_iterators(__first, __last);
|
||||
_Base::erase(__first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
void erase(const key_type* __first, const key_type* __last) {
|
||||
while (__first != __last) erase(*__first++);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
_Invalidate_all();
|
||||
_Base::clear();
|
||||
}
|
||||
};
|
||||
|
||||
#define _STLP_TEMPLATE_HEADER template <class _Key, class _Value, class _KeyOfValue, class _Compare, class _Alloc>
|
||||
#define _STLP_TEMPLATE_CONTAINER _DBG_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>
|
||||
#define _STLP_TEMPLATE_CONTAINER_BASE _STLP_DBG_TREE_SUPER
|
||||
#include <stl/debug/_relops_cont.h>
|
||||
#undef _STLP_TEMPLATE_CONTAINER_BASE
|
||||
#undef _STLP_TEMPLATE_CONTAINER
|
||||
#undef _STLP_TEMPLATE_HEADER
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
# undef _STLP_DBG_TREE_SUPER
|
||||
|
||||
#endif /* _STLP_INTERNAL_DBG_TREE_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
300
STLPORT/stlport/stl/debug/_vector.h
Normal file
300
STLPORT/stlport/stl/debug/_vector.h
Normal file
@@ -0,0 +1,300 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_DBG_VECTOR_H
|
||||
#define _STLP_INTERNAL_DBG_VECTOR_H
|
||||
|
||||
#include <stl/debug/_iterator.h>
|
||||
|
||||
# ifndef _STLP_USE_WRAPPER_FOR_ALLOC_PARAM
|
||||
# undef _DBG_vector
|
||||
# define _DBG_vector vector
|
||||
# endif
|
||||
|
||||
# define _STLP_DBG_VECTOR_BASE __WORKAROUND_DBG_RENAME(vector) <_Tp, _Alloc>
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
# ifdef _STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _Tp*
|
||||
value_type(const _DBG_iter_base< _STLP_DBG_VECTOR_BASE >&) {
|
||||
return (_Tp*)0;
|
||||
}
|
||||
template <class _Tp, class _Alloc>
|
||||
inline random_access_iterator_tag
|
||||
iterator_category(const _DBG_iter_base< _STLP_DBG_VECTOR_BASE >&) {
|
||||
return random_access_iterator_tag();
|
||||
}
|
||||
# endif
|
||||
|
||||
template <class _Tp, class _NcIt>
|
||||
struct _Vector_nonconst_traits
|
||||
{
|
||||
typedef _Nonconst_traits<_Tp> _BaseT;
|
||||
typedef _Tp value_type;
|
||||
typedef _Tp& reference;
|
||||
typedef _Tp* pointer;
|
||||
typedef _Vector_nonconst_traits<_Tp, _NcIt> _Non_const_traits;
|
||||
};
|
||||
|
||||
template <class _Tp, class _NcIt>
|
||||
struct _Vector_const_traits
|
||||
{
|
||||
typedef _Const_traits<_Tp> _BaseT;
|
||||
typedef _Tp value_type;
|
||||
typedef const _Tp& reference;
|
||||
typedef const _Tp* pointer;
|
||||
typedef _Vector_nonconst_traits<_Tp, _NcIt> _Non_const_traits;
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct _Vector_nonconst_traits<bool, _Bit_iterator>
|
||||
{
|
||||
typedef _Bit_iterator::value_type value_type;
|
||||
typedef _Bit_iterator::reference reference;
|
||||
typedef _Bit_iterator::pointer pointer;
|
||||
typedef _Vector_nonconst_traits<bool, _Bit_iterator> _Non_const_traits;
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct _Vector_const_traits<bool, _Bit_iterator>
|
||||
{
|
||||
typedef _Bit_const_iterator::value_type value_type;
|
||||
typedef _Bit_const_iterator::reference reference;
|
||||
typedef _Bit_const_iterator::pointer pointer;
|
||||
typedef _Vector_nonconst_traits<bool, _Bit_iterator> _Non_const_traits;
|
||||
};
|
||||
|
||||
template <class _Tp, _STLP_DBG_ALLOCATOR_SELECT(_Tp) >
|
||||
class _DBG_vector : public _STLP_DBG_VECTOR_BASE {
|
||||
private:
|
||||
typedef _STLP_DBG_VECTOR_BASE _Base;
|
||||
typedef _DBG_vector<_Tp, _Alloc> _Self;
|
||||
mutable __owned_list _M_iter_list;
|
||||
|
||||
public:
|
||||
|
||||
__IMPORT_CONTAINER_TYPEDEFS(_Base)
|
||||
|
||||
typedef _DBG_iter<_Base,
|
||||
_Vector_nonconst_traits<value_type, typename _Base::iterator> > iterator;
|
||||
|
||||
typedef _DBG_iter<_Base,
|
||||
_Vector_const_traits<value_type, typename _Base::iterator> > const_iterator;
|
||||
|
||||
_STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
|
||||
|
||||
iterator begin() { return iterator(&_M_iter_list, this->_M_start); }
|
||||
const_iterator begin() const { return const_iterator(&_M_iter_list, this->_M_start); }
|
||||
iterator end() { return iterator(&_M_iter_list, this->_M_finish); }
|
||||
const_iterator end() const { return const_iterator(&_M_iter_list, this->_M_finish); }
|
||||
|
||||
reverse_iterator rbegin()
|
||||
{ return reverse_iterator(end()); }
|
||||
const_reverse_iterator rbegin() const
|
||||
{ return const_reverse_iterator(end()); }
|
||||
reverse_iterator rend()
|
||||
{ return reverse_iterator(begin()); }
|
||||
const_reverse_iterator rend() const
|
||||
{ return const_reverse_iterator(begin()); }
|
||||
|
||||
reference operator[](size_type __n) {
|
||||
_STLP_VERBOSE_ASSERT(__n < _Base::size(), _StlMsg_OUT_OF_BOUNDS)
|
||||
return _Base::operator[](__n);
|
||||
}
|
||||
|
||||
const_reference operator[](size_type __n) const {
|
||||
_STLP_VERBOSE_ASSERT(__n < _Base::size(), _StlMsg_OUT_OF_BOUNDS)
|
||||
return _Base::operator[](__n);
|
||||
}
|
||||
|
||||
_Base* _Get_base() { return (_Base*)this; }
|
||||
const _Base* _Get_base() const { return (const _Base*)this; }
|
||||
|
||||
explicit _DBG_vector(const allocator_type& __a = allocator_type())
|
||||
: _STLP_DBG_VECTOR_BASE(__a), _M_iter_list((const _Base*)this) {}
|
||||
|
||||
_DBG_vector(size_type __n, const _Tp& __value,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _STLP_DBG_VECTOR_BASE(__n, __value, __a), _M_iter_list((const _Base*)this) {}
|
||||
|
||||
explicit _DBG_vector(size_type __n)
|
||||
: _STLP_DBG_VECTOR_BASE(__n), _M_iter_list((const _Base*)this) {}
|
||||
|
||||
|
||||
_DBG_vector(const _Self& __x)
|
||||
: _STLP_DBG_VECTOR_BASE(__x), _M_iter_list((const _Base*)this) {}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
|
||||
template <class _InputIterator>
|
||||
_DBG_vector(_InputIterator __first, _InputIterator __last):
|
||||
_STLP_DBG_VECTOR_BASE(__first, __last), _M_iter_list((const _Base*)this) {}
|
||||
# endif
|
||||
template <class _InputIterator>
|
||||
_DBG_vector(_InputIterator __first, _InputIterator __last,
|
||||
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) :
|
||||
_STLP_DBG_VECTOR_BASE(__first, __last, __a), _M_iter_list((const _Base*)this) {}
|
||||
|
||||
#else
|
||||
_DBG_vector(const _Tp* __first, const _Tp* __last,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _STLP_DBG_VECTOR_BASE(__first, __last, __a), _M_iter_list((const _Base*)this) {}
|
||||
|
||||
// mysterious VC++ bug ?
|
||||
_DBG_vector(const_iterator __first, const_iterator __last ,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _STLP_DBG_VECTOR_BASE(__first._M_iterator, __last._M_iterator, __a),
|
||||
_M_iter_list((const _Base*)this) { }
|
||||
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
_Self& operator=(const _Self& __x) {
|
||||
_M_iter_list._Invalidate_all();
|
||||
(_Base&)*this = (const _Base&)__x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
reference front() { return *begin(); }
|
||||
const_reference front() const { return *begin(); }
|
||||
|
||||
reference back() {
|
||||
iterator __tmp = end();
|
||||
--__tmp;
|
||||
return *__tmp;
|
||||
}
|
||||
const_reference back() const {
|
||||
const_iterator __tmp = end();
|
||||
--__tmp;
|
||||
return *__tmp;
|
||||
}
|
||||
|
||||
void swap(_Self& __x) {
|
||||
_M_iter_list._Swap_owners(__x._M_iter_list);
|
||||
_Base::swap((_Base&)__x);
|
||||
}
|
||||
|
||||
iterator insert(iterator __position, const _Tp& __x) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
|
||||
if (this->size()+1 > this->capacity()) _M_iter_list._Invalidate_all();
|
||||
return iterator(&_M_iter_list, _Base::insert(__position._M_iterator, __x));
|
||||
}
|
||||
|
||||
iterator insert(iterator __position) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
|
||||
if (this->size()+1 > this->capacity()) _M_iter_list._Invalidate_all();
|
||||
return iterator(&_M_iter_list, _Base::insert(__position._M_iterator));
|
||||
}
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
// Check whether it's an integral type. If so, it's not an iterator.
|
||||
template <class _InputIterator>
|
||||
void insert(iterator __position, _InputIterator __first, _InputIterator __last) {
|
||||
_STLP_DEBUG_CHECK(__check_range(__first,__last))
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
|
||||
size_type __n = distance(__first, __last);
|
||||
if (this->size()+__n > this->capacity()) _M_iter_list._Invalidate_all();
|
||||
_Base::insert(__position._M_iterator, __first, __last);
|
||||
}
|
||||
#else /* _STLP_MEMBER_TEMPLATES */
|
||||
void insert(iterator __position,
|
||||
const_iterator __first, const_iterator __last) {
|
||||
_STLP_DEBUG_CHECK(__check_range(__first,__last))
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
|
||||
size_type __n = distance(__first, __last);
|
||||
if (this->size()+__n > this->capacity()) _M_iter_list._Invalidate_all();
|
||||
_Base::insert(__position._M_iterator,
|
||||
__first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
|
||||
void insert (iterator __position, const_pointer __first, const_pointer __last) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
|
||||
_STLP_DEBUG_CHECK(__check_range(__first,__last))
|
||||
size_type __n = distance(__first, __last);
|
||||
if (this->size()+__n > this->capacity()) _M_iter_list._Invalidate_all();
|
||||
_Base::insert(__position._M_iterator, __first, __last);
|
||||
}
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
void insert (iterator __position, size_type __n, const _Tp& __x){
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
|
||||
if (this->size()+__n > this->capacity()) _M_iter_list._Invalidate_all();
|
||||
_Base::insert(__position._M_iterator, __n, __x);
|
||||
}
|
||||
|
||||
void pop_back() {
|
||||
_STLP_VERBOSE_ASSERT(!this->empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
__invalidate_iterator(&_M_iter_list,end());
|
||||
_Base::pop_back();
|
||||
}
|
||||
iterator erase(iterator __position) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __position))
|
||||
_STLP_VERBOSE_ASSERT(__position._M_iterator !=this->_M_finish,_StlMsg_ERASE_PAST_THE_END)
|
||||
__invalidate_range(&_M_iter_list, __position+1, end());
|
||||
return iterator(&_M_iter_list,_Base::erase(__position._M_iterator));
|
||||
}
|
||||
iterator erase(iterator __first, iterator __last) {
|
||||
_STLP_DEBUG_CHECK(__check_range(__first,__last, begin(), end()))
|
||||
__invalidate_range(&_M_iter_list, __first._M_iterator == this->_M_finish ?
|
||||
__first : __first+1, end());
|
||||
return iterator(&_M_iter_list, _Base::erase(__first._M_iterator, __last._M_iterator));
|
||||
}
|
||||
void clear() {
|
||||
_M_iter_list._Invalidate_all();
|
||||
_Base::clear();
|
||||
}
|
||||
void push_back(const _Tp& __x) {
|
||||
if (this->size()+1 > this->capacity()) _M_iter_list._Invalidate_all();
|
||||
_Base::push_back(__x);
|
||||
}
|
||||
};
|
||||
|
||||
#define _STLP_TEMPLATE_HEADER template <class _Tp, class _Alloc>
|
||||
#define _STLP_TEMPLATE_CONTAINER _DBG_vector<_Tp, _Alloc>
|
||||
#define _STLP_TEMPLATE_CONTAINER_BASE _STLP_DBG_VECTOR_BASE
|
||||
#include <stl/debug/_relops_cont.h>
|
||||
#undef _STLP_TEMPLATE_CONTAINER_BASE
|
||||
#undef _STLP_TEMPLATE_CONTAINER
|
||||
#undef _STLP_TEMPLATE_HEADER
|
||||
|
||||
# if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS _DBG_vector <void*,allocator<void*> >;
|
||||
# endif /* _STLP_USE_TEMPLATE_EXPORT */
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
# undef _STLP_DBG_VECTOR_BASE
|
||||
# undef _DBG_vector
|
||||
|
||||
#endif /* _STLP_DBG_VECTOR_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
Reference in New Issue
Block a user