blob: 0e4232de916f8f350cbadec2c21b0556896f154e [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 Pesavento5748e822024-01-26 18:40:22 -05003 * Copyright (c) 2014-2024, 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 Pesavento5748e822024-01-26 18:40:22 -050027#include <vector>
28
Davide Pesaventob3570c62022-02-19 19:19:00 -050029namespace ndn::dissect {
Junxiao Shi78c78cc2015-06-19 15:53:53 -070030
Davide Pesaventoa420e972021-02-25 00:56:25 -050031struct Options
32{
33 bool dissectContent = false;
34};
35
36class Dissector : noncopyable
Junxiao Shi78c78cc2015-06-19 15:53:53 -070037{
38public:
Davide Pesaventoa420e972021-02-25 00:56:25 -050039 Dissector(std::istream& input, std::ostream& output, const Options& options);
Davide Pesavento7ef5cf72021-01-29 00:20:24 -050040
Junxiao Shi78c78cc2015-06-19 15:53:53 -070041 void
Davide Pesavento7ef5cf72021-01-29 00:20:24 -050042 dissect();
Junxiao Shi78c78cc2015-06-19 15:53:53 -070043
44private:
45 void
Davide Pesavento7ef5cf72021-01-29 00:20:24 -050046 printBranches();
Junxiao Shi78c78cc2015-06-19 15:53:53 -070047
48 void
Davide Pesavento7ef5cf72021-01-29 00:20:24 -050049 printType(uint32_t type);
50
51 void
52 printBlock(const Block& block);
53
54private:
Davide Pesaventoa420e972021-02-25 00:56:25 -050055 const Options& m_options;
Davide Pesavento7ef5cf72021-01-29 00:20:24 -050056 std::istream& m_in;
57 std::ostream& m_out;
58
59 // m_branches[i] is true iff the i-th level of the tree has more branches after the current one
60 std::vector<bool> m_branches;
Junxiao Shi78c78cc2015-06-19 15:53:53 -070061};
62
Davide Pesaventob3570c62022-02-19 19:19:00 -050063} // namespace ndn::dissect
Davide Pesaventoc0702702017-08-24 22:04:00 -040064
Davide Pesaventoa420e972021-02-25 00:56:25 -050065#endif // NDN_TOOLS_DISSECT_DISSECTOR_HPP