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: tuple.cc /main/4 1996/06/11 17:26:06 cde-hal $
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
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.
51 #include "object/tuple.h"
55 tuple::tuple(c_code_t c_cd) : oid_list(c_cd)
59 tuple::tuple(int comps, c_code_t c_cd) : oid_list(comps, c_cd)
63 tuple::tuple(tuple& x) : oid_list(x)
71 handler* tuple::get_component(int index)
74 //MESSAGE(cerr, "in tuple():: get_component()");
76 //debug(cerr, my_oid());
77 //debug(cerr, int(storage_ptr));
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) );
85 oid_t x = oid_list::operator()(index);
89 //debug(cerr, x.ccode());
90 //debug(cerr, x.icode());
95 y = new handler(x, storage_ptr);
100 Boolean tuple::pinned_insert(int index, const oid_t& val)
102 //MESSAGE(cerr, "in tuple():: pinned_component()");
103 //debug(cerr, index);
105 return oid_list::update_component(index, val);
108 io_status tuple::asciiOut(ostream& out)
111 my_oid().asciiOut(out);
113 // debug(cerr, v_sz);
115 for ( unsigned int i=1; i<=v_sz; i++ ) {
117 handler* hd_ptr = get_component(i);
123 (*hd_ptr) -> asciiOut(out);
133 io_status tuple::asciiIn(istream& in)
137 MESSAGE(cerr, "in tuple asciiIn()");
138 my_oid().asciiOut(cerr);
141 int comps; in >> comps;
143 if ( comps > MAX_COMPS ) {
145 throw(stringException("exceed MAX_COMPS"));
148 //debug(cerr, comps);
154 throw(stringException("'\\n' expected"));
157 if ( comps > (int) v_sz ) {
158 MESSAGE(cerr, "tuple asciiIn(): to expand space");
161 oid_list::expand_space(comps - v_sz);
168 for ( int i=1; i<=comps; i++ ) {
173 if ( in.get() != '\n' ) {
174 throw(stringException("'\\n' expected"));
177 hd_ptr = new handler(ccode, storage_ptr);
179 (*hd_ptr) -> asciiIn(in);
181 pinned_insert(i, hd_ptr -> its_oid());
186 set_mode(UPDATE, true);
192 HANDLER_BODIES(tuple)