ENH: fileName hasPath(), removePath() methods

- improved move constructors/assignments for fileName, string, etc
This commit is contained in:
Mark Olesen
2018-10-03 14:05:45 +02:00
parent 3963cd95d9
commit 6c91048e8b
15 changed files with 469 additions and 371 deletions

View File

@ -621,12 +621,18 @@ int main(int argc, char *argv[])
<< "pathName.name() = >" << pathName.name() << "<\n"
<< "pathName.path() = " << pathName.path() << nl
<< "pathName.ext() = >" << pathName.ext() << "<\n"
<< "pathName.name(true) = >" << pathName.name(true) << "<\n";
<< "pathName.nameLessExt= >" << pathName.nameLessExt() << "<\n";
Info<< "pathName.components() = " << pathName.components() << nl
<< "pathName.component(2) = " << pathName.component(2) << nl
<< endl;
Info<< "hasPath = " << Switch(pathName.hasPath()) << nl;
pathName.removePath();
Info<< "removed path = " << pathName << nl;
Info<< nl << nl;
// try with different combination
// The final one should emit warnings
for (label start = 0; start <= wrdList.size(); ++start)

View File

@ -36,6 +36,7 @@ Description
#include "uint.H"
#include "scalar.H"
#include "Switch.H"
#include "fileName.H"
#include "stringList.H"
using namespace Foam;
@ -64,6 +65,34 @@ int main(int argc, char *argv[])
subDict.add("value2", "test2");
dict.add("FOAM_RUN", subDict);
if (false)
{
typedef std::string inputType;
typedef string outputType;
inputType in1("move-construct-from");
Info<<"move construct from " << in1.length() << nl;
outputType out1(std::move(in1));
Info<<"after move construct "
<< out1.size() << ", " << in1.size() << nl;
in1 = "move-assign-from";
out1 = "some-text-rubbish";
out1.resize(10);
Info<<"move assign from " << in1.length() << nl;
out1 = std::move(in1);
Info<<"after move assign "
<< out1.size() << ", " << in1.size() << nl;
return 0;
}
// basic expansions
{