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: long_pstring.cc /main/4 1996/06/11 17:24:42 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/long_pstring.h"
54 /****************************************************/
55 // long_pstring member funcions: CONS/DEST
56 /****************************************************/
58 long_pstring::long_pstring(c_code_t c_id) : pstring(c_id), v_str_index(0)
60 set_mode(SWAP_ALLOWED, false);
64 long_pstring::long_pstring(char* x, int leng, c_code_t c_id) : pstring(x, leng, c_id), v_str_index(0)
68 long_pstring::long_pstring(long_pstring& x) : pstring(x)
73 long_pstring::~long_pstring()
78 /****************************************************/
79 // long_pstring member funcions: OTHERS
80 /****************************************************/
82 long_pstring::extract(int left, int right, char* sink)
86 //debug(cerr, int(v_str_ptr.loc));
88 if ( left > right || right - left > (int) v_sz ) {
89 throw(boundaryException(left, right, v_sz));
92 if ( get_mode(PERSISTENT) == true ) {
94 if ( v_str_index == 0 &&
95 get_mode(OLD_OBJECT) == true && v_sz > PAGSIZ
97 v_str_index = new chunks_index(storage_ptr, v_str_ptr.loc);
101 str_index_record_t* anchor = v_str_index -> chunk_location(left);
103 //debug(cerr, left - anchor -> str_offset);
105 readString(anchor -> loc, sink,
106 right-left, left - anchor -> str_offset
112 storage_ptr -> readString(v_str_ptr.loc, sink, right-left, left);
116 memcpy(sink, v_str_ptr.p + left, right - left);
119 //for ( int i=0;i<right-left; i++)
120 // cerr << int(sink[i]) << " ";
128 Boolean long_pstring::value_LS(root& x, Boolean safe) const
131 ( f_oid.ccode() != LONG_STRING_CODE ||
132 x.my_oid().ccode() != LONG_STRING_CODE
137 return pstring::value_LS(x, false);
140 Boolean long_pstring::value_EQ(root& x, Boolean safe) const
143 ( f_oid.ccode() != LONG_STRING_CODE ||
144 x.my_oid().ccode() != LONG_STRING_CODE
149 return pstring::value_EQ(x, false);
153 io_status long_pstring::asciiIn(istream& in)
155 if ( pstring::asciiIn(in) == done ) {
156 v_str_index = ( get_mode(PERSISTENT) == true && v_sz > PAGSIZ ) ?
157 new chunks_index(storage_ptr, v_str_ptr.loc) :
164 MMDB_BODIES(long_pstring)
165 HANDLER_BODIES(long_pstring)