mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
IOobject: Added member function "member()" which returns the member name of the object
i.e. without the group suffix. Patch provided by William Bainbridge
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -31,23 +31,12 @@ License
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
defineTypeNameAndDebug(IOobject, 0);
|
defineTypeNameAndDebug(IOobject, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// Return components following the IOobject requirements
|
|
||||||
//
|
|
||||||
// behaviour
|
|
||||||
// input IOobject(instance, local, name)
|
|
||||||
// ----- ------
|
|
||||||
// "foo" ("", "", "foo")
|
|
||||||
// "foo/bar" ("foo", "", "bar")
|
|
||||||
// "/XXX/bar" ("/XXX", "", "bar")
|
|
||||||
// "foo/bar/" ERROR - no name
|
|
||||||
// "foo/xxx/bar" ("foo", "xxx", "bar")
|
|
||||||
// "foo/xxx/yyy/bar" ("foo", "xxx/yyy", "bar")
|
|
||||||
bool Foam::IOobject::fileNameComponents
|
bool Foam::IOobject::fileNameComponents
|
||||||
(
|
(
|
||||||
const fileName& path,
|
const fileName& path,
|
||||||
@ -72,8 +61,7 @@ bool Foam::IOobject::fileNameComponents
|
|||||||
"fileName&, "
|
"fileName&, "
|
||||||
"word&"
|
"word&"
|
||||||
")"
|
")"
|
||||||
)
|
) << " called with directory: " << path << endl;
|
||||||
<< " called with directory: " << path << endl;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -83,7 +71,7 @@ bool Foam::IOobject::fileNameComponents
|
|||||||
string::size_type last = path.rfind('/');
|
string::size_type last = path.rfind('/');
|
||||||
instance = path.substr(0, last);
|
instance = path.substr(0, last);
|
||||||
|
|
||||||
// check afterwards
|
// Check afterwards
|
||||||
name.string::operator=(path.substr(last+1));
|
name.string::operator=(path.substr(last+1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -114,7 +102,7 @@ bool Foam::IOobject::fileNameComponents
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// check for valid (and stripped) name, regardless of the debug level
|
// Check for valid (and stripped) name, regardless of the debug level
|
||||||
if (name.empty() || string::stripInvalid<word>(name))
|
if (name.empty() || string::stripInvalid<word>(name))
|
||||||
{
|
{
|
||||||
WarningIn
|
WarningIn
|
||||||
@ -287,6 +275,21 @@ Foam::word Foam::IOobject::group() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::word Foam::IOobject::member() const
|
||||||
|
{
|
||||||
|
word::size_type i = name_.find_last_of('.');
|
||||||
|
|
||||||
|
if (i == word::npos || i == 0)
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return name_.substr(0, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const Foam::fileName& Foam::IOobject::rootPath() const
|
const Foam::fileName& Foam::IOobject::rootPath() const
|
||||||
{
|
{
|
||||||
return time().rootPath();
|
return time().rootPath();
|
||||||
@ -312,7 +315,7 @@ Foam::fileName Foam::IOobject::path
|
|||||||
const fileName& local
|
const fileName& local
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
//Note: can only be called with relative instance since is word type
|
// Note: can only be called with relative instance since is word type
|
||||||
return rootPath()/caseName()/instance/db_.dbDir()/local;
|
return rootPath()/caseName()/instance/db_.dbDir()/local;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -180,6 +180,14 @@ public:
|
|||||||
// Static Member Functions
|
// Static Member Functions
|
||||||
|
|
||||||
//- Split path into instance, local, name components
|
//- Split path into instance, local, name components
|
||||||
|
// input IOobject(instance, local, name)
|
||||||
|
// ----- ------
|
||||||
|
// "foo" ("", "", "foo")
|
||||||
|
// "foo/bar" ("foo", "", "bar")
|
||||||
|
// "/XXX/bar" ("/XXX", "", "bar")
|
||||||
|
// "foo/bar/" ERROR - no name
|
||||||
|
// "foo/xxx/bar" ("foo", "xxx", "bar")
|
||||||
|
// "foo/xxx/yyy/bar" ("foo", "xxx/yyy", "bar")
|
||||||
static bool fileNameComponents
|
static bool fileNameComponents
|
||||||
(
|
(
|
||||||
const fileName& path,
|
const fileName& path,
|
||||||
@ -320,6 +328,9 @@ public:
|
|||||||
//- Return group (extension part of name)
|
//- Return group (extension part of name)
|
||||||
word group() const;
|
word group() const;
|
||||||
|
|
||||||
|
//- Return member (name without the extension)
|
||||||
|
word member() const;
|
||||||
|
|
||||||
const fileName& rootPath() const;
|
const fileName& rootPath() const;
|
||||||
|
|
||||||
const fileName& caseName() const;
|
const fileName& caseName() const;
|
||||||
@ -432,7 +443,7 @@ Ostream& operator<<(Ostream& os, const InfoProxy<IOobject>& ip);
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
# include "IOobjectI.H"
|
#include "IOobjectI.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user