// $Id$ // // Copyright (C) 2007 // Fraunhofer Institute for Open Communication Systems (FOKUS) // // The contents of this file are subject to the Fraunhofer FOKUS Public License // Version 1.0 (the "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // http://senf.berlios.de/license.html // // The Fraunhofer FOKUS Public License Version 1.0 is based on, // but modifies the Mozilla Public License Version 1.1. // See the full license text for the amendments. // // Software distributed under the License is distributed on an "AS IS" basis, // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License // for the specific language governing rights and limitations under the License. // // The Original Code is Fraunhofer FOKUS code. // // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. // (registered association), Hansastraße 27 c, 80686 Munich, Germany. // All Rights Reserved. // // Contributor(s): // Stefan Bund /** \file \brief ListParser non-inline template implementation */ #include "ListParser.ih" // Custom includes #include #define prefix_ //-///////////////////////////////////////////////////////////////////////////////////////////////// //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::ListParser template prefix_ void senf::ListParser::init() const { ListPolicy::init(i(),state()); container c (*this); typename container::iterator i (c.begin()); typename container::iterator const e (c.end()); for (; i!=e; ++i) i->init(); } template prefix_ typename senf::ListParser::value_type senf::ListParser::back() const { SENF_ASSERT( ! empty(), "back() called on empty list" ); container c(*this); typename container::iterator i (c.begin()), j; typename container::iterator const e (c.end()); for (j=i; i!=e; j=i, ++i) ; return *j; } //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::ListParser_Container template prefix_ typename senf::ListParser_Container::value_type senf::ListParser_Container::back() const { SENF_ASSERT( ! empty(), "back() called on empty list" ); iterator i (begin()), j; iterator const e (end()); for (j=i; i!=e; j=i, ++i) ; return *j; } template prefix_ typename senf::ListParser_Container::value_type senf::ListParser_Container::shift(iterator pos, size_type n) { ListPolicy::update(*this); safe_data_iterator sp (data(),pos.raw()); for (; n>0; --n) { data().insert(sp,senf::init_bytes::value,0); value_type(sp,state()).init(); ListPolicy::insert(*this,sp); } return value_type(sp,state()); } template template prefix_ void senf::ListParser_Container::insert(iterator pos, size_type n, Value const & t) { ListPolicy::update(*this); safe_data_iterator sp (data(),pos.raw()); for (; n>0; --n) { data().insert(sp,senf::init_bytes::value,0); value_type(sp,state()).init(); value_type(sp,state()) << t; ListPolicy::insert(*this,sp); } } #ifndef DOXYGEN template template prefix_ void senf::ListParser_Container:: insert(iterator pos, ForwardIterator f, ForwardIterator l, typename boost::disable_if< boost::is_convertible >::type *) { ListPolicy::update(*this); safe_data_iterator sp (data(),pos.raw()); for (; f!=l; ++f) { data().insert(sp,senf::init_bytes::value,0); value_type(sp,state()).init(); value_type(sp,state()) << *f; ListPolicy::insert(*this,sp); sp += senf::bytes(value_type(sp,state())); } } #else template template prefix_ void senf::ListParser_Container:: insert(iterator pos, ForwardIterator f, ForwardIterator l) {} #endif template prefix_ void senf::ListParser_Container::erase(iterator pos, size_type n) { ListPolicy::update(*this); safe_data_iterator sp (data(),pos.raw()); for (; n>0; --n) { ListPolicy::erase(*this,sp); data().erase(sp,boost::next(sp,senf::bytes(value_type(sp,state())))); } } template prefix_ void senf::ListParser_Container::clear() { size_type sz (bytes()); if (sz > ListPolicy::init_bytes) data().erase(boost::next(i(),ListPolicy::init_bytes),boost::next(i(),sz)); else data().insert(boost::next(i(),sz), ListPolicy::init_bytes-sz, 0u); std::fill(i(),boost::next(i(),ListPolicy::init_bytes), 0u); ListPolicy::init(i(),state()); } template prefix_ void senf::ListParser_Container::resize(size_type n) { size_type sz (size()); if (sz>n) erase(boost::next(begin(),n),end()); else push_back_space(n-sz); } template template prefix_ void senf::ListParser_Container::resize(size_type n, Value value) { size_type sz (size()); if (sz>n) erase(boost::next(begin(),n),end()); else push_back(value,n-sz); } //-///////////////////////////////////////////////////////////////////////////////////////////////// #undef prefix_ // Local Variables: // mode: c++ // fill-column: 100 // comment-column: 40 // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" // End: