/****************************************************************************/
/* Copyright (c) 2000 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : StringAttribute.cc                                            */
/* Author   :                                                               */
/* Project  :                                                               */
/* Version  : 1.0                                                           */
/* Created  : 02/07/2000                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
#include <string.h>
#include <malloc.h>
#include "StringAttribute.h"
#include "StringConverter.h"

StringAttribute::StringAttribute(const char *name, const char *description,
				 char **valueAddress,
				 const char *defaultString)
  : Attribute(name, description)
{
  _valueAddress = valueAddress;

  if (defaultString) {
    *_valueAddress = strdup(defaultString);
    _hasDefault = True;
  }
}


StringAttribute::~StringAttribute()
{
}


void StringAttribute::setValue(const char *stringRep)
{
  *_valueAddress = strdup(stringRep);
}



const char *StringAttribute::valueString()
{
  if (!valueHasBeenSet() && !hasDefault())
    return "";

  return (const char *)*_valueAddress;

}
