comparison src/ov-base-scalar.cc @ 3933:f9ea3dcf58ee

[project @ 2002-05-15 03:21:00 by jwe]
author jwe
date Wed, 15 May 2002 03:21:01 +0000
parents b80bbb43a1a9
children 7690958e7726
comparison
equal deleted inserted replaced
3932:2e2e32198722 3933:f9ea3dcf58ee
29 #endif 29 #endif
30 30
31 #include <iostream> 31 #include <iostream>
32 32
33 #include "ov-base.h" 33 #include "ov-base.h"
34 #include "ov-cx-mat.h"
35 #include "ov-re-mat.h"
34 #include "ov-base-scalar.h" 36 #include "ov-base-scalar.h"
35 #include "pr-output.h" 37 #include "pr-output.h"
38
39 template <class ST>
40 octave_value
41 octave_base_scalar<ST>::subsref (const std::string type,
42 const SLList<octave_value_list>& idx)
43 {
44 octave_value retval;
45
46 switch (type[0])
47 {
48 case '(':
49 retval = do_index_op (idx.front ());
50 break;
51
52 case '{':
53 case '.':
54 {
55 std::string nm = type_name ();
56 error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
57 }
58 break;
59
60 default:
61 panic_impossible ();
62 }
63
64 return retval.next_subsref (type, idx);
65 }
66
67 template <class ST>
68 octave_value
69 octave_base_scalar<ST>::subsasgn (const std::string type,
70 const SLList<octave_value_list>& idx,
71 const octave_value& rhs)
72 {
73 octave_value retval;
74
75 switch (type[0])
76 {
77 case '(':
78 {
79 if (type.length () == 1)
80 {
81 if (idx.front().valid_scalar_indices ()
82 && rhs.is_scalar_type ()
83 && rhs.is_numeric_type ())
84 retval = rhs;
85 else
86 retval = numeric_assign (type, idx, rhs);
87 }
88 else
89 {
90 std::string nm = type_name ();
91 error ("in indexed assignment of %s, last rhs index must be ()",
92 nm.c_str ());
93 }
94 }
95 break;
96
97 case '{':
98 case '.':
99 {
100 std::string nm = type_name ();
101 error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
102 }
103 break;
104
105 default:
106 panic_impossible ();
107 }
108
109 return retval;
110 }
36 111
37 template <class ST> 112 template <class ST>
38 void 113 void
39 octave_base_scalar<ST>::print (std::ostream& os, bool pr_as_read_syntax) const 114 octave_base_scalar<ST>::print (std::ostream& os, bool pr_as_read_syntax) const
40 { 115 {
42 newline (os); 117 newline (os);
43 } 118 }
44 119
45 template <class ST> 120 template <class ST>
46 void 121 void
47 octave_base_scalar<ST>::print_raw (std::ostream& os, bool pr_as_read_syntax) const 122 octave_base_scalar<ST>::print_raw (std::ostream& os,
123 bool pr_as_read_syntax) const
48 { 124 {
49 indent (os); 125 indent (os);
50 octave_print_internal (os, scalar, pr_as_read_syntax); 126 octave_print_internal (os, scalar, pr_as_read_syntax);
51 } 127 }
52 128
53 template <class ST> 129 template <class ST>
54 bool 130 bool
55 octave_base_scalar<ST>::print_name_tag (std::ostream& os, const std::string& name) const 131 octave_base_scalar<ST>::print_name_tag (std::ostream& os,
132 const std::string& name) const
56 { 133 {
57 indent (os); 134 indent (os);
58 os << name << " = "; 135 os << name << " = ";
59 return false; 136 return false;
60 } 137 }