Commit 50055b3d authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: add IOobject::scopedName() static method

- preliminary to further changes (#1675)
parent 119796b6
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -37,6 +37,17 @@ namespace Foam
defineTypeNameAndDebug(IOobject, 0);
}
char Foam::IOobject::scopeSeparator
(
#ifdef _WIN32
// Windows: using ':' for scoping conflicts with d:/path etc
Foam::debug::infoSwitch("scopeSeparator", '_')
#else
Foam::debug::infoSwitch("scopeSeparator", ':')
#endif
);
const Foam::Enum
<
Foam::IOobject::fileCheckTypes
......
......@@ -204,6 +204,10 @@ public:
// Static Data Members
//- Character for scoping object names (':' or '_')
// Change with caution.
static char scopeSeparator;
//- Type of file modification checking
static fileCheckTypes fileModificationChecking;
......@@ -233,11 +237,10 @@ public:
word& name
);
//- Create dot-delimited name.group
// If the group is an empty string, it is ignored.
//- Create dot-delimited name.group string
// An empty group is ignored.
template<class StringType>
static inline word groupName(StringType name, const word& group);
static inline word groupName(StringType base, const word& group);
//- Return group (extension part of name)
static word group(const word& name);
......@@ -245,6 +248,11 @@ public:
//- Return member (name without the extension)
static word member(const word& name);
//- Create scope:name or scope_name string
// An empty scope or name is ignored.
template<class StringType>
static inline word scopedName(StringType scope, const word& name);
//- Return the IOobject, but also consider an alternative file name.
//
// \param io The expected IOobject to use
......
......@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -28,14 +28,38 @@ License
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class StringType>
inline Foam::word Foam::IOobject::groupName(StringType name, const word& group)
inline Foam::word Foam::IOobject::groupName
(
StringType base,
const word& group
)
{
if (group.empty())
{
return base;
}
return base + ('.' + group);
}
template<class StringType>
inline Foam::word Foam::IOobject::scopedName
(
StringType scope,
const word& name
)
{
if (name.empty())
{
return scope;
}
else if (scope.empty())
{
return name;
}
return name + ('.' + group);
return scope + (IOobject::scopeSeparator + name);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment