Mercurial > hg > octave-nkf
comparison src/ov-struct.cc @ 2901:e6d25bc478dd
[project @ 1997-04-30 03:41:26 by jwe]
author | jwe |
---|---|
date | Wed, 30 Apr 1997 03:43:29 +0000 |
parents | 8b262e771614 |
children | 4c8dd4d79558 |
comparison
equal
deleted
inserted
replaced
2900:5ed088015839 | 2901:e6d25bc478dd |
---|---|
63 { | 63 { |
64 return map [nm]; | 64 return map [nm]; |
65 } | 65 } |
66 | 66 |
67 void | 67 void |
68 octave_struct::print (ostream& os, bool) | 68 octave_struct::print (ostream& os, bool) const |
69 { | |
70 print_raw (os); | |
71 } | |
72 | |
73 void | |
74 octave_struct::print_raw (ostream& os, bool) const | |
69 { | 75 { |
70 // XXX FIXME XXX -- would be nice to print the output in some | 76 // XXX FIXME XXX -- would be nice to print the output in some |
71 // standard order. Maybe all substructures first, maybe | 77 // standard order. Maybe all substructures first, maybe |
72 // alphabetize entries, etc. | 78 // alphabetize entries, etc. |
73 | 79 |
74 begin_unwind_frame ("octave_struct_print"); | 80 begin_unwind_frame ("octave_struct_print"); |
75 | 81 |
76 unwind_protect_int (struct_indent); | |
77 unwind_protect_int (Vstruct_levels_to_print); | 82 unwind_protect_int (Vstruct_levels_to_print); |
78 | 83 |
79 if (Vstruct_levels_to_print-- > 0) | 84 if (Vstruct_levels_to_print-- > 0) |
80 { | 85 { |
81 os.form ("\n%*s{\n", struct_indent, ""); | 86 newline (os); |
87 indent (os); | |
88 os << "{"; | |
89 newline (os); | |
82 | 90 |
83 increment_struct_indent (); | 91 increment_indent_level (); |
84 | 92 |
85 Pix p = map.first (); | 93 for (Pix p = map.first (); p; map.next (p)) |
86 | |
87 while (p) | |
88 { | 94 { |
89 bool pad_after = false; | |
90 | |
91 string key = map.key (p); | 95 string key = map.key (p); |
92 octave_value val = map.contents (p); | 96 octave_value val = map.contents (p); |
93 | 97 |
94 map.next (p); | 98 val.print_with_name (os, key); |
95 | |
96 os.form ("%*s%s =", struct_indent, "", key.c_str ()); | |
97 | |
98 if (val.print_as_scalar ()) | |
99 os << " "; | |
100 else if (val.is_map ()) | |
101 { | |
102 if (p) | |
103 pad_after = true; | |
104 } | |
105 else | |
106 { | |
107 if (p) | |
108 pad_after = true; | |
109 | |
110 os << "\n\n"; | |
111 } | |
112 | |
113 val.print (os); | |
114 | |
115 if (pad_after) | |
116 os << "\n"; | |
117 } | 99 } |
118 | 100 |
119 decrement_struct_indent (); | 101 decrement_indent_level (); |
120 | 102 |
121 os.form ("%*s%s", struct_indent, "", "}\n"); | 103 indent (os); |
104 os << "}"; | |
105 newline (os); | |
122 } | 106 } |
123 else | 107 else |
124 os << " <structure>\n"; | 108 { |
109 os << " <structure>"; | |
110 newline (os); | |
111 } | |
125 | 112 |
126 run_unwind_frame ("octave_struct_print"); | 113 run_unwind_frame ("octave_struct_print"); |
114 } | |
115 | |
116 bool | |
117 octave_struct::print_name_tag (ostream& os, const string& name) const | |
118 { | |
119 indent (os); | |
120 os << name << " ="; | |
121 newline (os); | |
122 return false; | |
127 } | 123 } |
128 | 124 |
129 /* | 125 /* |
130 ;;; Local Variables: *** | 126 ;;; Local Variables: *** |
131 ;;; mode: C++ *** | 127 ;;; mode: C++ *** |