8#ifndef INCLUDED_BSLTF_TESTVALUESARRAY
9#define INCLUDED_BSLTF_TESTVALUESARRAY
183#include <bslscm_version.h>
195#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
203template <
class VALUE,
class ALLOCATOR>
204struct TestValuesArray_DefaultConverter;
206template <
class VALUE>
207class TestValuesArray_PostIncrementPtr;
230template <
class VALUE>
234 const VALUE *d_data_p;
237 const VALUE *d_end_p;
239 bool *d_dereferenceable_p;
247 template <
class OTHER_VALUE>
251 template <
class OTHER_VALUE>
276 bool *dereferenceable,
318template <
class VALUE>
325template <
class VALUE>
337template <
class VALUE,
348 typedef typename AllocatorTraits::allocator_type AllocatorType;
349 typedef typename AllocatorTraits::size_type size_type;
352 ALLOCATOR d_allocator;
359 bool *d_dereferenceable_p;
362 bool *d_validIterator_p;
373 void initialize(
const char *
spec);
422 const VALUE *
data()
const;
440template <
class VALUE,
class ALLOCATOR>
451 static void createInplace(VALUE *objPtr,
char value, ALLOCATOR allocator);
462template <
class VALUE>
467 const VALUE *d_data_p;
492template <
class VALUE>
497 bool *dereferenceable,
501, d_dereferenceable_p(dereferenceable)
502, d_isValid_p(isValid)
511template <
class VALUE>
515: d_data_p(original.d_data_p)
516, d_end_p(original.d_end_p)
517, d_dereferenceable_p(original.d_dereferenceable_p)
518, d_isValid_p(original.d_isValid_p)
524template <
class VALUE>
530 d_data_p = other.d_data_p;
531 d_end_p = other.d_end_p;
532 d_dereferenceable_p = other.d_dereferenceable_p;
533 d_isValid_p = other.d_isValid_p;
538template <
class VALUE>
545 *d_dereferenceable_p =
false;
546 *d_isValid_p =
false;
549 ++d_dereferenceable_p;
554template <
class VALUE>
567template <
class VALUE>
574 *d_dereferenceable_p =
false;
578template <
class VALUE>
585 *d_dereferenceable_p =
false;
592template <
class VALUE>
600 return lhs.d_data_p == rhs.d_data_p;
603template <
class VALUE>
611 return !(lhs == rhs);
620template <
class VALUE,
class ALLOCATOR,
class CONVERTER>
622: d_allocator(&
bslma::MallocFreeAllocator::singleton())
625 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
630template <
class VALUE,
class ALLOCATOR,
class CONVERTER>
632 ALLOCATOR basicAllocator)
633: d_allocator(basicAllocator)
636 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
641template <
class VALUE,
class ALLOCATOR,
class CONVERTER>
644: d_allocator(&
bslma::MallocFreeAllocator::singleton())
649template <
class VALUE,
class ALLOCATOR,
class CONVERTER>
653 ALLOCATOR basicAllocator)
654: d_allocator(basicAllocator)
659template <
class VALUE,
class ALLOCATOR,
class CONVERTER>
662 for (
size_t i = 0; i < d_size; ++i) {
666 size_type numBytes =
static_cast<size_type
>(
667 d_size *
sizeof(VALUE) + 2 * (d_size + 1) *
sizeof(bool));
668 size_type numMaxAlignedType =
672 AllocatorType alignAlloc(d_allocator);
673 AllocatorTraits::deallocate(
676 reinterpret_cast<void *
>(d_data_p)),
683template <
class VALUE,
class ALLOCATOR,
class CONVERTER>
688 d_size = strlen(spec);
692 size_type numBytes =
static_cast<size_type
>(
693 d_size *
sizeof(VALUE) + 2 * (d_size + 1) *
sizeof(bool));
694 size_type numMaxAlignedType =
698 AllocatorType alignAlloc(d_allocator);
699 d_data_p =
reinterpret_cast<VALUE *
>(AllocatorTraits::allocate(
700 alignAlloc, numMaxAlignedType));
702 d_dereferenceable_p =
reinterpret_cast<bool *
>(d_data_p + d_size);
703 d_validIterator_p = d_dereferenceable_p + d_size + 1;
705 for (
int i = 0;
'\0' != spec[i]; ++i) {
706 CONVERTER::createInplace(d_data_p + i, spec[i], d_allocator);
709 memset(d_dereferenceable_p,
true, d_size *
sizeof(
bool));
710 d_dereferenceable_p[d_size] =
false;
711 memset(d_validIterator_p,
true, (d_size + 1) *
sizeof(
bool));
715template <
class VALUE,
class ALLOCATOR,
class CONVERTER>
726template <
class VALUE,
class ALLOCATOR,
class CONVERTER>
733 d_dereferenceable_p + d_size,
734 d_validIterator_p + d_size);
737template <
class VALUE,
class ALLOCATOR,
class CONVERTER>
746 d_dereferenceable_p + position,
747 d_validIterator_p + position);
750template <
class VALUE,
class ALLOCATOR,
class CONVERTER>
753 memset(d_dereferenceable_p, 1, d_size *
sizeof(
bool));
754 d_dereferenceable_p[d_size] =
false;
755 memset(d_validIterator_p, 1, (d_size + 1) *
sizeof(
bool));
759template <
class VALUE,
class ALLOCATOR,
class CONVERTER>
766template <
class VALUE,
class ALLOCATOR,
class CONVERTER>
773 return data()[index];
776template <
class VALUE,
class ALLOCATOR,
class CONVERTER>
787template <
class VALUE,
class ALLOCATOR>
801template <
class VALUE>
810template <
class VALUE>
Definition bslma_bslallocator.h:580
Definition bsltf_testvaluesarray.h:231
TestValuesArrayIterator & operator=(const TestValuesArrayIterator &other)
Definition bsltf_testvaluesarray.h:526
TestValuesArrayIterator & operator++()
Definition bsltf_testvaluesarray.h:540
VALUE value_type
Definition bsltf_testvaluesarray.h:258
const VALUE * pointer
Definition bsltf_testvaluesarray.h:260
friend bool operator==(const TestValuesArrayIterator< OTHER_VALUE > &, const TestValuesArrayIterator< OTHER_VALUE > &)
ptrdiff_t difference_type
Definition bsltf_testvaluesarray.h:259
std::input_iterator_tag iterator_category
Definition bsltf_testvaluesarray.h:257
const VALUE * operator->() const
Definition bsltf_testvaluesarray.h:580
const VALUE & operator*() const
Definition bsltf_testvaluesarray.h:569
TestValuesArrayIterator(const VALUE *object, const VALUE *end, bool *dereferenceable, bool *isValid)
Definition bsltf_testvaluesarray.h:494
friend bool operator!=(const TestValuesArrayIterator< OTHER_VALUE > &, const TestValuesArrayIterator< OTHER_VALUE > &)
const VALUE & reference
Standard iterator defined types [24.4.2].
Definition bsltf_testvaluesarray.h:263
Definition bsltf_testvaluesarray.h:464
const VALUE & operator*() const
Definition bsltf_testvaluesarray.h:812
TestValuesArray_PostIncrementPtr(const VALUE *ptr)
Definition bsltf_testvaluesarray.h:804
Definition bsltf_testvaluesarray.h:342
void resetIterators()
Make all iterators dereferenceable and comparable again.
Definition bsltf_testvaluesarray.h:751
TestValuesArrayIterator< VALUE > iterator
Iterator for this container.
Definition bsltf_testvaluesarray.h:379
const VALUE * data() const
Definition bsltf_testvaluesarray.h:761
size_t size() const
Return number of elements in this container.
Definition bsltf_testvaluesarray.h:778
iterator index(size_t position)
Definition bsltf_testvaluesarray.h:740
iterator end()
Definition bsltf_testvaluesarray.h:729
~TestValuesArray()
Destroy this container and all contained elements.
Definition bsltf_testvaluesarray.h:660
const VALUE & operator[](size_t index) const
Definition bsltf_testvaluesarray.h:769
TestValuesArray()
Definition bsltf_testvaluesarray.h:621
iterator begin()
Definition bsltf_testvaluesarray.h:718
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_ASSERT_OPT(X)
Definition bsls_assert.h:1856
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition balxml_encoderoptions.h:68
Definition bsltf_allocargumenttype.h:92
bool operator!=(const AllocBitwiseMoveableTestType &lhs, const AllocBitwiseMoveableTestType &rhs)
bool operator==(const AllocBitwiseMoveableTestType &lhs, const AllocBitwiseMoveableTestType &rhs)
Definition bslma_allocatortraits.h:1061
static void destroy(ALLOCATOR_TYPE &basicAllocator, ELEMENT_TYPE *elementAddr)
Definition bslma_allocatortraits.h:1494
AlignmentToType< BSLS_MAX_ALIGNMENT >::Type MaxAlignedType
Definition bsls_alignmentutil.h:282
@ BSLS_MAX_ALIGNMENT
Definition bsls_alignmentutil.h:275
static void emplace(TYPE *address, int identifier, ALLOCATOR allocator)
Definition bsltf_templatetestfacility.h:1199
Definition bsltf_testvaluesarray.h:442
static void createInplace(VALUE *objPtr, char value, ALLOCATOR allocator)
Definition bsltf_testvaluesarray.h:789