From 96b07a22f5392f5d7f821f5743deb3d64bd94e89 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 16 Oct 2009 12:59:45 +0000 Subject: Although this looks like a load of code changes, this represents no functional change to the Taf system. Really all that's happened is I've broken out the core taf data types into seperate files, and gone ahead and created a helpful new header file ("taf.h") that will include the entire taf system, including the reader and writer for you. This means that a lot of programs will start complaining, but fortunately, there's an easy solution, if it complains about taf, make sure to include taf.h at the top, instead of other taf files and you'll be set. The next set of changes will add lots of helpers to the taf system and change the reader to read non-const structures, i.e. I'll actually add editing support to created taf structures. --- src/tafnode.cpp | 195 -------------------------------------------------------- 1 file changed, 195 deletions(-) (limited to 'src/tafnode.cpp') diff --git a/src/tafnode.cpp b/src/tafnode.cpp index 8ea2e95..e7711fb 100644 --- a/src/tafnode.cpp +++ b/src/tafnode.cpp @@ -23,198 +23,3 @@ Bu::TafNode::NodeType Bu::TafNode::getType() const return eType; } -Bu::TafGroup::TafGroup( const Bu::FString &sName ) : - TafNode( typeGroup ), - sName( sName ) -{ -} - -Bu::TafGroup::~TafGroup() -{ - for( NodeList::iterator i = lChildren.begin(); i != lChildren.end(); i++ ) - { - delete (*i); - } -} - -const Bu::FString &Bu::TafGroup::getName() const -{ - return sName; -} - -void Bu::TafGroup::setName( const Bu::FString &sName ) -{ - this->sName = sName; -} - -Bu::TafNode *Bu::TafGroup::addChild( Bu::TafNode *pNode ) -{ - switch( pNode->getType() ) - { - case typeGroup: - addChild( (Bu::TafGroup *)pNode ); - break; - - case typeProperty: - addChild( (Bu::TafProperty *)pNode ); - break; - - case typeComment: - addChild( (Bu::TafComment *)pNode ); - break; - } - - return pNode; -} - -Bu::TafGroup *Bu::TafGroup::addChild( TafGroup *pNode ) -{ - TafGroup *pGroup = (TafGroup *)pNode; - if( !hChildren.has( pGroup->getName() ) ) - hChildren.insert( pGroup->getName(), GroupList() ); - hChildren.get( pGroup->getName() ).append( pGroup ); - lChildren.append( pNode ); - return pNode; -} - -Bu::TafProperty *Bu::TafGroup::addChild( TafProperty *pNode ) -{ - TafProperty *pProperty = (TafProperty *)pNode; - if( !hProp.has( pProperty->getName() ) ) - hProp.insert( pProperty->getName(), PropList() ); - hProp.get( pProperty->getName() ).append( pProperty->getValue() ); - lChildren.append( pNode ); - return pNode; -} - -Bu::TafComment *Bu::TafGroup::addChild( TafComment *pNode ) -{ - lChildren.append( pNode ); - return pNode; -} - -Bu::TafGroup *Bu::TafGroup::addGroup( const Bu::FString &sName ) -{ - return addChild( new TafGroup( sName ) ); -} - -Bu::TafProperty *Bu::TafGroup::addProperty( - const Bu::FString &sName, const Bu::FString &sValue ) -{ - return addChild( new TafProperty( sName, sValue ) ); -} - -bool Bu::TafGroup::hasChild( const Bu::FString &sName ) const -{ - return hChildren.has( sName ); -} - -const Bu::TafGroup::GroupList &Bu::TafGroup::getChildren( const Bu::FString &sName ) const -{ - try { - return hChildren.get( sName ); - } catch( Bu::HashException &e ) - { - throw Bu::TafException("No children of group \"%s\" match \"%s\".", - this->sName.getStr(), sName.getStr() ); - } -} - -const Bu::TafGroup::NodeList &Bu::TafGroup::getChildren() const -{ - return lChildren; -} - -const Bu::TafGroup *Bu::TafGroup::getChild( const Bu::FString &sName ) const -{ - try { - return hChildren.get( sName ).first(); - } catch( Bu::HashException &e ) - { - throw Bu::TafException("No children of group \"%s\" match \"%s\".", - this->sName.getStr(), sName.getStr() ); - } -} - -bool Bu::TafGroup::hasProperty( const Bu::FString &sName ) const -{ - return hProp.has( sName ); -} - -const Bu::TafGroup::PropList &Bu::TafGroup::getProperties( const Bu::FString &sName ) const -{ - try { - return hProp.get( sName ); - } catch( Bu::HashException &e ) - { - throw Bu::TafException("No properties of group \"%s\" match \"%s\".", - this->sName.getStr(), sName.getStr() ); - } -} - -const Bu::FString &Bu::TafGroup::getProperty( const Bu::FString &sName ) const -{ - try { - return hProp.get( sName ).first(); - } catch( Bu::HashException &e ) - { - throw Bu::TafException("No properties of group \"%s\" match \"%s\".", - this->sName.getStr(), sName.getStr() ); - } -} - -const Bu::FString &Bu::TafGroup::getProperty( const Bu::FString &sName, - const Bu::FString &sDef ) const -{ - try - { - return hProp.get( sName ).first(); - } - catch( Bu::HashException &e ) - { - return sDef; - } -} - -Bu::TafProperty::TafProperty( const Bu::FString &sName, const Bu::FString &sValue ) : - TafNode( typeProperty ), - sName( sName ), - sValue( sValue ) -{ -} - -Bu::TafProperty::~TafProperty() -{ -} - -const Bu::FString &Bu::TafProperty::getName() const -{ - return sName; -} - -const Bu::FString &Bu::TafProperty::getValue() const -{ - return sValue; -} - -Bu::TafComment::TafComment( const Bu::FString &sText, bool bEOL ) : - TafNode( typeComment ), - sText( sText ), - bEOL( bEOL ) -{ -} - -Bu::TafComment::~TafComment() -{ -} - -const Bu::FString &Bu::TafComment::getText() const -{ - return sText; -} - -bool Bu::TafComment::isEOLStyle() const -{ - return bEOL; -} - -- cgit v1.2.3