Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / TAO_IDL / util / utl_list.cpp
blobe3f2672cd7450ecb3e99fb8c3d4a04eec59b57ed
1 /*
3 COPYRIGHT
5 Copyright 1992, 1993, 1994 Sun Microsystems, Inc. Printed in the United
6 States of America. All Rights Reserved.
8 This product is protected by copyright and distributed under the following
9 license restricting its use.
11 The Interface Definition Language Compiler Front End (CFE) is made
12 available for your use provided that you include this license and copyright
13 notice on all media and documentation and the software program in which
14 this product is incorporated in whole or part. You may copy and extend
15 functionality (but may not remove functionality) of the Interface
16 Definition Language CFE without charge, but you are not authorized to
17 license or distribute it to anyone else except as part of a product or
18 program developed by you or with the express written consent of Sun
19 Microsystems, Inc. ("Sun").
21 The names of Sun Microsystems, Inc. and any of its subsidiaries or
22 affiliates may not be used in advertising or publicity pertaining to
23 distribution of Interface Definition Language CFE as permitted herein.
25 This license is effective until terminated by Sun for failure to comply
26 with this license. Upon termination, you shall destroy or return all code
27 and documentation for the Interface Definition Language CFE.
29 INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED AS IS WITH NO WARRANTIES OF
30 ANY KIND INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS
31 FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR ARISING FROM A COURSE OF
32 DEALING, USAGE OR TRADE PRACTICE.
34 INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED WITH NO SUPPORT AND WITHOUT
35 ANY OBLIGATION ON THE PART OF Sun OR ANY OF ITS SUBSIDIARIES OR AFFILIATES
36 TO ASSIST IN ITS USE, CORRECTION, MODIFICATION OR ENHANCEMENT.
38 SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH
39 RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY
40 INTERFACE DEFINITION LANGUAGE CFE OR ANY PART THEREOF.
42 IN NO EVENT WILL SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR
43 ANY LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL
44 DAMAGES, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
46 Use, duplication, or disclosure by the government is subject to
47 restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
48 Technical Data and Computer Software clause at DFARS 252.227-7013 and FAR
49 52.227-19.
51 Sun, Sun Microsystems and the Sun logo are trademarks or registered
52 trademarks of Sun Microsystems, Inc.
54 SunSoft, Inc.
55 2550 Garcia Avenue
56 Mountain View, California 94043
58 NOTE:
60 SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are
61 trademarks or registered trademarks of Sun Microsystems, Inc.
65 // Implementation of generic single-linked list.
67 // NOTE: This list class only works correctly because we use single public
68 // inheritance, as opposed to multiple inheritance or public virtual.
69 // It relies on a type-unsafe cast from UTL_List to subclasses, which
70 // will cease to operate correctly if you use either multiple or
71 // public virtual inheritance.
73 #include "utl_list.h"
74 #include "ace/OS_Memory.h"
76 UTL_List::UTL_List (UTL_List *c)
77 : pd_cdr_data (c)
81 UTL_List::~UTL_List ()
85 // Compute list length.
86 ACE_CDR::Long
87 UTL_List::list_length (ACE_CDR::Long n)
89 if (this->pd_cdr_data == nullptr)
91 return n;
93 else
95 return this->pd_cdr_data->list_length (n + 1);
99 // Smash last cdr with l.
100 void
101 UTL_List::nconc (UTL_List *l)
103 if (this->pd_cdr_data == nullptr)
105 this->pd_cdr_data = l;
107 else
109 this->pd_cdr_data->nconc (l);
113 // Override this operation to copy lists of other types.
114 UTL_List *
115 UTL_List::copy ()
117 UTL_List *retval = nullptr;
119 if (this->pd_cdr_data == nullptr)
121 ACE_NEW_RETURN (retval,
122 UTL_List (nullptr),
123 nullptr);
125 else
127 ACE_NEW_RETURN (retval,
128 UTL_List (this->pd_cdr_data->copy ()),
129 nullptr);
132 return retval;
135 // Get next list.
136 UTL_List *
137 UTL_List::tail ()
139 return pd_cdr_data;
142 // Set next list.
143 void
144 UTL_List::set_tail (UTL_List *l)
146 this->pd_cdr_data->destroy ();
147 delete this->pd_cdr_data;
148 this->pd_cdr_data = l;
151 // Compute list length.
152 ACE_CDR::Long
153 UTL_List::length ()
155 return list_length (1);
158 void
159 UTL_List::destroy ()
161 if (this->pd_cdr_data != nullptr)
163 this->pd_cdr_data->destroy ();
164 delete this->pd_cdr_data;
165 this->pd_cdr_data = nullptr;
169 // UTL_List active iterator.
171 UTL_ListActiveIterator::UTL_ListActiveIterator (UTL_List *s)
172 : source (s)
176 // Is iterator done?
177 bool
178 UTL_ListActiveIterator::is_done ()
180 return (this->source == nullptr) ? true : false;
183 // Advance to next item.
184 void
185 UTL_ListActiveIterator::next ()
187 if (this->source != nullptr)
189 this->source = this->source->tail ();