From bf53de3dfa4db68627f2935e6b2144835604df3a Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 16 Oct 2009 16:09:02 +0000 Subject: Finally added the substream class, and added getByPath (for properties) and getChildByPath (for groups) to the TafGroup class. --- src/tafgroup.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/tafgroup.cpp') diff --git a/src/tafgroup.cpp b/src/tafgroup.cpp index 1837bd8..9440912 100644 --- a/src/tafgroup.cpp +++ b/src/tafgroup.cpp @@ -162,3 +162,40 @@ const Bu::FString &Bu::TafGroup::getProperty( const Bu::FString &sName, } } +const Bu::TafGroup *Bu::TafGroup::getChildByPath( + const Bu::FString &sPath ) const +{ + return getChildByPath( sPath.split('/') ); +} + +const Bu::TafGroup *Bu::TafGroup::getChildByPath( Bu::StrList lPath ) const +{ + const Bu::TafGroup *cur = this; + + for( Bu::StrList::const_iterator i = lPath.begin(); i; i++ ) + { + cur = cur->getChild( *i ); + } + + return cur; +} + +const Bu::FString &Bu::TafGroup::getByPath( const Bu::FString &sPath ) const +{ + return getByPath( sPath.split('/') ); +} + +const Bu::FString &Bu::TafGroup::getByPath( Bu::StrList lPath ) const +{ + const Bu::TafGroup *cur = this; + + for( Bu::StrList::const_iterator i = lPath.begin(); i; i++ ) + { + if( !(i+1) ) + break; + cur = cur->getChild( *i ); + } + + return cur->getProperty( lPath.last() ); +} + -- cgit v1.2.3