Junxiao Shi | 78c78cc | 2015-06-19 15:53:53 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | 7ef5cf7 | 2021-01-29 00:20:24 -0500 | [diff] [blame] | 2 | /* |
Davide Pesavento | b3570c6 | 2022-02-19 19:19:00 -0500 | [diff] [blame^] | 3 | * Copyright (c) 2014-2022, Regents of the University of California. |
Junxiao Shi | 78c78cc | 2015-06-19 15:53:53 -0700 | [diff] [blame] | 4 | * |
| 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 Pesavento | a420e97 | 2021-02-25 00:56:25 -0500 | [diff] [blame] | 20 | #ifndef NDN_TOOLS_DISSECT_DISSECTOR_HPP |
| 21 | #define NDN_TOOLS_DISSECT_DISSECTOR_HPP |
Davide Pesavento | c070270 | 2017-08-24 22:04:00 -0400 | [diff] [blame] | 22 | |
| 23 | #include "core/common.hpp" |
| 24 | |
Junxiao Shi | 78c78cc | 2015-06-19 15:53:53 -0700 | [diff] [blame] | 25 | #include <ndn-cxx/encoding/block.hpp> |
Junxiao Shi | 78c78cc | 2015-06-19 15:53:53 -0700 | [diff] [blame] | 26 | |
Davide Pesavento | b3570c6 | 2022-02-19 19:19:00 -0500 | [diff] [blame^] | 27 | namespace ndn::dissect { |
Junxiao Shi | 78c78cc | 2015-06-19 15:53:53 -0700 | [diff] [blame] | 28 | |
Davide Pesavento | a420e97 | 2021-02-25 00:56:25 -0500 | [diff] [blame] | 29 | struct Options |
| 30 | { |
| 31 | bool dissectContent = false; |
| 32 | }; |
| 33 | |
| 34 | class Dissector : noncopyable |
Junxiao Shi | 78c78cc | 2015-06-19 15:53:53 -0700 | [diff] [blame] | 35 | { |
| 36 | public: |
Davide Pesavento | a420e97 | 2021-02-25 00:56:25 -0500 | [diff] [blame] | 37 | Dissector(std::istream& input, std::ostream& output, const Options& options); |
Davide Pesavento | 7ef5cf7 | 2021-01-29 00:20:24 -0500 | [diff] [blame] | 38 | |
Junxiao Shi | 78c78cc | 2015-06-19 15:53:53 -0700 | [diff] [blame] | 39 | void |
Davide Pesavento | 7ef5cf7 | 2021-01-29 00:20:24 -0500 | [diff] [blame] | 40 | dissect(); |
Junxiao Shi | 78c78cc | 2015-06-19 15:53:53 -0700 | [diff] [blame] | 41 | |
| 42 | private: |
| 43 | void |
Davide Pesavento | 7ef5cf7 | 2021-01-29 00:20:24 -0500 | [diff] [blame] | 44 | printBranches(); |
Junxiao Shi | 78c78cc | 2015-06-19 15:53:53 -0700 | [diff] [blame] | 45 | |
| 46 | void |
Davide Pesavento | 7ef5cf7 | 2021-01-29 00:20:24 -0500 | [diff] [blame] | 47 | printType(uint32_t type); |
| 48 | |
| 49 | void |
| 50 | printBlock(const Block& block); |
| 51 | |
| 52 | private: |
Davide Pesavento | a420e97 | 2021-02-25 00:56:25 -0500 | [diff] [blame] | 53 | const Options& m_options; |
Davide Pesavento | 7ef5cf7 | 2021-01-29 00:20:24 -0500 | [diff] [blame] | 54 | 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 Shi | 78c78cc | 2015-06-19 15:53:53 -0700 | [diff] [blame] | 59 | }; |
| 60 | |
Davide Pesavento | b3570c6 | 2022-02-19 19:19:00 -0500 | [diff] [blame^] | 61 | } // namespace ndn::dissect |
Davide Pesavento | c070270 | 2017-08-24 22:04:00 -0400 | [diff] [blame] | 62 | |
Davide Pesavento | a420e97 | 2021-02-25 00:56:25 -0500 | [diff] [blame] | 63 | #endif // NDN_TOOLS_DISSECT_DISSECTOR_HPP |