1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Write primitive and binary block from OPstream
28 \*---------------------------------------------------------------------------*/
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
47 const commsTypes commsType,
54 Pstream(commsType, bufSize),
55 Ostream(format, version),
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 Ostream& OPstream::write(const token&)
72 notImplemented("Ostream& OPstream::write(const token&)");
78 Ostream& OPstream::write(const char c)
89 Ostream& OPstream::write(const char* s)
91 word nonWhiteChars(string::validate<word>(s));
93 if (nonWhiteChars.size() == 0)
97 else if (nonWhiteChars.size() == 1)
99 return write(nonWhiteChars.c_str()[1]);
103 return write(nonWhiteChars);
108 Ostream& OPstream::write(const word& w)
110 write(char(token::WORD));
112 size_t ws = w.size();
114 writeToBuffer(w.c_str(), ws + 1, 1);
120 Ostream& OPstream::write(const string& s)
122 write(char(token::STRING));
124 size_t ss = s.size();
126 writeToBuffer(s.c_str(), ss + 1, 1);
132 Ostream& OPstream::write(const label l)
134 write(char(token::LABEL));
142 Ostream& OPstream::write(const floatScalar s)
144 write(char(token::FLOAT_SCALAR));
152 Ostream& OPstream::write(const doubleScalar s)
154 write(char(token::DOUBLE_SCALAR));
162 Ostream& OPstream::write(const char* data, std::streamsize count)
164 if (format() != BINARY)
166 FatalErrorIn("Ostream::write(const char*, std::streamsize)")
167 << "stream format not binary"
168 << Foam::abort(FatalError);
171 writeToBuffer(data, count, 8);
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 } // End namespace Foam
181 // ************************************************************************* //