// $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 Packet inline non-template implementation */ // Custom includes #include #define prefix_ inline //-///////////////////////////////////////////////////////////////////////////////////////////////// //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::Packet // protected members prefix_ senf::Packet::Packet(PacketInterpreterBase::ptr const & packet) : packet_(packet) {} prefix_ senf::PacketInterpreterBase::ptr const & senf::Packet::ptr() const { SENF_ASSERT(packet_, "Invalid operation (dereferencing) on in-valid() Packet"); return packet_; } // public structors prefix_ senf::Packet::Packet() {} // public members prefix_ senf::Packet senf::Packet::clone() const { return Packet(ptr()->clone()); } // Interpreter chain access prefix_ senf::Packet senf::Packet::next(NoThrow_t) const { PacketInterpreterBase::ptr p (ptr()->next()); if (p) return Packet(p); PacketInterpreterBase::optional_range r (ptr()->nextPacketRange()); return (r && ! r->empty()) ? Packet(getNext(r)) : Packet(); } prefix_ senf::Packet senf::Packet::next() const { Packet p (next(nothrow)); if (!p) throw InvalidPacketChainException(); return p; } prefix_ senf::Packet senf::Packet::prev(NoThrow_t) const { return Packet(ptr()->prev()); } prefix_ senf::Packet senf::Packet::prev() const { Packet p (prev(nothrow)); if (!p) throw InvalidPacketChainException(); return p; } prefix_ senf::Packet senf::Packet::first() const { return Packet(ptr()->first()); } prefix_ senf::Packet senf::Packet::last() const { Packet p (ptr()->last()); return p.next(nothrow) ? getLast() : p; } prefix_ senf::Packet senf::Packet::parseNextAs(factory_t factory) const { return Packet(ptr()->parseNextAs(factory, ptr()->nextPacketRange())); } prefix_ senf::PacketInterpreterBase::ptr senf::Packet::parseNextAs(factory_t factory, PacketInterpreterBase::optional_range const & range) const { return ptr()->parseNextAs(factory, range); } prefix_ senf::Packet senf::Packet::append(Packet const & packet) const { return Packet(ptr()->append(packet.ptr())); } // Data access prefix_ senf::PacketData & senf::Packet::data() const { return ptr()->data(); } prefix_ senf::Packet::size_type senf::Packet::size() const { return data().size(); } // Other methods prefix_ bool senf::Packet::operator==(Packet const & other) const { return ptr() == other.ptr(); } prefix_ void senf::Packet::finalizeThis() { ptr()->finalizeThis(); } prefix_ void senf::Packet::finalizeTo(Packet const & other) { ptr()->finalizeTo(other.ptr()); } prefix_ void senf::Packet::finalizeAll() { ptr()->finalizeTo(last().ptr()); } prefix_ senf::TypeIdValue senf::Packet::typeId() const { return ptr()->typeId(); } prefix_ senf::Packet::factory_t senf::Packet::factory() const { return ptr()->factory(); } prefix_ unsigned long senf::Packet::id() const { return reinterpret_cast(&ptr()->impl()); } prefix_ bool senf::Packet::boolean_test() const { return packet_ && packet_->valid(); } prefix_ bool senf::Packet::valid() const { return *this; } prefix_ bool senf::Packet::is_shared() const { return ptr()->is_shared() || (ptr()->impl().refcount() > 1); } prefix_ void senf::Packet::reparse() const { ptr()->reparse(); } prefix_ void senf::Packet::clearAnnotations() { ptr()->clearAnnotations(); } template prefix_ Parser senf::operator<<(Parser target, ConcretePacket const & packet) { target << packet.parser(); return target; } //-///////////////////////////////////////////////////////////////////////////////////////////////// #undef prefix_ // Local Variables: // mode: c++ // fill-column: 100 // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" // comment-column: 40 // End: