]>
Commit | Line | Data |
---|---|---|
ac884b6a | 1 | // |
503b54c9 | 2 | // Group 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 | // |
e3101897 | 7 | // Licensed under Apache License v2.0. See the file "LICENSE" for more information. |
ac884b6a MS |
8 | // |
9 | ||
10 | // | |
11 | // Include necessary headers... | |
12 | // | |
13 | ||
38e73f87 | 14 | #include "ppdc-private.h" |
ac884b6a MS |
15 | |
16 | ||
17 | // | |
18 | // 'ppdcGroup::ppdcGroup()' - Create a new group. | |
19 | // | |
20 | ||
21 | ppdcGroup::ppdcGroup(const char *n, // I - Name of group | |
22 | const char *t) // I - Text of group | |
23 | { | |
97c9a8d7 | 24 | PPDC_NEWVAL(n); |
94da7e34 | 25 | |
ac884b6a MS |
26 | name = new ppdcString(n); |
27 | text = new ppdcString(t); | |
28 | options = new ppdcArray(); | |
29 | } | |
30 | ||
31 | ||
32 | // | |
33 | // 'ppdcGroup::ppdcGroup()' - Copy a new group. | |
34 | // | |
35 | ||
36 | ppdcGroup::ppdcGroup(ppdcGroup *g) // I - Group template | |
37 | { | |
97c9a8d7 | 38 | PPDC_NEWVAL(g->name->value); |
94da7e34 | 39 | |
e4572d57 MS |
40 | g->name->retain(); |
41 | g->text->retain(); | |
ac884b6a MS |
42 | |
43 | name = g->name; | |
44 | text = g->text; | |
45 | ||
46 | options = new ppdcArray(); | |
97c9a8d7 MS |
47 | for (ppdcOption *o = (ppdcOption *)g->options->first(); |
48 | o; | |
49 | o = (ppdcOption *)g->options->next()) | |
ac884b6a MS |
50 | options->add(new ppdcOption(o)); |
51 | } | |
52 | ||
53 | ||
54 | // | |
55 | // 'ppdcGroup::~ppdcGroup()' - Destroy a group. | |
56 | // | |
57 | ||
58 | ppdcGroup::~ppdcGroup() | |
59 | { | |
97c9a8d7 | 60 | PPDC_DELETEVAL(name ? name->value : NULL); |
94da7e34 | 61 | |
ac884b6a MS |
62 | name->release(); |
63 | text->release(); | |
e4572d57 | 64 | options->release(); |
97c9a8d7 MS |
65 | |
66 | name = text = 0; | |
67 | options = 0; | |
ac884b6a MS |
68 | } |
69 | ||
70 | ||
71 | // | |
72 | // 'ppdcGroup::find_option()' - Find an option in a group. | |
73 | // | |
74 | ||
75 | ppdcOption * | |
76 | ppdcGroup::find_option(const char *n) // I - Name of option | |
77 | { | |
78 | ppdcOption *o; // Current option | |
79 | ||
80 | ||
81 | for (o = (ppdcOption *)options->first(); o; o = (ppdcOption *)options->next()) | |
88f9aafc | 82 | if (!_cups_strcasecmp(n, o->name->value)) |
ac884b6a MS |
83 | return (o); |
84 | ||
85 | return (0); | |
86 | } |