StringParser.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #ifndef HH_SENF_Packets_StringParser_
18 #define HH_SENF_Packets_StringParser_ 1
19 
20 #ifndef HH_SENF_Packets_Packets_
21 #error "Don't include 'StringParser.hh' directly, include 'Packets.hh'"
22 #endif
23 
24 // Custom includes
25 #include "IntParser.hh"
26 
27 //#include "StringParser.mpp"
28 //-/////////////////////////////////////////////////////////////////////////////////////////////////
29 
30 namespace senf {
31 
32  template <class LengthParser=senf::UInt16Parser>
34  : public PacketParserBase
35  {
36  public:
38 
39 # include SENF_PARSER()
40  SENF_PARSER_FIELD_RO( length, LengthParser );
41 
42  typedef std::string value_type;
44  size_type bytes() const;
45 
46  value_type value() const;
47  void value(value_type v);
48  operator value_type() const;
49  StringParser const & operator=(value_type other);
50 
51  bool empty() const;
52  void clear();
53 
54  bool operator==(value_type const & other) const;
55  };
56 
57  template <class LengthParser>
58  std::ostream & operator<<(std::ostream & os, StringParser<LengthParser> const & value);
59 
60 
61  template <std::string::size_type N>
63  : public PacketParserBase
64  {
65  public:
67 
68  typedef std::string value_type;
69  static size_type const fixed_bytes = N;
70 
71  value_type value() const;
72  void value(value_type v);
73  operator value_type() const;
74  FixedSizeStringParser<N> const & operator=(value_type other);
75 
76  bool operator==(value_type const & other) const;
77 };
78 
79  template <std::string::size_type N>
80  std::ostream & operator<<(std::ostream & os, FixedSizeStringParser<N> const & value);
81 
82 }
83 
84 //-/////////////////////////////////////////////////////////////////////////////////////////////////
85 #endif
86 #if !defined(HH_SENF_Packets_Packets__decls_) && !defined(HH_SENF_Packets_StringParser_i_)
87 #define HH_SENF_Packets_StringParser_i_
88 //#include "StringParser.cci"
89 //#include "StringParser.ct"
90 #include "StringParser.cti"
91 #endif
92 
93 
94 // Local Variables:
95 // mode: c++
96 // fill-column: 100
97 // comment-column: 40
98 // c-file-style: "senf"
99 // indent-tabs-mode: nil
100 // ispell-local-dictionary: "american"
101 // compile-command: "scons -u test"
102 // End:
LengthParser ::value_type length() const
bool operator==(value_type const &other) const
std::string value_type
Definition: StringParser.hh:40
Return number of bytes to allocate to new object of given type.
Packet data STL-sequence view.
Definition: PacketData.hh:61
#define SENF_PARSER_FIELD_RO(name, type)
Define parser field (read-only)
data_iterator i() const
Return beginning of data to parse.
bool empty() const
detail::packet::size_type size_type
Unsigned integral type.
StringParser const & operator=(value_type other)
Parser Base class.
StringParser(data_iterator i, state_type s)
FixedSizeStringParser(data_iterator i, state_type s)
Definition: StringParser.hh:66
value_type value() const
detail::packet::iterator data_iterator
Raw data iterator type.
size_type bytes() const
IntParser public header.