foamVtkBase64Layer.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) 2017 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::vtk::foamVtkBase64Layer
28 
29 Description
30  Base-64 encoded output layer - normally only used indirectly by formatters.
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #ifndef Foam_vtk_base64Layer_H
35 #define Foam_vtk_base64Layer_H
36 
37 #include "foamVtkFormatter.H"
38 #include "base64Layer.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 namespace vtk
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class vtk::foamVtkBase64Layer Declaration
49 \*---------------------------------------------------------------------------*/
50 
52 :
53  public formatter,
54  protected base64Layer
55 {
56  // Private Data Members
57 
58  static const char* encoding_;
59 
60 
61  // Private Member Functions
62 
63  //- No copy construct
64  foamVtkBase64Layer(const foamVtkBase64Layer&) = delete;
65 
66  //- No copy assignment
67  void operator=(const foamVtkBase64Layer&) = delete;
68 
69 
70 protected:
71 
72  // Protected Member Functions
73 
74  //- Write
75  void write(const char* s, std::streamsize n);
76 
77 
78  // Constructors
79 
80  //- Construct and attach to an output stream
81  foamVtkBase64Layer(std::ostream& os);
82 
83 public:
84 
85  //- Destructor. Closes/flushes the underlying layer
86  virtual ~foamVtkBase64Layer();
87 
88 
89  // Member Functions
90 
91  //- Name for the XML append encoding ("base64").
92  virtual const char* encoding() const;
93 
94  //- Write leading size for binary output
95  // \return True - format uses this information
96  virtual bool writeSize(const uint64_t numbytes);
97 
98  virtual void write(const uint8_t val);
99  virtual void write(const label val);
100  virtual void write(const float val);
101  virtual void write(const double val);
102 
103  //- End the encoding sequence (padding the final characters with '=')
104  virtual void flush();
105 
106  //- The encoded length for base64 encoded output.
107  virtual std::size_t encodedLength(std::size_t n) const;
108 
109 };
110 
111 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112 
113 } // End namespace vtk
114 } // End namespace Foam
115 
116 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
117 
118 #endif
119 
120 // ************************************************************************* //
Foam::vtk::foamVtkBase64Layer
Base-64 encoded output layer - normally only used indirectly by formatters.
Definition: foamVtkBase64Layer.H:50
base64Layer.H
s
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputSpray.H:25
foamVtkFormatter.H
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::vtk::formatter::os
std::ostream & os()
Access to the underlying output stream.
Definition: foamVtkFormatterI.H:70
Foam::vtk::foamVtkBase64Layer::~foamVtkBase64Layer
virtual ~foamVtkBase64Layer()
Destructor. Closes/flushes the underlying layer.
Definition: foamVtkBase64Layer.C:59
Foam::vtk::foamVtkBase64Layer::flush
virtual void flush()
End the encoding sequence (padding the final characters with '=')
Definition: foamVtkBase64Layer.C:121
Foam::vtk::foamVtkBase64Layer::writeSize
virtual bool writeSize(const uint64_t numbytes)
Write leading size for binary output.
Definition: foamVtkBase64Layer.C:73
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::vtk::foamVtkBase64Layer::encoding
virtual const char * encoding() const
Name for the XML append encoding ("base64").
Definition: foamVtkBase64Layer.C:67
Foam::base64Layer
An output filter layer to write base-64 encoded content.
Definition: base64Layer.H:55
Foam::vtk::foamVtkBase64Layer::write
void write(const char *s, std::streamsize n)
Write.
Definition: foamVtkBase64Layer.C:39
Foam::vtk::foamVtkBase64Layer::encodedLength
virtual std::size_t encodedLength(std::size_t n) const
The encoded length for base64 encoded output.
Definition: foamVtkBase64Layer.C:127
Foam::vtk::formatter
Abstract class for a VTK output stream formatter.
Definition: foamVtkFormatter.H:68