123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361 |
- /************************************************************************************
- * *
- * Copyright (c) 2014 - 2018 Axel Menzel <info@rttr.org> *
- * *
- * This file is part of RTTR (Run Time Type Reflection) *
- * License: MIT License *
- * *
- * Permission is hereby granted, free of charge, to any person obtaining *
- * a copy of this software and associated documentation files (the "Software"), *
- * to deal in the Software without restriction, including without limitation *
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
- * and/or sell copies of the Software, and to permit persons to whom the *
- * Software is furnished to do so, subject to the following conditions: *
- * *
- * The above copyright notice and this permission notice shall be included in *
- * all copies or substantial portions of the Software. *
- * *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *
- * SOFTWARE. *
- * *
- *************************************************************************************/
- #include "rttr/variant_sequential_view.h"
- #include "rttr/argument.h"
- #include "rttr/instance.h"
- using namespace std;
- namespace rttr
- {
- /////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view::variant_sequential_view()
- {
- }
- /////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view::variant_sequential_view(const variant_sequential_view& other)
- : m_view(other.m_view)
- {
- }
- /////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view::~variant_sequential_view() RTTR_NOEXCEPT
- {
- }
- /////////////////////////////////////////////////////////////////////////////////
- void variant_sequential_view::swap(variant_sequential_view& other) RTTR_NOEXCEPT
- {
- std::swap(m_view, other.m_view);
- }
- /////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view& variant_sequential_view::operator=(const variant_sequential_view& other) RTTR_NOEXCEPT
- {
- variant_sequential_view(other).swap(*this);
- return *this;
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- bool variant_sequential_view::is_valid() const RTTR_NOEXCEPT
- {
- return m_view.get_type().is_valid();
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view::operator bool() const RTTR_NOEXCEPT
- {
- return m_view.get_type().is_valid();
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- type variant_sequential_view::get_type() const RTTR_NOEXCEPT
- {
- return m_view.get_type();
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- type variant_sequential_view::get_value_type() const RTTR_NOEXCEPT
- {
- return m_view.get_value_type();
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- bool variant_sequential_view::is_empty() const RTTR_NOEXCEPT
- {
- return m_view.is_empty();
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- bool variant_sequential_view::is_dynamic() const RTTR_NOEXCEPT
- {
- return m_view.is_dynamic();
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- std::size_t variant_sequential_view::get_rank() const RTTR_NOEXCEPT
- {
- return m_view.get_rank();
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- type variant_sequential_view::get_rank_type(std::size_t index) const RTTR_NOEXCEPT
- {
- return m_view.get_rank_type(index);
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- std::size_t variant_sequential_view::get_size() const RTTR_NOEXCEPT
- {
- return m_view.get_size();
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- bool variant_sequential_view::set_size(std::size_t size) const RTTR_NOEXCEPT
- {
- return m_view.set_size(size);
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view::const_iterator variant_sequential_view::insert(const const_iterator& pos, argument value)
- {
- const_iterator itr(&m_view);
- m_view.insert(pos.m_itr, value, itr.m_itr);
- return itr;
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view::const_iterator variant_sequential_view::erase(const const_iterator& pos)
- {
- const_iterator itr(&m_view);
- m_view.erase(pos.m_itr, itr.m_itr);
- return itr;
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- void variant_sequential_view::clear()
- {
- m_view.clear();
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- bool variant_sequential_view::set_value(std::size_t index, argument arg)
- {
- return m_view.set_value(index, arg);
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- variant variant_sequential_view::get_value(std::size_t index) const
- {
- return m_view.get_value(index);
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view::const_iterator variant_sequential_view::begin() const
- {
- const_iterator itr(&m_view);
- m_view.begin(itr.m_itr);
- return itr;
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view::const_iterator variant_sequential_view::end() const
- {
- const_iterator itr(&m_view);
- m_view.end(itr.m_itr);
- return itr;
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view::const_iterator::const_iterator(const detail::variant_sequential_view_private* view) RTTR_NOEXCEPT
- : m_view(view)
- {
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view::const_iterator::~const_iterator()
- {
- m_view->destroy(m_itr);
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view::const_iterator::const_iterator(const const_iterator &other)
- : m_view(other.m_view),
- m_itr(other.m_itr)
- {
- m_view->copy(m_itr, other.m_itr);
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view::const_iterator& variant_sequential_view::const_iterator::operator=(const_iterator other)
- {
- swap(other);
- return *this;
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- void variant_sequential_view::const_iterator::swap(const_iterator& other)
- {
- std::swap(m_itr, other.m_itr);
- std::swap(m_view, other.m_view);
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- const variant variant_sequential_view::const_iterator::operator*() const
- {
- return m_view->get_data(m_itr);
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- const variant variant_sequential_view::const_iterator::get_data() const
- {
- return m_view->get_data(m_itr);
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view::const_iterator& variant_sequential_view::const_iterator::operator++()
- {
- m_view->advance(m_itr, 1);
- return *this;
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view::const_iterator variant_sequential_view::const_iterator::operator++(int)
- {
- const_iterator result(m_view);
- m_view->copy(result.m_itr, m_itr);
- m_view->advance(m_itr, 1);
- return result;
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view::const_iterator& variant_sequential_view::const_iterator::operator--()
- {
- m_view->advance(m_itr, -1);
- return *this;
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view::const_iterator variant_sequential_view::const_iterator::operator--(int)
- {
- const_iterator result(m_view);
- m_view->copy(result.m_itr, m_itr);
- m_view->advance(m_itr, -1);
- return result;
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view::const_iterator& variant_sequential_view::const_iterator::operator+=(int i)
- {
- m_view->advance(m_itr, i);
- return *this;
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view::const_iterator& variant_sequential_view::const_iterator::operator-=(int i)
- {
- m_view->advance(m_itr, -i);
- return *this;
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view::const_iterator variant_sequential_view::const_iterator::operator+(int i) const
- {
- const_iterator result(m_view);
- m_view->copy(result.m_itr, m_itr);
- result.m_view->advance(result.m_itr, i);
- return result;
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- variant_sequential_view::const_iterator variant_sequential_view::const_iterator::operator-(int i) const
- {
- const_iterator result(m_view);
- m_view->copy(result.m_itr, m_itr);
- result.m_view->advance(result.m_itr, -i);
- return result;
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- bool variant_sequential_view::const_iterator::operator==(const const_iterator& other) const
- {
- return m_view->equal(m_itr, other.m_itr);
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- bool variant_sequential_view::const_iterator::operator!=(const const_iterator& other) const
- {
- return !m_view->equal(m_itr, other.m_itr);
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- } // end namespace rttr
|