]>
Commit | Line | Data |
---|---|---|
ac884b6a | 1 | // |
503b54c9 | 2 | // Option class for the CUPS PPD Compiler. |
ac884b6a | 3 | // |
503b54c9 MS |
4 | // Copyright 2007-2011 by Apple Inc. |
5 | // Copyright 2002-2005 by Easy Software Products. | |
ac884b6a | 6 | // |
503b54c9 MS |
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 | // file is missing or damaged, see the license at "http://www.cups.org/". | |
ac884b6a MS |
12 | // |
13 | ||
14 | // | |
15 | // Include necessary headers... | |
16 | // | |
17 | ||
38e73f87 | 18 | #include "ppdc-private.h" |
ac884b6a MS |
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 | |
94da7e34 | 30 | : ppdcShared() |
ac884b6a | 31 | { |
94da7e34 | 32 | PPDC_NEW; |
ac884b6a MS |
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 | { | |
94da7e34 MS |
50 | PPDC_NEW; |
51 | ||
e4572d57 MS |
52 | o->name->retain(); |
53 | o->text->retain(); | |
ac884b6a | 54 | if (o->defchoice) |
e4572d57 | 55 | o->defchoice->retain(); |
ac884b6a MS |
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 | { | |
94da7e34 MS |
73 | PPDC_DELETE; |
74 | ||
ac884b6a MS |
75 | name->release(); |
76 | text->release(); | |
77 | if (defchoice) | |
78 | defchoice->release(); | |
e4572d57 | 79 | choices->release(); |
ac884b6a MS |
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()) | |
88f9aafc | 94 | if (!_cups_strcasecmp(n, c->name->value)) |
ac884b6a MS |
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) | |
e4572d57 | 112 | c->name->retain(); |
ac884b6a MS |
113 | |
114 | defchoice = c->name; | |
115 | } |