blob: e408efe4a3279602a0094b1be0735b747edcc9cd [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/*
3 * Copyright (c) 2014-2021, 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
27namespace ndn {
28namespace dissect {
29
Davide Pesaventoa420e972021-02-25 00:56:25 -050030struct Options
31{
32 bool dissectContent = false;
33};
34
35class Dissector : noncopyable
Junxiao Shi78c78cc2015-06-19 15:53:53 -070036{
37public:
Davide Pesaventoa420e972021-02-25 00:56:25 -050038 Dissector(std::istream& input, std::ostream& output, const Options& options);
Davide Pesavento7ef5cf72021-01-29 00:20:24 -050039
Junxiao Shi78c78cc2015-06-19 15:53:53 -070040 void
Davide Pesavento7ef5cf72021-01-29 00:20:24 -050041 dissect();
Junxiao Shi78c78cc2015-06-19 15:53:53 -070042
43private:
44 void
Davide Pesavento7ef5cf72021-01-29 00:20:24 -050045 printBranches();
Junxiao Shi78c78cc2015-06-19 15:53:53 -070046
47 void
Davide Pesavento7ef5cf72021-01-29 00:20:24 -050048 printType(uint32_t type);
49
50 void
51 printBlock(const Block& block);
52
53private:
Davide Pesaventoa420e972021-02-25 00:56:25 -050054 const Options& m_options;
Davide Pesavento7ef5cf72021-01-29 00:20:24 -050055 std::istream& m_in;
56 std::ostream& m_out;
57
58 // m_branches[i] is true iff the i-th level of the tree has more branches after the current one
59 std::vector<bool> m_branches;
Junxiao Shi78c78cc2015-06-19 15:53:53 -070060};
61
62} // namespace dissect
63} // namespace ndn
Davide Pesaventoc0702702017-08-24 22:04:00 -040064
Davide Pesaventoa420e972021-02-25 00:56:25 -050065#endif // NDN_TOOLS_DISSECT_DISSECTOR_HPP