4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief Packet inline non-template implementation */
32 #include <senf/Utils/senfassert.hh>
34 #define prefix_ inline
35 //-/////////////////////////////////////////////////////////////////////////////////////////////////
37 //-/////////////////////////////////////////////////////////////////////////////////////////////////
42 prefix_ senf::Packet::Packet(PacketInterpreterBase::ptr const & packet)
46 prefix_ senf::PacketInterpreterBase::ptr const & senf::Packet::ptr()
49 SENF_ASSERT(packet_, "Invalid operation (dereferencing) on in-valid() Packet");
55 prefix_ senf::Packet::Packet()
60 prefix_ senf::Packet senf::Packet::clone()
63 return Packet(ptr()->clone());
66 // Interpreter chain access
68 prefix_ senf::Packet senf::Packet::next(NoThrow_t)
71 PacketInterpreterBase::ptr p (ptr()->next());
72 if (p) return Packet(p);
73 PacketInterpreterBase::optional_range r (ptr()->nextPacketRange());
74 return (r && ! r->empty()) ? Packet(getNext(r)) : Packet();
77 prefix_ senf::Packet senf::Packet::next()
80 Packet p (next(nothrow));
81 if (!p) throw InvalidPacketChainException();
85 prefix_ senf::Packet senf::Packet::prev(NoThrow_t)
88 return Packet(ptr()->prev());
91 prefix_ senf::Packet senf::Packet::prev()
94 Packet p (prev(nothrow));
95 if (!p) throw InvalidPacketChainException();
99 prefix_ senf::Packet senf::Packet::first()
102 return Packet(ptr()->first());
105 prefix_ senf::Packet senf::Packet::last()
108 Packet p (ptr()->last());
109 return p.next(nothrow) ? getLast() : p;
112 prefix_ senf::Packet senf::Packet::parseNextAs(factory_t factory)
115 return Packet(ptr()->parseNextAs(factory, ptr()->nextPacketRange()));
118 prefix_ senf::PacketInterpreterBase::ptr
119 senf::Packet::parseNextAs(factory_t factory, PacketInterpreterBase::optional_range const & range)
122 return ptr()->parseNextAs(factory, range);
125 prefix_ senf::Packet senf::Packet::append(Packet const & packet)
128 return Packet(ptr()->append(packet.ptr()));
133 prefix_ senf::PacketData & senf::Packet::data()
136 return ptr()->data();
139 prefix_ senf::Packet::size_type senf::Packet::size()
142 return data().size();
147 prefix_ bool senf::Packet::operator==(Packet const & other)
150 return ptr() == other.ptr();
153 prefix_ void senf::Packet::finalizeThis()
155 ptr()->finalizeThis();
158 prefix_ void senf::Packet::finalizeTo(Packet const & other)
160 ptr()->finalizeTo(other.ptr());
163 prefix_ void senf::Packet::finalizeAll()
165 ptr()->finalizeTo(last().ptr());
168 prefix_ senf::TypeIdValue senf::Packet::typeId()
171 return ptr()->typeId();
174 prefix_ senf::Packet::factory_t senf::Packet::factory()
177 return ptr()->factory();
180 prefix_ unsigned long senf::Packet::id()
183 return reinterpret_cast<unsigned long>(&ptr()->impl());
186 prefix_ bool senf::Packet::boolean_test()
189 return packet_ && packet_->valid();
192 prefix_ bool senf::Packet::valid()
198 prefix_ bool senf::Packet::is_shared()
201 return ptr()->is_shared() || (ptr()->impl().refcount() > 1);
204 prefix_ void senf::Packet::reparse()
210 prefix_ void senf::Packet::clearAnnotations()
212 ptr()->clearAnnotations();
215 template <class PacketType, class Parser>
216 prefix_ Parser senf::operator<<(Parser target, ConcretePacket<PacketType> const & packet)
218 target << packet.parser();
222 //-/////////////////////////////////////////////////////////////////////////////////////////////////
229 // c-file-style: "senf"
230 // indent-tabs-mode: nil
231 // ispell-local-dictionary: "american"
232 // compile-command: "scons -u test"
233 // comment-column: 40