diff --git a/applications/test/string/Test-string.C b/applications/test/string/Test-string.C index d2584be13f..37f49b9a7a 100644 --- a/applications/test/string/Test-string.C +++ b/applications/test/string/Test-string.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011, 2016 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011, 2016-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2013 OpenFOAM Foundation @@ -40,6 +40,7 @@ Description #include "Switch.H" #include "fileName.H" #include "stringList.H" +#include "stringOps.H" using namespace Foam; @@ -132,7 +133,8 @@ int main(int argc, char *argv[]) string output(stringOps::expand(input)); Info<< "input: " << input << nl - << "expand: " << output << nl << nl; + << "expand: " << output << nl + << "split: " << stringOps::split(output, "/") << nl << nl; } } diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H index 3a31cfcbc5..e195c5b3a9 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.H +++ b/src/OpenFOAM/containers/Lists/UList/UList.H @@ -58,6 +58,7 @@ SourceFiles #include #include #include +#include // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -567,6 +568,10 @@ Ostream& operator<<(Ostream& os, const UList& list) return list.writeList(os, Detail::ListPolicy::short_length::value); } +//- Write std::vector to Ostream +template +Ostream& operator<<(Ostream& os, const std::vector& list); + // * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * // @@ -666,6 +671,7 @@ struct sizeOp #ifdef NoRepository #include "UList.C" + #include "stdVectorIO.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/Lists/UList/stdVectorIO.C b/src/OpenFOAM/containers/Lists/UList/stdVectorIO.C new file mode 100644 index 0000000000..f1cfb363f2 --- /dev/null +++ b/src/OpenFOAM/containers/Lists/UList/stdVectorIO.C @@ -0,0 +1,60 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "UList.H" +#include "Ostream.H" +#include "token.H" +#include + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +template +Foam::Ostream& Foam::operator<<(Ostream& os, const std::vector& list) +{ + auto iter = list.cbegin(); + const auto last = list.cend(); + + // Write ascii list contents, no breaks + + os << label(list.size()) << token::BEGIN_LIST; + + if (iter != last) + { + os << *iter; + + for (++iter; iter != last; ++iter) + { + os << token::SPACE << *iter; + } + } + + os << token::END_LIST; + + os.check(FUNCTION_NAME); + return os; +} + + +// ************************************************************************* //