Mercurial > hg > octave-lyh
annotate liboctave/dir-ops.h @ 10396:a0b51ac0f88a
optimize accumdim with summation
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 05 Mar 2010 12:31:30 +0100 |
parents | cbc402e64d83 |
children | 331fcc41ca23 |
rev | line source |
---|---|
1782 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 2000, 2005, 2006, 2007 John W. Eaton |
1782 | 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 | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1782 | 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 | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1782 | 20 |
21 */ | |
22 | |
23 #if !defined (octave_dir_ops_h) | |
24 #define octave_dir_ops_h 1 | |
25 | |
26 #include <string> | |
27 | |
28 #include "str-vec.h" | |
29 | |
30 class | |
6108 | 31 OCTAVE_API |
1782 | 32 dir_entry |
33 { | |
34 public: | |
35 | |
3504 | 36 dir_entry (const std::string& n = std::string ()) : name (n), dir (0) |
1879 | 37 { |
38 if (! name.empty ()) | |
39 open (); | |
40 } | |
1782 | 41 |
42 dir_entry (const dir_entry& d) { copy (d); } | |
43 | |
44 dir_entry& operator = (const dir_entry& d) | |
45 { | |
1929 | 46 if (this != &d) |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
47 copy (d); |
1929 | 48 |
1782 | 49 return *this; |
50 } | |
51 | |
52 ~dir_entry (void) { close (); } | |
53 | |
3504 | 54 bool open (const std::string& = std::string ()); |
1782 | 55 |
56 string_vector read (void); | |
57 | |
58 void close (void); | |
59 | |
60 bool ok (void) const { return dir && ! fail; } | |
61 | |
3145 | 62 operator bool () const { return ok (); } |
1782 | 63 |
3504 | 64 std::string error (void) const { return ok () ? std::string () : errmsg; } |
1782 | 65 |
66 private: | |
67 | |
68 // Name of the directory. | |
3504 | 69 std::string name; |
1782 | 70 |
1929 | 71 // A pointer to the contents of the directory. We use void here to |
72 // avoid possible conflicts with the way some systems declare the | |
73 // type DIR. | |
74 void *dir; | |
1782 | 75 |
76 // TRUE means the open for this directory failed. | |
77 bool fail; | |
78 | |
79 // If a failure occurs, this contains the system error text. | |
3504 | 80 std::string errmsg; |
1782 | 81 |
82 void copy (const dir_entry&); | |
83 }; | |
84 | |
85 #endif |