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