Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / object / tuple.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: tuple.cc /main/4 1996/06/11 17:26:06 cde-hal $
25  *
26  * Copyright (c) 1993 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 #include "object/tuple.h"
52
53 #define MAX_COMPS 50
54
55 tuple::tuple(c_code_t c_cd) : oid_list(c_cd)
56 {
57 }
58
59 tuple::tuple(int comps, c_code_t c_cd) : oid_list(comps, c_cd)
60 {
61 }
62
63 tuple::tuple(tuple& x) : oid_list(x)
64 {
65 }
66
67 tuple::~tuple()
68 {
69 }
70
71 handler* tuple::get_component(int index) 
72 {
73
74 //MESSAGE(cerr, "in tuple():: get_component()");
75 //debug(cerr, index);
76 //debug(cerr, my_oid());
77 //debug(cerr, int(storage_ptr));
78
79
80    if (!INRANGE(index, 1, (int) v_sz)) {
81       MESSAGE(cerr, "out of range in tuple::get_component()");
82       throw( boundaryException(1, v_sz, index) );
83    }
84
85    oid_t x = oid_list::operator()(index);
86
87 //debug(cerr, x);
88
89 //debug(cerr, x.ccode());
90 //debug(cerr, x.icode());
91
92    handler* y = 0;
93
94    if ( x.icode() != 0 )
95       y = new handler(x, storage_ptr);
96
97    return y;
98 }
99
100 Boolean tuple::pinned_insert(int index, const oid_t& val) 
101 {
102 //MESSAGE(cerr, "in tuple():: pinned_component()");
103 //debug(cerr, index);
104 //debug(cerr, val);
105       return oid_list::update_component(index, val);
106 }
107
108 io_status tuple::asciiOut(ostream& out) 
109 {
110    out << "OID_T:\n";
111    my_oid().asciiOut(out); 
112    out << "\n";
113    // debug(cerr, v_sz);
114
115    for ( unsigned int i=1; i<=v_sz; i++ ) {
116     
117       handler* hd_ptr = get_component(i);
118
119       if ( hd_ptr == 0 )
120          continue;
121
122
123       (*hd_ptr) -> asciiOut(out);
124
125
126       out << "\n";
127
128       delete hd_ptr;
129    }
130    return done;
131 }
132
133 io_status tuple::asciiIn(istream& in)
134 {
135
136 /*
137 MESSAGE(cerr, "in tuple asciiIn()");
138 my_oid().asciiOut(cerr);
139 MESSAGE(cerr, "\n");
140 */
141    int comps; in >> comps; 
142
143    if ( comps > MAX_COMPS ) {
144       debug(cerr, comps);
145       throw(stringException("exceed MAX_COMPS"));
146    }
147
148 //debug(cerr, comps);
149
150    int ret = in.get();
151
152    if ( ret != '\n' ) {
153       debug(cerr, ret);
154       throw(stringException("'\\n' expected"));
155    }
156
157    if ( comps > (int) v_sz ) {
158 MESSAGE(cerr, "tuple asciiIn(): to expand space");
159 debug(cerr, comps);
160 debug(cerr, v_sz);
161      oid_list::expand_space(comps - v_sz);
162      v_sz = comps;
163    }
164
165
166    handler *hd_ptr = 0;
167
168    for ( int i=1; i<=comps; i++ ) {
169  
170       c_code_t ccode;
171       in >> ccode;  
172
173       if ( in.get() != '\n' ) {
174          throw(stringException("'\\n' expected"));
175       }
176
177       hd_ptr = new handler(ccode, storage_ptr);
178
179       (*hd_ptr) -> asciiIn(in);
180
181       pinned_insert(i, hd_ptr -> its_oid());
182
183       delete hd_ptr;
184    }
185
186    set_mode(UPDATE, true);
187
188    return done;
189 }
190
191 MMDB_BODIES(tuple)
192 HANDLER_BODIES(tuple)