/* This software is distributed under the Lesser General Public License */
//
// Attributes.cpp
//
// This file implements the classes
//   GT_Attribute_Base
//   GT_Attribut<T>
//   GT_Attributes
//   GT_List_of_Attributes
//
//------------------------------------------ CVS
//
// CVS Headers -- The following headers are generated by the CVS
// version control system. Note that especially the attribute
// Author is not necessarily the author of the code.
//
// $Source: /home/br/CVS/graphlet/src/gt_base/Attribute_string.cpp,v $
// $Author: himsolt $
// $Revision: 1.2 $
// $Date: 1999/03/05 20:43:06 $
// $Locker:  $
// $State: Exp $
//
//------------------------------------------ CVS
//
// (C) University of Passau 1995-1999, graphlet Project
//

#include "Graphlet.h"
#include "GML.h"
#include "Key_description.h"

#include "Attribute_string.h"


//////////////////////////////////////////
//
// class GT_Attribute_string
//
//////////////////////////////////////////


GT_Attribute_string::GT_Attribute_string (const GT_Key key, const string& i,
    const int flags) :
	GT_Attribute_Base (key, flags)
{
    the_value = i;
    the_flags |= the_is_string;
}


GT_Attribute_string::~GT_Attribute_string()
{
}


//////////////////////////////////////////
//
// Cloning
//
//////////////////////////////////////////


void GT_Attribute_string::copy (const GT_Attribute_string* from,
    GT_Copy type)
{
    GT_Attribute_Base::copy (from, type);
    the_value = from->the_value;
}


GT_Attribute_Base* GT_Attribute_string::clone (GT_Copy /* type */) const
{
    if (the_flags | the_is_safe) {
	return new GT_Attribute_string (the_key, the_value, the_flags);
    } else {
	return 0;
    }
}


//////////////////////////////////////////
//
// Printing
//
//////////////////////////////////////////


void GT_Attribute_string::print (ostream &out) const
{
    if (the_key.description()->safe() || (the_flags & the_is_safe)) {
	baseclass::print (out);
	GT_print (out, the_value);
    }
}



//////////////////////////////////////////
//
// Value extraction
//
//////////////////////////////////////////


bool GT_Attribute_string::value_string (string& i) const
{
    i = the_value;
    return true;
}
