Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
senf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wiback
senf
Commits
9afd086b
Commit
9afd086b
authored
17 years ago
by
g0dil
Browse files
Options
Downloads
Patches
Plain Diff
Packets: Add SENF_PACKET_PARSER_DEFINE_[FIXED_]FIELDS_OFFSET
parent
32d5f7ca
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Packets/PacketParser.hh
+60
-2
60 additions, 2 deletions
Packets/PacketParser.hh
Packets/PacketParser.mpp
+4
-4
4 additions, 4 deletions
Packets/PacketParser.mpp
with
64 additions
and
6 deletions
Packets/PacketParser.hh
+
60
−
2
View file @
9afd086b
...
@@ -463,8 +463,37 @@ namespace senf {
...
@@ -463,8 +463,37 @@ namespace senf {
\hideinitializer
\hideinitializer
*/
*/
# define SENF_PACKET_PARSER_DEFINE_FIELDS(fields) \
# define SENF_PACKET_PARSER_DEFINE_FIELDS(fields) \
SENF_PACKET_PARSER_I_DEFINE_FIELDS(fields)
SENF_PACKET_PARSER_I_DEFINE_FIELDS(
0,
fields)
/** \brief Define fields for a dynamically sized parser (with offset)
Define the fields as specified in \a fields. This macro supports dynamically sized
subfields, the resulting parser will be dynamically sized.
The \a offset argument gives the byte offset at which to start parsing the fields. This
helps defining extended parser deriving from a base parser:
\code
struct ExtendedParser : public BaseParser
{
SENF_PACKET_PARSER_NO_INIT(ExtendedParser);
SENF_PACKET_PARSER_DEFINE_FIELDS_OFFSET(senf::bytes(BaseParser(*this)),
( ... fields ... ) );
void init() {
BaseParser::init();
defaultInit();
// other init code
}
}
\endcode
\ingroup packetparsermacros
\hideinitializer
*/
# define SENF_PACKET_PARSER_DEFINE_FIELDS_OFFSET(offset,fields) \
SENF_PACKET_PARSER_I_DEFINE_FIELDS(offset,fields)
/** \brief Define fields for a fixed size parser
/** \brief Define fields for a fixed size parser
Define the fields as specified in \a fields. This macro only supports fixed size
Define the fields as specified in \a fields. This macro only supports fixed size
...
@@ -474,7 +503,36 @@ namespace senf {
...
@@ -474,7 +503,36 @@ namespace senf {
\hideinitializer
\hideinitializer
*/
*/
# define SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(fields) \
# define SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(fields) \
SENF_PACKET_PARSER_I_DEFINE_FIXED_FIELDS(fields)
SENF_PACKET_PARSER_I_DEFINE_FIXED_FIELDS(0,fields)
/** \brief Define fields for a fixed size parser
Define the fields as specified in \a fields. This macro only supports fixed size
subfields, the resulting parser will also be a fixed size parser.
The \a offset argument gives the byte offset at which to start parsing the fields. This
helps defining extended parser deriving from a base parser:
\code
struct ExtendedParser : public BaseParser
{
SENF_PACKET_PARSER_NO_INIT(ExtendedParser);
SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS_OFFSET(BaseParser::fixed_bytes,
( ... fields ... ) );
void init() {
BaseParser::init();
defaultInit();
// other init code
}
}
\endcode
\ingroup packetparsermacros
\hideinitializer
*/
# define SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS_OFFSET(offset,fields) \
SENF_PACKET_PARSER_I_DEFINE_FIXED_FIELDS(offset,fields)
struct
VoidPacketParser
struct
VoidPacketParser
:
public
PacketParserBase
:
public
PacketParserBase
...
...
This diff is collapsed.
Click to expand it.
Packets/PacketParser.mpp
+
4
−
4
View file @
9afd086b
...
@@ -65,8 +65,8 @@
...
@@ -65,8 +65,8 @@
# define SENF_PACKET_PARSER_I_INITSIZE_C(_0,_1,n,elt) \
# define SENF_PACKET_PARSER_I_INITSIZE_C(_0,_1,n,elt) \
BOOST_PP_IF(n,+,) senf::init_bytes< SENF_PACKET_PARSER_I_GET_TYPE(elt) >::value
BOOST_PP_IF(n,+,) senf::init_bytes< SENF_PACKET_PARSER_I_GET_TYPE(elt) >::value
#
#
# define SENF_PACKET_PARSER_I_DEFINE_FIELDS(fields)
\
# define SENF_PACKET_PARSER_I_DEFINE_FIELDS(
offset,
fields) \
size_type offset_0_() const { return
0; }
\
size_type offset_0_() const { return
offset; }
\
BOOST_PP_SEQ_FOR_EACH_I(SENF_PACKET_PARSER_I_FIELD_C, _, fields) \
BOOST_PP_SEQ_FOR_EACH_I(SENF_PACKET_PARSER_I_FIELD_C, _, fields) \
size_type bytes() const { \
size_type bytes() const { \
return BOOST_PP_CAT(offset_,BOOST_PP_CAT(BOOST_PP_SEQ_SIZE(fields),_)) (); \
return BOOST_PP_CAT(offset_,BOOST_PP_CAT(BOOST_PP_SEQ_SIZE(fields),_)) (); \
...
@@ -82,8 +82,8 @@
...
@@ -82,8 +82,8 @@
BOOST_PP_EXPAND( \
BOOST_PP_EXPAND( \
SENF_PACKET_PARSER_I_FIXED_FIELD_DISPATCH SENF_PACKET_PARSER_I_UNWRAP(n,elt))
SENF_PACKET_PARSER_I_FIXED_FIELD_DISPATCH SENF_PACKET_PARSER_I_UNWRAP(n,elt))
#
#
# define SENF_PACKET_PARSER_I_DEFINE_FIXED_FIELDS(fields)
\
# define SENF_PACKET_PARSER_I_DEFINE_FIXED_FIELDS(
offset,
fields) \
static const size_type offset_0_ =
0;
\
static const size_type offset_0_ =
offset;
\
BOOST_PP_SEQ_FOR_EACH_I(SENF_PACKET_PARSER_I_FIXED_FIELD_C, _, fields) \
BOOST_PP_SEQ_FOR_EACH_I(SENF_PACKET_PARSER_I_FIXED_FIELD_C, _, fields) \
static const size_type fixed_bytes = \
static const size_type fixed_bytes = \
BOOST_PP_CAT(offset_,BOOST_PP_CAT(BOOST_PP_SEQ_SIZE(fields),_)); \
BOOST_PP_CAT(offset_,BOOST_PP_CAT(BOOST_PP_SEQ_SIZE(fields),_)); \
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment