blob: 6ab7087cc6ac23ae4f5aac7e3b0ec3a86503f4ff [file] [log] [blame]
Junxiao Shi78c78cc2015-06-19 15:53:53 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento7ef5cf72021-01-29 00:20:24 -05002/*
Davide Pesaventob3570c62022-02-19 19:19:00 -05003 * Copyright (c) 2014-2022, Regents of the University of California.
Junxiao Shi78c78cc2015-06-19 15:53:53 -07004 *
5 * This file is part of ndn-tools (Named Data Networking Essential Tools).
6 * See AUTHORS.md for complete list of ndn-tools authors and contributors.
7 *
8 * ndn-tools is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 */
19
Davide Pesaventoa420e972021-02-25 00:56:25 -050020#ifndef NDN_TOOLS_DISSECT_DISSECTOR_HPP
21#define NDN_TOOLS_DISSECT_DISSECTOR_HPP
Davide Pesaventoc0702702017-08-24 22:04:00 -040022
23#include "core/common.hpp"
24
Junxiao Shi78c78cc2015-06-19 15:53:53 -070025#include <ndn-cxx/encoding/block.hpp>
Junxiao Shi78c78cc2015-06-19 15:53:53 -070026
Davide Pesaventob3570c62022-02-19 19:19:00 -050027namespace ndn::dissect {
Junxiao Shi78c78cc2015-06-19 15:53:53 -070028
Davide Pesaventoa420e972021-02-25 00:56:25 -050029struct Options
30{
31 bool dissectContent = false;
32};
33
34class Dissector : noncopyable
Junxiao Shi78c78cc2015-06-19 15:53:53 -070035{
36public:
Davide Pesaventoa420e972021-02-25 00:56:25 -050037 Dissector(std::istream& input, std::ostream& output, const Options& options);
Davide Pesavento7ef5cf72021-01-29 00:20:24 -050038
Junxiao Shi78c78cc2015-06-19 15:53:53 -070039 void
Davide Pesavento7ef5cf72021-01-29 00:20:24 -050040 dissect();
Junxiao Shi78c78cc2015-06-19 15:53:53 -070041
42private:
43 void
Davide Pesavento7ef5cf72021-01-29 00:20:24 -050044 printBranches();
Junxiao Shi78c78cc2015-06-19 15:53:53 -070045
46 void
Davide Pesavento7ef5cf72021-01-29 00:20:24 -050047 printType(uint32_t type);
48
49 void
50 printBlock(const Block& block);
51
52private:
Davide Pesaventoa420e972021-02-25 00:56:25 -050053 const Options& m_options;
Davide Pesavento7ef5cf72021-01-29 00:20:24 -050054 std::istream& m_in;
55 std::ostream& m_out;
56
57 // m_branches[i] is true iff the i-th level of the tree has more branches after the current one
58 std::vector<bool> m_branches;
Junxiao Shi78c78cc2015-06-19 15:53:53 -070059};
60
Davide Pesaventob3570c62022-02-19 19:19:00 -050061} // namespace ndn::dissect
Davide Pesaventoc0702702017-08-24 22:04:00 -040062
Davide Pesaventoa420e972021-02-25 00:56:25 -050063#endif // NDN_TOOLS_DISSECT_DISSECTOR_HPP