Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / object / long_pstring.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: long_pstring.cc /main/4 1996/06/11 17:24:42 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/long_pstring.h"
52
53
54 /****************************************************/
55 // long_pstring member funcions: CONS/DEST
56 /****************************************************/
57
58 long_pstring::long_pstring(c_code_t c_id) : pstring(c_id), v_str_index(0)
59 {
60     set_mode(SWAP_ALLOWED, false); 
61 }
62    
63
64 long_pstring::long_pstring(char* x, int leng, c_code_t c_id) : pstring(x, leng, c_id), v_str_index(0)
65 {
66 }
67
68 long_pstring::long_pstring(long_pstring& x) : pstring(x)
69 {
70    v_str_index = 0;
71 }
72
73 long_pstring::~long_pstring()
74 {
75    delete v_str_index;
76 }
77
78 /****************************************************/
79 // long_pstring member funcions: OTHERS
80 /****************************************************/
81 Boolean 
82 long_pstring::extract(int left, int right, char* sink)
83 {
84 //debug(cerr, left);
85 //debug(cerr, right);
86 //debug(cerr, int(v_str_ptr.loc));
87
88    if ( left > right || right - left > (int) v_sz ) {
89       throw(boundaryException(left, right, v_sz));
90    }
91   
92    if ( get_mode(PERSISTENT) == true ) {
93
94    if ( v_str_index == 0 && 
95         get_mode(OLD_OBJECT) == true && v_sz > PAGSIZ 
96       )
97       v_str_index = new chunks_index(storage_ptr, v_str_ptr.loc);
98
99       if ( v_str_index ) {
100
101          str_index_record_t* anchor = v_str_index -> chunk_location(left);
102
103 //debug(cerr, left - anchor -> str_offset);
104          storage_ptr -> 
105              readString(anchor -> loc, sink, 
106                         right-left, left - anchor -> str_offset
107                        );
108
109       } else 
110
111 //debug(cerr, left);
112          storage_ptr -> readString(v_str_ptr.loc, sink, right-left, left);
113
114
115    } else {
116       memcpy(sink, v_str_ptr.p + left, right - left);
117    }
118
119 //for ( int i=0;i<right-left; i++)
120 //  cerr << int(sink[i]) << " ";
121 //cerr << "\n";
122
123    return true;
124 }
125
126
127 /*
128 Boolean long_pstring::value_LS(root& x, Boolean safe) const
129 {
130    if ( safe == true &&
131         ( f_oid.ccode() != LONG_STRING_CODE ||
132           x.my_oid().ccode() != LONG_STRING_CODE
133         ) 
134       ) 
135      return false;
136
137    return pstring::value_LS(x, false);
138 }
139
140 Boolean long_pstring::value_EQ(root& x, Boolean safe) const
141 {
142    if ( safe == true &&
143         ( f_oid.ccode() != LONG_STRING_CODE ||
144            x.my_oid().ccode() != LONG_STRING_CODE
145         ) 
146       )
147      return false;
148    
149    return pstring::value_EQ(x, false);
150 }
151 */
152
153 io_status long_pstring::asciiIn(istream& in) 
154 {
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) : 
158                  0;
159      return done;
160   } else
161      return fail; 
162 }
163
164 MMDB_BODIES(long_pstring)
165 HANDLER_BODIES(long_pstring)