src/OpenFOAM: Rationalised use of enumerations by using the C++11 scoped form
for
db/functionObjects/timeControl/timeControl.H: timeControls
primitives/bools/Switch/Switch.H: class switchType
primitives/strings/fileName/fileName.H: fileType
primitives/strings/wordRe/wordRe.H: compOption
This commit is contained in:
@ -243,7 +243,7 @@ Foam::cvControls::cvControls
|
|||||||
|
|
||||||
if (filterFaces_)
|
if (filterFaces_)
|
||||||
{
|
{
|
||||||
filterEdges_ = Switch::ON;
|
filterEdges_ = Switch::switchType::on;
|
||||||
}
|
}
|
||||||
|
|
||||||
writeTetDualMesh_ = Switch(filteringDict.lookup("writeTetDualMesh"));
|
writeTetDualMesh_ = Switch(filteringDict.lookup("writeTetDualMesh"));
|
||||||
|
|||||||
@ -408,7 +408,7 @@ int main(int argc, char *argv[])
|
|||||||
fileHandler().readDir
|
fileHandler().readDir
|
||||||
(
|
(
|
||||||
lagrangianDirs[0],
|
lagrangianDirs[0],
|
||||||
fileName::DIRECTORY
|
fileType::directory
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -328,7 +328,7 @@ int main(int argc, char *argv[])
|
|||||||
fileHandler().readDir
|
fileHandler().readDir
|
||||||
(
|
(
|
||||||
runTime.path(),
|
runTime.path(),
|
||||||
fileName::Type::DIRECTORY
|
fileType::directory
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
forAllReverse(dirs, diri)
|
forAllReverse(dirs, diri)
|
||||||
@ -661,7 +661,7 @@ int main(int argc, char *argv[])
|
|||||||
fileHandler().readDir
|
fileHandler().readDir
|
||||||
(
|
(
|
||||||
runTime.timePath()/cloud::prefix,
|
runTime.timePath()/cloud::prefix,
|
||||||
fileName::DIRECTORY
|
fileType::directory
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -520,7 +520,7 @@ int main(int argc, char *argv[])
|
|||||||
cloudDirs = fileHandler().readDir
|
cloudDirs = fileHandler().readDir
|
||||||
(
|
(
|
||||||
lagrangianDir,
|
lagrangianDir,
|
||||||
fileName::DIRECTORY
|
fileType::directory
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -307,7 +307,7 @@ int main(int argc, char *argv[])
|
|||||||
fileNameList cloudDirs = readDir
|
fileNameList cloudDirs = readDir
|
||||||
(
|
(
|
||||||
runTime.timePath()/regionPrefix/cloud::prefix,
|
runTime.timePath()/regionPrefix/cloud::prefix,
|
||||||
fileName::DIRECTORY
|
fileType::directory
|
||||||
);
|
);
|
||||||
|
|
||||||
forAll(cloudDirs, cloudI)
|
forAll(cloudDirs, cloudI)
|
||||||
@ -557,7 +557,7 @@ int main(int argc, char *argv[])
|
|||||||
fileNameList currentCloudDirs = readDir
|
fileNameList currentCloudDirs = readDir
|
||||||
(
|
(
|
||||||
runTime.timePath()/regionPrefix/cloud::prefix,
|
runTime.timePath()/regionPrefix/cloud::prefix,
|
||||||
fileName::DIRECTORY
|
fileType::directory
|
||||||
);
|
);
|
||||||
|
|
||||||
bool cloudExists = inFileNameList(currentCloudDirs, cloudName);
|
bool cloudExists = inFileNameList(currentCloudDirs, cloudName);
|
||||||
|
|||||||
@ -37,7 +37,7 @@ if (timeDirs.size())
|
|||||||
/ timeDirs.last().name()
|
/ timeDirs.last().name()
|
||||||
/ regionPrefix
|
/ regionPrefix
|
||||||
/ cloud::prefix,
|
/ cloud::prefix,
|
||||||
fileName::DIRECTORY
|
fileType::directory
|
||||||
);
|
);
|
||||||
|
|
||||||
forAll(cloudDirs, cloudI)
|
forAll(cloudDirs, cloudI)
|
||||||
|
|||||||
@ -1213,7 +1213,7 @@ int main(int argc, char *argv[])
|
|||||||
readDir
|
readDir
|
||||||
(
|
(
|
||||||
runTime.timePath()/regionPrefix/cloud::prefix,
|
runTime.timePath()/regionPrefix/cloud::prefix,
|
||||||
fileName::DIRECTORY
|
fileType::directory
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -446,7 +446,7 @@ int main(int argc, char *argv[])
|
|||||||
readDir
|
readDir
|
||||||
(
|
(
|
||||||
runTime.timePath()/regionPrefix/cloud::prefix,
|
runTime.timePath()/regionPrefix/cloud::prefix,
|
||||||
fileName::DIRECTORY
|
fileType::directory
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
forAll(cloudDirs, i)
|
forAll(cloudDirs, i)
|
||||||
@ -1210,14 +1210,14 @@ int main(int argc, char *argv[])
|
|||||||
/"VTK"
|
/"VTK"
|
||||||
);
|
);
|
||||||
|
|
||||||
fileNameList dirs(readDir(procVTK, fileName::DIRECTORY));
|
fileNameList dirs(readDir(procVTK, fileType::directory));
|
||||||
label sz = dirs.size();
|
label sz = dirs.size();
|
||||||
dirs.setSize(sz+1);
|
dirs.setSize(sz+1);
|
||||||
dirs[sz] = ".";
|
dirs[sz] = ".";
|
||||||
|
|
||||||
forAll(dirs, i)
|
forAll(dirs, i)
|
||||||
{
|
{
|
||||||
fileNameList subFiles(readDir(procVTK/dirs[i], fileName::FILE));
|
fileNameList subFiles(readDir(procVTK/dirs[i], fileType::file));
|
||||||
|
|
||||||
forAll(subFiles, j)
|
forAll(subFiles, j)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -48,7 +48,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
#include "createTime.H"
|
#include "createTime.H"
|
||||||
|
|
||||||
fileNameList fieldNames = readDir(runTime.timePath(), fileName::FILE);
|
fileNameList fieldNames = readDir(runTime.timePath(), fileType::file);
|
||||||
dictionary fieldNameDict;
|
dictionary fieldNameDict;
|
||||||
forAll(fieldNames, i)
|
forAll(fieldNames, i)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -202,7 +202,7 @@ void Foam::vtkPVFoam::updateInfoLagrangian
|
|||||||
readDir
|
readDir
|
||||||
(
|
(
|
||||||
dbPtr_->path()/times[timei].name()/lagrangianPrefix,
|
dbPtr_->path()/times[timei].name()/lagrangianPrefix,
|
||||||
fileName::DIRECTORY
|
fileType::directory
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -105,7 +105,7 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp)
|
|||||||
readDir
|
readDir
|
||||||
(
|
(
|
||||||
meshSource.time().timePath()/cloud::prefix,
|
meshSource.time().timePath()/cloud::prefix,
|
||||||
fileName::DIRECTORY
|
fileType::directory
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -94,7 +94,7 @@ void mapLagrangian(const meshToMesh& interp)
|
|||||||
readDir
|
readDir
|
||||||
(
|
(
|
||||||
meshSource.time().timePath()/cloud::prefix,
|
meshSource.time().timePath()/cloud::prefix,
|
||||||
fileName::DIRECTORY
|
fileType::directory
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -483,7 +483,7 @@ mode_t Foam::mode
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::fileName::Type Foam::type
|
Foam::fileType Foam::type
|
||||||
(
|
(
|
||||||
const fileName& name,
|
const fileName& name,
|
||||||
const bool checkVariants,
|
const bool checkVariants,
|
||||||
@ -498,19 +498,19 @@ Foam::fileName::Type Foam::type
|
|||||||
|
|
||||||
if (S_ISREG(m))
|
if (S_ISREG(m))
|
||||||
{
|
{
|
||||||
return fileName::FILE;
|
return fileType::file;
|
||||||
}
|
}
|
||||||
else if (S_ISLNK(m))
|
else if (S_ISLNK(m))
|
||||||
{
|
{
|
||||||
return fileName::LINK;
|
return fileType::link;
|
||||||
}
|
}
|
||||||
else if (S_ISDIR(m))
|
else if (S_ISDIR(m))
|
||||||
{
|
{
|
||||||
return fileName::DIRECTORY;
|
return fileType::directory;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return fileName::UNDEFINED;
|
return fileType::undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,7 +660,7 @@ double Foam::highResLastModified
|
|||||||
Foam::fileNameList Foam::readDir
|
Foam::fileNameList Foam::readDir
|
||||||
(
|
(
|
||||||
const fileName& directory,
|
const fileName& directory,
|
||||||
const fileName::Type type,
|
const fileType type,
|
||||||
const bool filterVariants,
|
const bool filterVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
)
|
)
|
||||||
@ -714,10 +714,10 @@ Foam::fileNameList Foam::readDir
|
|||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
(type == fileName::DIRECTORY)
|
(type == fileType::directory)
|
||||||
||
|
||
|
||||||
(
|
(
|
||||||
type == fileName::FILE
|
type == fileType::file
|
||||||
&& fName[fName.size()-1] != '~'
|
&& fName[fName.size()-1] != '~'
|
||||||
&& fExt != "bak"
|
&& fExt != "bak"
|
||||||
&& fExt != "BAK"
|
&& fExt != "BAK"
|
||||||
@ -777,15 +777,15 @@ bool Foam::cp(const fileName& src, const fileName& dest, const bool followLink)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fileName::Type srcType = src.type(false, followLink);
|
const fileType srcType = src.type(false, followLink);
|
||||||
|
|
||||||
fileName destFile(dest);
|
fileName destFile(dest);
|
||||||
|
|
||||||
// Check type of source file.
|
// Check type of source file.
|
||||||
if (srcType == fileName::FILE)
|
if (srcType == fileType::file)
|
||||||
{
|
{
|
||||||
// If dest is a directory, create the destination file name.
|
// If dest is a directory, create the destination file name.
|
||||||
if (destFile.type() == fileName::DIRECTORY)
|
if (destFile.type() == fileType::directory)
|
||||||
{
|
{
|
||||||
destFile = destFile/src.name();
|
destFile = destFile/src.name();
|
||||||
}
|
}
|
||||||
@ -822,10 +822,10 @@ bool Foam::cp(const fileName& src, const fileName& dest, const bool followLink)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (srcType == fileName::LINK)
|
else if (srcType == fileType::link)
|
||||||
{
|
{
|
||||||
// If dest is a directory, create the destination file name.
|
// If dest is a directory, create the destination file name.
|
||||||
if (destFile.type() == fileName::DIRECTORY)
|
if (destFile.type() == fileType::directory)
|
||||||
{
|
{
|
||||||
destFile = destFile/src.name();
|
destFile = destFile/src.name();
|
||||||
}
|
}
|
||||||
@ -838,10 +838,10 @@ bool Foam::cp(const fileName& src, const fileName& dest, const bool followLink)
|
|||||||
|
|
||||||
ln(src, destFile);
|
ln(src, destFile);
|
||||||
}
|
}
|
||||||
else if (srcType == fileName::DIRECTORY)
|
else if (srcType == fileType::directory)
|
||||||
{
|
{
|
||||||
// If dest is a directory, create the destination file name.
|
// If dest is a directory, create the destination file name.
|
||||||
if (destFile.type() == fileName::DIRECTORY)
|
if (destFile.type() == fileType::directory)
|
||||||
{
|
{
|
||||||
destFile = destFile/src.component(src.components().size() -1);
|
destFile = destFile/src.component(src.components().size() -1);
|
||||||
}
|
}
|
||||||
@ -879,7 +879,7 @@ bool Foam::cp(const fileName& src, const fileName& dest, const bool followLink)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy files
|
// Copy files
|
||||||
fileNameList contents = readDir(src, fileName::FILE, false, followLink);
|
fileNameList contents = readDir(src, fileType::file, false, followLink);
|
||||||
forAll(contents, i)
|
forAll(contents, i)
|
||||||
{
|
{
|
||||||
if (POSIX::debug)
|
if (POSIX::debug)
|
||||||
@ -897,7 +897,7 @@ bool Foam::cp(const fileName& src, const fileName& dest, const bool followLink)
|
|||||||
fileNameList subdirs = readDir
|
fileNameList subdirs = readDir
|
||||||
(
|
(
|
||||||
src,
|
src,
|
||||||
fileName::DIRECTORY,
|
fileType::directory,
|
||||||
false,
|
false,
|
||||||
followLink
|
followLink
|
||||||
);
|
);
|
||||||
@ -975,8 +975,8 @@ bool Foam::mv(const fileName& src, const fileName& dst, const bool followLink)
|
|||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
dst.type() == fileName::DIRECTORY
|
dst.type() == fileType::directory
|
||||||
&& src.type(false, followLink) != fileName::DIRECTORY
|
&& src.type(false, followLink) != fileType::directory
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const fileName dstName(dst/src.name());
|
const fileName dstName(dst/src.name());
|
||||||
@ -1098,7 +1098,7 @@ bool Foam::rmDir(const fileName& directory)
|
|||||||
{
|
{
|
||||||
fileName path = directory/fName;
|
fileName path = directory/fName;
|
||||||
|
|
||||||
if (path.type(false, false) == fileName::DIRECTORY)
|
if (path.type(false, false) == fileType::directory)
|
||||||
{
|
{
|
||||||
if (!rmDir(path))
|
if (!rmDir(path))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -62,14 +62,14 @@ Foam::OFstreamAllocator::OFstreamAllocator
|
|||||||
if (compression == IOstream::COMPRESSED)
|
if (compression == IOstream::COMPRESSED)
|
||||||
{
|
{
|
||||||
// Get identically named uncompressed version out of the way
|
// Get identically named uncompressed version out of the way
|
||||||
fileName::Type pathType = Foam::type(pathname, false, false);
|
fileType pathType = Foam::type(pathname, false, false);
|
||||||
if (pathType == fileName::FILE || pathType == fileName::LINK)
|
if (pathType == fileType::file || pathType == fileType::link)
|
||||||
{
|
{
|
||||||
rm(pathname);
|
rm(pathname);
|
||||||
}
|
}
|
||||||
fileName gzPathName(pathname + ".gz");
|
fileName gzPathName(pathname + ".gz");
|
||||||
|
|
||||||
if (!append && Foam::type(gzPathName) == fileName::LINK)
|
if (!append && Foam::type(gzPathName) == fileType::link)
|
||||||
{
|
{
|
||||||
// Disallow writing into softlink to avoid any problems with
|
// Disallow writing into softlink to avoid any problems with
|
||||||
// e.g. softlinked initial fields
|
// e.g. softlinked initial fields
|
||||||
@ -82,15 +82,15 @@ Foam::OFstreamAllocator::OFstreamAllocator
|
|||||||
{
|
{
|
||||||
// get identically named compressed version out of the way
|
// get identically named compressed version out of the way
|
||||||
fileName gzPathName(pathname + ".gz");
|
fileName gzPathName(pathname + ".gz");
|
||||||
fileName::Type gzType = Foam::type(gzPathName, false, false);
|
fileType gzType = Foam::type(gzPathName, false, false);
|
||||||
if (gzType == fileName::FILE || gzType == fileName::LINK)
|
if (gzType == fileType::file || gzType == fileType::link)
|
||||||
{
|
{
|
||||||
rm(gzPathName);
|
rm(gzPathName);
|
||||||
}
|
}
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
!append
|
!append
|
||||||
&& Foam::type(pathname, false, false) == fileName::LINK
|
&& Foam::type(pathname, false, false) == fileType::link
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Disallow writing into softlink to avoid any problems with
|
// Disallow writing into softlink to avoid any problems with
|
||||||
|
|||||||
@ -92,7 +92,7 @@ void Foam::functionObjectList::listDir
|
|||||||
|
|
||||||
// Recurse into sub-directories
|
// Recurse into sub-directories
|
||||||
{
|
{
|
||||||
fileNameList foDirs(fileHandler().readDir(dir, fileName::DIRECTORY));
|
fileNameList foDirs(fileHandler().readDir(dir, fileType::directory));
|
||||||
forAll(foDirs, fd)
|
forAll(foDirs, fd)
|
||||||
{
|
{
|
||||||
listDir(dir/foDirs[fd], foMap);
|
listDir(dir/foDirs[fd], foMap);
|
||||||
|
|||||||
@ -60,7 +60,7 @@ Foam::timeControl::timeControl
|
|||||||
:
|
:
|
||||||
time_(t),
|
time_(t),
|
||||||
prefix_(prefix),
|
prefix_(prefix),
|
||||||
timeControl_(ocTimeStep),
|
timeControl_(timeControls::timeStep),
|
||||||
intervalSteps_(0),
|
intervalSteps_(0),
|
||||||
interval_(-1),
|
interval_(-1),
|
||||||
executionIndex_(0)
|
executionIndex_(0)
|
||||||
@ -102,28 +102,28 @@ void Foam::timeControl::read(const dictionary& dict)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
timeControl_ = ocTimeStep;
|
timeControl_ = timeControls::timeStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (timeControl_)
|
switch (timeControl_)
|
||||||
{
|
{
|
||||||
case ocTimeStep:
|
case timeControls::timeStep:
|
||||||
{
|
{
|
||||||
intervalSteps_ = dict.lookupOrDefault<label>(intervalName, 0);
|
intervalSteps_ = dict.lookupOrDefault<label>(intervalName, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ocWriteTime:
|
case timeControls::writeTime:
|
||||||
case ocOutputTime:
|
case timeControls::outputTime:
|
||||||
{
|
{
|
||||||
intervalSteps_ = dict.lookupOrDefault<label>(intervalName, 1);
|
intervalSteps_ = dict.lookupOrDefault<label>(intervalName, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ocClockTime:
|
case timeControls::clockTime:
|
||||||
case ocRunTime:
|
case timeControls::runTime:
|
||||||
case ocCpuTime:
|
case timeControls::cpuTime:
|
||||||
case ocAdjustableRunTime:
|
case timeControls::adjustableRunTime:
|
||||||
{
|
{
|
||||||
interval_ = readScalar(dict.lookup(intervalName));
|
interval_ = readScalar(dict.lookup(intervalName));
|
||||||
break;
|
break;
|
||||||
@ -141,7 +141,7 @@ bool Foam::timeControl::execute()
|
|||||||
{
|
{
|
||||||
switch (timeControl_)
|
switch (timeControl_)
|
||||||
{
|
{
|
||||||
case ocTimeStep:
|
case timeControls::timeStep:
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
(
|
(
|
||||||
@ -151,8 +151,8 @@ bool Foam::timeControl::execute()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ocWriteTime:
|
case timeControls::writeTime:
|
||||||
case ocOutputTime:
|
case timeControls::outputTime:
|
||||||
{
|
{
|
||||||
if (time_.writeTime())
|
if (time_.writeTime())
|
||||||
{
|
{
|
||||||
@ -162,8 +162,8 @@ bool Foam::timeControl::execute()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ocRunTime:
|
case timeControls::runTime:
|
||||||
case ocAdjustableRunTime:
|
case timeControls::adjustableRunTime:
|
||||||
{
|
{
|
||||||
label executionIndex = label
|
label executionIndex = label
|
||||||
(
|
(
|
||||||
@ -182,7 +182,7 @@ bool Foam::timeControl::execute()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ocCpuTime:
|
case timeControls::cpuTime:
|
||||||
{
|
{
|
||||||
label executionIndex = label
|
label executionIndex = label
|
||||||
(
|
(
|
||||||
@ -197,7 +197,7 @@ bool Foam::timeControl::execute()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ocClockTime:
|
case timeControls::clockTime:
|
||||||
{
|
{
|
||||||
label executionIndex = label
|
label executionIndex = label
|
||||||
(
|
(
|
||||||
@ -212,7 +212,7 @@ bool Foam::timeControl::execute()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ocNone:
|
case timeControls::none:
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,16 +52,16 @@ class timeControl
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
//- The time control options
|
//- The time control options
|
||||||
enum timeControls
|
enum class timeControls
|
||||||
{
|
{
|
||||||
ocTimeStep, //!< execution is coupled to the time-step
|
timeStep, //!< execution is coupled to the time-step
|
||||||
ocWriteTime, //!< execution is coupled to the write-time
|
writeTime, //!< execution is coupled to the write-time
|
||||||
ocOutputTime, //!< execution is coupled to the output-time
|
outputTime, //!< execution is coupled to the output-time
|
||||||
ocAdjustableRunTime, //!< Adjust time step for execution
|
adjustableRunTime, //!< Adjust time step for execution
|
||||||
ocRunTime, //!< run time for execution
|
runTime, //!< run time for execution
|
||||||
ocClockTime, //!< clock time for execution
|
clockTime, //!< clock time for execution
|
||||||
ocCpuTime, //!< cpu time for execution
|
cpuTime, //!< cpu time for execution
|
||||||
ocNone //!< no execution
|
none //!< no execution
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -124,7 +124,8 @@ Foam::scalar Foam::functionObjects::timeControl::timeToNextWrite()
|
|||||||
if
|
if
|
||||||
(
|
(
|
||||||
active()
|
active()
|
||||||
&& writeControl_.control() == Foam::timeControl::ocAdjustableRunTime
|
&& writeControl_.control() ==
|
||||||
|
Foam::timeControl::timeControls::adjustableRunTime
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const label writeTimeIndex = writeControl_.executionIndex();
|
const label writeTimeIndex = writeControl_.executionIndex();
|
||||||
|
|||||||
@ -96,7 +96,7 @@ bool Foam::functionObjects::writeLocalObjects::read(const dictionary& dict)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
resetWriteObjectName(wordRe(".*", wordRe::DETECT));
|
resetWriteObjectName(wordRe(".*", wordRe::compOption::detect));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -272,7 +272,7 @@ Foam::fileOperation::lookupProcessorsPath(const fileName& fName) const
|
|||||||
|
|
||||||
// Note: use parallel synchronised reading so cache will be same
|
// Note: use parallel synchronised reading so cache will be same
|
||||||
// order on all processors
|
// order on all processors
|
||||||
fileNameList dirNames(readDir(path, fileName::Type::DIRECTORY));
|
fileNameList dirNames(readDir(path, fileType::directory));
|
||||||
|
|
||||||
// Extract info from processorsDDD or processorDDD:
|
// Extract info from processorsDDD or processorDDD:
|
||||||
// - highest processor number
|
// - highest processor number
|
||||||
@ -687,7 +687,7 @@ Foam::instantList Foam::fileOperation::findTimes
|
|||||||
Foam::readDir
|
Foam::readDir
|
||||||
(
|
(
|
||||||
directory,
|
directory,
|
||||||
fileName::DIRECTORY
|
fileType::directory
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -707,7 +707,7 @@ Foam::instantList Foam::fileOperation::findTimes
|
|||||||
Foam::readDir
|
Foam::readDir
|
||||||
(
|
(
|
||||||
collDir,
|
collDir,
|
||||||
fileName::DIRECTORY
|
fileType::directory
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
mergeTimes
|
mergeTimes
|
||||||
@ -902,7 +902,7 @@ Foam::fileNameList Foam::fileOperation::readObjects
|
|||||||
if (Foam::isDir(path))
|
if (Foam::isDir(path))
|
||||||
{
|
{
|
||||||
newInstance = instance;
|
newInstance = instance;
|
||||||
objectNames = Foam::readDir(path, fileName::FILE);
|
objectNames = Foam::readDir(path, fileType::file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -912,7 +912,7 @@ Foam::fileNameList Foam::fileOperation::readObjects
|
|||||||
if (!procsPath.empty())
|
if (!procsPath.empty())
|
||||||
{
|
{
|
||||||
newInstance = instance;
|
newInstance = instance;
|
||||||
objectNames = Foam::readDir(procsPath, fileName::FILE);
|
objectNames = Foam::readDir(procsPath, fileType::file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return objectNames;
|
return objectNames;
|
||||||
@ -932,7 +932,7 @@ Foam::label Foam::fileOperation::nProcs
|
|||||||
label nProcs = 0;
|
label nProcs = 0;
|
||||||
if (Pstream::master(comm_))
|
if (Pstream::master(comm_))
|
||||||
{
|
{
|
||||||
fileNameList dirNames(Foam::readDir(dir, fileName::Type::DIRECTORY));
|
fileNameList dirNames(Foam::readDir(dir, fileType::directory));
|
||||||
|
|
||||||
// Detect any processorsDDD or processorDDD
|
// Detect any processorsDDD or processorDDD
|
||||||
label maxProc = -1;
|
label maxProc = -1;
|
||||||
@ -1233,7 +1233,7 @@ Foam::fileName Foam::search(const word& file, const fileName& directory)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If not found search each of the sub-directories
|
// If not found search each of the sub-directories
|
||||||
fileNameList dirs(fileHandler().readDir(directory, fileName::DIRECTORY));
|
fileNameList dirs(fileHandler().readDir(directory, fileType::directory));
|
||||||
forAll(dirs, i)
|
forAll(dirs, i)
|
||||||
{
|
{
|
||||||
fileName path = search(file, directory/dirs[i]);
|
fileName path = search(file, directory/dirs[i]);
|
||||||
@ -1251,7 +1251,7 @@ void Foam::cpFiles(const fileName& srcDir, const fileName& targetDir)
|
|||||||
{
|
{
|
||||||
mkDir(targetDir);
|
mkDir(targetDir);
|
||||||
|
|
||||||
const fileNameList srcFiles(readDir(srcDir, fileName::FILE, true));
|
const fileNameList srcFiles(readDir(srcDir, fileType::file, true));
|
||||||
|
|
||||||
forAll(srcFiles, filei)
|
forAll(srcFiles, filei)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -202,15 +202,15 @@ public:
|
|||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const = 0;
|
) const = 0;
|
||||||
|
|
||||||
//- Return the file type: DIRECTORY, FILE or LINK
|
//- Return the file type: directory, file or link
|
||||||
virtual fileName::Type type
|
virtual fileType type
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const bool checkVariants = true,
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const = 0;
|
) const = 0;
|
||||||
|
|
||||||
//- Does the name exist (as DIRECTORY or FILE) in the file system?
|
//- Does the name exist (as directory or file) in the file system?
|
||||||
// Optionally enable/disable check for gzip file.
|
// Optionally enable/disable check for gzip file.
|
||||||
virtual bool exists
|
virtual bool exists
|
||||||
(
|
(
|
||||||
@ -219,14 +219,14 @@ public:
|
|||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const = 0;
|
) const = 0;
|
||||||
|
|
||||||
//- Does the name exist as a DIRECTORY in the file system?
|
//- Does the name exist as a directory in the file system?
|
||||||
virtual bool isDir
|
virtual bool isDir
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const = 0;
|
) const = 0;
|
||||||
|
|
||||||
//- Does the name exist as a FILE in the file system?
|
//- Does the name exist as a file in the file system?
|
||||||
// Optionally enable/disable check for gzip file.
|
// Optionally enable/disable check for gzip file.
|
||||||
virtual bool isFile
|
virtual bool isFile
|
||||||
(
|
(
|
||||||
@ -263,7 +263,7 @@ public:
|
|||||||
virtual fileNameList readDir
|
virtual fileNameList readDir
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const fileName::Type=fileName::FILE,
|
const fileType = fileType::file,
|
||||||
const bool filterVariants = true,
|
const bool filterVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const = 0;
|
) const = 0;
|
||||||
|
|||||||
@ -889,14 +889,14 @@ mode_t Foam::fileOperations::masterUncollatedFileOperation::mode
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::fileName::Type Foam::fileOperations::masterUncollatedFileOperation::type
|
Foam::fileType Foam::fileOperations::masterUncollatedFileOperation::type
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
const bool checkVariants,
|
const bool checkVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return fileName::Type
|
return fileType
|
||||||
(
|
(
|
||||||
masterOp<label, typeOp>
|
masterOp<label, typeOp>
|
||||||
(
|
(
|
||||||
@ -1059,7 +1059,7 @@ bool Foam::fileOperations::masterUncollatedFileOperation::rmDir
|
|||||||
Foam::fileNameList Foam::fileOperations::masterUncollatedFileOperation::readDir
|
Foam::fileNameList Foam::fileOperations::masterUncollatedFileOperation::readDir
|
||||||
(
|
(
|
||||||
const fileName& dir,
|
const fileName& dir,
|
||||||
const fileName::Type type,
|
const fileType type,
|
||||||
const bool filtergz,
|
const bool filtergz,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
) const
|
) const
|
||||||
|
|||||||
@ -156,7 +156,7 @@ protected:
|
|||||||
|
|
||||||
label operator()(const fileName& fName) const
|
label operator()(const fileName& fName) const
|
||||||
{
|
{
|
||||||
return Foam::type(fName, checkVariants_, followLink_);
|
return label(Foam::type(fName, checkVariants_, followLink_));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -371,13 +371,15 @@ protected:
|
|||||||
|
|
||||||
class readDirOp
|
class readDirOp
|
||||||
{
|
{
|
||||||
const fileName::Type type_;
|
const fileType type_;
|
||||||
const bool filterVariants_;
|
const bool filterVariants_;
|
||||||
const bool followLink_;
|
const bool followLink_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
readDirOp
|
readDirOp
|
||||||
(
|
(
|
||||||
const fileName::Type type,
|
const fileType type,
|
||||||
const bool filterVariants,
|
const bool filterVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
)
|
)
|
||||||
@ -389,8 +391,7 @@ protected:
|
|||||||
|
|
||||||
fileNameList operator()(const fileName& fName) const
|
fileNameList operator()(const fileName& fName) const
|
||||||
{
|
{
|
||||||
return
|
return Foam::readDir
|
||||||
Foam::readDir
|
|
||||||
(
|
(
|
||||||
fName,
|
fName,
|
||||||
type_,
|
type_,
|
||||||
@ -530,15 +531,15 @@ public:
|
|||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Return the file type: DIRECTORY, FILE or LINK
|
//- Return the file type: directory, file or link
|
||||||
virtual fileName::Type type
|
virtual fileType type
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const bool checkVariants = true,
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Does the name exist (as DIRECTORY or FILE) in the file system?
|
//- Does the name exist (as directory or file) in the file system?
|
||||||
// Optionally enable/disable check for gzip file.
|
// Optionally enable/disable check for gzip file.
|
||||||
virtual bool exists
|
virtual bool exists
|
||||||
(
|
(
|
||||||
@ -547,14 +548,14 @@ public:
|
|||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Does the name exist as a DIRECTORY in the file system?
|
//- Does the name exist as a directory in the file system?
|
||||||
virtual bool isDir
|
virtual bool isDir
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Does the name exist as a FILE in the file system?
|
//- Does the name exist as a file in the file system?
|
||||||
// Optionally enable/disable check for gzip file.
|
// Optionally enable/disable check for gzip file.
|
||||||
virtual bool isFile
|
virtual bool isFile
|
||||||
(
|
(
|
||||||
@ -591,7 +592,7 @@ public:
|
|||||||
virtual fileNameList readDir
|
virtual fileNameList readDir
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const fileName::Type=fileName::FILE,
|
const fileType = fileType::file,
|
||||||
const bool filterVariants = true,
|
const bool filterVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|||||||
@ -214,7 +214,7 @@ mode_t Foam::fileOperations::uncollatedFileOperation::mode
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::fileName::Type Foam::fileOperations::uncollatedFileOperation::type
|
Foam::fileType Foam::fileOperations::uncollatedFileOperation::type
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
const bool checkVariants,
|
const bool checkVariants,
|
||||||
@ -321,7 +321,7 @@ bool Foam::fileOperations::uncollatedFileOperation::rmDir
|
|||||||
Foam::fileNameList Foam::fileOperations::uncollatedFileOperation::readDir
|
Foam::fileNameList Foam::fileOperations::uncollatedFileOperation::readDir
|
||||||
(
|
(
|
||||||
const fileName& dir,
|
const fileName& dir,
|
||||||
const fileName::Type type,
|
const fileType type,
|
||||||
const bool filtergz,
|
const bool filtergz,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
) const
|
) const
|
||||||
|
|||||||
@ -97,15 +97,15 @@ public:
|
|||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Return the file type: DIRECTORY, FILE or LINK
|
//- Return the file type: directory, file or link
|
||||||
virtual fileName::Type type
|
virtual fileType type
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const bool checkVariants = true,
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Does the name exist (as DIRECTORY or FILE) in the file system?
|
//- Does the name exist (as directory or file) in the file system?
|
||||||
// Optionally enable/disable check for gzip file.
|
// Optionally enable/disable check for gzip file.
|
||||||
virtual bool exists
|
virtual bool exists
|
||||||
(
|
(
|
||||||
@ -114,7 +114,7 @@ public:
|
|||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Does the name exist as a DIRECTORY in the file system?
|
//- Does the name exist as a directory in the file system?
|
||||||
virtual bool isDir
|
virtual bool isDir
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
@ -158,7 +158,7 @@ public:
|
|||||||
virtual fileNameList readDir
|
virtual fileNameList readDir
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const fileName::Type=fileName::FILE,
|
const fileType = fileType::file,
|
||||||
const bool filtergz=true,
|
const bool filtergz=true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|||||||
@ -107,15 +107,15 @@ mode_t mode
|
|||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Return the file type: DIRECTORY or FILE
|
//- Return the file type: directory or file
|
||||||
fileName::Type type
|
fileType type
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const bool checkVariants = true,
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Does the name exist (as DIRECTORY or FILE) in the file system?
|
//- Does the name exist (as directory or file) in the file system?
|
||||||
// Optionally enable/disable check for variant files.
|
// Optionally enable/disable check for variant files.
|
||||||
bool exists
|
bool exists
|
||||||
(
|
(
|
||||||
@ -124,10 +124,10 @@ bool exists
|
|||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Does the name exist as a DIRECTORY in the file system?
|
//- Does the name exist as a directory in the file system?
|
||||||
bool isDir(const fileName&, const bool followLink = true);
|
bool isDir(const fileName&, const bool followLink = true);
|
||||||
|
|
||||||
//- Does the name exist as a FILE in the file system?
|
//- Does the name exist as a file in the file system?
|
||||||
// Optionally enable/disable check for variant files.
|
// Optionally enable/disable check for variant files.
|
||||||
bool isFile
|
bool isFile
|
||||||
(
|
(
|
||||||
@ -164,7 +164,7 @@ double highResLastModified
|
|||||||
fileNameList readDir
|
fileNameList readDir
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const fileName::Type=fileName::FILE,
|
const fileType = fileType::file,
|
||||||
const bool filterVariants = true,
|
const bool filterVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
);
|
);
|
||||||
|
|||||||
@ -24,19 +24,24 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "Switch.H"
|
#include "Switch.H"
|
||||||
#include "error.H"
|
|
||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const char* Foam::Switch::names[Foam::Switch::INVALID+1] =
|
const char* Foam::Switch::names[nSwitchType] =
|
||||||
{
|
{
|
||||||
"false", "true",
|
"false",
|
||||||
"off", "on",
|
"true",
|
||||||
"no", "yes",
|
"off",
|
||||||
"n", "y",
|
"on",
|
||||||
"f", "t",
|
"no",
|
||||||
"none", "true", // Is there a reasonable counterpart to "none"?
|
"yes",
|
||||||
|
"n",
|
||||||
|
"y",
|
||||||
|
"f",
|
||||||
|
"t",
|
||||||
|
"none",
|
||||||
|
"any",
|
||||||
"invalid"
|
"invalid"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -49,35 +54,36 @@ Foam::Switch::switchType Foam::Switch::asEnum
|
|||||||
const bool allowInvalid
|
const bool allowInvalid
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
for (int sw = 0; sw < Switch::INVALID; ++sw)
|
for (switchType sw=switchType::False; sw<switchType::invalid; ++sw)
|
||||||
{
|
{
|
||||||
if (str == names[sw])
|
if (str == names[toInt(sw)])
|
||||||
{
|
{
|
||||||
// handle aliases
|
// Handle aliases
|
||||||
switch (sw)
|
switch (sw)
|
||||||
{
|
{
|
||||||
case Switch::NO_1:
|
case switchType::n:
|
||||||
case Switch::NONE:
|
case switchType::none:
|
||||||
{
|
{
|
||||||
return Switch::NO;
|
return switchType::no;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Switch::YES_1:
|
case switchType::y:
|
||||||
|
case switchType::any:
|
||||||
{
|
{
|
||||||
return Switch::YES;
|
return switchType::yes;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Switch::FALSE_1:
|
case switchType::f:
|
||||||
{
|
{
|
||||||
return Switch::FALSE;
|
return switchType::False;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Switch::TRUE_1:
|
case switchType::t:
|
||||||
{
|
{
|
||||||
return Switch::TRUE;
|
return switchType::True;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +103,7 @@ Foam::Switch::switchType Foam::Switch::asEnum
|
|||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Switch::INVALID;
|
return switchType::invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -116,13 +122,13 @@ Foam::Switch Foam::Switch::lookupOrAddToDict
|
|||||||
|
|
||||||
bool Foam::Switch::valid() const
|
bool Foam::Switch::valid() const
|
||||||
{
|
{
|
||||||
return switch_ <= Switch::NONE;
|
return switch_ <= switchType::none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char* Foam::Switch::asText() const
|
const char* Foam::Switch::asText() const
|
||||||
{
|
{
|
||||||
return names[switch_];
|
return names[toInt(switch_)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ Class
|
|||||||
|
|
||||||
Description
|
Description
|
||||||
A simple wrapper around bool so that it can be read as a word:
|
A simple wrapper around bool so that it can be read as a word:
|
||||||
true/false, on/off, yes/no, y/n, t/f, or none.
|
true/false, on/off, yes/no, y/n, t/f, or none/any.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
Switch.C
|
Switch.C
|
||||||
@ -60,52 +60,61 @@ Ostream& operator<<(Ostream&, const Switch&);
|
|||||||
|
|
||||||
class Switch
|
class Switch
|
||||||
{
|
{
|
||||||
// Private data
|
|
||||||
|
|
||||||
//- The logic and enumerated text representation stored as a single byte
|
|
||||||
unsigned char switch_;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Public data types
|
// Public data types
|
||||||
|
|
||||||
// avoid issues with pre-processor defines
|
|
||||||
#undef FALSE
|
|
||||||
#undef TRUE
|
|
||||||
#undef OFF
|
|
||||||
#undef ON
|
|
||||||
#undef NO
|
|
||||||
#undef YES
|
|
||||||
#undef NO_1
|
|
||||||
#undef YES_1
|
|
||||||
#undef FALSE_1
|
|
||||||
#undef TRUE_1
|
|
||||||
#undef NONE
|
|
||||||
#undef PLACEHOLDER
|
|
||||||
#undef INVALID
|
|
||||||
|
|
||||||
//- The various text representations for a switch value.
|
//- The various text representations for a switch value.
|
||||||
// These also correspond to the entries in names.
|
// These also correspond to the entries in names.
|
||||||
enum switchType
|
enum class switchType : unsigned char
|
||||||
{
|
{
|
||||||
FALSE = 0, TRUE = 1,
|
False = 0,
|
||||||
OFF = 2, ON = 3,
|
True = 1,
|
||||||
NO = 4, YES = 5,
|
off = 2,
|
||||||
NO_1 = 6, YES_1 = 7,
|
on = 3,
|
||||||
FALSE_1 = 8, TRUE_1 = 9,
|
no = 4,
|
||||||
NONE = 10, PLACEHOLDER = 11,
|
yes = 5,
|
||||||
INVALID
|
n = 6,
|
||||||
|
y = 7,
|
||||||
|
f = 8,
|
||||||
|
t = 9,
|
||||||
|
none = 10,
|
||||||
|
any = 11,
|
||||||
|
invalid
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//- Number of switchTypes
|
||||||
|
static const unsigned char nSwitchType =
|
||||||
|
static_cast<unsigned char>(switchType::invalid) + 1;
|
||||||
|
|
||||||
|
//- Convert switchType to integer (unsigned char)
|
||||||
|
inline static unsigned char toInt(const switchType x)
|
||||||
|
{
|
||||||
|
return static_cast<unsigned char>(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Increment the switchType counter
|
||||||
|
inline friend switchType operator++(switchType& x)
|
||||||
|
{
|
||||||
|
return x = switchType(toInt(x) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- The logic and enumerated text representation stored as a single byte
|
||||||
|
switchType switch_;
|
||||||
|
|
||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|
||||||
//- The set of names corresponding to the switchType enumeration
|
//- The set of names corresponding to the switchType enumeration
|
||||||
// Includes an extra entry for "invalid".
|
// Includes an extra entry for "invalid".
|
||||||
static const char* names[INVALID+1];
|
static const char* names[nSwitchType];
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
// Static Member Functions
|
// Static Member Functions
|
||||||
|
|
||||||
//- Return a switchType representation of a word
|
//- Return a switchType representation of a word
|
||||||
@ -119,7 +128,7 @@ public:
|
|||||||
//- Construct null as false
|
//- Construct null as false
|
||||||
Switch()
|
Switch()
|
||||||
:
|
:
|
||||||
switch_(Switch::FALSE)
|
switch_(switchType::False)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Construct from enumerated value
|
//- Construct from enumerated value
|
||||||
@ -131,13 +140,13 @@ public:
|
|||||||
//- Construct from bool
|
//- Construct from bool
|
||||||
Switch(const bool b)
|
Switch(const bool b)
|
||||||
:
|
:
|
||||||
switch_(b ? Switch::TRUE : Switch::FALSE)
|
switch_(b ? switchType::True : switchType::False)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Construct from integer values (treats integer as bool value)
|
//- Construct from integer values (treats integer as bool value)
|
||||||
Switch(const int i)
|
Switch(const int i)
|
||||||
:
|
:
|
||||||
switch_(i ? Switch::TRUE : Switch::FALSE)
|
switch_(i ? switchType::True : switchType::False)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Construct from std::string, string, word
|
//- Construct from std::string, string, word
|
||||||
@ -184,7 +193,7 @@ public:
|
|||||||
//- Conversion to bool
|
//- Conversion to bool
|
||||||
operator bool() const
|
operator bool() const
|
||||||
{
|
{
|
||||||
return (switch_ & 0x1);
|
return (toInt(switch_) & 0x1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Assignment to enumerated value
|
//- Assignment to enumerated value
|
||||||
@ -196,7 +205,7 @@ public:
|
|||||||
//- Assignment to bool
|
//- Assignment to bool
|
||||||
void operator=(const bool b)
|
void operator=(const bool b)
|
||||||
{
|
{
|
||||||
switch_ = (b ? Switch::TRUE : Switch::FALSE);
|
switch_ = (b ? switchType::True : switchType::False);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -89,7 +89,7 @@ Foam::Istream& Foam::operator>>(Istream& is, Switch& s)
|
|||||||
|
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const Switch& s)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const Switch& s)
|
||||||
{
|
{
|
||||||
os << Switch::names[s.switch_];
|
os << Switch::names[int(s.switch_)];
|
||||||
os.check("Ostream& operator<<(Ostream&, const Switch&)");
|
os.check("Ostream& operator<<(Ostream&, const Switch&)");
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,7 +48,7 @@ Foam::fileName::fileName(const wordList& lst)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fileName::Type Foam::fileName::type
|
Foam::fileType Foam::fileName::type
|
||||||
(
|
(
|
||||||
const bool checkVariants,
|
const bool checkVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
|
|||||||
@ -63,6 +63,16 @@ Istream& operator>>(Istream&, fileName&);
|
|||||||
Ostream& operator<<(Ostream&, const fileName&);
|
Ostream& operator<<(Ostream&, const fileName&);
|
||||||
|
|
||||||
|
|
||||||
|
//- Enumeration of file types
|
||||||
|
enum class fileType
|
||||||
|
{
|
||||||
|
undefined,
|
||||||
|
file,
|
||||||
|
directory,
|
||||||
|
link
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class fileName Declaration
|
Class fileName Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -79,16 +89,6 @@ class fileName
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Enumerations to handle file types and modes.
|
|
||||||
enum Type
|
|
||||||
{
|
|
||||||
UNDEFINED,
|
|
||||||
FILE,
|
|
||||||
DIRECTORY,
|
|
||||||
LINK
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|
||||||
static const char* const typeName;
|
static const char* const typeName;
|
||||||
@ -154,9 +154,9 @@ public:
|
|||||||
|
|
||||||
// Interrogation
|
// Interrogation
|
||||||
|
|
||||||
//- Return the file type: FILE, DIRECTORY, UNDEFINED or
|
//- Return the file type: file, directory, undefined or
|
||||||
// LINK (only if followLink=false)
|
// link (only if followLink=false)
|
||||||
Type type
|
fileType type
|
||||||
(
|
(
|
||||||
const bool checkVariants = true,
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
|
|||||||
@ -28,10 +28,10 @@ Description
|
|||||||
A wordRe is a word, but can also have a regular expression for matching
|
A wordRe is a word, but can also have a regular expression for matching
|
||||||
words.
|
words.
|
||||||
|
|
||||||
By default the constructors will generally preserve the argument as a
|
By default the constructors will generally preserve the argument as a string
|
||||||
string literal and the assignment operators will use the wordRe::DETECT
|
literal and the assignment operators will use the wordRe::compOption::detect
|
||||||
compOption to scan the string for regular expression meta characters
|
compOption to scan the string for regular expression meta characters and/or
|
||||||
and/or invalid word characters and react accordingly.
|
invalid word characters and react accordingly.
|
||||||
|
|
||||||
The exceptions are when constructing/assigning from another
|
The exceptions are when constructing/assigning from another
|
||||||
Foam::wordRe (preserve the same type) or from a Foam::word (always
|
Foam::wordRe (preserve the same type) or from a Foam::word (always
|
||||||
@ -92,15 +92,15 @@ public:
|
|||||||
// Public data types
|
// Public data types
|
||||||
|
|
||||||
//- Enumeration with compile options
|
//- Enumeration with compile options
|
||||||
// Note that 'REGEXP' is implicit if 'NOCASE' is specified alone.
|
// Note that 'regexp' is implicit if 'noCase' is specified alone.
|
||||||
enum compOption
|
enum class compOption
|
||||||
{
|
{
|
||||||
LITERAL = 0, //!< treat as a string literal
|
literal = 0, //!< treat as a string literal
|
||||||
DETECT = 1, //!< detect if the string contains meta-characters
|
detect = 1, //!< detect if the string contains meta-characters
|
||||||
REGEXP = 2, //!< treat as regular expression
|
regExp = 2, //!< treat as regular expression
|
||||||
NOCASE = 4, //!< ignore case in regular expression
|
noCase = 4, //!< ignore case in regular expression
|
||||||
DETECT_NOCASE = DETECT | NOCASE,
|
detectNoCase = detect | noCase,
|
||||||
REGEXP_NOCASE = REGEXP | NOCASE
|
regExpNoCase = regExp | noCase
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -130,15 +130,27 @@ public:
|
|||||||
|
|
||||||
//- Construct as copy of character array
|
//- Construct as copy of character array
|
||||||
// Optionally specify how it should be treated.
|
// Optionally specify how it should be treated.
|
||||||
inline explicit wordRe(const char*, const compOption = LITERAL);
|
inline explicit wordRe
|
||||||
|
(
|
||||||
|
const char*,
|
||||||
|
const compOption = compOption::literal
|
||||||
|
);
|
||||||
|
|
||||||
//- Construct as copy of string.
|
//- Construct as copy of string.
|
||||||
// Optionally specify how it should be treated.
|
// Optionally specify how it should be treated.
|
||||||
inline explicit wordRe(const string&, const compOption = LITERAL);
|
inline explicit wordRe
|
||||||
|
(
|
||||||
|
const string&,
|
||||||
|
const compOption = compOption::literal
|
||||||
|
);
|
||||||
|
|
||||||
//- Construct as copy of std::string
|
//- Construct as copy of std::string
|
||||||
// Optionally specify how it should be treated.
|
// Optionally specify how it should be treated.
|
||||||
inline explicit wordRe(const std::string&, const compOption = LITERAL);
|
inline explicit wordRe
|
||||||
|
(
|
||||||
|
const std::string&,
|
||||||
|
const compOption = compOption::literal
|
||||||
|
);
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
// Words are treated as literals, strings with an auto-test
|
// Words are treated as literals, strings with an auto-test
|
||||||
@ -172,10 +184,18 @@ public:
|
|||||||
// Editing
|
// Editing
|
||||||
|
|
||||||
//- Copy string, auto-test for regular expression or other options
|
//- Copy string, auto-test for regular expression or other options
|
||||||
inline void set(const std::string&, const compOption = DETECT);
|
inline void set
|
||||||
|
(
|
||||||
|
const std::string&,
|
||||||
|
const compOption = compOption::detect
|
||||||
|
);
|
||||||
|
|
||||||
//- Copy string, auto-test for regular expression or other options
|
//- Copy string, auto-test for regular expression or other options
|
||||||
inline void set(const char*, const compOption = DETECT);
|
inline void set
|
||||||
|
(
|
||||||
|
const char*,
|
||||||
|
const compOption = compOption::detect
|
||||||
|
);
|
||||||
|
|
||||||
//- Clear string and precompiled regular expression
|
//- Clear string and precompiled regular expression
|
||||||
inline void clear();
|
inline void clear();
|
||||||
@ -236,6 +256,13 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline int operator&
|
||||||
|
(
|
||||||
|
const wordRe::compOption co1,
|
||||||
|
const wordRe::compOption co2
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|||||||
@ -128,18 +128,18 @@ inline bool Foam::wordRe::compile(const compOption opt) const
|
|||||||
{
|
{
|
||||||
bool doCompile = false;
|
bool doCompile = false;
|
||||||
|
|
||||||
if (opt & wordRe::REGEXP)
|
if (opt & compOption::regExp)
|
||||||
{
|
{
|
||||||
doCompile = true;
|
doCompile = true;
|
||||||
}
|
}
|
||||||
else if (opt & wordRe::DETECT)
|
else if (opt & compOption::detect)
|
||||||
{
|
{
|
||||||
if (string::meta<regExp>(*this) || !string::valid<word>(*this))
|
if (string::meta<regExp>(*this) || !string::valid<word>(*this))
|
||||||
{
|
{
|
||||||
doCompile = true;
|
doCompile = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (opt & wordRe::NOCASE)
|
else if (opt & compOption::noCase)
|
||||||
{
|
{
|
||||||
doCompile = true;
|
doCompile = true;
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ inline bool Foam::wordRe::compile(const compOption opt) const
|
|||||||
|
|
||||||
if (doCompile)
|
if (doCompile)
|
||||||
{
|
{
|
||||||
re_.set(*this, (opt & wordRe::NOCASE));
|
re_.set(*this, (opt & compOption::noCase));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -271,21 +271,31 @@ inline void Foam::wordRe::operator=(const keyType& str)
|
|||||||
inline void Foam::wordRe::operator=(const string& str)
|
inline void Foam::wordRe::operator=(const string& str)
|
||||||
{
|
{
|
||||||
string::operator=(str);
|
string::operator=(str);
|
||||||
compile(DETECT); // auto-detect regex
|
compile(compOption::detect); // auto-detect regex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void Foam::wordRe::operator=(const std::string& str)
|
inline void Foam::wordRe::operator=(const std::string& str)
|
||||||
{
|
{
|
||||||
string::operator=(str);
|
string::operator=(str);
|
||||||
compile(DETECT); // auto-detect regex
|
compile(compOption::detect); // auto-detect regex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void Foam::wordRe::operator=(const char* str)
|
inline void Foam::wordRe::operator=(const char* str)
|
||||||
{
|
{
|
||||||
string::operator=(str);
|
string::operator=(str);
|
||||||
compile(DETECT); // auto-detect regex
|
compile(compOption::detect); // auto-detect regex
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline int Foam::operator&
|
||||||
|
(
|
||||||
|
const wordRe::compOption co1,
|
||||||
|
const wordRe::compOption co2
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return int(co1) & int(co2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user