minor fixes for clang++
[senf.git] / senf / Packets / Packet.cci
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 //
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
10 //
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.
14 //
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.
18 //
19 // The Original Code is Fraunhofer FOKUS code.
20 //
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.
24 //
25 // Contributor(s):
26 //   Stefan Bund <g0dil@berlios.de>
27
28 /** \file
29     \brief Packet inline non-template implementation */
30
31 // Custom includes
32 #include <senf/Utils/senfassert.hh>
33
34 #define prefix_ inline
35 //-/////////////////////////////////////////////////////////////////////////////////////////////////
36
37 //-/////////////////////////////////////////////////////////////////////////////////////////////////
38 // senf::Packet
39
40 // protected members
41
42 prefix_  senf::Packet::Packet(PacketInterpreterBase::ptr const & packet)
43     : packet_(packet)
44 {}
45
46 prefix_ senf::PacketInterpreterBase::ptr const & senf::Packet::ptr()
47     const
48 {
49     SENF_ASSERT(packet_, "Invalid operation (dereferencing) on in-valid() Packet");
50     return packet_;
51 }
52
53 // public structors
54
55 prefix_ senf::Packet::Packet()
56 {}
57
58 // public members
59
60 prefix_ senf::Packet senf::Packet::clone()
61     const
62 {
63     return Packet(ptr()->clone());
64 }
65
66 // Interpreter chain access
67
68 prefix_ senf::Packet senf::Packet::next(NoThrow_t)
69     const
70 {
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();
75 }
76
77 prefix_ senf::Packet senf::Packet::next()
78     const
79 {
80     Packet p (next(nothrow));
81     if (!p) throw InvalidPacketChainException();
82     return p;
83 }
84
85 prefix_ senf::Packet senf::Packet::prev(NoThrow_t)
86     const
87 {
88     return Packet(ptr()->prev());
89 }
90
91 prefix_ senf::Packet senf::Packet::prev()
92     const
93 {
94     Packet p (prev(nothrow));
95     if (!p) throw InvalidPacketChainException();
96     return p;
97 }
98
99 prefix_ senf::Packet senf::Packet::first()
100     const
101 {
102     return Packet(ptr()->first());
103 }
104
105 prefix_ senf::Packet senf::Packet::last()
106     const
107 {
108     Packet p (ptr()->last());
109     return p.next(nothrow) ? getLast() : p;
110 }
111
112 prefix_ senf::Packet senf::Packet::parseNextAs(factory_t factory)
113     const
114 {
115     return Packet(ptr()->parseNextAs(factory, ptr()->nextPacketRange()));
116 }
117
118 prefix_ senf::PacketInterpreterBase::ptr
119 senf::Packet::parseNextAs(factory_t factory, PacketInterpreterBase::optional_range const & range)
120     const
121 {
122     return ptr()->parseNextAs(factory, range);
123 }
124
125 prefix_ senf::Packet senf::Packet::append(Packet const & packet)
126     const
127 {
128     return Packet(ptr()->append(packet.ptr()));
129 }
130
131 // Data access
132
133 prefix_ senf::PacketData & senf::Packet::data()
134     const
135 {
136     return ptr()->data();
137 }
138
139 prefix_ senf::Packet::size_type senf::Packet::size()
140     const
141 {
142     return data().size();
143 }
144
145 // Other methods
146
147 prefix_ bool senf::Packet::operator==(Packet const & other)
148     const
149 {
150     return ptr() == other.ptr();
151 }
152
153 prefix_ void senf::Packet::finalizeThis()
154 {
155     ptr()->finalizeThis();
156 }
157
158 prefix_ void senf::Packet::finalizeTo(Packet const & other)
159 {
160     ptr()->finalizeTo(other.ptr());
161 }
162
163 prefix_ void senf::Packet::finalizeAll()
164 {
165     ptr()->finalizeTo(last().ptr());
166 }
167
168 prefix_ senf::TypeIdValue senf::Packet::typeId()
169     const
170 {
171     return ptr()->typeId();
172 }
173
174 prefix_ senf::Packet::factory_t senf::Packet::factory()
175     const
176 {
177     return ptr()->factory();
178 }
179
180 prefix_ unsigned long senf::Packet::id()
181     const
182 {
183     return reinterpret_cast<unsigned long>(&ptr()->impl());
184 }
185
186 prefix_ bool senf::Packet::boolean_test()
187     const
188 {
189     return packet_ && packet_->valid();
190 }
191
192 prefix_ bool senf::Packet::valid()
193     const
194 {
195     return *this;
196 }
197
198 prefix_ bool senf::Packet::is_shared()
199     const
200 {
201     return ptr()->is_shared() || (ptr()->impl().refcount() > 1);
202 }
203
204 prefix_ void senf::Packet::reparse()
205     const
206 {
207     ptr()->reparse();
208 }
209
210 prefix_ void senf::Packet::clearAnnotations()
211 {
212     ptr()->clearAnnotations();
213 }
214
215 template <class PacketType, class Parser>
216 prefix_ Parser senf::operator<<(Parser target, ConcretePacket<PacketType> const & packet)
217 {
218     target << packet.parser();
219     return target;
220 }
221
222 //-/////////////////////////////////////////////////////////////////////////////////////////////////
223 #undef prefix_
224
225 \f
226 // Local Variables:
227 // mode: c++
228 // fill-column: 100
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
234 // End: