]> git.ipfire.org Git - thirdparty/cups.git/blob - ppdc/ppdc-option.cxx
Fix source file header text duplication text duplication.
[thirdparty/cups.git] / ppdc / ppdc-option.cxx
1 //
2 // Option class for the CUPS PPD Compiler.
3 //
4 // Copyright 2007-2011 by Apple Inc.
5 // Copyright 2002-2005 by Easy Software Products.
6 //
7 // These coded instructions, statements, and computer programs are the
8 // property of Apple Inc. and are protected by Federal copyright
9 // law. Distribution and use rights are outlined in the file "LICENSE.txt"
10 // which should have been included with this file. If this file is
11 // missing or damaged, see the license at "http://www.cups.org/".
12 //
13
14 //
15 // Include necessary headers...
16 //
17
18 #include "ppdc-private.h"
19
20
21 //
22 // 'ppdcOption::ppdcOption()' - Create a new option.
23 //
24
25 ppdcOption::ppdcOption(ppdcOptType ot, // I - Option type
26 const char *n, // I - Option name
27 const char *t, // I - Option text
28 ppdcOptSection s, // I - Section
29 float o) // I - Ordering number
30 : ppdcShared()
31 {
32 PPDC_NEW;
33
34 type = ot;
35 name = new ppdcString(n);
36 text = new ppdcString(t);
37 section = s;
38 order = o;
39 choices = new ppdcArray();
40 defchoice = 0;
41 }
42
43
44 //
45 // 'ppdcOption::ppdcOption()' - Copy a new option.
46 //
47
48 ppdcOption::ppdcOption(ppdcOption *o) // I - Template option
49 {
50 PPDC_NEW;
51
52 o->name->retain();
53 o->text->retain();
54 if (o->defchoice)
55 o->defchoice->retain();
56
57 type = o->type;
58 name = o->name;
59 text = o->text;
60 section = o->section;
61 order = o->order;
62 choices = new ppdcArray(o->choices);
63 defchoice = o->defchoice;
64 }
65
66
67 //
68 // 'ppdcOption::~ppdcOption()' - Destroy an option.
69 //
70
71 ppdcOption::~ppdcOption()
72 {
73 PPDC_DELETE;
74
75 name->release();
76 text->release();
77 if (defchoice)
78 defchoice->release();
79 choices->release();
80 }
81
82
83 //
84 // 'ppdcOption::find_choice()' - Find an option choice.
85 //
86
87 ppdcChoice * // O - Choice or NULL
88 ppdcOption::find_choice(const char *n) // I - Name of choice
89 {
90 ppdcChoice *c; // Current choice
91
92
93 for (c = (ppdcChoice *)choices->first(); c; c = (ppdcChoice *)choices->next())
94 if (!_cups_strcasecmp(n, c->name->value))
95 return (c);
96
97 return (0);
98 }
99
100
101 //
102 // 'ppdcOption::set_defchoice()' - Set the default choice.
103 //
104
105 void
106 ppdcOption::set_defchoice(ppdcChoice *c) // I - Choice
107 {
108 if (defchoice)
109 defchoice->release();
110
111 if (c->name)
112 c->name->retain();
113
114 defchoice = c->name;
115 }