]>
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 | // |
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 | // 'ppdcGroup::ppdcGroup()' - Create a new group. | |
23 | // | |
24 | ||
25 | ppdcGroup::ppdcGroup(const char *n, // I - Name of group | |
26 | const char *t) // I - Text of group | |
27 | { | |
97c9a8d7 | 28 | PPDC_NEWVAL(n); |
94da7e34 | 29 | |
ac884b6a MS |
30 | name = new ppdcString(n); |
31 | text = new ppdcString(t); | |
32 | options = new ppdcArray(); | |
33 | } | |
34 | ||
35 | ||
36 | // | |
37 | // 'ppdcGroup::ppdcGroup()' - Copy a new group. | |
38 | // | |
39 | ||
40 | ppdcGroup::ppdcGroup(ppdcGroup *g) // I - Group template | |
41 | { | |
97c9a8d7 | 42 | PPDC_NEWVAL(g->name->value); |
94da7e34 | 43 | |
e4572d57 MS |
44 | g->name->retain(); |
45 | g->text->retain(); | |
ac884b6a MS |
46 | |
47 | name = g->name; | |
48 | text = g->text; | |
49 | ||
50 | options = new ppdcArray(); | |
97c9a8d7 MS |
51 | for (ppdcOption *o = (ppdcOption *)g->options->first(); |
52 | o; | |
53 | o = (ppdcOption *)g->options->next()) | |
ac884b6a MS |
54 | options->add(new ppdcOption(o)); |
55 | } | |
56 | ||
57 | ||
58 | // | |
59 | // 'ppdcGroup::~ppdcGroup()' - Destroy a group. | |
60 | // | |
61 | ||
62 | ppdcGroup::~ppdcGroup() | |
63 | { | |
97c9a8d7 | 64 | PPDC_DELETEVAL(name ? name->value : NULL); |
94da7e34 | 65 | |
ac884b6a MS |
66 | name->release(); |
67 | text->release(); | |
e4572d57 | 68 | options->release(); |
97c9a8d7 MS |
69 | |
70 | name = text = 0; | |
71 | options = 0; | |
ac884b6a MS |
72 | } |
73 | ||
74 | ||
75 | // | |
76 | // 'ppdcGroup::find_option()' - Find an option in a group. | |
77 | // | |
78 | ||
79 | ppdcOption * | |
80 | ppdcGroup::find_option(const char *n) // I - Name of option | |
81 | { | |
82 | ppdcOption *o; // Current option | |
83 | ||
84 | ||
85 | for (o = (ppdcOption *)options->first(); o; o = (ppdcOption *)options->next()) | |
88f9aafc | 86 | if (!_cups_strcasecmp(n, o->name->value)) |
ac884b6a MS |
87 | return (o); |
88 | ||
89 | return (0); | |
90 | } |