3
Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2002, 2003, 2004,
4
2005, 2006, 2007 John W. Eaton
6
This file is part of Octave.
8
Octave is free software; you can redistribute it and/or modify it
9
under the terms of the GNU General Public License as published by the
10
Free Software Foundation; either version 3 of the License, or (at your
11
option) any later version.
13
Octave is distributed in the hope that it will be useful, but WITHOUT
14
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18
You should have received a copy of the GNU General Public License
19
along with Octave; see the file COPYING. If not, see
20
<http://www.gnu.org/licenses/>.
24
#if !defined (octave_oct_obj_h)
25
#define octave_oct_obj_h 1
30
#include "oct-alloc.h"
41
octave_value_list (void)
44
octave_value_list (octave_idx_type n, const octave_value& val)
47
octave_value_list (const octave_value& tc)
50
octave_value_list (const octave_value_list& obj)
51
: data (obj.data), names (obj.names) { }
53
~octave_value_list (void) { }
55
void *operator new (size_t size)
56
{ return allocator.alloc (size); }
58
void operator delete (void *p, size_t size)
59
{ allocator.free (p, size); }
61
// FIXME -- without this, I have errors with the stack of
62
// octave_value_list objects in ov-usr-fcn.h. Why?
63
void *operator new (size_t size, void *p)
64
{ return ::operator new (size, p); }
66
void operator delete (void *p, void *)
68
#if defined (HAVE_PLACEMENT_DELETE)
69
::operator delete (p, static_cast<void *> (0));
71
::operator delete (p);
75
octave_value_list& operator = (const octave_value_list& obj)
86
bool valid_scalar_indices (void) const;
88
// Assignment will resize on range errors.
90
octave_value& operator () (octave_idx_type n) { return elem (n); }
92
octave_value operator () (octave_idx_type n) const { return elem (n); }
94
octave_idx_type length (void) const { return data.size (); }
96
bool empty (void) const { return length () == 0; }
98
void resize (octave_idx_type n) { data.resize (n); }
100
void resize (octave_idx_type n, const octave_value& val);
102
octave_value_list& prepend (const octave_value& val);
104
octave_value_list& append (const octave_value& val);
106
octave_value_list& append (const octave_value_list& lst);
108
octave_value_list& reverse (void);
111
splice (octave_idx_type offset, octave_idx_type len,
112
const octave_value_list& lst = octave_value_list ()) const;
114
bool all_strings_p (void) const;
116
bool has_magic_colon (void) const;
118
string_vector make_argv (const std::string&) const;
120
void stash_name_tags (const string_vector& nm) { names = nm; }
122
string_vector name_tags (void) const { return names; }
126
static octave_allocator allocator;
128
std::vector<octave_value> data;
130
// This list of strings can be used to tag each element of data with
131
// a name. By default, it is empty.
134
// This constructor is private with no definition to keep statements
137
// octave_value_list foo = 5;
138
// octave_value_list foo = 5.0;
140
// from doing different things. Instead, you have to use the
143
// octave_value_list (n, val);
145
// and supply a default value to create a vector-valued
146
// octave_value_list.
148
octave_value_list (octave_idx_type n);
150
octave_value_list (const Array<octave_value>& d);
152
octave_value& elem (octave_idx_type n)
154
static Matrix empty_matrix;
157
resize (n+1, empty_matrix);
162
octave_value elem (octave_idx_type n) const
164
#if defined (BOUNDS_CHECKING)
175
;;; Local Variables: ***