// $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 ListBParser inline template implementation */ #include "ListBParser.ih" // Custom includes #define prefix_ inline //-///////////////////////////////////////////////////////////////////////////////////////////////// //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::detail::ListBParser_Policy template prefix_ senf::detail::ListBParser_Policy::ListBParser_Policy() {} template template prefix_ senf::detail::ListBParser_Policy::ListBParser_Policy(Arg const & arg) : AuxPolicy (arg) {} template prefix_ typename senf::detail::ListBParser_Policy::size_type senf::detail::ListBParser_Policy::bytes(data_iterator i, state_type s) const { return AuxPolicy::aux(i,s) + AuxPolicy::aux_bytes; } template prefix_ typename senf::detail::ListBParser_Policy::size_type senf::detail::ListBParser_Policy::size(data_iterator i, state_type s) const { parser_type p (*this, i, s); container_type c (p); return std::distance(c.begin(),c.end()); } template prefix_ void senf::detail::ListBParser_Policy::init(data_iterator i, state_type s) const { AuxPolicy::aux(0,i,s); } //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::detail::ListBParser_Policy template prefix_ typename senf::detail::ListBParser_Policy::container_policy::size_type senf::detail::ListBParser_Policy::container_policy::bytes(data_iterator i, state_type s) const { return AuxPolicy::WrapperPolicy::aux(i,s) + AuxPolicy::aux_bytes; } template prefix_ typename senf::detail::ListBParser_Policy::container_policy::size_type senf::detail::ListBParser_Policy::container_policy::size(data_iterator i, state_type s) const { return n_; } template prefix_ void senf::detail::ListBParser_Policy::container_policy:: init(data_iterator i, state_type s) { n_ = 0; container_size_ = s->size(); AuxPolicy::WrapperPolicy::aux(0,i,s); } template prefix_ void senf::detail::ListBParser_Policy::container_policy:: construct(container_type & c) const {} template prefix_ void senf::detail::ListBParser_Policy::container_policy:: destruct(container_type & c) const {} template prefix_ void senf::detail::ListBParser_Policy::container_policy:: erase(container_type & c, data_iterator p) { size_type b (senf::bytes(ElementParser(p,c.state()))); AuxPolicy::WrapperPolicy::aux( AuxPolicy::WrapperPolicy::aux(c.i(), c.state())-b, c.i(), c.state()); --n_; // The container will be reduced by b bytes directly after this call container_size_ = c.data().size()-b; } template prefix_ void senf::detail::ListBParser_Policy::container_policy:: insert(container_type & c, data_iterator p) { size_type b (senf::bytes(ElementParser(p,c.state()))); AuxPolicy::WrapperPolicy::aux( AuxPolicy::WrapperPolicy::aux(c.i(), c.state())+b, c.i(), c.state()); ++n_; container_size_ = c.data().size(); } template prefix_ void senf::detail::ListBParser_Policy::container_policy:: update(container_type const & c) const { if (container_size_ == c.data().size()) return; #if 1 data_iterator i (AuxPolicy::WrapperPolicy::adjust(c.i(), c.state())); data_iterator j (i); for (size_type n (n_); n; --n, std::advance(j,senf::bytes(ElementParser(j,c.state())))) ; AuxPolicy::WrapperPolicy::aux( std::distance(i,j), c.i(), c.state() ); #else AuxPolicy::WrapperPolicy::aux( aux(c.i(),c.state()) + c.data().size() - container_size_, c.i(), c.state() ); #endif container_size_ = c.data().size(); } template prefix_ typename senf::detail::ListBParser_Policy::container_policy::data_iterator senf::detail::ListBParser_Policy::container_policy:: setBegin(container_type const & c, iterator_data & d) const { return AuxPolicy::WrapperPolicy::adjust(c.i(), c.state()); } template prefix_ typename senf::detail::ListBParser_Policy::container_policy::data_iterator senf::detail::ListBParser_Policy::container_policy:: setEnd(container_type const & c, iterator_data & d) const { return boost::next(AuxPolicy::WrapperPolicy::adjust(c.i(), c.state()),AuxPolicy::WrapperPolicy::aux(c.i(),c.state())); } template prefix_ void senf::detail::ListBParser_Policy::container_policy:: setFromPosition(container_type const & c, iterator_data & d, data_iterator p) const {} template prefix_ typename senf::detail::ListBParser_Policy::container_policy::data_iterator senf::detail::ListBParser_Policy::container_policy:: next(container_type const & c, iterator_data & d) const { return boost::next( container_type::iterator::get(d).i(), senf::bytes(ElementParser( container_type::iterator::get(d).i(), c.state() )) ); } template prefix_ typename senf::detail::ListBParser_Policy::container_policy::data_iterator senf::detail::ListBParser_Policy::container_policy:: raw(container_type const & c, iterator_data const & d) const { return container_type::iterator::get(d).i(); } //-///////////////////////////////////////////////////////////////////////////////////////////////// #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: