#include "ppdc-private.h"
ppdcOption::ppdcOption(ppdcOptType ot, const char *n, const char *t, ppdcOptSection s, float o) : ppdcShared()
{
PPDC_NEW;
type = ot;
name = new ppdcString(n);
text = new ppdcString(t);
section = s;
order = o;
choices = new ppdcArray();
defchoice = 0;
}
ppdcOption::ppdcOption(ppdcOption *o) {
PPDC_NEW;
o->name->retain();
o->text->retain();
if (o->defchoice)
o->defchoice->retain();
type = o->type;
name = o->name;
text = o->text;
section = o->section;
order = o->order;
choices = new ppdcArray(o->choices);
defchoice = o->defchoice;
}
ppdcOption::~ppdcOption()
{
PPDC_DELETE;
name->release();
text->release();
if (defchoice)
defchoice->release();
choices->release();
}
ppdcChoice * ppdcOption::find_choice(const char *n) {
ppdcChoice *c;
for (c = (ppdcChoice *)choices->first(); c; c = (ppdcChoice *)choices->next())
if (!_cups_strcasecmp(n, c->name->value))
return (c);
return (0);
}
void
ppdcOption::set_defchoice(ppdcChoice *c) {
if (defchoice)
defchoice->release();
if (c->name)
c->name->retain();
defchoice = c->name;
}