We have the following formats for moose path
/foo[0]/bar[0]/baz[1]
But path() methods in many classes, strip off the ending "[n]".Therefore if one wants to join two paths, the resulting path format becomes invalid.
For example, joining path1 = /a[1]/b[0] and path2 = /c[1]/d[0] should produce /a[1]/b[0]/c[1]/d[0]
but since path() returns /a[1]/b
and /c[1]/d
and
joing them results in an invalid path /a[1]/b/c[1]/d
.
To overcome this a function fixPath()
is implemented in global.cpp
file.
Ideally the path functions should return a well-defined path. Till this is
fixed, we call this function with an appropriate warning message printed on the
console.
The problem seems to be the while loop in path() function which removes the ending []
from path.
~~~~
// Function to convert it into its fully separated path.
string Id::path( const string& separator) const
{
string ret = Neutral::path( eref() );
// Trim off trailing []
assert( ret.length() > 0 );
// the 'back' operation is not supported by pre 2011 compilers
while ( ret[ ret.length() - 1 ] == ']' ) { size_t pos = ret.find_last_of( '[' ); if ( pos != string::npos && pos > 0 ) { ret = ret.substr( 0, pos ); } } return ret;
}
~~~~~
Anonymous
Dear Dilawar,
There is a difference in the path method for Ids and for ObjIds.
Ids strip off the [], ObjIds do not. This is useful when building up
paths step by step. Also logically, an Id does not have any indices.
-- Upi
On Thursday 01 May 2014 08:32 PM, dilawars wrote:
Related
Bugs: #134