Checkpoint. Reorganizing ccnb parsing into many small files.
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.cc
new file mode 100644
index 0000000..64f7d0b
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.cc
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "ccnb-parser-content-object-visitor.h"
+#include "ccnb-parser-name-components-visitor.h"
+
+#include "ns3/ccnb-parser-block.h"
+#include "ns3/ccnb-parser-dtag.h"
+#include "ns3/name-components.h"
+#include "ns3/assert.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+// We don't really care about any other fields
+void
+ContentObjectVisitor::visit (Dtag &n, boost::any param/*should be CcnxContentObjectHeader&*/)
+{
+ // uint32_t n.m_dtag;
+ // std::list<Ptr<Block> > n.m_nestedBlocks;
+ static NameComponentsVisitor m_nameComponentsVisitor;
+
+ CcnxContentObjectHeader &contentObject = boost::any_cast<CcnxContentObjectHeader&> (param);
+
+ switch (n.m_dtag)
+ {
+ case CCN_DTAG_ContentObject:
+ // process nested blocks
+ BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
+ {
+ block->accept (*this, param);
+ }
+ break;
+ case CCN_DTAG_Name:
+ {
+ // process name components
+ Ptr<Name::Components> name = Create<Name::Components> ();
+
+ BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
+ {
+ block->accept (nameComponentsVisitor, *name);
+ }
+ contentObject.SetName (name);
+ break;
+ }
+ case CCN_DTAG_Signature: // ignoring
+ break;
+ case CCN_DTAG_SignedInfo: // ignoring
+ break;
+ case CCN_DTAG_Content: // !!! HACK
+ // This hack was necessary for memory optimizations (i.e., content is virtual payload)
+ NS_ASSERT_MSG (n.m_nestedBlocks.size() == 0, "Parser should have stopped just after processing <Content> tag");
+ break;
+ }
+}
+
+} // namespace CcnbParser
+} // namespace ns3
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.h
new file mode 100644
index 0000000..e15e290
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.h
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_CONTENT_OBJECT_VISITOR_H_
+#define _CCNB_PARSER_CONTENT_OBJECT_VISITOR_H_
+
+#include "ccnb-parser-void-depth-first-visitor.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Visitor that fills fields in CcnxContentObjectHeader
+ *
+ * Usage example:
+ * \code
+ * Ptr<CcnxContentObjectHeader> header = Create<CcnxContentObjectHeader> ();
+ * Ptr<CcnbParser::Block> root = CcnbParser::Block::ParseBlock (i);
+ * ContentObjectVisitor visitor;
+ * root->accept (visitor, *header);
+ * \endcode
+ */
+class ContentObjectVisitor : public VoidDepthFirstVisitor
+{
+public:
+ virtual void visit (Dtag &n, boost::any param/*should be CcnxContentObjectHeader&*/);
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_CONTENT_OBJECT_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-depth-first-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-depth-first-visitor.cc
new file mode 100644
index 0000000..aa78e85
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-depth-first-visitor.cc
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "ccnb-parser-depth-first-visitor.h"
+
+#include "ns3/ccnb-parser-blob.h"
+#include "ns3/ccnb-parser-udata.h"
+#include "ns3/ccnb-parser-tag.h"
+#include "ns3/ccnb-parser-dtag.h"
+#include "ns3/ccnb-parser-attr.h"
+#include "ns3/ccnb-parser-dattr.h"
+#include "ns3/ccnb-parser-ext.h"
+
+#include <boost/foreach.hpp>
+
+namespace ns3 {
+namespace CcnbParser {
+
+boost::any
+GJDepthFirstVisitor::visit (Blob &n, boost::any param)
+{
+ // Buffer n.m_blob;
+ return n.m_blob;
+}
+
+boost::any
+GJDepthFirstVisitor::visit (Udata &n, boost::any param)
+{
+ // std::string n.m_udata;
+ return n.m_udata;
+}
+
+boost::any
+GJDepthFirstVisitor::visit (Tag &n, boost::any param)
+{
+ // std::string n.m_tag;
+ // std::list<Ptr<Block> > n.m_attrs;
+ // std::list<Ptr<Block> > n.m_nestedBlocks;
+ BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
+ {
+ block->accept (*this, param);
+ }
+ BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
+ {
+ block->accept (*this, param);
+ }
+ return boost::any();
+}
+
+boost::any
+GJDepthFirstVisitor::visit (Dtag &n, boost::any param)
+{
+ // std::string n.m_tag;
+ // std::list<Ptr<Block> > n.m_attrs;
+ // std::list<Ptr<Block> > n.m_nestedBlocks;
+ BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
+ {
+ block->accept (*this, param);
+ }
+ BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
+ {
+ block->accept (*this, param);
+ }
+ return boost::any ();
+}
+
+boost::any
+GJDepthFirstVisitor::visit (Attr &n, boost::any param)
+{
+ // std::string n.m_attr;
+ // Ptr<Udata> n.m_value;
+ return boost::any ();
+}
+
+boost::any
+GJDepthFirstVisitor::visit (Dattr &n, boost::any param)
+{
+ // uint32_t n.m_dattr;
+ // Ptr<Udata> n.m_value;
+ return boost::any ();
+}
+
+boost::any
+GJDepthFirstVisitor::visit (Ext &n, boost::any param)
+{
+ // uint64_t n.m_extSubtype;
+ return n.m_extSubtype;
+}
+
+}
+}
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-depth-first-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-depth-first-visitor.h
new file mode 100644
index 0000000..d68b4ad
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-depth-first-visitor.h
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_DEPTH_FIRST_VISITOR_H_
+#define _CCNB_PARSER_DEPTH_FIRST_VISITOR_H_
+
+#include "ccnb-parser-visitor.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingrou ccnx-ccnb
+ * \brief Depth-first visitor that takes boot::any as argument and returns boost::any value
+ */
+class DepthFirstVisitor : public Visitor
+{
+public:
+ virtual boost::any visit (Blob&, boost::any);
+ virtual boost::any visit (Udata&, boost::any);
+ virtual boost::any visit (Tag&, boost::any);
+ virtual boost::any visit (Attr&, boost::any);
+ virtual boost::any visit (Dtag&, boost::any);
+ virtual boost::any visit (Dattr&, boost::any);
+ virtual boost::any visit (Ext&, boost::any);
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_DEPTH_FIRST_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-interest-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-interest-visitor.cc
new file mode 100644
index 0000000..d33b2b0
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-interest-visitor.cc
@@ -0,0 +1,133 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "ccnb-parser-interest-visitor.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+// We don't care about any other fields
+void
+InterestVisitor::visit (Dtag &n, boost::any param/*should be CcnxInterestHeader&*/)
+{
+ // uint32_t n.m_dtag;
+ // std::list<Ptr<Block> > n.m_nestedBlocks;
+
+ static NonNegativeIntegerVisitor nonNegativeIntegerVisitor;
+ static NameComponentsVisitor m_nameComponentsVisitor;
+
+ CcnxInterestHeader &interest = boost::any_cast<CcnxInterestHeader&> (param);
+
+ switch (n.m_dtag)
+ {
+ case CCN_DTAG_Interest:
+ // process nested blocks
+ BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
+ {
+ block->accept (*this, param);
+ }
+ break;
+ case CCN_DTAG_Name:
+ {
+ // process name components
+ Ptr<Name::Components> name = Create<Name::Components> ();
+
+ BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
+ {
+ block->accept (nameComponentsVisitor, *name);
+ }
+ interest.SetName (name);
+ break;
+ }
+ case CCN_DTAG_MinSuffixComponents:
+ if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
+ throw CcnxDecodingException ();
+ interest.SetMinSuffixComponents (
+ boost::any_cast<uint32_t> (
+ (*n.m_nestedBlocks.begin())->accept(
+ nonNegativeIntegerVisitor
+ )));
+ break;
+ case CCN_DTAG_MaxSuffixComponents:
+ if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
+ throw CcnxDecodingException ();
+ interest.SetMaxSuffixComponents (
+ boost::any_cast<uint32_t> (
+ (*n.m_nestedBlocks.begin())->accept(
+ nonNegativeIntegerVisitor
+ )));
+ break;
+ case CCN_DTAG_Exclude:
+ {
+ // process exclude components
+ Ptr<Name::Components> exclude = Create<Name::Components> ();
+
+ BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
+ {
+ block->accept (nameComponentsVisitor, *exclude);
+ }
+ interest.SetExclude (exclude);
+ break;
+ }
+ case CCN_DTAG_ChildSelector:
+ if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
+ throw CcnxDecodingException ();
+
+ interest.SetChildSelector (
+ 1 == boost::any_cast<uint32_t> (
+ (*n.m_nestedBlocks.begin())->accept(
+ nonNegativeIntegerVisitor
+ )));
+ break;
+ case CCN_DTAG_AnswerOriginKind:
+ if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
+ throw CcnxDecodingException ();
+ interest.SetAnswerOriginKind (
+ 1 == boost::any_cast<uint32_t> (
+ (*n.m_nestedBlocks.begin())->accept(
+ nonNegativeIntegerVisitor
+ )));
+ break;
+ case CCN_DTAG_Scope:
+ if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
+ throw CcnxDecodingException ();
+ interest.SetScope (
+ boost::any_cast<uint32_t> (
+ (*n.m_nestedBlocks.begin())->accept(
+ nonNegativeIntegerVisitor
+ )));
+ break;
+ case CCN_DTAG_InterestLifetime:
+ if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
+ throw CcnxDecodingException ();
+
+ /// \todo Decode InterestLifetime
+ break;
+ case CCN_DTAG_Nonce:
+ if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
+ throw CcnxDecodingException ();
+
+ /// \todo Decode Nonce
+ break;
+ }
+}
+
+} // namespace CcnbParser
+} // namespace ns3
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-interest-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-interest-visitor.h
new file mode 100644
index 0000000..e2cc574
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-interest-visitor.h
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_INTEREST_VISITOR_H_
+#define _CCNB_PARSER_INTEREST_VISITOR_H_
+
+#include "ccnb-parser-void-depth-first-visitor.h"
+#include "ccnb-parser-name-components-visitor.h"
+#include "ccnb-parser-non-negative-integer-visitor.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Visitor that fills fields in CcnxInterestHeader
+ *
+ * Usage example:
+ * \code
+ * Ptr<CcnxInterestHeader> header = Create<CcnxInterestHeader> ();
+ * Ptr<CcnbParser::Block> root = CcnbParser::Block::ParseBlock (i);
+ * InterestVisitor visitor;
+ * root->accept (visitor, *header);
+ * \endcode
+ */
+class InterestVisitor : public VoidDepthFirstVisitor
+{
+public:
+ virtual void visit (Dtag &n, boost::any param/*should be CcnxInterestHeader&*/);
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_INTEREST_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-name-components-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-name-components-visitor.cc
new file mode 100644
index 0000000..5ffd71f
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-name-components-visitor.cc
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "ccnb-parser-name-components-visitor.h"
+
+#include "ccnb-parser-string-visitor.h"
+#include "ns3/ccnb-parser-dtag.h"
+#include "ns3/name-components.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+void
+NameComponentsVisitor::visit (Dtag &n, boost::any param/*should be Name::Components&*/)
+{
+ // uint32_t n.m_dtag;
+ // std::list<Ptr<Block> > n.m_nestedBlocks;
+ static StringVisitor stringVisitor;
+
+ Name::Components &components = boost::any_cast<Name::Components&> (param);
+
+ switch (n.m_dtag)
+ {
+ case CCN_DTAG_Component:
+ if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
+ throw CcnxDecodingException ();
+ components.Add (
+ boost::any_cast<std::string> ((*n.m_nestedBlocks.begin())->accept(
+ stringVisitor
+ )));
+ break;
+ default:
+ // ignore any other components
+ // when parsing Exclude, there could be <Any /> and <Bloom /> tags
+ break;
+ }
+}
+
+}
+}
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-name-components-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-name-components-visitor.h
new file mode 100644
index 0000000..c68eb56
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-name-components-visitor.h
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_NAME_COMPONENTS_VISITOR_H_
+#define _CCNB_PARSER_NAME_COMPONENTS_VISITOR_H_
+
+#include "ccnb-parser-void-depth-first-visitor.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Visitor to obtain fill Name::Components object with name components
+ */
+class NameComponentsVisitor : public VoidDepthFirstVisitor
+{
+public:
+ virtual void visit (Dtag &n, boost::any param/*should be Name::Components&*/);
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_NAME_COMPONENTS_VISITOR_H_
+
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-no-argu-depth-first-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-no-argu-depth-first-visitor.cc
new file mode 100644
index 0000000..6cd9aac
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-no-argu-depth-first-visitor.cc
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "ccnb-parser-no-argu-depth-first-visitor.h"
+
+#include "ns3/ccnb-parser-blob.h"
+#include "ns3/ccnb-parser-udata.h"
+#include "ns3/ccnb-parser-tag.h"
+#include "ns3/ccnb-parser-dtag.h"
+#include "ns3/ccnb-parser-attr.h"
+#include "ns3/ccnb-parser-dattr.h"
+#include "ns3/ccnb-parser-ext.h"
+
+#include <boost/foreach.hpp>
+
+namespace ns3 {
+namespace CcnbParser {
+
+boost::any
+NoArguDepthFirstVisitor::visit (Blob &n)
+{
+ // Buffer n.m_blob;
+ return n.m_blob;
+}
+
+boost::any
+NoArguDepthFirstVisitor::visit (Udata &n)
+{
+ // std::string n.m_udata;
+ return n.m_udata;
+}
+
+boost::any
+NoArguDepthFirstVisitor::visit (Tag &n)
+{
+ // uint32_t n.m_dtag;
+ // std::list<Ptr<Block> > n.m_attrs;
+ // std::list<Ptr<Block> > n.m_nestedBlocks;
+ BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
+ {
+ block->accept (*this);
+ }
+ BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
+ {
+ block->accept (*this);
+ }
+ return boost::any ();
+}
+
+boost::any
+NoArguDepthFirstVisitor::visit (Dtag &n)
+{
+ // uint32_t n.m_dtag;
+ // std::list<Ptr<Block> > n.m_attrs;
+ // std::list<Ptr<Block> > n.m_nestedBlocks;
+ BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
+ {
+ block->accept (*this);
+ }
+ BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
+ {
+ block->accept (*this);
+ }
+ return boost::any();
+}
+
+boost::any
+NoArguDepthFirstVisitor::visit (Attr &n)
+{
+ // std::string n.m_attr;
+ // Ptr<Udata> n.m_value;
+ return boost::any ();
+}
+
+boost::any
+NoArguDepthFirstVisitor::visit (Dattr &n)
+{
+ // uint32_t n.m_dattr;
+ // Ptr<Udata> n.m_value;
+ return boost::any ();
+}
+
+boost::any
+NoArguDepthFirstVisitor::visit (Ext &n)
+{
+ // uint64_t n.m_extSubtype;
+ return n.m_extSubtype;
+}
+
+}
+}
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-no-argu-depth-first-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-no-argu-depth-first-visitor.h
new file mode 100644
index 0000000..1990d87
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-no-argu-depth-first-visitor.h
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_NO_ARGU_DEPTH_FIRST_VISITOR_H_
+#define _CCNB_PARSER_NO_ARGU_DEPTH_FIRST_VISITOR_H_
+
+#include "ccnb-parser-no-argu-visitor.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingrou ccnx-ccnb
+ * \brief Depth-first visitor that takes no arguments and returns boost::any value
+ */
+class NoArguDepthFirstVisitor : public NoArguVisitor
+{
+public:
+ virtual boost::any visit (Blob& );
+ virtual boost::any visit (Udata&);
+ virtual boost::any visit (Tag& );
+ virtual boost::any visit (Attr& );
+ virtual boost::any visit (Dtag& );
+ virtual boost::any visit (Dattr&);
+ virtual boost::any visit (Ext& );
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_NO_ARGU_DEPTH_FIRST_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-no-argu-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-no-argu-visitor.h
new file mode 100644
index 0000000..ea3b56b
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-no-argu-visitor.h
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_NO_ARGU_VISITOR_H_
+#define _CCNB_PARSER_NO_ARGU_VISITOR_H_
+
+#include "ccnb-parser-commoh.h"
+#include <boost/any.hpp>
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Visitor interface that takes no arguments and returns boost::any
+ *
+ * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+ * for ccnb encoding format help
+ */
+class NoArguVisitor
+{
+public:
+ virtual boost::any visit (Blob& )=0; ///< \brief Method accepting BLOB block
+ virtual boost::any visit (Udata&)=0; ///< \brief Method accepting UDATA block
+ virtual boost::any visit (Tag& )=0; ///< \brief Method accepting TAG block
+ virtual boost::any visit (Attr& )=0; ///< \brief Method accepting ATTR block
+ virtual boost::any visit (Dtag& )=0; ///< \brief Method accepting DTAG block
+ virtual boost::any visit (Dattr&)=0; ///< \brief Method accepting DATTR block
+ virtual boost::any visit (Ext& )=0; ///< \brief Method accepting EXT block
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_NO_ARGU_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-non-negative-integer-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-non-negative-integer-visitor.cc
new file mode 100644
index 0000000..319eefa
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-non-negative-integer-visitor.cc
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "ccnb-parser-non-negative-integer-visitor.h"
+
+#include "ns3/ccnb-parser-blob.h"
+#include "ns3/ccnb-parser-udata.h"
+#include <sstream>
+
+namespace ns3 {
+namespace CcnbParser {
+
+boost::any
+NonNegativeIntegerVisitor::visit (Blob &n) //to throw parsing error
+{
+ // Buffer n.m_blob;
+ throw CcnxDecodingException ();
+}
+
+boost::any
+NonNegativeIntegerVisitor::visit (Udata &n)
+{
+ // std::string n.m_udata;
+ std::istringstream is (n.m_udata);
+ int32_t value;
+ is >> value;
+ if (value<0) // value should be non-negative
+ throw CcnxDecodingException ();
+
+ return static_cast<uint32_t> (value);
+}
+
+}
+}
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-non-negative-integer-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-non-negative-integer-visitor.h
new file mode 100644
index 0000000..7ecc3a9
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-non-negative-integer-visitor.h
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_NON_NEGATIVE_INTEGER_VISITOR_H_
+#define _CCNB_PARSER_NON_NEGATIVE_INTEGER_VISITOR_H_
+
+#include "ccnb-parser-no-argu-depth-first-visitor.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Visitor to obtain non-negative integer value from UDATA block
+ *
+ * Will return empty boost::any() if called on anything except UDATA block
+ */
+class NonNegativeIntegerVisitor : public NoArguDepthFirstVisitor
+{
+public:
+ virtual boost::any visit (Blob &n); ///< Throws an exception if BLOB object is encountered
+ virtual boost::any visit (Udata &n);
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_NON_NEGATIVE_INTEGER_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-string-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-string-visitor.cc
new file mode 100644
index 0000000..078b326
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-string-visitor.cc
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "ccnb-parser-string-visitor.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+boost::any
+StringVisitor::visit (Blob &n)
+{
+ // Buffer n.m_blob;
+ throw CcnxDecodingException ();
+}
+
+boost::any
+StringVisitor::visit (Udata &n)
+{
+ // std::string n.m_udata;
+ return n.m_udata;
+}
+
+}
+}
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-string-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-string-visitor.h
new file mode 100644
index 0000000..b2a2a29
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-string-visitor.h
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_STRING_VISITOR_H_
+#define _CCNB_PARSER_STRING_VISITOR_H_
+
+#include "ccnb-parser-no-argu-depth-first-visitor.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Visitor to obtain string value from UDATA block
+ *
+ * Will return empty boost::any() if called on anything except UDATA block
+ */
+class StringVisitor : public NoArguDepthFirstVisitor
+{
+public:
+ virtual boost::any visit (Blob &n); ///< Throws parsing error if BLOB object is encountered
+ virtual boost::any visit (Udata &n);
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_STRING_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-visitor.h
new file mode 100644
index 0000000..d098c3e
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-visitor.h
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_VISITOR_H_
+#define _CCNB_PARSER_VISITOR_H_
+
+#include "ccnb-parser-commoh.h"
+#include <boost/any.hpp>
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Visitor interface that takes one boost::any argument and returns boost::any
+ *
+ * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+ * for ccnb encoding format help
+ */
+class Visitor
+{
+public:
+ virtual boost::any visit (Blob&, boost::any)=0; ///< \brief Method accepting BLOB block
+ virtual boost::any visit (Udata&, boost::any)=0; ///< \brief Method accepting UDATA block
+ virtual boost::any visit (Tag&, boost::any)=0; ///< \brief Method accepting TAG block
+ virtual boost::any visit (Attr&, boost::any)=0; ///< \brief Method accepting ATTR block
+ virtual boost::any visit (Dtag&, boost::any)=0; ///< \brief Method accepting DTAG block
+ virtual boost::any visit (Dattr&, boost::any)=0; ///< \brief Method accepting DATTR block
+ virtual boost::any visit (Ext&, boost::any)=0; ///< \brief Method accepting EXT block
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-void-depth-first-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-void-depth-first-visitor.cc
new file mode 100644
index 0000000..c2b8401
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-void-depth-first-visitor.cc
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "ccnb-parser-void-depth-first-visitor.h"
+
+#include "ns3/ccnb-parser-blob.h"
+#include "ns3/ccnb-parser-udata.h"
+#include "ns3/ccnb-parser-tag.h"
+#include "ns3/ccnb-parser-dtag.h"
+#include "ns3/ccnb-parser-attr.h"
+#include "ns3/ccnb-parser-dattr.h"
+#include "ns3/ccnb-parser-ext.h"
+
+#include <boost/foreach.hpp>
+
+namespace ns3 {
+namespace CcnbParser {
+
+void
+VoidDepthFirstVisitor::visit (Blob &n, boost::any param)
+{
+ // Buffer n.m_blob;
+}
+
+void
+VoidDepthFirstVisitor::visit (Udata &n, boost::any param)
+{
+ // std::string n.m_udata;
+}
+
+void
+VoidDepthFirstVisitor::visit (Tag &n, boost::any param)
+{
+ // std::string n.m_tag;
+ // std::list<Ptr<Block> > n.m_attrs;
+ // std::list<Ptr<Block> > n.m_nestedBlocks;
+ BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
+ {
+ block->accept (*this, param);
+ }
+ BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
+ {
+ block->accept (*this, param);
+ }
+}
+
+void
+VoidDepthFirstVisitor::visit (Dtag &n, boost::any param)
+{
+ // std::string n.m_tag;
+ // std::list<Ptr<Block> > n.m_attrs;
+ // std::list<Ptr<Block> > n.m_nestedBlocks;
+ BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
+ {
+ block->accept (*this, param);
+ }
+ BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
+ {
+ block->accept (*this, param);
+ }
+}
+
+void
+VoidDepthFirstVisitor::visit (Attr &n, boost::any param)
+{
+ // std::string n.m_attr;
+ // Ptr<Udata> n.m_value;
+}
+
+void
+VoidDepthFirstVisitor::visit (Dattr &n, boost::any param)
+{
+ // uint32_t n.m_dattr;
+ // Ptr<Udata> n.m_value;
+}
+
+void
+VoidDepthFirstVisitor::visit (Ext &n, boost::any param)
+{
+ // uint64_t n.m_extSubtype;
+}
+
+}
+}
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-void-depth-first-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-void-depth-first-visitor.h
new file mode 100644
index 0000000..f2b78e3
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-void-depth-first-visitor.h
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_VOID_DEPTH_FIRST_VISITOR_H_
+#define _CCNB_PARSER_VOID_DEPTH_FIRST_VISITOR_H_
+
+#include "ccnb-parser-void-visitor.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingrou ccnx-ccnb
+ * \brief Depth-first visitor that takes one argument and returns nothing
+ */
+class VoidDepthFirstVisitor : public VoidVisitor
+{
+public:
+ virtual void visit (Blob&, boost::any);
+ virtual void visit (Udata&, boost::any);
+ virtual void visit (Tag&, boost::any);
+ virtual void visit (Attr&, boost::any);
+ virtual void visit (Dtag&, boost::any);
+ virtual void visit (Dattr&, boost::any);
+ virtual void visit (Ext&, boost::any);
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_VOID_DEPTH_FIRST_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-void-no-argu-depth-first-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-void-no-argu-depth-first-visitor.cc
new file mode 100644
index 0000000..7f8e6de
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-void-no-argu-depth-first-visitor.cc
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "ccnb-parser-void-no-argu-depth-first-visitor.h"
+
+#include "ns3/ccnb-parser-blob.h"
+#include "ns3/ccnb-parser-udata.h"
+#include "ns3/ccnb-parser-tag.h"
+#include "ns3/ccnb-parser-dtag.h"
+#include "ns3/ccnb-parser-attr.h"
+#include "ns3/ccnb-parser-dattr.h"
+#include "ns3/ccnb-parser-ext.h"
+
+#include <boost/foreach.hpp>
+
+namespace ns3 {
+namespace CcnbParser {
+
+void
+VoidNoArguDepthFirstVisitor::visit (Blob &n)
+{
+ // Buffer n.m_blob;
+}
+
+void
+VoidNoArguDepthFirstVisitor::visit (Udata &n)
+{
+ // std::string n.m_udata;
+}
+
+void
+VoidNoArguDepthFirstVisitor::visit (Tag &n)
+{
+ // std::string n.m_tag;
+ // std::list<Ptr<Block> > n.m_attrs;
+ // std::list<Ptr<Block> > n.m_nestedBlocks;
+ BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
+ {
+ block->accept (*this);
+ }
+ BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
+ {
+ block->accept (*this);
+ }
+}
+
+void
+VoidNoArguDepthFirstVisitor::visit (Dtag &n)
+{
+ // uint32_t n.m_dtag;
+ // std::list<Ptr<Block> > n.m_attrs;
+ // std::list<Ptr<Block> > n.m_nestedBlocks;
+ BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
+ {
+ block->accept (*this);
+ }
+ BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
+ {
+ block->accept (*this);
+ }
+}
+
+void
+VoidNoArguDepthFirstVisitor::visit (Attr &n)
+{
+ // std::string n.m_attr;
+ // Ptr<Udata> n.m_value;
+}
+
+void
+VoidNoArguDepthFirstVisitor::visit (Dattr &n)
+{
+ // uint32_t n.m_dattr;
+ // Ptr<Udata> n.m_value;
+}
+
+void
+VoidNoArguDepthFirstVisitor::visit (Ext &n)
+{
+ // uint64_t n.m_extSubtype;
+}
+
+}
+}
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-void-no-argu-depth-first-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-void-no-argu-depth-first-visitor.h
new file mode 100644
index 0000000..9237c2c
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-void-no-argu-depth-first-visitor.h
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_VOID_NO_ARGU_DEPTH_FIRST_VISITOR_H_
+#define _CCNB_PARSER_VOID_NO_ARGU_DEPTH_FIRST_VISITOR_H_
+
+#include "ccnb-parser-void-no-argu-visitor.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingrou ccnx-ccnb
+ * \brief Depth-first visitor that takes no arguments and returns nothing
+ */
+class VoidNoArguDepthFirstVisitor : public VoidNoArguVisitor
+{
+public:
+ virtual void visit (Blob& );
+ virtual void visit (Udata&);
+ virtual void visit (Tag& );
+ virtual void visit (Attr& );
+ virtual void visit (Dtag& );
+ virtual void visit (Dattr&);
+ virtual void visit (Ext& );
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_VOID_NO_ARGU_DEPTH_FIRST_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-void-no-argu-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-void-no-argu-visitor.h
new file mode 100644
index 0000000..ef45c98
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-void-no-argu-visitor.h
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_VOID_NO_ARGU_VISITOR_H_
+#define _CCNB_PARSER_VOID_NO_ARGU_VISITOR_H_
+
+#include "ccnb-parser-commoh.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Visitor interface that takes no arguments and returns nothing
+ *
+ * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+ * for ccnb encoding format help
+ */
+class VoidNoArguVisitor
+{
+public:
+ virtual void visit (Blob& )=0; ///< \brief Method accepting BLOB block
+ virtual void visit (Udata&)=0; ///< \brief Method accepting UDATA block
+ virtual void visit (Tag& )=0; ///< \brief Method accepting TAG block
+ virtual void visit (Attr& )=0; ///< \brief Method accepting ATTR block
+ virtual void visit (Dtag& )=0; ///< \brief Method accepting DTAG block
+ virtual void visit (Dattr&)=0; ///< \brief Method accepting DATTR block
+ virtual void visit (Ext& )=0; ///< \brief Method accepting EXT block
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_VOID_NO_ARGU_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-void-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-void-visitor.h
new file mode 100644
index 0000000..7f412c2
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-void-visitor.h
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_VOID_VISITOR_H_
+#define _CCNB_PARSER_VOID_VISITOR_H_
+
+#include "ccnb-parser-commoh.h"
+#include <boost/any.hpp>
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Visitor interface that takes one boost::any argument and returns nothing
+ *
+ * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+ * for ccnb encoding format help
+ */
+class VoidVisitor
+{
+public:
+ virtual void visit (Blob&, boost::any)=0; ///< \brief Method accepting BLOB block
+ virtual void visit (Udata&, boost::any)=0; ///< \brief Method accepting UDATA block
+ virtual void visit (Tag&, boost::any)=0; ///< \brief Method accepting TAG block
+ virtual void visit (Attr&, boost::any)=0; ///< \brief Method accepting ATTR block
+ virtual void visit (Dtag&, boost::any)=0; ///< \brief Method accepting DTAG block
+ virtual void visit (Dattr&, boost::any)=0; ///< \brief Method accepting DATTR block
+ virtual void visit (Ext&, boost::any)=0; ///< \brief Method accepting EXT block
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_VOID_VISITOR_H_