Bitstream Interpretation Library (BIL)  0.1
Bitstream.cpp
Go to the documentation of this file.
1 
8 
9 using namespace bil;
10 
11 
12 void Bitstream::append(std::auto_ptr<Packet> packet)
13 {
14  m_packets.push_back(packet);
15 }
16 
17 
18 void Bitstream::insert(std::auto_ptr<Packet> packet, size_t packetIndex)
19 {
20  if (m_packets.size() <= packetIndex) throw Exception();
21  m_packets.insert(m_packets.begin() + packetIndex, packet);
22 }
23 
24 
25 void Bitstream::erase(size_t packetIndex)
26 {
27  if (m_packets.size() <= packetIndex) throw Exception();
28  m_packets.erase(m_packets.begin() + packetIndex);
29 }
30 
31 
33 {
34  m_packets.clear();
35 }
36 
37 
38 size_t Bitstream::size() const
39 {
40  return m_packets.size();
41 }
42 
43 
44 Packet& Bitstream::at(size_t packetIndex)
45 {
46  if (m_packets.size() <= packetIndex) throw Exception();
47  return m_packets[packetIndex];
48 }
49 
50 
51 const Packet& Bitstream::at(size_t packetIndex) const
52 {
53  if (m_packets.size() <= packetIndex) throw Exception();
54  return m_packets[packetIndex];
55 }
56 
57 
59 {
60  size_t packetCount = m_packets.size();
61  for (size_t i = 0; i < packetCount; ++i)
62  (m_packets[i]).accept(visitor);
63 }