blob: 305fff6161046db7a7cd15a6c6e3d9f4e1534705 [file] [log] [blame]
Alexander Afanasyev8b379052011-08-21 16:58:20 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2011 University of California, Los Angeles
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 */
20
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070021#include "depth-first-visitor.h"
Alexander Afanasyev8b379052011-08-21 16:58:20 -070022
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070023#include "../syntax-tree/blob.h"
24#include "../syntax-tree/udata.h"
25#include "../syntax-tree/tag.h"
26#include "../syntax-tree/dtag.h"
27#include "../syntax-tree/attr.h"
28#include "../syntax-tree/dattr.h"
29#include "../syntax-tree/ext.h"
Alexander Afanasyev8b379052011-08-21 16:58:20 -070030
31#include <boost/foreach.hpp>
32
33namespace ns3 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070034namespace ndn {
Alexander Afanasyev8b379052011-08-21 16:58:20 -070035namespace CcnbParser {
36
37boost::any
Alexander Afanasyeve709f3d2011-08-21 17:55:45 -070038DepthFirstVisitor::visit (Blob &n, boost::any param)
Alexander Afanasyev8b379052011-08-21 16:58:20 -070039{
40 // Buffer n.m_blob;
41 return n.m_blob;
42}
43
44boost::any
Alexander Afanasyeve709f3d2011-08-21 17:55:45 -070045DepthFirstVisitor::visit (Udata &n, boost::any param)
Alexander Afanasyev8b379052011-08-21 16:58:20 -070046{
47 // std::string n.m_udata;
48 return n.m_udata;
49}
50
51boost::any
Alexander Afanasyeve709f3d2011-08-21 17:55:45 -070052DepthFirstVisitor::visit (Tag &n, boost::any param)
Alexander Afanasyev8b379052011-08-21 16:58:20 -070053{
54 // std::string n.m_tag;
55 // std::list<Ptr<Block> > n.m_attrs;
56 // std::list<Ptr<Block> > n.m_nestedBlocks;
57 BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
58 {
59 block->accept (*this, param);
60 }
Alexander Afanasyeve709f3d2011-08-21 17:55:45 -070061 BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
Alexander Afanasyev8b379052011-08-21 16:58:20 -070062 {
63 block->accept (*this, param);
64 }
65 return boost::any();
66}
67
68boost::any
Alexander Afanasyeve709f3d2011-08-21 17:55:45 -070069DepthFirstVisitor::visit (Dtag &n, boost::any param)
Alexander Afanasyev8b379052011-08-21 16:58:20 -070070{
71 // std::string n.m_tag;
72 // std::list<Ptr<Block> > n.m_attrs;
73 // std::list<Ptr<Block> > n.m_nestedBlocks;
74 BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
75 {
76 block->accept (*this, param);
77 }
Alexander Afanasyeve709f3d2011-08-21 17:55:45 -070078 BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
Alexander Afanasyev8b379052011-08-21 16:58:20 -070079 {
80 block->accept (*this, param);
81 }
82 return boost::any ();
83}
84
85boost::any
Alexander Afanasyeve709f3d2011-08-21 17:55:45 -070086DepthFirstVisitor::visit (Attr &n, boost::any param)
Alexander Afanasyev8b379052011-08-21 16:58:20 -070087{
88 // std::string n.m_attr;
89 // Ptr<Udata> n.m_value;
90 return boost::any ();
91}
92
93boost::any
Alexander Afanasyeve709f3d2011-08-21 17:55:45 -070094DepthFirstVisitor::visit (Dattr &n, boost::any param)
Alexander Afanasyev8b379052011-08-21 16:58:20 -070095{
96 // uint32_t n.m_dattr;
97 // Ptr<Udata> n.m_value;
98 return boost::any ();
99}
100
101boost::any
Alexander Afanasyeve709f3d2011-08-21 17:55:45 -0700102DepthFirstVisitor::visit (Ext &n, boost::any param)
Alexander Afanasyev8b379052011-08-21 16:58:20 -0700103{
104 // uint64_t n.m_extSubtype;
105 return n.m_extSubtype;
106}
107
108}
109}
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700110}