mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: allow alternative delimiter for fileName::concat. Default: '/'
This commit is contained in:
committed by
Andrew Heather
parent
e3b05494f7
commit
5382ce775f
@ -124,7 +124,8 @@ Foam::fileName Foam::fileName::validate
|
||||
Foam::fileName Foam::fileName::concat
|
||||
(
|
||||
const std::string& s1,
|
||||
const std::string& s2
|
||||
const std::string& s2,
|
||||
const char delim
|
||||
)
|
||||
{
|
||||
const auto n1 = s1.length();
|
||||
@ -135,10 +136,10 @@ Foam::fileName Foam::fileName::concat
|
||||
|
||||
out += s1;
|
||||
|
||||
if (n1 && n2 && s1.back() != '/' && s2.front() != '/')
|
||||
if (n1 && n2 && s1.back() != delim && s2.front() != delim)
|
||||
{
|
||||
// Add separator
|
||||
out += '/';
|
||||
// Add delimiter
|
||||
out += delim;
|
||||
}
|
||||
|
||||
out += s2;
|
||||
@ -473,9 +474,9 @@ bool Foam::fileName::hasExt(const wordRe& ending) const
|
||||
}
|
||||
|
||||
|
||||
Foam::wordList Foam::fileName::components(const char delimiter) const
|
||||
Foam::wordList Foam::fileName::components(const char delim) const
|
||||
{
|
||||
const auto parsed = stringOps::split<string>(*this, delimiter);
|
||||
const auto parsed = stringOps::split<string>(*this, delim);
|
||||
|
||||
wordList words(parsed.size());
|
||||
|
||||
@ -495,10 +496,10 @@ Foam::wordList Foam::fileName::components(const char delimiter) const
|
||||
Foam::word Foam::fileName::component
|
||||
(
|
||||
const size_type cmpt,
|
||||
const char delimiter
|
||||
const char delim
|
||||
) const
|
||||
{
|
||||
const auto parsed = stringOps::split<string>(*this, delimiter);
|
||||
const auto parsed = stringOps::split<string>(*this, delim);
|
||||
|
||||
if (cmpt < parsed.size())
|
||||
{
|
||||
|
||||
@ -149,11 +149,16 @@ public:
|
||||
//- removing duplicate or trailing slashes, etc.
|
||||
static fileName validate(const std::string& s, const bool doClean=true);
|
||||
|
||||
//- Join two strings with '/' as a path separator.
|
||||
// No '/' separator is added if either argument is an empty string or
|
||||
//- Join two strings with a path separator ('/' by default).
|
||||
// No separator is added if either argument is an empty string or
|
||||
// if the arguments already had the path separator at the junction.
|
||||
// Invalid characters are \em not stripped (ie, retained).
|
||||
static fileName concat(const std::string& s1, const std::string& s2);
|
||||
static fileName concat
|
||||
(
|
||||
const std::string& s1,
|
||||
const std::string& s2,
|
||||
const char delim = '/'
|
||||
);
|
||||
|
||||
//- This is a specialized (possibly slower) version of compare()
|
||||
//- that ignores duplicate or trailing slashes.
|
||||
@ -343,14 +348,10 @@ public:
|
||||
// "/abc/def" ("abc", "def")
|
||||
// "/abc/def/" ("abc", "def")
|
||||
// \endverbatim
|
||||
wordList components(const char delimiter = '/') const;
|
||||
wordList components(const char delim = '/') const;
|
||||
|
||||
//- Return a single component of the path
|
||||
word component
|
||||
(
|
||||
const size_type cmpt,
|
||||
const char delimiter = '/'
|
||||
) const;
|
||||
word component(const size_type cmpt, const char delim = '/') const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
Reference in New Issue
Block a user