cpf_packet.cpp
Go to the documentation of this file.
1 
26 #include <boost/make_shared.hpp>
27 #include <boost/foreach.hpp>
28 
30 
31 using boost::make_shared;
32 
33 namespace eip {
34 
35 size_t CPFPacket::getLength() const
36 {
37  // 2 bytes just for the number of items
38  size_t l = 2;
39  BOOST_FOREACH(CPFItem i, items_)
40  {
41  l += i.getLength();
42  }
43  return l;
44 }
45 
46 Writer& CPFPacket::serialize(Writer& writer) const
47 {
48  writer.write(getItemCount());
49  BOOST_FOREACH(CPFItem i, items_)
50  {
51  i.serialize(writer);
52  }
53  return writer;
54 }
55 
56 Reader& CPFPacket::deserialize(Reader& reader)
57 {
58  items_.clear();
59  EIP_UINT num_items;
60  reader.read(num_items);
61  for (int i = 0; i < num_items; ++i)
62  {
63  CPFItem item;
64  item.deserialize(reader);
65  items_.push_back(item);
66  }
67  return reader;
68 }
69 
70 } // namespace eip
virtual Reader & deserialize(Reader &reader, size_t length)
Definition: cpf_packet.h:89
virtual size_t getLength() const
Definition: cpf_item.h:121
vector< CPFItem > items_
Definition: cpf_packet.h:104
virtual Writer & serialize(Writer &writer) const
Definition: cpf_item.cpp:37
Definition: connection.h:41
virtual Reader & deserialize(Reader &reader, size_t length)
Definition: cpf_item.cpp:47
virtual size_t getLength() const
Definition: cpf_packet.cpp:35
virtual Writer & serialize(Writer &writer) const
Definition: cpf_packet.cpp:46
uint16_t EIP_UINT
Definition: eip_types.h:39
EIP_UINT getItemCount() const
Definition: cpf_packet.h:57


odva_ethernetip
Author(s): Kareem Shehata
autogenerated on Mon Jun 10 2019 14:00:16