![[]](/images/special/trans.gif)
LibN2L-4 Library Code ReferenceClassesCompounds Files Members Method Index Full Reference cConfValidatorIsVfsNodeType.cppGo to the documentation of this file.00001 /************************************************************************ 00002 Nova-2 Library (libN2L, or simply n2l) Game development C++ Library 00003 Copyright (C) 2003 Aaron Cameron 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 A copy of the GNU Lesser General Public License has been provided with 00020 this library in the file 'COPYING'. 00021 00022 Contact information for the author of this library has been provided 00023 with this library in the file 'AUTHOR'. 00024 ************************************************************************/ 00025 #include "cConfValidatorIsVfsNodeType.h" 00026 #include "cConfParsingErrors.h" 00027 #include "cConfParsingError.h" 00028 00029 #include "n2l/dynVars.h" 00030 00031 namespace n2l 00032 { 00033 00034 /* ************************************************************ */ 00035 cConfValidatorIsVfsNodeType::cConfValidatorIsVfsNodeType( 00036 const tLikeType iType, 00037 const cAutoPtr<const cVfsDirectoryInterface> & iInDir) : 00038 mType(iType), 00039 mDir(iInDir) 00040 { 00041 } 00042 00043 00044 /* ************************************************************ */ 00045 cConfValidatorIsVfsNodeType::~cConfValidatorIsVfsNodeType() 00046 { 00047 } 00048 00049 00050 /* ************************************************************ */ 00051 const cConfValidatorIsVfsNodeType::tLikeType cConfValidatorIsVfsNodeType::type() const 00052 { 00053 return mType; 00054 } 00055 00056 00057 /* ************************************************************ */ 00058 const tString cConfValidatorIsVfsNodeType::describe() const 00059 { 00060 static const tString Prefix("Vfs Node needs to be of type: "); 00061 tString retStr = Prefix+anyTypeStr(type()); 00062 retStr += " in dir \""; 00063 if (mDir->supportsFsName()) { 00064 retStr += mDir->fsName(); 00065 } else { 00066 retStr += mDir->name(); 00067 } 00068 retStr += "\""; 00069 return retStr; 00070 } 00071 00072 00073 /* ************************************************************ */ 00074 const cConfValidatorInterface * const cConfValidatorIsVfsNodeType::valueOk( 00075 const cDynVar & iValue ) const 00076 { 00077 switch (type()) { 00078 case LikeType_Nothing: 00079 if (mDir->find(tString(iValue))!=mDir->end()) 00080 return this; 00081 return 0; 00082 00083 case LikeType_Anything: 00084 if (mDir->find(tString(iValue))==mDir->end()) 00085 return this; 00086 return 0; 00087 00088 case LikeType_File: { 00089 cVfsDirectoryInterface::tConstIterator node = mDir->find(tString(iValue)); 00090 if (node==mDir->end() || !node->second->likeFile()) return this; 00091 return 0; 00092 } 00093 00094 case LikeType_Directory: { 00095 cVfsDirectoryInterface::tConstIterator node = mDir->find(tString(iValue)); 00096 if (node==mDir->end() || !node->second->likeDirectory()) return this; 00097 return 0; 00098 } 00099 00100 default: 00101 return this; 00102 } 00103 } 00104 00105 00106 /* ************************************************************ */ 00107 const tString & cConfValidatorIsVfsNodeType::anyTypeStr( const tLikeType iType ) 00108 { 00109 static const tString Type_UnknownStr = "Unknown"; 00110 static const tString Type_NothingStr = "No file"; 00111 static const tString Type_AnythingStr = "Anything"; 00112 static const tString Type_LikeFileStr = "Like a file"; 00113 static const tString Type_LikeDirStr = "Like a directory"; 00114 switch (iType) { 00115 case LikeType_Nothing: 00116 return Type_NothingStr; 00117 case LikeType_Anything: 00118 return Type_AnythingStr; 00119 case LikeType_File: 00120 return Type_LikeFileStr; 00121 case LikeType_Directory: 00122 return Type_LikeDirStr; 00123 default: 00124 return Type_UnknownStr; 00125 } 00126 } 00127 00128 00129 } // namespace |