4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief Packet inline non-template implementation */
27 #include <senf/Utils/senfassert.hh>
29 #define prefix_ inline
30 //-/////////////////////////////////////////////////////////////////////////////////////////////////
32 //-/////////////////////////////////////////////////////////////////////////////////////////////////
37 prefix_ senf::Packet::Packet(PacketInterpreterBase::ptr const & packet)
41 prefix_ senf::PacketInterpreterBase::ptr const & senf::Packet::ptr()
44 SENF_ASSERT(packet_, "Invalid operation (dereferencing) on in-valid() Packet");
50 prefix_ senf::Packet::Packet()
55 prefix_ senf::Packet senf::Packet::clone()
58 return Packet(ptr()->clone());
61 // Interpreter chain access
63 prefix_ senf::Packet senf::Packet::next(NoThrow_t)
66 PacketInterpreterBase::ptr p (ptr()->next());
67 if (p) return Packet(p);
68 PacketInterpreterBase::optional_range r (ptr()->nextPacketRange());
69 return (r && ! r->empty()) ? getNext() : Packet();
72 prefix_ senf::Packet senf::Packet::next()
75 Packet p (next(nothrow));
76 if (!p) throw InvalidPacketChainException();
80 prefix_ senf::Packet senf::Packet::prev(NoThrow_t)
83 return Packet(ptr()->prev());
86 prefix_ senf::Packet senf::Packet::prev()
89 Packet p (prev(nothrow));
90 if (!p) throw InvalidPacketChainException();
94 prefix_ senf::Packet senf::Packet::first()
97 return Packet(ptr()->first());
100 prefix_ senf::Packet senf::Packet::last()
103 Packet p (ptr()->last());
104 return p.next(nothrow) ? getLast() : p;
107 prefix_ senf::Packet senf::Packet::parseNextAs(factory_t factory)
110 return Packet(ptr()->parseNextAs(factory));
113 prefix_ senf::Packet senf::Packet::append(Packet const & packet)
116 return Packet(ptr()->append(packet.ptr()));
121 prefix_ senf::PacketData & senf::Packet::data()
124 return ptr()->data();
127 prefix_ senf::Packet::size_type senf::Packet::size()
130 return data().size();
135 prefix_ bool senf::Packet::operator==(Packet const & other)
138 return ptr() == other.ptr();
141 prefix_ void senf::Packet::finalizeThis()
143 ptr()->finalizeThis();
146 prefix_ void senf::Packet::finalizeTo(Packet const & other)
148 ptr()->finalizeTo(other.ptr());
151 prefix_ void senf::Packet::finalizeAll()
153 ptr()->finalizeTo(last().ptr());
156 prefix_ senf::TypeIdValue senf::Packet::typeId()
159 return ptr()->typeId();
162 prefix_ senf::Packet::factory_t senf::Packet::factory()
165 return ptr()->factory();
168 prefix_ unsigned long senf::Packet::id()
171 return reinterpret_cast<unsigned long>(&ptr()->impl());
174 prefix_ bool senf::Packet::boolean_test()
177 return packet_ && packet_->valid();
180 prefix_ bool senf::Packet::valid()
186 prefix_ bool senf::Packet::is_shared()
189 return ptr()->is_shared() || (ptr()->impl().refcount() > 1);
192 prefix_ void senf::Packet::reparse()
195 return ptr()->reparse();
198 prefix_ void senf::Packet::clearAnnotations()
200 return ptr()->clearAnnotations();
203 template <class PacketType, class Parser>
204 prefix_ Parser senf::operator<<(Parser target, ConcretePacket<PacketType> const & packet)
206 target << packet.parser();
210 //-/////////////////////////////////////////////////////////////////////////////////////////////////
217 // c-file-style: "senf"
218 // indent-tabs-mode: nil
219 // ispell-local-dictionary: "american"
220 // compile-command: "scons -u test"
221 // comment-column: 40