]> git.ipfire.org Git - thirdparty/cups.git/blob - ppdc/ppdc-group.cxx
Merge changes from CUPS 1.4svn-r8469.
[thirdparty/cups.git] / ppdc / ppdc-group.cxx
1 //
2 // "$Id$"
3 //
4 // Group class for the CUPS PPD Compiler.
5 //
6 // Copyright 2007-2009 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 // ppdcGroup::ppdcGroup() - Copy a new group.
18 // ppdcGroup::~ppdcGroup() - Destroy a group.
19 // ppdcGroup::find_option() - Find an option in a group.
20 //
21
22 //
23 // Include necessary headers...
24 //
25
26 #include "ppdc.h"
27
28
29 //
30 // 'ppdcGroup::ppdcGroup()' - Create a new group.
31 //
32
33 ppdcGroup::ppdcGroup(const char *n, // I - Name of group
34 const char *t) // I - Text of group
35 {
36 PPDC_NEW;
37
38 name = new ppdcString(n);
39 text = new ppdcString(t);
40 options = new ppdcArray();
41 }
42
43
44 //
45 // 'ppdcGroup::ppdcGroup()' - Copy a new group.
46 //
47
48 ppdcGroup::ppdcGroup(ppdcGroup *g) // I - Group template
49 {
50 ppdcOption *o; // Current option
51
52
53 PPDC_NEW;
54
55 g->name->retain();
56 g->text->retain();
57
58 name = g->name;
59 text = g->text;
60
61 options = new ppdcArray();
62 for (o = (ppdcOption *)g->options->first(); o; o = (ppdcOption *)g->options->next())
63 options->add(new ppdcOption(o));
64 }
65
66
67 //
68 // 'ppdcGroup::~ppdcGroup()' - Destroy a group.
69 //
70
71 ppdcGroup::~ppdcGroup()
72 {
73 PPDC_DELETE;
74
75 name->release();
76 text->release();
77 options->release();
78 }
79
80
81 //
82 // 'ppdcGroup::find_option()' - Find an option in a group.
83 //
84
85 ppdcOption *
86 ppdcGroup::find_option(const char *n) // I - Name of option
87 {
88 ppdcOption *o; // Current option
89
90
91 for (o = (ppdcOption *)options->first(); o; o = (ppdcOption *)options->next())
92 if (!strcasecmp(n, o->name->value))
93 return (o);
94
95 return (0);
96 }
97
98
99 //
100 // End of "$Id$".
101 //