comparison src/ls-oct-binary.cc @ 5828:22e23bee74c8

[project @ 2006-05-23 06:05:14 by jwe]
author jwe
date Tue, 23 May 2006 06:05:14 +0000
parents ace8d8d26933
children 3e5a3b5fd40e
comparison
equal deleted inserted replaced
5827:1fe78adb91bc 5828:22e23bee74c8
139 { 139 {
140 std::string retval; 140 std::string retval;
141 141
142 char tmp = 0; 142 char tmp = 0;
143 143
144 FOUR_BYTE_INT name_len = 0; 144 int32_t name_len = 0;
145 FOUR_BYTE_INT doc_len = 0; 145 int32_t doc_len = 0;
146 146
147 doc.resize (0); 147 doc.resize (0);
148 148
149 // We expect to fail here, at the beginning of a record, so not 149 // We expect to fail here, at the beginning of a record, so not
150 // being able to read another name should not result in an error. 150 // being able to read another name should not result in an error.
207 case 5: 207 case 5:
208 { 208 {
209 // FIXMEX 209 // FIXMEX
210 // This is cruft, since its for a save type that is old. Maybe 210 // This is cruft, since its for a save type that is old. Maybe
211 // this is taking backward compatability too far!! 211 // this is taking backward compatability too far!!
212 FOUR_BYTE_INT len; 212 int32_t len;
213 if (! is.read (reinterpret_cast<char *> (&len), 4)) 213 if (! is.read (reinterpret_cast<char *> (&len), 4))
214 goto data_read_error; 214 goto data_read_error;
215 if (swap) 215 if (swap)
216 swap_bytes<4> (&len); 216 swap_bytes<4> (&len);
217 OCTAVE_LOCAL_BUFFER (char, s, len+1); 217 OCTAVE_LOCAL_BUFFER (char, s, len+1);
234 break; 234 break;
235 235
236 case 255: 236 case 255:
237 { 237 {
238 // Read the saved variable type 238 // Read the saved variable type
239 FOUR_BYTE_INT len; 239 int32_t len;
240 if (! is.read (reinterpret_cast<char *> (&len), 4)) 240 if (! is.read (reinterpret_cast<char *> (&len), 4))
241 goto data_read_error; 241 goto data_read_error;
242 if (swap) 242 if (swap)
243 swap_bytes<4> (&len); 243 swap_bytes<4> (&len);
244 OCTAVE_LOCAL_BUFFER (char, s, len+1); 244 OCTAVE_LOCAL_BUFFER (char, s, len+1);
270 bool 270 bool
271 save_binary_data (std::ostream& os, const octave_value& tc, 271 save_binary_data (std::ostream& os, const octave_value& tc,
272 const std::string& name, const std::string& doc, 272 const std::string& name, const std::string& doc,
273 bool mark_as_global, bool save_as_floats) 273 bool mark_as_global, bool save_as_floats)
274 { 274 {
275 FOUR_BYTE_INT name_len = name.length (); 275 int32_t name_len = name.length ();
276 276
277 os.write (reinterpret_cast<char *> (&name_len), 4); 277 os.write (reinterpret_cast<char *> (&name_len), 4);
278 os << name; 278 os << name;
279 279
280 FOUR_BYTE_INT doc_len = doc.length (); 280 int32_t doc_len = doc.length ();
281 281
282 os.write (reinterpret_cast<char *> (&doc_len), 4); 282 os.write (reinterpret_cast<char *> (&doc_len), 4);
283 os << doc; 283 os << doc;
284 284
285 unsigned char tmp; 285 unsigned char tmp;
291 tmp = 255; 291 tmp = 255;
292 os.write (reinterpret_cast<char *> (&tmp), 1); 292 os.write (reinterpret_cast<char *> (&tmp), 1);
293 293
294 // Write the string corresponding to the octave_value type 294 // Write the string corresponding to the octave_value type
295 std::string typ = tc.type_name (); 295 std::string typ = tc.type_name ();
296 FOUR_BYTE_INT len = typ.length (); 296 int32_t len = typ.length ();
297 os.write (reinterpret_cast<char *> (&len), 4); 297 os.write (reinterpret_cast<char *> (&len), 4);
298 const char *btmp = typ.data (); 298 const char *btmp = typ.data ();
299 os.write (btmp, len); 299 os.write (btmp, len);
300 300
301 // The octave_value of tc is const. Make a copy... 301 // The octave_value of tc is const. Make a copy...