comparison src/ov-streamoff.h @ 4645:bd2067547b40

[project @ 2003-11-23 08:07:52 by jwe]
author jwe
date Sun, 23 Nov 2003 08:07:53 +0000
parents
children eff8f977508c
comparison
equal deleted inserted replaced
4644:3b74f1a86750 4645:bd2067547b40
1 /*
2
3 Copyright (C) 2003 John W. Eaton
4
5 This file is part of Octave.
6
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
10 later version.
11
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
21 */
22
23 #if !defined (octave_streamoff_h)
24 #define octave_streamoff_h 1
25
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION)
27 #pragma interface
28 #endif
29
30 #include <iostream>
31 #include <string>
32
33 #include "mx-base.h"
34 #include "mx-op-defs.h"
35 #include "oct-alloc.h"
36 #include "str-vec.h"
37
38 #include "error.h"
39 #include "oct-obj.h"
40 #include "ov-base-mat.h"
41 #include "ov-typeinfo.h"
42
43 class tree_walker;
44
45 // Stream offsets.
46
47 class streamoff_array : public ArrayN<std::streamoff>
48 {
49 public:
50
51 streamoff_array (void) : ArrayN<std::streamoff> () { }
52
53 streamoff_array (const dim_vector& dv,
54 const std::streamoff& val = resize_fill_value ())
55 : ArrayN<std::streamoff> (dv, val) { }
56
57 streamoff_array (const ArrayN<std::streamoff>& sa)
58 : ArrayN<std::streamoff> (sa) { }
59
60 streamoff_array (const streamoff_array& sa)
61 : ArrayN<std::streamoff> (sa) { }
62
63 ~streamoff_array (void) { }
64
65 streamoff_array& operator = (const streamoff_array& a)
66 {
67 if (this != &a)
68 ArrayN<std::streamoff>::operator = (a);
69
70 return *this;
71 }
72
73 streamoff_array squeeze (void) const
74 { return ArrayN<std::streamoff>::squeeze (); }
75
76 boolNDArray all (int dim = -1) const;
77 boolNDArray any (int dim = -1) const;
78
79 // streamoff_array& operator += (const streamoff_array& a);
80 // streamoff_array& operator -= (const streamoff_array& a);
81
82 static int compute_index (Array<int>& ra_idx,
83 const dim_vector& dimensions);
84
85 static std::streamoff resize_fill_value (void) { return 0; }
86 };
87
88 NDCMP_OP_DECL (mx_el_eq, std::streamoff, streamoff_array);
89 NDCMP_OP_DECL (mx_el_ne, std::streamoff, streamoff_array);
90
91 NDCMP_OP_DECL (mx_el_eq, streamoff_array, std::streamoff);
92 NDCMP_OP_DECL (mx_el_ne, streamoff_array, std::streamoff);
93
94 NDCMP_OP_DECL (mx_el_eq, streamoff_array, streamoff_array);
95 NDCMP_OP_DECL (mx_el_ne, streamoff_array, streamoff_array);
96
97 BIN_OP_DECL (streamoff_array, operator +, streamoff_array, streamoff_array);
98 BIN_OP_DECL (streamoff_array, operator -, streamoff_array, streamoff_array);
99
100 BIN_OP_DECL (streamoff_array, operator +, streamoff_array, std::streamoff);
101 BIN_OP_DECL (streamoff_array, operator -, streamoff_array, std::streamoff);
102
103 BIN_OP_DECL (streamoff_array, operator +, std::streamoff, streamoff_array);
104 BIN_OP_DECL (streamoff_array, operator -, std::streamoff, streamoff_array);
105
106 class
107 octave_streamoff : public octave_base_matrix<streamoff_array>
108 {
109 public:
110
111 octave_streamoff (void)
112 : octave_base_matrix<streamoff_array> () { }
113
114 octave_streamoff (const std::streamoff& off)
115 : octave_base_matrix<streamoff_array>
116 (streamoff_array (dim_vector (1, 1), off)) { }
117
118 octave_streamoff (const streamoff_array& off)
119 : octave_base_matrix<streamoff_array> (off) { }
120
121 octave_streamoff (const octave_streamoff& off)
122 : octave_base_matrix<streamoff_array> (off) { }
123
124 ~octave_streamoff (void) { }
125
126 octave_value *clone (void) const { return new octave_streamoff (*this); }
127 octave_value *empty_clone (void) const { return new octave_streamoff (); }
128
129 bool is_defined (void) const { return true; }
130
131 bool is_streamoff (void) const { return true; }
132
133 std::streamoff streamoff_value (void) const;
134
135 streamoff_array streamoff_array_value (void) const { return matrix; }
136
137 // void increment (void) { matrix += 1; }
138
139 // void decrement (void) { matrix -= 1; }
140
141 bool print_as_scalar (void) const { return true; }
142
143 void print (std::ostream& os, bool pr_as_read_syntax = false) const;
144
145 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
146
147 private:
148
149 DECLARE_OCTAVE_ALLOCATOR
150
151 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
152 };
153
154 #endif
155
156 /*
157 ;;; Local Variables: ***
158 ;;; mode: C++ ***
159 ;;; End: ***
160 */