44 #include "config_hdf.h"
65 void hdfistream_annot::_init(
const string filename)
67 _an_id = _index = _tag = _ref = 0;
70 _an_ids = vector < int32 > ();
76 void hdfistream_annot::_init(
const string filename, int32 tag, int32 ref)
85 void hdfistream_annot::_open(
const char *filename)
89 if ((_file_id = Hopen(filename, DFACC_READ, 0)) < 0)
91 if ((_an_id = ANstart(_file_id)) < 0)
98 void hdfistream_annot::_get_anninfo(
void)
108 void hdfistream_annot::_get_file_anninfo(
void)
114 if (ANfileinfo(_an_id, &nlab, &ndesc, &junk, &junk2) == FAIL)
118 _an_ids = vector < int32 > ();
120 for (i = 0; _lab && i < nlab; ++i) {
121 if ((_ann_id = ANselect(_an_id, i, AN_FILE_LABEL)) == FAIL)
123 _an_ids.push_back(_ann_id);
125 for (i = 0; _desc && i < ndesc; ++i) {
126 if ((_ann_id = ANselect(_an_id, i, AN_FILE_DESC)) == FAIL)
128 _an_ids.push_back(_ann_id);
134 void hdfistream_annot::_get_obj_anninfo(
void)
136 int nlab = 0, ndesc = 0;
138 (ndesc = ANnumann(_an_id, AN_DATA_DESC, _tag, _ref)) == FAIL)
141 (nlab = ANnumann(_an_id, AN_DATA_LABEL, _tag, _ref)) == FAIL)
143 if (nlab + ndesc > 0) {
144 int32 *annlist =
new int32[nlab + ndesc];
148 ANannlist(_an_id, AN_DATA_DESC, _tag, _ref, annlist) == FAIL) {
154 ANannlist(_an_id, AN_DATA_LABEL, _tag, _ref,
155 annlist + ndesc) == FAIL) {
162 _an_ids = vector < int32 > (annlist[0], annlist[nlab + ndesc]);
178 hdfistream_annot::hdfistream_annot(
const string filename):
182 if (_filename.length() != 0)
183 open(_filename.c_str());
187 hdfistream_annot::hdfistream_annot(
const string filename, int32 tag, int32 ref):
191 open(_filename.c_str(), tag, ref);
195 void hdfistream_annot::open(
const char *filename)
203 void hdfistream_annot::open(
const char *filename, int32 tag, int32 ref)
212 void hdfistream_annot::close(
void)
215 (void) ANend(_an_id);
217 (void) Hclose(_file_id);
228 if (_an_id == 0 || _index < 0)
233 int32 _ann_id = _an_ids[_index];
234 int32 ann_length = ANannlen(_ann_id) ;
235 char buf[ann_length+1];
236 if (ANreadann(_ann_id, buf, ann_length+1) < 0)
238 buf[ann_length] =
'\0';
247 for (
string an; !eos();) {