• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Group class for the CUPS PPD Compiler.
3 //
4 // Copyright © 2020-2024 by OpenPrinting.
5 // Copyright 2007-2011 by Apple Inc.
6 // Copyright 2002-2005 by Easy Software Products.
7 //
8 // Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
9 //
10 
11 //
12 // Include necessary headers...
13 //
14 
15 #include "ppdc-private.h"
16 
17 
18 //
19 // 'ppdcGroup::ppdcGroup()' - Create a new group.
20 //
21 
ppdcGroup(const char * n,const char * t)22 ppdcGroup::ppdcGroup(const char *n,	// I - Name of group
23                      const char *t)	// I - Text of group
24 {
25   PPDC_NEWVAL(n);
26 
27   name    = new ppdcString(n);
28   text    = new ppdcString(t);
29   options = new ppdcArray();
30 }
31 
32 
33 //
34 // 'ppdcGroup::ppdcGroup()' - Copy a new group.
35 //
36 
ppdcGroup(ppdcGroup * g)37 ppdcGroup::ppdcGroup(ppdcGroup *g)	// I - Group template
38 {
39   PPDC_NEWVAL(g->name->value);
40 
41   g->name->retain();
42   g->text->retain();
43 
44   name = g->name;
45   text = g->text;
46 
47   options = new ppdcArray();
48   for (ppdcOption *o = (ppdcOption *)g->options->first();
49        o;
50        o = (ppdcOption *)g->options->next())
51     options->add(new ppdcOption(o));
52 }
53 
54 
55 //
56 // 'ppdcGroup::~ppdcGroup()' - Destroy a group.
57 //
58 
~ppdcGroup()59 ppdcGroup::~ppdcGroup()
60 {
61   PPDC_DELETEVAL(name ? name->value : NULL);
62 
63   name->release();
64   text->release();
65   options->release();
66 
67   name = text = 0;
68   options = 0;
69 }
70 
71 
72 //
73 // 'ppdcGroup::find_option()' - Find an option in a group.
74 //
75 
76 ppdcOption *
find_option(const char * n)77 ppdcGroup::find_option(const char *n)	// I - Name of option
78 {
79   ppdcOption	*o;			// Current option
80 
81 
82   for (o = (ppdcOption *)options->first(); o; o = (ppdcOption *)options->next())
83     if (!_cups_strcasecmp(n, o->name->value))
84       return (o);
85 
86   return (0);
87 }
88