GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ov-legacy-range.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2024 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_ov_legacy_range_h)
27 #define octave_ov_legacy_range_h 1
28 
29 #include "octave-config.h"
30 
31 #include <cstdlib>
32 
33 #include <iosfwd>
34 #include <memory>
35 #include <string>
36 
37 #include "lo-mappers.h"
38 #include "lo-utils.h"
39 #include "mx-base.h"
40 
41 #include "error.h"
42 #include "oct-stream.h"
43 #include "ov-base.h"
44 #include "ov-re-mat.h"
45 #include "ov-typeinfo.h"
46 
47 class Range;
48 
49 class octave_value_list;
50 
51 // Legacy Range values.
52 
53 // Provide enough of the old octave_range class to allow Range objects
54 // to be loaded from files. After loading, they are converted to some
55 // other type by a call to octave_value::maybe_mutate in
56 // load_save_system::load_vars so there should no longer be any values
57 // of this type used by the interpreter. The action of maybe_mutate is
58 // performed by octave_legacy_range::try_narrowing_conversion.
59 
60 class
62 {
63 public:
64 
66 
67  octave_legacy_range (const Range& r);
68 
70 
71  // No assignment.
72 
74 
75  ~octave_legacy_range () = default;
76 
78  {
79  return new octave_legacy_range (*this);
80  }
81 
82  // A range is really just a special kind of real matrix object. In
83  // the places where we need to call empty_clone, it makes more sense
84  // to create an empty matrix (0x0) instead of an empty range (1x0).
85  octave_base_value * empty_clone () const { return new octave_matrix (); }
86 
87  type_conv_info numeric_conversion_function () const;
88 
89  octave_base_value * try_narrowing_conversion ();
90 
91  bool is_defined () const { return true; }
92 
93  bool is_legacy_object () const { return true; }
94 
95  bool is_constant () const { return true; }
96 
97  bool load_ascii (std::istream& is);
98 
99  bool load_binary (std::istream& is, bool swap,
101 
102  bool load_hdf5 (octave_hdf5_id loc_id, const char *name);
103 
104 private:
105 
106  std::unique_ptr<Range> m_range;
107 
109 };
110 
111 #endif
~octave_legacy_range()=default
octave_base_value * clone() const
octave_base_value * empty_clone() const
bool is_legacy_object() const
bool is_defined() const
bool is_constant() const
octave_value_list & operator=(const octave_value_list &obj)=default
float_format
Definition: mach-info.h:38
T * r
Definition: mx-inlines.cc:781
int64_t octave_hdf5_id
#define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
Definition: ov-base.h:181