mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-01 14:45:42 +08:00
containers: added opaque pointer access to implementation container, to help with debugging
This commit is contained in:
@@ -310,6 +310,13 @@ namespace BlackMisc
|
|||||||
*/
|
*/
|
||||||
bool operator !=(const CCollection &other) const { return !(*this == other); }
|
bool operator !=(const CCollection &other) const { return !(*this == other); }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Return an opaque pointer to the implementation container.
|
||||||
|
* \details Can be useful in unusual debugging situations.
|
||||||
|
* \warning Not for general use.
|
||||||
|
*/
|
||||||
|
void *getImpl() { return pimpl() ? pimpl()->impl() : nullptr; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class PimplBase
|
class PimplBase
|
||||||
{
|
{
|
||||||
@@ -333,6 +340,7 @@ namespace BlackMisc
|
|||||||
virtual iterator find(const T &value) = 0;
|
virtual iterator find(const T &value) = 0;
|
||||||
virtual const_iterator find(const T &value) const = 0;
|
virtual const_iterator find(const T &value) const = 0;
|
||||||
virtual bool operator ==(const PimplBase &other) const = 0;
|
virtual bool operator ==(const PimplBase &other) const = 0;
|
||||||
|
virtual void *impl() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class C> class Pimpl : public PimplBase
|
template <class C> class Pimpl : public PimplBase
|
||||||
@@ -359,6 +367,7 @@ namespace BlackMisc
|
|||||||
iterator find(const T &value) override { return iterator::fromImpl(m_impl.find(value)); }
|
iterator find(const T &value) override { return iterator::fromImpl(m_impl.find(value)); }
|
||||||
const_iterator find(const T &value) const override { return const_iterator::fromImpl(m_impl.find(value)); }
|
const_iterator find(const T &value) const override { return const_iterator::fromImpl(m_impl.find(value)); }
|
||||||
bool operator ==(const PimplBase &other) const override { Pimpl copy = C(); for (auto i = other.cbegin(); i != other.cend(); ++i) copy.insert(*i); return m_impl == copy.m_impl; }
|
bool operator ==(const PimplBase &other) const override { Pimpl copy = C(); for (auto i = other.cbegin(); i != other.cend(); ++i) copy.insert(*i); return m_impl == copy.m_impl; }
|
||||||
|
void *impl() override { return &m_impl; }
|
||||||
private:
|
private:
|
||||||
C m_impl;
|
C m_impl;
|
||||||
// insertHelper: QOrderedSet::insert returns an iterator, but std::set::insert returns a std::pair<interator, bool>
|
// insertHelper: QOrderedSet::insert returns an iterator, but std::set::insert returns a std::pair<interator, bool>
|
||||||
|
|||||||
@@ -486,6 +486,13 @@ namespace BlackMisc
|
|||||||
*/
|
*/
|
||||||
bool operator !=(const CSequence &other) const { return !(*this == other); }
|
bool operator !=(const CSequence &other) const { return !(*this == other); }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Return an opaque pointer to the implementation container.
|
||||||
|
* \details Can be useful in unusual debugging situations.
|
||||||
|
* \warning Not for general use.
|
||||||
|
*/
|
||||||
|
void *getImpl() { return pimpl() ? pimpl()->impl() : nullptr; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class PimplBase
|
class PimplBase
|
||||||
{
|
{
|
||||||
@@ -515,6 +522,7 @@ namespace BlackMisc
|
|||||||
virtual iterator erase(iterator pos) = 0;
|
virtual iterator erase(iterator pos) = 0;
|
||||||
virtual iterator erase(iterator it1, iterator it2) = 0;
|
virtual iterator erase(iterator it1, iterator it2) = 0;
|
||||||
virtual bool operator ==(const PimplBase &other) const = 0;
|
virtual bool operator ==(const PimplBase &other) const = 0;
|
||||||
|
virtual void *impl() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class C> class Pimpl : public PimplBase
|
template <class C> class Pimpl : public PimplBase
|
||||||
@@ -546,6 +554,7 @@ namespace BlackMisc
|
|||||||
iterator erase(iterator pos) override { return iterator::fromImpl(m_impl.erase(*static_cast<const typename C::iterator*>(pos.getImpl()))); }
|
iterator erase(iterator pos) override { return iterator::fromImpl(m_impl.erase(*static_cast<const typename C::iterator*>(pos.getImpl()))); }
|
||||||
iterator erase(iterator it1, iterator it2) override { return iterator::fromImpl(m_impl.erase(*static_cast<const typename C::iterator*>(it1.getImpl()), *static_cast<const typename C::iterator*>(it2.getImpl()))); }
|
iterator erase(iterator it1, iterator it2) override { return iterator::fromImpl(m_impl.erase(*static_cast<const typename C::iterator*>(it1.getImpl()), *static_cast<const typename C::iterator*>(it2.getImpl()))); }
|
||||||
bool operator ==(const PimplBase &other) const override { Pimpl copy = C(); for (auto i = other.cbegin(); i != other.cend(); ++i) copy.push_back(*i); return m_impl == copy.m_impl; }
|
bool operator ==(const PimplBase &other) const override { Pimpl copy = C(); for (auto i = other.cbegin(); i != other.cend(); ++i) copy.push_back(*i); return m_impl == copy.m_impl; }
|
||||||
|
void *impl() override { return &m_impl; }
|
||||||
private:
|
private:
|
||||||
C m_impl;
|
C m_impl;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user