OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

dimensionSetIO.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "dimensionSet.H"
00028 #include "IOstreams.H"
00029 
00030 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00031 
00032 Foam::dimensionSet::dimensionSet(Istream& is)
00033 {
00034     is >> *this;
00035 }
00036 
00037 
00038 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
00039 
00040 Foam::Istream& Foam::operator>>(Istream& is, dimensionSet& dset)
00041 {
00042     // Read begining of dimensionSet
00043     if (token(is) != token::BEGIN_SQR)
00044     {
00045         Info<< "expected a " << token::BEGIN_SQR << " in dimensionSet"
00046             << endl << "in stream " << is.info() << endl;
00047     }
00048 
00049     // Read first five dimensions
00050     for (int Dimension=0; Dimension<dimensionSet::CURRENT; Dimension++)
00051     {
00052         is >> dset.exponents_[Dimension];
00053     }
00054 
00055     // Read next token
00056     token nextToken(is);
00057 
00058     // If next token is another number
00059     // read last two dimensions
00060     // and then read another token for the end of the dimensionSet
00061     if (nextToken.isNumber())
00062     {
00063         dset.exponents_[dimensionSet::CURRENT] = nextToken.number();
00064         is >> dset.exponents_[dimensionSet::LUMINOUS_INTENSITY];
00065         is >> nextToken;
00066     }
00067     else
00068     {
00069         dset.exponents_[dimensionSet::CURRENT] = 0;
00070         dset.exponents_[dimensionSet::LUMINOUS_INTENSITY] = 0;
00071     }
00072 
00073     // Check end of dimensionSet
00074     if (nextToken != token::END_SQR)
00075     {
00076         Info<< "expected a " << token::END_SQR << " in dimensionSet"
00077             << endl << "in stream " << is.info() << endl;
00078     }
00079 
00080     // Check state of Istream
00081     is.check("Istream& operator>>(Istream&, dimensionSet&)");
00082 
00083     return is;
00084 }
00085 
00086 
00087 Foam::Ostream& Foam::operator<<(Ostream& os, const dimensionSet& dset)
00088 {
00089     os << token::BEGIN_SQR;
00090 
00091     for (int Dimension=0; Dimension<dimensionSet::nDimensions-1; Dimension++)
00092     {
00093         os << dset.exponents_[Dimension] << token::SPACE;
00094     }
00095     os << dset.exponents_[dimensionSet::nDimensions-1] << token::END_SQR;
00096 
00097     // Check state of Ostream
00098     os.check("Ostream& operator<<(Ostream&, const dimensionSet&)");
00099 
00100     return os;
00101 }
00102 
00103 
00104 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd