2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * $XConsortium: short_list.cc /main/4 1996/06/11 17:25:56 cde-hal $
26 * Copyright (c) 1992 HAL Computer Systems International, Ltd.
27 * All rights reserved. Unpublished -- rights reserved under
28 * the Copyright Laws of the United States. USE OF A COPYRIGHT
29 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
32 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
33 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
34 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
35 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
38 * RESTRICTED RIGHTS LEGEND
39 * Use, duplication, or disclosure by the Government is subject
40 * to the restrictions as set forth in subparagraph (c)(l)(ii)
41 * of the Rights in Technical Data and Computer Software clause
42 * at DFARS 252.227-7013.
44 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
52 #include "object/short_list.h"
54 short_list::short_list(rootPtr t, c_code_t c_cd) :
55 oid_list(c_cd), v_tempt(t)
59 short_list::short_list(short_list& x) : oid_list(x)
64 short_list::~short_list()
69 //Boolean short_list::value_LS(root& x, Boolean safe) const
71 // if ( safe == true &&
72 // ( my_oid().ccode() != SHORT_LIST_CODE ||
73 // x.my_oid().ccode() != SHORT_LIST_CODE
78 // short_list &y = *(short_list*)&x;
83 ///************************************************/
84 //// Note: the components are indexed from 1 to sz
85 ///************************************************/
87 // for ( int i=1; i<=sz; i++ ) {
89 // handler* rootPtr1 = get_component(i);
90 // handler* rootPtr2 = y.get_component(i);
92 // if ( (*rootPtr1) -> value_LS( *rootPtr2 ) == true )
94 // if ( (*rootPtr1) -> value_EQ( *rootPtr2 ) == false )
100 //Boolean short_list::value_EQ(root& x, Boolean safe) const
102 // if ( safe == true &&
103 // ( my_oid().ccode() != SHORT_LIST_CODE ||
104 // x.my_oid().ccode() != SHORT_LIST_CODE
109 // short_list &y = *(short_list*)&x;
114 ///************************************************/
115 //// Note: the components are indexed from 1 to sz
116 ///************************************************/
118 // for ( int i=1; i<sz; i++ ) {
120 // handler* rootPtr1 = get_component(i);
121 // handler* rootPtr2 = y.get_component(i);
123 // if ( (*rootPtr1) -> value_EQ( *rootPtr2 ) == false )
130 handler* short_list::get_component(int index)
132 if ( !INRANGE(index, 1, (int) v_sz) ) {
133 MESSAGE(cerr, "out of range in short_list::get_component()");
134 throw(boundaryException(1, v_sz, index));
137 oid_t x = oid_list::operator()(index);
141 if ( x.icode() != 0 )
142 y = new handler(x, storage_ptr);
147 Boolean short_list::pinned_insert(int index, oid_t& val)
149 return oid_list::update_component(index, val);
152 io_status short_list::asciiOut(ostream& out)
155 my_oid().asciiOut(out);
158 for ( unsigned int i=1; i<=v_sz; i++ ) {
160 handler* hd_ptr = get_component(i);
163 (*hd_ptr) -> asciiOut(out);
173 #define OID_BUFFER_SIZE 40
175 io_status short_list::asciiIn(istream& in)
177 if ( in.get() != LIST_MARK_CHAR ) {
178 throw(formatException("short_list::asciiIn(): LIST_MARK_CHAR"));
181 if ( in.get() != '\n' ) {
182 throw(formatException("short_list::asciiIn(): \n"));
188 oid_t oid_buffer[OID_BUFFER_SIZE];
189 int oid_buffer_level = 0;
194 while ( (c = in.get()) != LIST_MARK_CHAR ) {
199 in >> ccode; in.get();
201 hd_ptr = new handler (oid_t(ccode, 0), storage_ptr);
204 (*hd_ptr) -> asciiIn(in);
207 if ( oid_buffer_level == OID_BUFFER_SIZE ) {
208 ct = oid_list::count();
209 oid_list::expand_space(OID_BUFFER_SIZE);
210 for ( int i=0; i<OID_BUFFER_SIZE; i++ ) {
211 oid_list::update_component(ct+i+1, oid_buffer[i]);
213 oid_buffer_level = 0;
216 oid_buffer[oid_buffer_level] = hd_ptr -> its_oid();
221 oid_list::insert_component(hd_ptr -> its_oid());
227 if ( in.get() != '\n' ) {
228 throw(formatException("short_list::asciiIn(): \n"));
233 if ( oid_buffer_level > 0 ) {
234 ct = oid_list::count();
235 oid_list::expand_space(oid_buffer_level);
236 for ( int i=0; i<oid_buffer_level; i++ ) {
237 oid_list::update_component(ct+i+1, oid_buffer[i]);
245 rootPtr short_list::get_template()
250 MMDB_BODIES(short_list)
251 HANDLER_BODIES(short_list)