IOSS 2.0

Iohb_Layout.h
Go to the documentation of this file.
1 // Copyright(C) 1999-2017 National Technology & Engineering Solutions
2 // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 // NTESS, the U.S. Government retains certain rights in this software.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // * Redistributions in binary form must reproduce the above
13 // copyright notice, this list of conditions and the following
14 // disclaimer in the documentation and/or other materials provided
15 // with the distribution.
16 //
17 // * Neither the name of NTESS nor the names of its
18 // contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 #ifndef IOSS_Iohb_Layout_h
34 #define IOSS_Iohb_Layout_h
35
36 #include <iostream>
37 #include <sstream>
38 #include <string>
39 #include <vector>
40
41 namespace Iohb {
42 class Layout
43 {
44 public:
45 Layout(bool show_labels, int precision, std::string separator, int field_width);
46 Layout(const Layout &) = delete;
47 Layout &operator=(const Layout &) = delete;
48
49 ~Layout();
50
51 friend std::ostream &operator<<(std::ostream & /*o*/, Layout & /*lo*/);
52
53 void add_literal(const std::string &label);
54 void add_legend(const std::string &label);
55 void add(const std::string &name, double value);
56 void add(const std::string &name, int value);
57 void add(const std::string &name, long value);
58 void add(const std::string &name, const std::string &value);
59
60 void add(const std::string &name, std::vector<double> &value);
61 void add(const std::string &name, std::vector<int> &value);
62 void add(const std::string &name, std::vector<long> &value);
63 void add(const std::string &name, std::vector<std::string> &value);
64
65 private:
66 std::ostringstream layout_;
67 std::string separator_;
68
69 int precision_;
70 int count_; // Number of fields on current line...
71 int fieldWidth_;
72 bool showLabels;
73 bool legendStarted;
74 };
75 } // namespace Iohb
76
77 #endif // IOSS_Iohb_Layout_h
Iohb::Layout::precision_
int precision_
Definition: Iohb_Layout.h:69
Iohb::Layout::operator<<
friend std::ostream & operator<<(std::ostream &, Layout &)
Definition: Iohb_Layout.C:47
Iohb::Layout::count_
int count_
Definition: Iohb_Layout.h:70
Iohb::Layout::separator_
std::string separator_
Definition: Iohb_Layout.h:67
Iohb::Layout::fieldWidth_
int fieldWidth_
Definition: Iohb_Layout.h:71
Iohb::Layout::add_legend
void add_legend(const std::string &label)
Definition: Iohb_Layout.C:55
Iohb::Layout::operator=
Layout & operator=(const Layout &)=delete
anonymous_namespace{io_info.C}::name
std::string name(Ioss::GroupingEntity *entity)
Definition: io_info.C:88
Iohb
A namespace for the heartbeat database format.
Definition: Iohb_DatabaseIO.C:146
Iohb::Layout::add
void add(const std::string &name, double value)
Definition: Iohb_Layout.C:72
Iohb::Layout::~Layout
~Layout()
Iohb::Layout::layout_
std::ostringstream layout_
Definition: Iohb_Layout.h:66
Iohb::Layout::Layout
Layout(bool show_labels, int precision, std::string separator, int field_width)
Definition: Iohb_Layout.C:39
Iohb::Layout::add_literal
void add_literal(const std::string &label)
Definition: Iohb_Layout.C:53
Iohb::Layout::legendStarted
bool legendStarted
Definition: Iohb_Layout.h:73
Iohb::Layout::showLabels
bool showLabels
Definition: Iohb_Layout.h:72
Iohb::Layout
Definition: Iohb_Layout.h:42