]>
Commit | Line | Data |
---|---|---|
ac884b6a MS |
1 | // |
2 | // "$Id$" | |
3 | // | |
4 | // Option class for the CUPS PPD Compiler. | |
5 | // | |
6 | // Copyright 2007 by Apple Inc. | |
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 | // | |
17 | // ppdcOption::ppdcOption() - Create a new option. | |
18 | // ppdcOption::ppdcOption() - Copy a new option. | |
19 | // ppdcOption::~ppdcOption() - Destroy an option. | |
20 | // ppdcOption::find_choice() - Find an option choice. | |
21 | // ppdcOption::set_defchoice() - Set the default choice. | |
22 | // | |
23 | ||
24 | // | |
25 | // Include necessary headers... | |
26 | // | |
27 | ||
28 | #include "ppdc.h" | |
29 | ||
30 | ||
31 | // | |
32 | // 'ppdcOption::ppdcOption()' - Create a new option. | |
33 | // | |
34 | ||
35 | ppdcOption::ppdcOption(ppdcOptType ot, // I - Option type | |
36 | const char *n, // I - Option name | |
37 | const char *t, // I - Option text | |
38 | ppdcOptSection s, // I - Section | |
39 | float o) // I - Ordering number | |
40 | { | |
41 | // printf("ppdcOption(ot=%d, n=\"%s\", t=\"%s\"), this=%p\n", | |
42 | // ot, n, t, this); | |
43 | ||
44 | type = ot; | |
45 | name = new ppdcString(n); | |
46 | text = new ppdcString(t); | |
47 | section = s; | |
48 | order = o; | |
49 | choices = new ppdcArray(); | |
50 | defchoice = 0; | |
51 | } | |
52 | ||
53 | ||
54 | // | |
55 | // 'ppdcOption::ppdcOption()' - Copy a new option. | |
56 | // | |
57 | ||
58 | ppdcOption::ppdcOption(ppdcOption *o) // I - Template option | |
59 | { | |
60 | o->name->get(); | |
61 | o->text->get(); | |
62 | if (o->defchoice) | |
63 | o->defchoice->get(); | |
64 | ||
65 | type = o->type; | |
66 | name = o->name; | |
67 | text = o->text; | |
68 | section = o->section; | |
69 | order = o->order; | |
70 | choices = new ppdcArray(o->choices); | |
71 | defchoice = o->defchoice; | |
72 | } | |
73 | ||
74 | ||
75 | // | |
76 | // 'ppdcOption::~ppdcOption()' - Destroy an option. | |
77 | // | |
78 | ||
79 | ppdcOption::~ppdcOption() | |
80 | { | |
81 | name->release(); | |
82 | text->release(); | |
83 | if (defchoice) | |
84 | defchoice->release(); | |
85 | delete choices; | |
86 | } | |
87 | ||
88 | ||
89 | // | |
90 | // 'ppdcOption::find_choice()' - Find an option choice. | |
91 | // | |
92 | ||
93 | ppdcChoice * // O - Choice or NULL | |
94 | ppdcOption::find_choice(const char *n) // I - Name of choice | |
95 | { | |
96 | ppdcChoice *c; // Current choice | |
97 | ||
98 | ||
99 | for (c = (ppdcChoice *)choices->first(); c; c = (ppdcChoice *)choices->next()) | |
100 | if (!strcasecmp(n, c->name->value)) | |
101 | return (c); | |
102 | ||
103 | return (0); | |
104 | } | |
105 | ||
106 | ||
107 | // | |
108 | // 'ppdcOption::set_defchoice()' - Set the default choice. | |
109 | // | |
110 | ||
111 | void | |
112 | ppdcOption::set_defchoice(ppdcChoice *c) // I - Choice | |
113 | { | |
114 | if (defchoice) | |
115 | defchoice->release(); | |
116 | ||
117 | if (c->name) | |
118 | c->name->get(); | |
119 | ||
120 | defchoice = c->name; | |
121 | } | |
122 | ||
123 | ||
124 | // | |
125 | // End of "$Id$". | |
126 | // |