ArmNN
 24.02
JsonUtils.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include <iomanip>
9 
10 #include "armnn/Types.hpp"
12 
13 namespace armnn
14 {
15 
16 class JsonUtils
17 {
18 public:
19  JsonUtils(std::ostream& outputStream)
20  : m_NumTabs(0), m_OutputStream(outputStream)
21  {}
22 
23  void PrintTabs()
24  {
25  unsigned int numTabs = m_NumTabs;
26  while ( numTabs-- > 0 )
27  {
28  m_OutputStream << "\t";
29  }
30  }
31 
33  {
34  if ( m_NumTabs == 0 )
35  {
36  return;
37  }
38  --m_NumTabs;
39  }
40 
42  {
43  ++m_NumTabs;
44  }
45 
46  void PrintNewLine()
47  {
48  m_OutputStream << std::endl;
49  }
50 
51  void PrintFooter()
52  {
54  PrintTabs();
55  m_OutputStream << "}";
56  }
57 
58  void PrintHeader()
59  {
60  m_OutputStream << "{" << std::endl;
62  }
63 
65  {
66  PrintTabs();
67  m_OutputStream << R"("ArmNN": {)" << std::endl;
69  }
71  {
72  m_OutputStream << ",";
73  }
74 
75 private:
76  unsigned int m_NumTabs;
77  std::ostream& m_OutputStream;
78 };
79 
80 } // namespace armnn
armnn::JsonUtils::PrintNewLine
void PrintNewLine()
Definition: JsonUtils.hpp:46
armnn::JsonUtils::IncrementNumberOfTabs
void IncrementNumberOfTabs()
Definition: JsonUtils.hpp:41
armnn::JsonUtils::PrintArmNNHeader
void PrintArmNNHeader()
Definition: JsonUtils.hpp:64
armnn::JsonUtils::DecrementNumberOfTabs
void DecrementNumberOfTabs()
Definition: JsonUtils.hpp:32
armnn::JsonUtils
Definition: JsonUtils.hpp:16
armnn::JsonUtils::PrintHeader
void PrintHeader()
Definition: JsonUtils.hpp:58
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
Types.hpp
armnn::JsonUtils::PrintFooter
void PrintFooter()
Definition: JsonUtils.hpp:51
armnn::JsonUtils::PrintSeparator
void PrintSeparator()
Definition: JsonUtils.hpp:70
armnn::JsonUtils::JsonUtils
JsonUtils(std::ostream &outputStream)
Definition: JsonUtils.hpp:19
WorkloadInfo.hpp
armnn::JsonUtils::PrintTabs
void PrintTabs()
Definition: JsonUtils.hpp:23