3978
|
1 /* |
|
2 |
|
3 Copyright (C) 2002 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
4192
|
23 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
3978
|
24 #pragma implementation |
|
25 #endif |
|
26 |
|
27 #ifdef HAVE_CONFIG_H |
|
28 #include <config.h> |
|
29 #endif |
|
30 |
|
31 #include <iostream> |
|
32 |
4051
|
33 #include "lo-sstream.h" |
3978
|
34 #include "lo-utils.h" |
|
35 |
|
36 #include "defun.h" |
|
37 #include "error.h" |
|
38 #include "ov-cs-list.h" |
|
39 #include "unwind-prot.h" |
|
40 |
|
41 DEFINE_OCTAVE_ALLOCATOR (octave_cs_list); |
|
42 |
|
43 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_cs_list, "cs-list"); |
|
44 |
4591
|
45 octave_cs_list::octave_cs_list (const Cell& c) |
3978
|
46 { |
4591
|
47 int n = c.length (); |
3978
|
48 |
4591
|
49 lst.resize (n); |
3978
|
50 |
4591
|
51 for (int i = 0; i < n; i++) |
|
52 lst(i) = c(i); |
3978
|
53 } |
|
54 |
|
55 void |
4499
|
56 octave_cs_list::print_raw (std::ostream& os, bool) const |
3978
|
57 { |
4591
|
58 unwind_protect::begin_frame ("octave_cs_list_print"); |
3978
|
59 |
|
60 int n = lst.length (); |
|
61 |
|
62 if (n > 0) |
|
63 { |
|
64 indent (os); |
4499
|
65 os << "(,"; |
3978
|
66 newline (os); |
|
67 |
|
68 increment_indent_level (); |
|
69 |
|
70 for (int i = 0; i < n; i++) |
|
71 { |
4051
|
72 OSSTREAM buf; |
|
73 buf << "[" << i+1 << "]" << OSSTREAM_ENDS; |
3978
|
74 |
|
75 octave_value val = lst(i); |
|
76 |
4051
|
77 val.print_with_name (os, OSSTREAM_STR (buf)); |
3978
|
78 |
4051
|
79 OSSTREAM_FREEZE (buf); |
3978
|
80 } |
|
81 |
|
82 decrement_indent_level (); |
|
83 |
|
84 indent (os); |
4499
|
85 os << ",)"; |
3978
|
86 } |
|
87 else |
4499
|
88 os << "(,,)"; |
3978
|
89 |
|
90 newline (os); |
|
91 |
4591
|
92 unwind_protect::run_frame ("octave_cs_list_print"); |
3978
|
93 } |
|
94 |
|
95 /* |
|
96 ;;; Local Variables: *** |
|
97 ;;; mode: C++ *** |
|
98 ;;; End: *** |
|
99 */ |