Skip to content
Snippets Groups Projects
Commit 4428aeed authored by Henry's avatar Henry
Browse files

IOobject: Add support for group name

.group() returns the group name of the object otherwise null
groupName(name, group) returns the constructed group name (currently name.group)
parent ecd53eae
No related merge requests found
......@@ -243,6 +243,21 @@ const Foam::fileName& Foam::IOobject::caseName() const
}
Foam::word Foam::IOobject::group() const
{
word::size_type i = name_.find_last_of('.');
if (i == word::npos || i == 0)
{
return word::null;
}
else
{
return name_.substr(i+1, word::npos);
}
}
const Foam::fileName& Foam::IOobject::rootPath() const
{
return time().rootPath();
......
......@@ -154,6 +154,7 @@ private:
//- IOobject state
objectState objState_;
protected:
// Protected Member Functions
......@@ -187,6 +188,9 @@ public:
word& name
);
template<class Name>
static inline word groupName(Name name, const word& group);
// Constructors
......@@ -313,6 +317,9 @@ public:
// Path components
//- Return group (extension part of name)
word group() const;
const fileName& rootPath() const;
const fileName& caseName() const;
......
......@@ -27,6 +27,20 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Name>
inline Foam::word Foam::IOobject::groupName(Name name, const word& group)
{
if (group != word::null)
{
return name + ('.' + group);
}
else
{
return name;
}
}
template<class Stream>
inline Stream& Foam::IOobject::writeBanner(Stream& os, bool noHint)
{
......
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