IOobjectI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "foamVersion.H"
27 
28 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
29 
30 template<class Name>
32 {
33  if (group != word::null)
34  {
35  return name + ('.' + group);
36  }
37  else
38  {
39  return name;
40  }
41 }
42 
43 
44 template<class Name>
45 inline Foam::word Foam::IOobject::modelName(Name name, const word& model)
46 {
47  if (model != word::null)
48  {
49  return (model + ':') + name;
50  }
51  else
52  {
53  return name;
54  }
55 }
56 
57 
58 inline Foam::word Foam::IOobject::modelName(const char* name) const
59 {
60  return type() + ':' + name;
61 }
62 
63 
64 template<class Stream>
65 inline Stream& Foam::IOobject::writeBanner(Stream& os, bool noHint)
66 {
67  static bool spacesSet(false);
68  static char spaces[40];
69 
70  if (!spacesSet)
71  {
72  memset(spaces, ' ', 40);
73 
74  size_t len = strlen(Foam::FOAMversion);
75  if (len < 38)
76  {
77  spaces[38 - len] = '\0';
78  }
79  else
80  {
81  spaces[0] = '\0';
82  }
83  spacesSet = true;
84  }
85 
86  if (noHint)
87  {
88  os <<
89  "/*--------------------------------------"
90  "-------------------------------------*\\\n";
91  }
92  else
93  {
94  os <<
95  "/*--------------------------------*- C++ "
96  "-*----------------------------------*\\\n";
97  }
98 
99  os <<
100  " ========= |\n"
101  " \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox\n"
102  " \\\\ / O peration | Website: https://openfoam.org\n"
103  " \\\\ / A nd | Version: " << FOAMversion << "\n"
104  " \\\\/ M anipulation |\n"
105  "\\*-----------------------------------------"
106  "----------------------------------*/\n";
107 
108  return os;
109 }
110 
111 
112 template<class Stream>
113 inline Stream& Foam::IOobject::writeDivider(Stream& os)
114 {
115  os <<
116  "// * * * * * * * * * * * * * * * * * "
117  "* * * * * * * * * * * * * * * * * * * * //\n";
118 
119  return os;
120 }
121 
122 template<class Stream>
123 inline Stream& Foam::IOobject::writeEndDivider(Stream& os)
124 {
125  os << "\n\n"
126  "// *****************************************"
127  "******************************** //\n";
128 
129  return os;
130 }
131 
132 
133 // ************************************************************************* //
const char *const group
Group name for atomic constants.
const word & name() const
Return name.
Definition: IOobject.H:303
static Stream & writeBanner(Stream &os, bool noHint=false)
Write the standard OpenFOAM file/dictionary banner.
Definition: IOobjectI.H:65
static Stream & writeDivider(Stream &os)
Write the standard file section divider.
Definition: IOobjectI.H:113
word group() const
Return group (extension part of name)
Definition: IOobject.C:330
const char *const FOAMversion
A class for handling words, derived from string.
Definition: word.H:59
static word groupName(Name name, const word &group)
static const word null
An empty word.
Definition: word.H:77
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
static Stream & writeEndDivider(Stream &os)
Write the standard end file divider.
Definition: IOobjectI.H:123
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
static word modelName(Name name, const word &model)
Return the name of the object within the given model.