foamVtkAsciiFormatter.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2016-2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::vtk::asciiFormatter
28
29Description
30 Inline ASCII output.
31 Adds spaces between entries and a newline every 9 items
32 (for consistency with what VTK itself outputs).
33
34SourceFiles
35 foamVtkAsciiFormatter.C
36
37\*---------------------------------------------------------------------------*/
38
39#ifndef Foam_vtk_asciiFormatter_H
40#define Foam_vtk_asciiFormatter_H
41
42#include "foamVtkFormatter.H"
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
48namespace vtk
49{
50
51/*---------------------------------------------------------------------------*\
52 Class vtk::asciiFormatter Declaration
53\*---------------------------------------------------------------------------*/
56:
57 public vtk::formatter
58{
59 // Private Data Members
60
61 static const char* name_;
62 static const outputOptions opts_;
63
64 //- Number of items per line
65 static constexpr unsigned short itemsPerLine_ = 9;
66
67 //- Track the current output position
68 unsigned short pos_;
69
70
71 // Private Member Functions
72
73 //- Advance to next position, adding space or newline as needed
74 inline void next();
75
76 //- Finish an output line, adding newline as needed
77 inline void done();
78
79
80 //- No copy construct
81 asciiFormatter(const asciiFormatter&) = delete;
82
83 //- No copy assignment
84 void operator=(const asciiFormatter&) = delete;
85
86
87public:
88
89 // Constructors
90
91 //- Construct and attach to an output stream, use default precision
92 explicit asciiFormatter(std::ostream& os);
93
94 //- Construct and attach to an output stream, use specified precision
95 asciiFormatter(std::ostream& os, unsigned prec);
96
97
98 //- Destructor. Finishes the output line as required.
99 virtual ~asciiFormatter();
100
101
102 // Member Functions
103
104 //- The output is INLINE_ASCII.
105 virtual const vtk::outputOptions& opts() const;
106
107 //- Name for the XML output type ("ascii")
108 virtual const char* name() const;
109
110 //- Name for the XML append encoding - unused.
111 // Currently identical to name(), but do not rely on this.
112 virtual const char* encoding() const;
113
114
115 //- Write leading size - this is a no-op for ascii output
116 // \return False - never used by this format
117 virtual bool writeSize(const uint64_t ignored);
118
119 virtual void write(const uint8_t val);
120 virtual void write(const label val);
121 virtual void write(const float val);
122 virtual void write(const double val);
123
124 //- Write a newline if needed to finish a line of output.
125 virtual void flush();
126
127 //- The encoded length for ascii output is not applicable.
128 // \return 0
129 virtual std::size_t encodedLength(std::size_t ignored) const;
130};
131
132
133// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134
135} // End namespace vtk
136} // End namespace Foam
137
138// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139
140#endif
141
142// ************************************************************************* //
Inline ASCII output. Adds spaces between entries and a newline every 9 items (for consistency with wh...
virtual ~asciiFormatter()
Destructor. Finishes the output line as required.
virtual const vtk::outputOptions & opts() const
The output is INLINE_ASCII.
virtual const char * name() const
Name for the XML output type ("ascii")
virtual bool writeSize(const uint64_t ignored)
Write leading size - this is a no-op for ascii output.
virtual std::size_t encodedLength(std::size_t ignored) const
The encoded length for ascii output is not applicable.
virtual void flush()
Write a newline if needed to finish a line of output.
virtual const char * encoding() const
Name for the XML append encoding - unused.
Abstract class for a VTK output stream formatter.
std::ostream & os() noexcept
Access to the underlying output stream.
Encapsulated combinations of output format options. This is primarily useful when defining the output...
Namespace for OpenFOAM.
runTime write()