Blame ppdc/ppdc-option.cxx

Packit 2fc92b
//
Packit 2fc92b
// Option class for the CUPS PPD Compiler.
Packit 2fc92b
//
Packit 2fc92b
// Copyright 2007-2011 by Apple Inc.
Packit 2fc92b
// Copyright 2002-2005 by Easy Software Products.
Packit 2fc92b
//
Packit 2fc92b
// These coded instructions, statements, and computer programs are the
Packit 2fc92b
// property of Apple Inc. and are protected by Federal copyright
Packit 2fc92b
// law.  Distribution and use rights are outlined in the file "LICENSE.txt"
Packit 2fc92b
// which should have been included with this file.  If this file is
Packit 2fc92b
// missing or damaged, see the license at "http://www.cups.org/".
Packit 2fc92b
//
Packit 2fc92b
Packit 2fc92b
//
Packit 2fc92b
// Include necessary headers...
Packit 2fc92b
//
Packit 2fc92b
Packit 2fc92b
#include "ppdc-private.h"
Packit 2fc92b
Packit 2fc92b
Packit 2fc92b
//
Packit 2fc92b
// 'ppdcOption::ppdcOption()' - Create a new option.
Packit 2fc92b
//
Packit 2fc92b
Packit 2fc92b
ppdcOption::ppdcOption(ppdcOptType    ot,	// I - Option type
Packit 2fc92b
                       const char     *n,	// I - Option name
Packit 2fc92b
		       const char     *t,	// I - Option text
Packit 2fc92b
		       ppdcOptSection s,	// I - Section
Packit 2fc92b
                       float          o)	// I - Ordering number
Packit 2fc92b
  : ppdcShared()
Packit 2fc92b
{
Packit 2fc92b
  PPDC_NEW;
Packit 2fc92b
Packit 2fc92b
  type      = ot;
Packit 2fc92b
  name      = new ppdcString(n);
Packit 2fc92b
  text      = new ppdcString(t);
Packit 2fc92b
  section   = s;
Packit 2fc92b
  order     = o;
Packit 2fc92b
  choices   = new ppdcArray();
Packit 2fc92b
  defchoice = 0;
Packit 2fc92b
}
Packit 2fc92b
Packit 2fc92b
Packit 2fc92b
//
Packit 2fc92b
// 'ppdcOption::ppdcOption()' - Copy a new option.
Packit 2fc92b
//
Packit 2fc92b
Packit 2fc92b
ppdcOption::ppdcOption(ppdcOption *o)		// I - Template option
Packit 2fc92b
{
Packit 2fc92b
  PPDC_NEW;
Packit 2fc92b
Packit 2fc92b
  o->name->retain();
Packit 2fc92b
  o->text->retain();
Packit 2fc92b
  if (o->defchoice)
Packit 2fc92b
    o->defchoice->retain();
Packit 2fc92b
Packit 2fc92b
  type      = o->type;
Packit 2fc92b
  name      = o->name;
Packit 2fc92b
  text      = o->text;
Packit 2fc92b
  section   = o->section;
Packit 2fc92b
  order     = o->order;
Packit 2fc92b
  choices   = new ppdcArray(o->choices);
Packit 2fc92b
  defchoice = o->defchoice;
Packit 2fc92b
}
Packit 2fc92b
Packit 2fc92b
Packit 2fc92b
//
Packit 2fc92b
// 'ppdcOption::~ppdcOption()' - Destroy an option.
Packit 2fc92b
//
Packit 2fc92b
Packit 2fc92b
ppdcOption::~ppdcOption()
Packit 2fc92b
{
Packit 2fc92b
  PPDC_DELETE;
Packit 2fc92b
Packit 2fc92b
  name->release();
Packit 2fc92b
  text->release();
Packit 2fc92b
  if (defchoice)
Packit 2fc92b
    defchoice->release();
Packit 2fc92b
  choices->release();
Packit 2fc92b
}
Packit 2fc92b
Packit 2fc92b
Packit 2fc92b
//
Packit 2fc92b
// 'ppdcOption::find_choice()' - Find an option choice.
Packit 2fc92b
//
Packit 2fc92b
Packit 2fc92b
ppdcChoice *					// O - Choice or NULL
Packit 2fc92b
ppdcOption::find_choice(const char *n)		// I - Name of choice
Packit 2fc92b
{
Packit 2fc92b
  ppdcChoice	*c;				// Current choice
Packit 2fc92b
Packit 2fc92b
Packit 2fc92b
  for (c = (ppdcChoice *)choices->first(); c; c = (ppdcChoice *)choices->next())
Packit 2fc92b
    if (!_cups_strcasecmp(n, c->name->value))
Packit 2fc92b
      return (c);
Packit 2fc92b
Packit 2fc92b
  return (0);
Packit 2fc92b
}
Packit 2fc92b
Packit 2fc92b
Packit 2fc92b
//
Packit 2fc92b
// 'ppdcOption::set_defchoice()' - Set the default choice.
Packit 2fc92b
//
Packit 2fc92b
Packit 2fc92b
void
Packit 2fc92b
ppdcOption::set_defchoice(ppdcChoice *c)	// I - Choice
Packit 2fc92b
{
Packit 2fc92b
  if (defchoice)
Packit 2fc92b
    defchoice->release();
Packit 2fc92b
Packit 2fc92b
  if (c->name)
Packit 2fc92b
    c->name->retain();
Packit 2fc92b
Packit 2fc92b
  defchoice = c->name;
Packit 2fc92b
}