ov-base-int.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2004-2012 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #if !defined (octave_base_int_matrix_h)
00024 #define octave_base_int_matrix_h 1
00025 
00026 #include <cstdlib>
00027 
00028 #include <iosfwd>
00029 #include <string>
00030 
00031 #include "mx-base.h"
00032 #include "oct-alloc.h"
00033 #include "str-vec.h"
00034 
00035 #include "error.h"
00036 #include "ov-base.h"
00037 #include "ov-base-mat.h"
00038 #include "ov-base-scalar.h"
00039 #include "ov-typeinfo.h"
00040 
00041 // base int matrix values.
00042 
00043 template <class T>
00044 class
00045 octave_base_int_matrix : public octave_base_matrix<T>
00046 {
00047 public:
00048 
00049   octave_base_int_matrix (void) : octave_base_matrix<T> () { }
00050 
00051   octave_base_int_matrix (const T& nda) : octave_base_matrix<T> (nda) { }
00052 
00053   ~octave_base_int_matrix (void) { }
00054 
00055   octave_base_value *clone (void) const { return new octave_base_int_matrix (*this); }
00056   octave_base_value *empty_clone (void) const { return new octave_base_int_matrix (); }
00057 
00058   octave_base_value *try_narrowing_conversion (void);
00059 
00060   bool is_real_type (void) const { return true; }
00061 
00062   //  void increment (void) { matrix += 1; }
00063 
00064   //  void decrement (void) { matrix -= 1; }
00065 
00066   void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
00067 
00068   octave_value convert_to_str_internal (bool, bool, char type) const;
00069 
00070   bool save_ascii (std::ostream& os);
00071 
00072   bool load_ascii (std::istream& is);
00073 
00074   bool save_binary (std::ostream& os, bool& );
00075 
00076   bool load_binary (std::istream& is, bool swap,
00077                     oct_mach_info::float_format );
00078 
00079 #if defined (HAVE_HDF5)
00080   bool save_hdf5 (hid_t loc_id, const char *name, bool);
00081 
00082   bool load_hdf5 (hid_t loc_id, const char *name);
00083 #endif
00084 };
00085 
00086 // base int scalar values.
00087 
00088 template <class T>
00089 class
00090 octave_base_int_scalar : public octave_base_scalar<T>
00091 {
00092 public:
00093 
00094   octave_base_int_scalar (void) : octave_base_scalar<T> () { }
00095 
00096   octave_base_int_scalar (const T& s) : octave_base_scalar<T> (s) { }
00097 
00098   ~octave_base_int_scalar (void) { }
00099 
00100   octave_base_value *clone (void) const { return new octave_base_int_scalar (*this); }
00101   octave_base_value *empty_clone (void) const { return new octave_base_int_scalar (); }
00102 
00103   octave_base_value *try_narrowing_conversion (void) { return 0; }
00104 
00105   bool is_real_type (void) const { return true; }
00106 
00107   //  void increment (void) { scalar += 1; }
00108 
00109   //  void decrement (void) { scalar -= 1; }
00110 
00111   octave_value convert_to_str_internal (bool, bool, char type) const;
00112 
00113   bool save_ascii (std::ostream& os);
00114 
00115   bool load_ascii (std::istream& is);
00116 
00117   bool save_binary (std::ostream& os, bool& );
00118 
00119   bool load_binary (std::istream& is, bool swap,
00120                     oct_mach_info::float_format );
00121 
00122 #if defined (HAVE_HDF5)
00123   bool save_hdf5 (hid_t loc_id, const char *name, bool );
00124 
00125   bool load_hdf5 (hid_t loc_id, const char *name);
00126 #endif
00127 };
00128 
00129 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines