/* * RpChoice - Rappture 2.0 About XML object * * ====================================================================== * AUTHOR: Derrick Kearney, Purdue University * Copyright (c) 2004-2005 Purdue Research Foundation * * See the file "license.terms" for information on usage and * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. * ====================================================================== */ #include "RpChoice.h" /**********************************************************************/ // METHOD: setDefaultValue() /// Set the default value of a RpChoice object. /** */ RpChoice& RpChoice::setDefaultValue(std::string newDefaultVal) { std::string* def = NULL; def = (std::string*) RpVariable::getDefaultValue(); if (!def) { RpVariable::setDefaultValue(new std::string (newDefaultVal)); } else { *def = newDefaultVal; } return *this; } /**********************************************************************/ // METHOD: setCurrentValue() /// Set the current value of a RpChoice object. /** */ RpChoice& RpChoice::setCurrentValue(std::string newCurrentVal) { std::string* cur = (std::string*) RpVariable::getCurrentValue(); std::string* def = (std::string*) RpVariable::getDefaultValue(); if (cur == def) { RpVariable::setCurrentValue(new std::string (newCurrentVal)); } else { *cur = newCurrentVal; } return *this; } /**********************************************************************/ // METHOD: setOption() /// Set an option for this object. /** */ RpChoice& RpChoice::setOption(std::string newOption) { options.push_back(RpOption(newOption)); return *this; } /**********************************************************************/ // METHOD: deleteOption() /// Delete the provided option from this object. /** */ RpChoice& RpChoice::deleteOption(std::string optionName) { int lvc = 0; int vsize = options.size(); // std::vector::iterator tempIterator; /* for (lvc=0,tempIterator=options.begin();lvc