AC3DsurfaceFormatCore.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::fileFormats::AC3DsurfaceFormatCore
29 
30 Description
31  Internal class used by the AC3DsurfaceFormat
32 
33 SourceFiles
34  AC3DsurfaceFormatCore.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef AC3DsurfaceFormatCore_H
39 #define AC3DsurfaceFormatCore_H
40 
41 #include "Fstream.H"
42 #include "surfZone.H"
43 #include "StringStream.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 namespace fileFormats
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class fileFormats::AC3DsurfaceFormatCore Declaration
54 \*---------------------------------------------------------------------------*/
55 
57 {
58 protected:
59 
60  // Protected Static Member Functions
61 
62  //- Read a type from string
63  template<class Type>
64  static Type parse(const string& str)
65  {
66  IStringStream is(str);
67 
68  Type t;
69  is >> t;
70 
71  return t;
72  }
73 
74  //- Read cmd, args from IFstream
75  // The cmd is the content up to the first space, args is the balance
76  // of the line (after the space).
77  // \return if the command was read
78  static bool readCmd(IFstream& is, string& cmd, string& args);
79 
80  //- Read up to a line starting with cmd. Sets args to rest of line.
81  //
82  // \return true if found, false if stream is not good anymore.
83  static bool cueTo(IFstream&, const string& cmd, string& args);
84 
85  //- Like cueTo(), but FatalError if not found.
86  // \return the command args on success
87  static string cueToOrDie
88  (
89  IFstream&,
90  const string& cmd,
91  const string& errorMsg=string::null
92  );
93 
94  //- Write header with materials for each zone
95  static void writeHeader(Ostream& os, const UList<surfZone>& zones);
96 };
97 
98 
99 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
100 
101 } // End namespace fileFormats
102 } // End namespace Foam
103 
104 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
105 
106 #endif
107 
108 // ************************************************************************* //
Foam::IFstream
Input from file stream, using an ISstream.
Definition: IFstream.H:53
StringStream.H
Input/output from string buffers.
surfZone.H
Foam::fileFormats::AC3DsurfaceFormatCore::readCmd
static bool readCmd(IFstream &is, string &cmd, string &args)
Read cmd, args from IFstream.
Definition: AC3DsurfaceFormatCore.C:52
Foam::string::null
static const string null
An empty string.
Definition: string.H:169
os
OBJstream os(runTime.globalPath()/outputName)
Foam::IStringStream
Input from string buffer, using a ISstream. Always UNCOMPRESSED.
Definition: StringStream.H:108
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fileFormats::AC3DsurfaceFormatCore::cueTo
static bool cueTo(IFstream &, const string &cmd, string &args)
Read up to a line starting with cmd. Sets args to rest of line.
Definition: AC3DsurfaceFormatCore.C:79
Foam::fileFormats::AC3DsurfaceFormatCore
Internal class used by the AC3DsurfaceFormat.
Definition: AC3DsurfaceFormatCore.H:55
Fstream.H
Foam::fileFormats::AC3DsurfaceFormatCore::parse
static Type parse(const string &str)
Read a type from string.
Definition: AC3DsurfaceFormatCore.H:63
Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
static void writeHeader(Ostream &os, const UList< surfZone > &zones)
Write header with materials for each zone.
Definition: AC3DsurfaceFormatCore.C:125
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:103
Foam::fileFormats::AC3DsurfaceFormatCore::cueToOrDie
static string cueToOrDie(IFstream &, const string &cmd, const string &errorMsg=string::null)
Like cueTo(), but FatalError if not found.
Definition: AC3DsurfaceFormatCore.C:105
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
args
Foam::argList args(argc, argv)