|
|
|
token.CGo 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 "token.H" 00028 00029 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // 00030 00031 const char* const Foam::token::typeName = "token"; 00032 Foam::token Foam::token::undefinedToken; 00033 00034 defineTypeNameAndDebug(Foam::token::compound, 0); 00035 defineRunTimeSelectionTable(Foam::token::compound, Istream); 00036 00037 00038 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // 00039 00040 void Foam::token::parseError(const char* expected) const 00041 { 00042 FatalIOError 00043 << "Parse error, expected a " << expected 00044 << ", found \n " << info() << endl; 00045 } 00046 00047 00048 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // 00049 00050 Foam::token::compound::~compound() 00051 {} 00052 00053 00054 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // 00055 00056 Foam::autoPtr<Foam::token::compound> Foam::token::compound::New 00057 ( 00058 const word& compoundType, 00059 Istream& is 00060 ) 00061 { 00062 IstreamConstructorTable::iterator cstrIter = 00063 IstreamConstructorTablePtr_->find(compoundType); 00064 00065 if (cstrIter == IstreamConstructorTablePtr_->end()) 00066 { 00067 FatalErrorIn("token::compound::New(const word&, Istream&)") 00068 << "Unknown compound type " << compoundType << nl << nl 00069 << "Valid compound types:" << endl 00070 << IstreamConstructorTablePtr_->toc() 00071 << abort(FatalError); 00072 } 00073 00074 return autoPtr<Foam::token::compound>(cstrIter()(is)); 00075 } 00076 00077 00078 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // 00079 00080 bool Foam::token::compound::isCompound(const word& name) 00081 { 00082 return 00083 ( 00084 IstreamConstructorTablePtr_ 00085 && IstreamConstructorTablePtr_->found(name) 00086 ); 00087 } 00088 00089 00090 Foam::token::compound& Foam::token::transferCompoundToken() 00091 { 00092 if (type_ == COMPOUND) 00093 { 00094 if (compoundTokenPtr_->empty()) 00095 { 00096 FatalErrorIn("token::transferCompoundToken()") 00097 << "compound has already been transfered from token\n " 00098 << info() << abort(FatalError); 00099 } 00100 else 00101 { 00102 compoundTokenPtr_->empty() = true; 00103 } 00104 00105 return *compoundTokenPtr_; 00106 } 00107 else 00108 { 00109 parseError("compound"); 00110 return *compoundTokenPtr_; 00111 } 00112 } 00113 00114 00115 // ************************************************************************* // |