Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026
00027 #include "ov-null-mat.h"
00028 #include "ops.h"
00029 #include "defun.h"
00030
00031 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_null_matrix, "null_matrix", "double");
00032
00033 const octave_value octave_null_matrix::instance (new octave_null_matrix ());
00034
00035 static octave_base_value *
00036 default_null_matrix_numeric_conversion_function (const octave_base_value& a)
00037 {
00038
00039
00040
00041 return a.empty_clone ();
00042 }
00043
00044 octave_base_value::type_conv_info
00045 octave_null_matrix::numeric_conversion_function (void) const
00046 {
00047 return octave_base_value::type_conv_info (default_null_matrix_numeric_conversion_function,
00048 octave_matrix::static_type_id ());
00049 }
00050
00051 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_null_str, "null_string", "char");
00052
00053 const octave_value octave_null_str::instance (new octave_null_str ());
00054
00055 static octave_base_value *
00056 default_null_str_numeric_conversion_function (const octave_base_value& a)
00057 {
00058
00059
00060
00061 return a.empty_clone ();
00062 }
00063
00064 octave_base_value::type_conv_info
00065 octave_null_str::numeric_conversion_function (void) const
00066 {
00067 return octave_base_value::type_conv_info (default_null_str_numeric_conversion_function,
00068 octave_char_matrix_str::static_type_id ());
00069 }
00070
00071 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_null_sq_str, "null_sq_string", "char");
00072
00073 const octave_value octave_null_sq_str::instance (new octave_null_sq_str ());
00074
00075 static octave_base_value *
00076 default_null_sq_str_numeric_conversion_function (const octave_base_value& a)
00077 {
00078
00079
00080
00081 return a.empty_clone ();
00082 }
00083
00084 octave_base_value::type_conv_info
00085 octave_null_sq_str::numeric_conversion_function (void) const
00086 {
00087 return octave_base_value::type_conv_info (default_null_sq_str_numeric_conversion_function,
00088 octave_char_matrix_sq_str::static_type_id ());
00089 }
00090
00091 DEFUN (isnull, args, ,
00092 "-*- texinfo -*-\n\
00093 @deftypefn {Built-in Function} {} isnull (@var{x})\n\
00094 Return true if @var{x} is a special null matrix, string, or single quoted\n\
00095 string. Indexed assignment with such a value on the right-hand side should\n\
00096 delete array elements. This function should be used when overloading\n\
00097 indexed assignment for user-defined classes instead of @code{isempty}, to\n\
00098 distinguish the cases:\n\
00099 @table @asis\n\
00100 @item @code{A(I) = []}\n\
00101 This should delete elements if @code{I} is nonempty.\n\
00102 \n\
00103 @item @code{X = []; A(I) = X}\n\
00104 This should give an error if @code{I} is nonempty.\n\
00105 @end table\n\
00106 @seealso{isempty, isindex}\n\
00107 @end deftypefn")
00108 {
00109 octave_value retval;
00110
00111 int nargin = args.length ();
00112
00113 if (nargin == 1 && args(0).is_defined ())
00114 retval = args(0).is_null_value ();
00115 else
00116 print_usage ();
00117
00118 return retval;
00119 }
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134