/*
Copyright 2005 Ethan McCallum (ethanqm -at- penguinmail.com)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

or in the file

	LICENSE

which is distributed with this package.

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
Limitations under the License.
*/

#include<TagStack.h>

#include<stack>
#include<cstring>

// - - - - - - - - - - - - - - - - - - - -

const char* const TagStack::TAGNAME_METADATA_package = "http://linux.duke.edu/metadata/common:package" ;

const char* const TagStack::TAGNAME_METADATA_name = "http://linux.duke.edu/metadata/common:name" ;

const char* const TagStack::TAGNAME_METADATA_arch = "http://linux.duke.edu/metadata/common:arch" ;

const char* const TagStack::TAGNAME_METADATA_version = "http://linux.duke.edu/metadata/common:version" ;

const char* const TagStack::TAGNAME_METADATA_location = "http://linux.duke.edu/metadata/common:location" ;

void TagStack::pushTag( const char* name ) {

	/*
	if there were a lot of tags to manage,
	this if/else structure could be replaced
	with queries against a std::map<>...
	*/


	if( 0 == strcmp( name , TAGNAME_METADATA_package ) ){

		stack_.push( TAG_METADATA_package ) ;

	} else if( 0 == strcmp( name , TAGNAME_METADATA_name ) ){

		stack_.push( TAG_METADATA_name ) ;

	} else if( 0 == strcmp( name , TAGNAME_METADATA_arch ) ){

		stack_.push( TAG_METADATA_arch ) ;

	} else if( 0 == strcmp( name , TAGNAME_METADATA_version ) ){

		stack_.push( TAG_METADATA_version ) ;

	} else if( 0 == strcmp( name , TAGNAME_METADATA_location ) ){

		stack_.push( TAG_METADATA_location ) ;

	} else {

		stack_.push( UNKNOWN_TAG ) ;

	}

} // TagStack::pushTag()


void TagStack::popTag() throw() {

	stack_.pop() ;
	return ;

} // TagStack::popTag()


int TagStack::currentTag() throw() {

	return( stack_.top() ) ;

} // TagStack::currentTag()

// - - - - - - - - - - - - - - - - - - - -

