]> git.ipfire.org Git - thirdparty/cups.git/blame - ppdc/ppdc-group.cxx
Import CUPS v1.7.1
[thirdparty/cups.git] / ppdc / ppdc-group.cxx
CommitLineData
ac884b6a 1//
61515785 2// "$Id: ppdc-group.cxx 3275 2011-05-20 07:26:13Z msweet $"
ac884b6a
MS
3//
4// Group class for the CUPS PPD Compiler.
5//
88f9aafc 6// Copyright 2007-2011 by Apple Inc.
ac884b6a
MS
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//
ac884b6a
MS
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
38e73f87 26#include "ppdc-private.h"
ac884b6a
MS
27
28
29//
30// 'ppdcGroup::ppdcGroup()' - Create a new group.
31//
32
33ppdcGroup::ppdcGroup(const char *n, // I - Name of group
34 const char *t) // I - Text of group
35{
97c9a8d7 36 PPDC_NEWVAL(n);
94da7e34 37
ac884b6a
MS
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
48ppdcGroup::ppdcGroup(ppdcGroup *g) // I - Group template
49{
97c9a8d7 50 PPDC_NEWVAL(g->name->value);
94da7e34 51
e4572d57
MS
52 g->name->retain();
53 g->text->retain();
ac884b6a
MS
54
55 name = g->name;
56 text = g->text;
57
58 options = new ppdcArray();
97c9a8d7
MS
59 for (ppdcOption *o = (ppdcOption *)g->options->first();
60 o;
61 o = (ppdcOption *)g->options->next())
ac884b6a
MS
62 options->add(new ppdcOption(o));
63}
64
65
66//
67// 'ppdcGroup::~ppdcGroup()' - Destroy a group.
68//
69
70ppdcGroup::~ppdcGroup()
71{
97c9a8d7 72 PPDC_DELETEVAL(name ? name->value : NULL);
94da7e34 73
ac884b6a
MS
74 name->release();
75 text->release();
e4572d57 76 options->release();
97c9a8d7
MS
77
78 name = text = 0;
79 options = 0;
ac884b6a
MS
80}
81
82
83//
84// 'ppdcGroup::find_option()' - Find an option in a group.
85//
86
87ppdcOption *
88ppdcGroup::find_option(const char *n) // I - Name of option
89{
90 ppdcOption *o; // Current option
91
92
93 for (o = (ppdcOption *)options->first(); o; o = (ppdcOption *)options->next())
88f9aafc 94 if (!_cups_strcasecmp(n, o->name->value))
ac884b6a
MS
95 return (o);
96
97 return (0);
98}
99
100
101//
61515785 102// End of "$Id: ppdc-group.cxx 3275 2011-05-20 07:26:13Z msweet $".
ac884b6a 103//