1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2021 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_colon_h)
27 #define octave_ov_colon_h 1
28 
29 #include "octave-config.h"
30 
31 #include <cstdlib>
32 
33 #include <iosfwd>
34 #include <string>
35 
36 #include "mx-base.h"
37 #include "str-vec.h"
38 
39 #include "error.h"
40 #include "ov-base.h"
41 #include "ov-typeinfo.h"
42 
43 class octave_value_list;
44 
45 // A type to represent ':' as used for indexing.
46 
47 class
48 octave_magic_colon : public octave_base_value
49 {
50 public:
51 
octave_magic_colon(void)52   octave_magic_colon (void)
53     : octave_base_value () { }
54 
octave_magic_colon(const octave_magic_colon &)55   octave_magic_colon (const octave_magic_colon&)
56     : octave_base_value () { }
57 
58   ~octave_magic_colon (void) = default;
59 
clone(void)60   octave_base_value * clone (void) const
61   { return new octave_magic_colon (*this); }
empty_clone(void)62   octave_base_value * empty_clone (void) const
63   { return new octave_magic_colon (); }
64 
65   idx_vector index_vector (bool /* require_integers */ = false) const { return idx_vector (':'); }
66 
is_defined(void)67   bool is_defined (void) const { return true; }
68 
is_constant(void)69   bool is_constant (void) const { return true; }
70 
is_magic_colon(void)71   bool is_magic_colon (void) const { return true; }
72 
73   void print (std::ostream& os, bool pr_as_read_syntax = false);
74 
75   void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
76 
77 private:
78 
79   DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
80 };
81 
82 #endif
83