Mercurial > hg > octave-nkf
comparison liboctave/Array.cc @ 5765:7ba9ad1fec11
[project @ 2006-04-17 05:05:15 by jwe]
author | jwe |
---|---|
date | Mon, 17 Apr 2006 05:05:17 +0000 |
parents | 6e9a14b3c299 |
children | ace8d8d26933 |
comparison
equal
deleted
inserted
replaced
5764:80409c2defcc | 5765:7ba9ad1fec11 |
---|---|
28 | 28 |
29 #include <cassert> | 29 #include <cassert> |
30 #include <climits> | 30 #include <climits> |
31 | 31 |
32 #include <iostream> | 32 #include <iostream> |
33 #include <sstream> | |
33 #include <vector> | 34 #include <vector> |
34 | 35 |
35 #include "Array.h" | 36 #include "Array.h" |
36 #include "Array-flags.h" | 37 #include "Array-flags.h" |
37 #include "Array-util.h" | 38 #include "Array-util.h" |
38 #include "Range.h" | 39 #include "Range.h" |
39 #include "idx-vector.h" | 40 #include "idx-vector.h" |
40 #include "lo-error.h" | 41 #include "lo-error.h" |
41 #include "lo-sstream.h" | |
42 | 42 |
43 // One dimensional array class. Handles the reference counting for | 43 // One dimensional array class. Handles the reference counting for |
44 // all the derived classes. | 44 // all the derived classes. |
45 | 45 |
46 template <class T> | 46 template <class T> |
352 | 352 |
353 template <class T> | 353 template <class T> |
354 T | 354 T |
355 Array<T>::range_error (const char *fcn, const Array<int>& ra_idx) const | 355 Array<T>::range_error (const char *fcn, const Array<int>& ra_idx) const |
356 { | 356 { |
357 OSSTREAM buf; | 357 std::ostringstream buf; |
358 | 358 |
359 buf << fcn << " ("; | 359 buf << fcn << " ("; |
360 | 360 |
361 octave_idx_type n = ra_idx.length (); | 361 octave_idx_type n = ra_idx.length (); |
362 | 362 |
366 for (octave_idx_type i = 1; i < n; i++) | 366 for (octave_idx_type i = 1; i < n; i++) |
367 buf << ", " << ra_idx(i); | 367 buf << ", " << ra_idx(i); |
368 | 368 |
369 buf << "): range error"; | 369 buf << "): range error"; |
370 | 370 |
371 buf << OSSTREAM_ENDS; | 371 std::string buf_str = buf.str (); |
372 | 372 |
373 (*current_liboctave_error_handler) (OSSTREAM_C_STR (buf)); | 373 (*current_liboctave_error_handler) (buf_str.c_str ()); |
374 | |
375 OSSTREAM_FREEZE (buf); | |
376 | 374 |
377 return T (); | 375 return T (); |
378 } | 376 } |
379 | 377 |
380 template <class T> | 378 template <class T> |
381 T& | 379 T& |
382 Array<T>::range_error (const char *fcn, const Array<int>& ra_idx) | 380 Array<T>::range_error (const char *fcn, const Array<int>& ra_idx) |
383 { | 381 { |
384 OSSTREAM buf; | 382 std::ostringstream buf; |
385 | 383 |
386 buf << fcn << " ("; | 384 buf << fcn << " ("; |
387 | 385 |
388 octave_idx_type n = ra_idx.length (); | 386 octave_idx_type n = ra_idx.length (); |
389 | 387 |
393 for (octave_idx_type i = 1; i < n; i++) | 391 for (octave_idx_type i = 1; i < n; i++) |
394 buf << ", " << ra_idx(i); | 392 buf << ", " << ra_idx(i); |
395 | 393 |
396 buf << "): range error"; | 394 buf << "): range error"; |
397 | 395 |
398 buf << OSSTREAM_ENDS; | 396 std::string buf_str = buf.str (); |
399 | 397 |
400 (*current_liboctave_error_handler) (OSSTREAM_C_STR (buf)); | 398 (*current_liboctave_error_handler) (buf_str.c_str ()); |
401 | |
402 OSSTREAM_FREEZE (buf); | |
403 | 399 |
404 static T foo; | 400 static T foo; |
405 return foo; | 401 return foo; |
406 } | 402 } |
407 | 403 |