Mercurial > hg > octave-lyh
comparison src/ls-hdf5.h @ 5255:3c4237738c3e
[project @ 2005-03-29 18:35:32 by jwe]
author | jwe |
---|---|
date | Tue, 29 Mar 2005 18:35:32 +0000 |
parents | b0d6da24caeb |
children | 4c8a2e4e0717 |
comparison
equal
deleted
inserted
replaced
5254:2fa6253e36a3 | 5255:3c4237738c3e |
---|---|
43 | 43 |
44 hdf5_fstreambase () { file_id = -1; } | 44 hdf5_fstreambase () { file_id = -1; } |
45 | 45 |
46 hdf5_fstreambase (const char *name, int mode, int /* prot */ = 0) | 46 hdf5_fstreambase (const char *name, int mode, int /* prot */ = 0) |
47 { | 47 { |
48 if (mode == std::ios::in) | 48 if (mode & std::ios::in) |
49 file_id = H5Fopen (name, H5F_ACC_RDONLY, H5P_DEFAULT); | 49 file_id = H5Fopen (name, H5F_ACC_RDONLY, H5P_DEFAULT); |
50 else if (mode == std::ios::out) | 50 else if (mode & std::ios::out) |
51 file_id = H5Fcreate (name, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); | 51 file_id = H5Fcreate (name, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); |
52 | 52 |
53 if (file_id < 0) | 53 if (file_id < 0) |
54 std::ios::setstate (std::ios::badbit); | 54 std::ios::setstate (std::ios::badbit); |
55 | 55 |
68 | 68 |
69 void open (const char *name, int mode, int prot = 0) | 69 void open (const char *name, int mode, int prot = 0) |
70 { | 70 { |
71 clear (); | 71 clear (); |
72 | 72 |
73 if (mode == std::ios::in) | 73 if (mode & std::ios::in) |
74 file_id = H5Fopen (name, H5F_ACC_RDONLY, H5P_DEFAULT); | 74 file_id = H5Fopen (name, H5F_ACC_RDONLY, H5P_DEFAULT); |
75 else if (mode == std::ios::out) | 75 else if (mode & std::ios::out) |
76 file_id = H5Fcreate (name, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); | 76 file_id = H5Fcreate (name, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); |
77 | 77 |
78 if (file_id < 0) | 78 if (file_id < 0) |
79 std::ios::setstate (std::ios::badbit); | 79 std::ios::setstate (std::ios::badbit); |
80 | 80 |
89 { | 89 { |
90 public: | 90 public: |
91 | 91 |
92 hdf5_ifstream () : hdf5_fstreambase (), std::istream (0) { } | 92 hdf5_ifstream () : hdf5_fstreambase (), std::istream (0) { } |
93 | 93 |
94 hdf5_ifstream (const char *name, int mode = std::ios::in, int prot = 0) | 94 hdf5_ifstream (const char *name, int mode = std::ios::in|std::ios::binary, |
95 int prot = 0) | |
95 : hdf5_fstreambase (name, mode, prot), std::istream (0) { } | 96 : hdf5_fstreambase (name, mode, prot), std::istream (0) { } |
96 | 97 |
97 void open (const char *name, int mode = std::ios::in, int prot = 0) | 98 void open (const char *name, int mode = std::ios::in|std::ios::binary, |
99 int prot = 0) | |
98 { hdf5_fstreambase::open (name, mode, prot); } | 100 { hdf5_fstreambase::open (name, mode, prot); } |
99 }; | 101 }; |
100 | 102 |
101 class hdf5_ofstream : public hdf5_fstreambase, public std::ostream | 103 class hdf5_ofstream : public hdf5_fstreambase, public std::ostream |
102 { | 104 { |
103 public: | 105 public: |
104 | 106 |
105 hdf5_ofstream () : hdf5_fstreambase (), std::ostream (0) { } | 107 hdf5_ofstream () : hdf5_fstreambase (), std::ostream (0) { } |
106 | 108 |
107 hdf5_ofstream (const char *name, int mode = std::ios::out, int prot = 0) | 109 hdf5_ofstream (const char *name, int mode = std::ios::out|std::ios::binary, |
110 int prot = 0) | |
108 : hdf5_fstreambase (name, mode, prot), std::ostream (0) { } | 111 : hdf5_fstreambase (name, mode, prot), std::ostream (0) { } |
109 | 112 |
110 void open (const char *name, int mode = std::ios::out, int prot = 0) | 113 void open (const char *name, int mode = std::ios::out|std::ios::binary, |
114 int prot = 0) | |
111 { hdf5_fstreambase::open (name, mode, prot); } | 115 { hdf5_fstreambase::open (name, mode, prot); } |
112 }; | 116 }; |
113 | 117 |
114 // Callback data structure for passing data to hdf5_read_next_data, below. | 118 // Callback data structure for passing data to hdf5_read_next_data, below. |
115 | 119 |