ov-ch-mat.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1996-2012 John W. Eaton
00004 Copyright (C) 2009-2010 VZLU Prague
00005 
00006 This file is part of Octave.
00007 
00008 Octave is free software; you can redistribute it and/or modify it
00009 under the terms of the GNU General Public License as published by the
00010 Free Software Foundation; either version 3 of the License, or (at your
00011 option) any later version.
00012 
00013 Octave is distributed in the hope that it will be useful, but WITHOUT
00014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00015 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00016 for more details.
00017 
00018 You should have received a copy of the GNU General Public License
00019 along with Octave; see the file COPYING.  If not, see
00020 <http://www.gnu.org/licenses/>.
00021 
00022 */
00023 
00024 #if !defined (octave_char_matrix_h)
00025 #define octave_char_matrix_h 1
00026 
00027 #include <cstdlib>
00028 
00029 #include <iosfwd>
00030 #include <string>
00031 
00032 #include "mx-base.h"
00033 #include "oct-alloc.h"
00034 #include "str-vec.h"
00035 
00036 #include "error.h"
00037 #include "ov.h"
00038 #include "ov-base.h"
00039 #include "ov-base-mat.h"
00040 #include "ov-re-mat.h"
00041 #include "ov-typeinfo.h"
00042 
00043 class octave_value_list;
00044 
00045 class tree_walker;
00046 
00047 // Character matrix values.
00048 
00049 class
00050 octave_char_matrix : public octave_base_matrix<charNDArray>
00051 {
00052 protected:
00053 
00054   octave_char_matrix (void)
00055     : octave_base_matrix<charNDArray> () { }
00056 
00057   octave_char_matrix (const charMatrix& chm)
00058     : octave_base_matrix<charNDArray> (chm) { }
00059 
00060   octave_char_matrix (const charNDArray& chm)
00061     : octave_base_matrix<charNDArray> (chm) { }
00062 
00063   octave_char_matrix (const Array<char>& chm)
00064     : octave_base_matrix<charNDArray> (chm) { }
00065 
00066   octave_char_matrix (char c)
00067     : octave_base_matrix<charNDArray> (c) { }
00068 
00069   octave_char_matrix (const char *s)
00070     : octave_base_matrix<charNDArray> (s) { }
00071 
00072   octave_char_matrix (const std::string& s)
00073     : octave_base_matrix<charNDArray> (s) { }
00074 
00075   octave_char_matrix (const string_vector& s)
00076     : octave_base_matrix<charNDArray> (s) { }
00077 
00078   octave_char_matrix (const octave_char_matrix& chm)
00079     : octave_base_matrix<charNDArray> (chm) { }
00080 
00081 public:
00082 
00083   ~octave_char_matrix (void) { }
00084 
00085   octave_base_value *clone (void) const { return new octave_char_matrix (*this); }
00086   octave_base_value *empty_clone (void) const { return new octave_char_matrix (); }
00087 
00088   idx_vector index_vector (void) const;
00089 
00090   builtin_type_t builtin_type (void) const { return btyp_char; }
00091 
00092   bool is_char_matrix (void) const { return true; }
00093   bool is_real_matrix (void) const { return true; }
00094 
00095   bool is_real_type (void) const { return true; }
00096 
00097   double double_value (bool = false) const;
00098 
00099   float float_value (bool = false) const;
00100 
00101   double scalar_value (bool frc_str_conv = false) const
00102     { return double_value (frc_str_conv); }
00103 
00104   float float_scalar_value (bool frc_str_conv = false) const
00105     { return float_value (frc_str_conv); }
00106 
00107   Matrix matrix_value (bool = false) const
00108     { return Matrix (matrix.matrix_value ()); }
00109 
00110   FloatMatrix float_matrix_value (bool = false) const
00111     { return FloatMatrix (matrix.matrix_value ()); }
00112 
00113   NDArray array_value (bool = false) const
00114     { return NDArray (matrix); }
00115 
00116   FloatNDArray float_array_value (bool = false) const
00117     { return FloatNDArray (matrix); }
00118 
00119   Complex complex_value (bool = false) const;
00120 
00121   FloatComplex float_complex_value (bool = false) const;
00122 
00123   ComplexMatrix complex_matrix_value (bool = false) const
00124     { return ComplexMatrix (matrix.matrix_value ()); }
00125 
00126   FloatComplexMatrix float_complex_matrix_value (bool = false) const
00127     { return FloatComplexMatrix (matrix.matrix_value ()); }
00128 
00129   ComplexNDArray complex_array_value (bool = false) const
00130     { return ComplexNDArray (matrix); }
00131 
00132   FloatComplexNDArray float_complex_array_value (bool = false) const
00133     { return FloatComplexNDArray (matrix); }
00134 
00135   charMatrix char_matrix_value (bool = false) const
00136     { return matrix.matrix_value (); }
00137 
00138   charNDArray char_array_value (bool = false) const
00139     { return matrix; }
00140 
00141   octave_value convert_to_str_internal (bool, bool, char type) const
00142     { return octave_value (matrix, type); }
00143 
00144   void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
00145 
00146   // Unsafe.  This function exists to support the MEX interface.
00147   // You should not use it anywhere else.
00148   void *mex_get_data (void) const { return matrix.mex_get_data (); }
00149 
00150   mxArray *as_mxArray (void) const;
00151 
00152   octave_value map (unary_mapper_t umap) const;
00153 };
00154 
00155 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines