Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / object / short_list.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /*
24  * $XConsortium: short_list.cc /main/4 1996/06/11 17:25:56 cde-hal $
25  *
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
30  * OR DISCLOSURE.
31  * 
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
36  * INTERNATIONAL, LTD.
37  * 
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.
43  *
44  *          HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
45  *                  1315 Dell Avenue
46  *                  Campbell, CA  95008
47  * 
48  */
49
50
51
52 #include "object/short_list.h"
53
54 short_list::short_list(rootPtr t, c_code_t c_cd) : 
55 oid_list(c_cd), v_tempt(t)
56 {
57 }
58
59 short_list::short_list(short_list& x) : oid_list(x)
60 {
61    v_tempt = x.v_tempt;
62 }
63
64 short_list::~short_list()
65 {
66 }
67
68 //
69 //Boolean short_list::value_LS(root& x, Boolean safe) const
70 //{
71 //   if ( safe == true &&
72 //        ( my_oid().ccode() != SHORT_LIST_CODE ||
73 //          x.my_oid().ccode() != SHORT_LIST_CODE  
74 //        ) 
75 //      )
76 //      return false;
77 //
78 //   short_list &y = *(short_list*)&x;
79 //
80 //   if ( sz != y.sz )
81 //      return false;
82 //
83 ///************************************************/
84 //// Note: the components are indexed from 1 to sz
85 ///************************************************/
86 //
87 //   for ( int i=1; i<=sz; i++ ) {
88 //
89 //      handler* rootPtr1 = get_component(i);
90 //      handler* rootPtr2 = y.get_component(i);
91 //
92 //      if ( (*rootPtr1) -> value_LS( *rootPtr2 ) == true )
93 //         return true;
94 //      if ( (*rootPtr1) -> value_EQ( *rootPtr2 ) == false )
95 //         return false;
96 //   }
97 //   return false;
98 //}
99 //
100 //Boolean short_list::value_EQ(root& x, Boolean safe) const
101 //{
102 //   if ( safe == true &&
103 //        ( my_oid().ccode() != SHORT_LIST_CODE ||
104 //          x.my_oid().ccode() != SHORT_LIST_CODE  
105 //        ) 
106 //      )
107 //      return false;
108 //
109 //   short_list &y = *(short_list*)&x;
110 //
111 //   if ( sz != y.sz )
112 //      return false;
113 //
114 ///************************************************/
115 //// Note: the components are indexed from 1 to sz
116 ///************************************************/
117 //
118 //   for ( int i=1; i<sz; i++ ) {
119 //
120 //      handler* rootPtr1 = get_component(i);
121 //      handler* rootPtr2 = y.get_component(i);
122 //
123 //      if ( (*rootPtr1) -> value_EQ( *rootPtr2 ) == false )
124 //         return false;
125 //   }
126 //   return true;
127 //}
128
129
130 handler* short_list::get_component(int index) 
131 {
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));
135   }
136
137   oid_t x = oid_list::operator()(index);
138
139   handler *y = 0;
140
141   if ( x.icode() != 0 )
142      y = new handler(x, storage_ptr);
143
144   return y;
145 }
146
147 Boolean short_list::pinned_insert(int index, oid_t& val) 
148 {
149    return oid_list::update_component(index, val);
150 }
151
152 io_status short_list::asciiOut(ostream& out) 
153 {
154    out << "OID_T:\n";
155    my_oid().asciiOut(out);
156    out << "\n";
157
158    for ( unsigned int i=1; i<=v_sz; i++ ) {
159
160       handler* hd_ptr = get_component(i);
161
162
163       (*hd_ptr) -> asciiOut(out);
164
165
166       out << "\n";
167
168       delete hd_ptr;
169    }
170    return done;
171 }
172
173 #define OID_BUFFER_SIZE 40
174
175 io_status short_list::asciiIn(istream& in)
176 {
177    if ( in.get() != LIST_MARK_CHAR ) {
178       throw(formatException("short_list::asciiIn(): LIST_MARK_CHAR"));
179    }
180
181    if ( in.get() != '\n' ) {
182       throw(formatException("short_list::asciiIn(): \n"));
183    }
184
185    handler* hd_ptr = 0;
186
187 #ifndef C_API
188    oid_t oid_buffer[OID_BUFFER_SIZE]; 
189    int oid_buffer_level = 0;
190    int ct = 0;
191 #endif
192
193    char c;
194    while ( (c = in.get()) != LIST_MARK_CHAR ) {
195
196       in.putback(c);
197
198       c_code_t ccode;
199       in >> ccode;  in.get();
200
201       hd_ptr = new handler (oid_t(ccode, 0), storage_ptr);
202
203
204       (*hd_ptr) -> asciiIn(in);
205
206 #ifndef C_API
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]);
212         }
213         oid_buffer_level = 0;
214       } 
215
216       oid_buffer[oid_buffer_level] = hd_ptr -> its_oid();
217       oid_buffer_level++;
218       
219 #else
220
221       oid_list::insert_component(hd_ptr -> its_oid());
222 #endif
223
224       delete hd_ptr;
225    }
226
227    if ( in.get() != '\n' ) {
228       throw(formatException("short_list::asciiIn(): \n"));
229    }
230
231
232 #ifndef C_API
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]);
238       }
239    }
240 #endif
241
242    return done;
243 }
244
245 rootPtr short_list::get_template()
246 {
247    return v_tempt ;
248 }
249
250 MMDB_BODIES(short_list)
251 HANDLER_BODIES(short_list)