diff --git a/src/OpenFOAM/db/IOobject/IOobject.H b/src/OpenFOAM/db/IOobject/IOobject.H index 7ff2b2a724..d73bade5c0 100644 --- a/src/OpenFOAM/db/IOobject/IOobject.H +++ b/src/OpenFOAM/db/IOobject/IOobject.H @@ -307,6 +307,15 @@ public: const word& name ); + //- Create scope:name1:name2 or scope_name1_name2 string + // An empty scope is ignored. + static inline word scopedName + ( + const std::string& scope, + const word& name1, + const word& name2 + ); + //- Return the IOobject, but also consider an alternative file name. // // \param io The expected IOobject to use @@ -341,7 +350,7 @@ public: // Constructors //- Construct from name, instance, registry, io options - // (default: NO_READ, NO_WRITE, register, non-global) + // (default: NO_READ, NO_WRITE, REGISTER, non-global) IOobject ( const word& name, @@ -351,7 +360,7 @@ public: ); //- Construct from name, instance, local, registry, io options - // (default: NO_READ, NO_WRITE, register, non-global) + // (default: NO_READ, NO_WRITE, REGISTER, non-global) IOobject ( const word& name, @@ -362,7 +371,7 @@ public: ); //- Construct from path, registry, io options. - // (default: NO_READ, NO_WRITE, register, non-global) + // (default: NO_READ, NO_WRITE, REGISTER, non-global) // // Uses fileNameComponents() to split path into components. // A path that starts with a '/' is regarded as a file system path. diff --git a/src/OpenFOAM/db/IOobject/IOobjectI.H b/src/OpenFOAM/db/IOobject/IOobjectI.H index eed345e0d2..f0d0c114b6 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectI.H +++ b/src/OpenFOAM/db/IOobject/IOobjectI.H @@ -54,7 +54,40 @@ inline Foam::word Foam::IOobject::scopedName return name; } - return scope + (IOobject::scopeSeparator + name); + word output; + output.reserve(scope.size() + name.size() + 1); + + output += scope; + output += IOobject::scopeSeparator; + output += name; + return output; +} + + +inline Foam::word Foam::IOobject::scopedName +( + const std::string& scope, + const word& name1, + const word& name2 +) +{ + if (scope.empty()) + { + return IOobject::scopedName(name1, name2); + } + + word output; + output.reserve(scope.size() + name1.size() + name2.size() + 2); + + output += scope; + output += IOobject::scopeSeparator; + output += name1; + if (!name2.empty()) + { + output += IOobject::scopeSeparator; + output += name2; + } + return output; }