mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'style-string-access' into 'develop'
Consistent use of string methods See merge request !128
This commit is contained in:
@ -83,7 +83,8 @@ int main(int argc, char *argv[])
|
||||
Info<<"camel-case => " << (word("camel") & "case") << nl;
|
||||
for (const auto& s : { " text with \"spaces'", "08/15 value" })
|
||||
{
|
||||
Info<<"validated \"" << s << "\" => " << word::validated(s) << nl;
|
||||
Info<<"validated \"" << s << "\" => "
|
||||
<< word::validated(s, true) << nl;
|
||||
}
|
||||
Info<< nl;
|
||||
|
||||
|
||||
3
applications/test/stringSplit/Make/files
Normal file
3
applications/test/stringSplit/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-stringSplit.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-stringSplit
|
||||
0
applications/test/stringSplit/Make/options
Normal file
0
applications/test/stringSplit/Make/options
Normal file
81
applications/test/stringSplit/Test-stringSplit.C
Normal file
81
applications/test/stringSplit/Test-stringSplit.C
Normal file
@ -0,0 +1,81 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Application
|
||||
Test-stringSplit
|
||||
|
||||
Description
|
||||
Test string splitting
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "fileName.H"
|
||||
#include "stringOps.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
template<class String>
|
||||
void printSplitting(const String& str, const char delimiter)
|
||||
{
|
||||
auto split = stringOps::split(str, delimiter);
|
||||
|
||||
Info<< "string {" << str.size() << " chars} = " << str << nl
|
||||
<< split.size() << " elements {" << split.length() << " chars}"
|
||||
<< nl;
|
||||
|
||||
unsigned i = 0;
|
||||
for (const auto s : split)
|
||||
{
|
||||
Info<< "[" << i++ << "] {" << s.length() << " chars} = "
|
||||
<< s.str() << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noBanner();
|
||||
argList::noParallel();
|
||||
|
||||
argList args(argc, argv, false, true);
|
||||
|
||||
if (args.size() <= 1 && args.options().empty())
|
||||
{
|
||||
args.printUsage();
|
||||
}
|
||||
|
||||
for (label argi=1; argi < args.size(); ++argi)
|
||||
{
|
||||
printSplitting(args[argi], '/');
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -221,6 +221,7 @@ redundantBlock {space}({comment}|{unknownPeriodicFace}|{periodicFace
|
||||
endOfSection {space}")"{space}
|
||||
|
||||
|
||||
/* balance "-quoted for editor */
|
||||
|
||||
/* ------------------------------------------------------------------------ *\
|
||||
----- Exclusive start states -----
|
||||
@ -693,7 +694,7 @@ endOfSection {space}")"{space}
|
||||
{lbrac}{label} {
|
||||
Warning
|
||||
<< "Found unknown block of type: "
|
||||
<< Foam::string(YYText())(1, YYLeng()-1) << nl
|
||||
<< std::string(YYText()).substr(1, YYLeng()-1) << nl
|
||||
<< " on line " << lineNo << endl;
|
||||
|
||||
yy_push_state(ignoreBlock);
|
||||
|
||||
@ -903,10 +903,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Strip off anything after #
|
||||
string::size_type i = rawLine.find_first_of("#");
|
||||
string::size_type i = rawLine.find('#');
|
||||
if (i != string::npos)
|
||||
{
|
||||
rawLine = rawLine(0, i);
|
||||
rawLine.resize(i);
|
||||
}
|
||||
|
||||
if (rawLine.empty())
|
||||
|
||||
@ -254,7 +254,7 @@ bool merge
|
||||
|
||||
if (key[0] == '~')
|
||||
{
|
||||
word eraseKey = key(1, key.size()-1);
|
||||
const word eraseKey = key.substr(1);
|
||||
if (thisDict.remove(eraseKey))
|
||||
{
|
||||
// Mark thisDict entry as having been match for wildcard
|
||||
@ -325,7 +325,7 @@ bool merge
|
||||
|
||||
if (key[0] == '~')
|
||||
{
|
||||
word eraseKey = key(1, key.size()-1);
|
||||
const word eraseKey = key.substr(1);
|
||||
|
||||
// List of indices into thisKeys
|
||||
labelList matches
|
||||
|
||||
Reference in New Issue
Block a user