61 #include <InternalErr.h>
71 static void LoadField(int32 vid,
int index, int32 begin, int32 end,
73 static bool IsInternalVdata(int32 fid, int32 ref);
91 while ((ref = VSgetid(
_file_id, ref)) != -1) {
145 open(filename.c_str());
152 if ((
_file_id = Hopen(filename, DFACC_RDONLY, 0)) < 0)
167 "vdata file closed: id=" <<
_file_id <<
", this: " <<
this << endl);
174 "vdata Vend status: " << status <<
", this: " <<
this << endl);
178 "vdata HClose status: " << status <<
", this: " <<
this << endl);
187 if (index < 0 || index >= (
int)
_vdata_refs.size())
212 if (il != FULL_INTERLACE)
217 if (begin < 0 || end >= cnt)
272 int32 number_type, count, size;
279 data =
new char[count * DFKNTsize(number_type)];
325 if (VSinquire(
_vdata_id, &nrecs, (int32 *) 0, (
char *) 0, (int32 *) 0, name)
328 hv.
name = string(name);
331 hv.
vclass = string(vclass);
339 hv.
fields = vector<hdf_field> ();
340 for (
int i = 0; i < nfields; ++i) {
354 set<string, less<string> > reserved_names;
355 reserved_names.insert(
"RIATTR0.0N");
357 set<string, less<string> > reserved_classes;
358 reserved_classes.insert(
"Attr0.0");
359 reserved_classes.insert(
"RIATTR0.0C");
360 reserved_classes.insert(
"DimVal0.0");
361 reserved_classes.insert(
"DimVal0.1");
362 reserved_classes.insert(
"_HDF_CHK_TBL_0");
366 if ((vid = VSattach(
_file_id, ref,
"r")) < 0) {
371 if (VSgetname(vid, name) < 0) {
375 if (reserved_names.find(
string(name)) != reserved_names.end()) {
380 if (VSgetclass(vid, vclass) < 0) {
387 if (reserved_classes.find(
string(vclass)) != reserved_classes.end())
393 static void LoadField(int32 vid,
int index, int32 begin, int32 end,
395 DBG(cerr <<
"LoadField - vid: " << vid << endl);
398 if (VSseek(vid, begin) < 0)
400 int32 nrecs = end - begin + 1;
403 DBG(cerr <<
"vid: " << vid <<
", index: " << index << endl);
404 char *fieldname = VFfieldname(vid, index);
407 f.
name = string(fieldname);
410 int32 fieldorder = VFfieldorder(vid, index);
415 int32 fieldsize = VFfieldisize(vid, index);
420 int32 fieldtype = VFfieldtype(vid, index);
430 data.resize(fieldsize * nrecs);
431 DBG(cerr <<
"LoadField: vid=" << vid <<
", fieldname=" << fieldname << endl);
440 if (VSsetfields(vid, fieldname) < 0) {
445 if (VSread(vid, (uchar8 *)&data[0], nrecs, FULL_INTERLACE) < 0) {
446 throw InternalErr(__FILE__, __LINE__,
"VSread error with the field: " + f.
name +
" (" + long_to_string(vid) +
").");
449 if ((VSsetfields(vid, fieldname) < 0) || (VSread(vid, (uchar8 *) data,
450 nrecs, FULL_INTERLACE) < 0)) {
456 int stride = fieldorder;
457 for (
int i = 0; i < fieldorder; ++i) {
461 gv =
hdf_genvec(fieldtype, &data[0], i, (nrecs * fieldorder) - 1, stride);
462 f.
vals.push_back(gv);
475 if (
vals.size() == 0)
480 if (
vals.size() > 1) {
481 int32 nt =
vals[0].number_type();
484 for (
int i = 1; i < (int)
vals.size(); ++i)
485 if (
vals[i].number_type() != nt ||
vals[i].number_type() == 0)
499 for (
int i = 0; i < (int)
fields.size(); ++i)
506 bool IsInternalVdata(int32 fid, int32 ref) {
507 set<string, less<string> > reserved_names;
508 reserved_names.insert(
"RIATTR0.0N");
510 set<string, less<string> > reserved_classes;
511 reserved_classes.insert(
"Attr0.0");
512 reserved_classes.insert(
"RIATTR0.0C");
513 reserved_classes.insert(
"DimVal0.0");
514 reserved_classes.insert(
"DimVal0.1");
515 reserved_classes.insert(
"_HDF_CHK_TBL_0");
519 if ((vid = VSattach(fid, ref,
"r")) < 0) {
524 if (VSgetname(vid, name) < 0) {
528 if (reserved_names.find(
string(name)) != reserved_names.end()) {
533 if (VSgetclass(vid, vclass) < 0) {
540 if (reserved_classes.find(
string(vclass)) != reserved_classes.end())
virtual void seek(int index=0)
virtual int index(void) const
vector< hdf_genvec > vals
virtual bool bos(void) const
vector< int32 > _vdata_refs
virtual bool eos(void) const
virtual void rewind(void)
vector< hdf_field > fields
hdfistream_vdata & operator>>(hdf_vdata &hs)
bool setrecs(int32 begin, int32 end)
hdfistream_vdata(const string filename="")
virtual void seek_ref(int ref)
void _seek(const char *name)
virtual bool isInternalVdata(int ref) const
struct hdfistream_vdata::@3 _recs
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
virtual void open(const char *filename)
virtual bool eo_attr(void) const