NeXus  1
NeXusFile.cpp
Go to the documentation of this file.
1 #include <cstring>
2 // REMOVE
3 #include <iostream>
4 #include <sstream>
5 #include <typeinfo>
6 #include "napiconfig.h"
7 #include "NeXusFile.hpp"
8 #include "NeXusException.hpp"
9 
10 using namespace NeXus;
11 using std::map;
12 using std::pair;
13 using std::string;
14 using std::stringstream;
15 using std::vector;
16 
22 static const string NULL_STR = "NULL";
23 
24 namespace { // anonymous namespace to keep it in the file
25 template <typename NumT>
26 static string toString(const vector<NumT>& data) {
27  stringstream result;
28  result << "[";
29  size_t size = data.size();
30  for (size_t i = 0; i < size; i++) {
31  result << data[i];
32  if (i+1 < size) {
33  result << ",";
34  }
35  }
36  result << "]";
37  return result.str();
38 }
39 
40 static vector<int64_t> toInt64(const vector<int> & small_v) {
41  // copy the dims over to call the int64_t version
42  vector<int64_t> big_v;
43  big_v.reserve(small_v.size());
44  for (vector<int>::const_iterator it = small_v.begin(); it != small_v.end(); ++it)
45  {
46  big_v.push_back(static_cast<int64_t>(*it));
47  }
48  return big_v;
49 }
50 
51 } // end of anonymous namespace
52 
53 namespace NeXus {
54 
55  // catch for undefined types
56  template <typename NumT>
57  NXnumtype getType(NumT number) {
58  stringstream msg;
59  msg << "NeXus::getType() does not know type of " << typeid(number).name();
60  throw Exception(msg.str());
61  }
62 
63  template<>
65  (void)number; // Avoid compiler warning
66  return CHAR;
67  }
68 
69  // template specialisations for types we know
70  template<>
71  NXDLL_EXPORT NXnumtype getType(float number) {
72  (void)number; // Avoid compiler warning
73  return FLOAT32;
74  }
75 
76  template<>
77  NXDLL_EXPORT NXnumtype getType(double number) {
78  (void)number; // Avoid compiler warning
79  return FLOAT64;
80  }
81 
82  template<>
83  NXDLL_EXPORT NXnumtype getType(int8_t number) {
84  (void)number; // Avoid compiler warning
85  return INT8;
86  }
87 
88  template<>
89  NXDLL_EXPORT NXnumtype getType(uint8_t number) {
90  (void)number; // Avoid compiler warning
91  return UINT8;
92  }
93 
94  template<>
95  NXDLL_EXPORT NXnumtype getType(int16_t number) {
96  (void)number; // Avoid compiler warning
97  return INT16;
98  }
99 
100  template<>
101  NXDLL_EXPORT NXnumtype getType(uint16_t number) {
102  (void)number; // Avoid compiler warning
103  return UINT16;
104  }
105 
106  template<>
107  NXDLL_EXPORT NXnumtype getType(int32_t number) {
108  (void)number; // Avoid compiler warning
109  return INT32;
110  }
111 
112  template<>
113  NXDLL_EXPORT NXnumtype getType(uint32_t number) {
114  (void)number; // Avoid compiler warning
115  return UINT32;
116  }
117 
118  template<>
119  NXDLL_EXPORT NXnumtype getType(int64_t number) {
120  (void)number; // Avoid compiler warning
121  return INT64;
122  }
123 
124  template<>
125  NXDLL_EXPORT NXnumtype getType(uint64_t number) {
126  (void)number; // Avoid compiler warning
127  return UINT64;
128  }
129 
130 
131 }
132 
133 // check type sizes - uses a trick that you cannot allocate an
134 // array of negative length
135 #ifdef _MSC_VER
136 #define ARRAY_OFFSET 1 /* cannot dimension an array with zero elements */
137 #else
138 #define ARRAY_OFFSET 0 /* can dimension an array with zero elements */
139 #endif /* _MSC_VER */
140 
141 /*
142 static int check_float_too_big[4 - sizeof(float) + ARRAY_OFFSET]; // error if float > 4 bytes
143 static int check_float_too_small[sizeof(float) - 4 + ARRAY_OFFSET]; // error if float < 4 bytes
144 static int check_double_too_big[8 - sizeof(double) + ARRAY_OFFSET]; // error if double > 8 bytes
145 static int check_double_too_small[sizeof(double) - 8 + ARRAY_OFFSET]; // error if double < 8 bytes
146 static int check_char_too_big[1 - sizeof(char) + ARRAY_OFFSET]; // error if char > 1 byte
147 */
148 
149 namespace {
150 
151 static void inner_malloc(void* & data, const std::vector<int64_t>& dims, NXnumtype type) {
152  int rank = dims.size();
153  int64_t c_dims[NX_MAXRANK];
154  for (int i = 0; i < rank; i++) {
155  c_dims[i] = dims[i];
156  }
157  NXstatus status = NXmalloc64(&data, rank, c_dims, type);
158  if (status != NX_OK) {
159  throw Exception("NXmalloc failed", status);
160  }
161 }
162 
163 
164 static void inner_free(void* & data) {
165  NXstatus status = NXfree(&data);
166  if (status != NX_OK) {
167  throw Exception("NXfree failed", status);
168  }
169 }
170 
171 } // end of anonymous namespace
172 
173 namespace NeXus {
174 File::File(NXhandle handle, bool close_handle) : m_file_id(handle), m_close_handle(close_handle) {
175 }
176 
177 File::File(const string& filename, const NXaccess access) : m_close_handle (true) {
178  this->initOpenFile(filename, access);
179 }
180 
181 File::File(const char *filename, const NXaccess access) : m_close_handle (true) {
182  this->initOpenFile(string(filename), access);
183 }
184 
185 void File::initOpenFile(const string& filename, const NXaccess access) {
186  if (filename.empty()) {
187  throw Exception("Filename specified is empty constructor");
188  }
189 
190  NXstatus status = NXopen(filename.c_str(), access, &(this->m_file_id));
191  if (status != NX_OK) {
192  stringstream msg;
193  msg << "NXopen(" << filename << ", " << access << ") failed";
194  throw Exception(msg.str(), status);
195  }
196 }
197 
199  if (m_close_handle && m_file_id != NULL) {
200  NXstatus status = NXclose(&(this->m_file_id));
201  this->m_file_id = NULL;
202  if (status != NX_OK) {
203  throw Exception("NXclose failed", status);
204  }
205  }
206 }
207 
208 void File::close() {
209  if (this->m_file_id != NULL) {
210  NXstatus status = NXclose(&(this->m_file_id));
211  this->m_file_id = NULL;
212  if (status != NX_OK) {
213  throw Exception("NXclose failed", status);
214  }
215  }
216 }
217 
218 void File::flush() {
219  NXstatus status = NXflush(&(this->m_file_id));
220  if (status != NX_OK) {
221  throw Exception("NXflush failed", status);
222  }
223 }
224 
225 void File::makeGroup(const string& name, const string& class_name, bool open_group) {
226  if (name.empty()) {
227  throw Exception("Supplied empty name to makeGroup");
228  }
229  if (class_name.empty()) {
230  throw Exception("Supplied empty class name to makeGroup");
231  }
232  NXstatus status = NXmakegroup(this->m_file_id, name.c_str(),
233  class_name.c_str());
234  if (status != NX_OK) {
235  stringstream msg;
236  msg << "NXmakegroup(" << name << ", " << class_name << ") failed";
237  throw Exception(msg.str(), status);
238  }
239  if (open_group) {
240  this->openGroup(name, class_name);
241  }
242 }
243 
244 void File::openGroup(const string& name, const string& class_name) {
245  if (name.empty()) {
246  throw Exception("Supplied empty name to openGroup");
247  }
248  if (class_name.empty()) {
249  throw Exception("Supplied empty class name to openGroup");
250  }
251  NXstatus status = NXopengroup(this->m_file_id, name.c_str(),
252  class_name.c_str());
253  if (status != NX_OK) {
254  stringstream msg;
255  msg << "NXopengroup(" << name << ", " << class_name << ") failed";
256  throw Exception(msg.str(), status);
257  }
258 }
259 
260 void File::openPath(const string& path) {
261  if (path.empty()) {
262  throw Exception("Supplied empty path to openPath");
263  }
264  NXstatus status = NXopenpath(this->m_file_id, path.c_str());
265  if (status != NX_OK) {
266  stringstream msg;
267  msg << "NXopenpath(" << path << ") failed";
268  throw Exception(msg.str(), status);
269  }
270 }
271 
272 void File::openGroupPath(const string& path) {
273  if (path.empty()) {
274  throw Exception("Supplied empty path to openGroupPath");
275  }
276  NXstatus status = NXopengrouppath(this->m_file_id, path.c_str());
277  if (status != NX_OK) {
278  stringstream msg;
279  msg << "NXopengrouppath(" << path << ") failed";
280  throw Exception(msg.str(), status);
281  }
282 }
283 
284 std::string File::getPath(){
285  char cPath[2048];
286 
287  memset(cPath,0,sizeof(cPath));
288  NXstatus status = NXgetpath(this->m_file_id,cPath, sizeof(cPath)-1);
289  if (status != NX_OK) {
290  stringstream msg;
291  msg << "NXgetpath() failed";
292  throw Exception(msg.str(), status);
293  }
294  return std::string(cPath);
295 }
296 
298  NXstatus status = NXclosegroup(this->m_file_id);
299  if (status != NX_OK) {
300  throw Exception("NXclosegroup failed", status);
301  }
302 }
303 
304 void File::makeData(const string& name, NXnumtype type,
305  const vector<int>& dims, bool open_data) {
306  this->makeData(name, type, toInt64(dims), open_data);
307 }
308 
309 void File::makeData(const string& name, NXnumtype type,
310  const vector<int64_t>& dims, bool open_data) {
311  // error check the parameters
312  if (name.empty()) {
313  throw Exception("Supplied empty label to makeData");
314  }
315  if (dims.empty()) {
316  throw Exception("Supplied empty dimensions to makeData");
317  }
318 
319  // do the work
320  NXstatus status = NXmakedata64(this->m_file_id, name.c_str(), (int)type,
321  dims.size(), const_cast<int64_t*>(&(dims[0])));
322  // report errors
323  if (status != NX_OK) {
324  stringstream msg;
325  msg << "NXmakedata(" << name << ", " << type << ", " << dims.size()
326  << ", " << toString(dims) << ") failed";
327  throw Exception(msg.str(), status);
328  }
329  if (open_data) {
330  this->openData(name);
331  }
332 }
333 
334 template <typename NumT>
335 void File::makeData(const string & name, const NXnumtype type,
336  const NumT length, bool open_data) {
337  vector<int64_t> dims;
338  dims.push_back(static_cast<int64_t>(length));
339  this->makeData(name, type, dims, open_data);
340 }
341 
342 template <typename NumT>
343 void File::writeData(const string& name, const NumT& value) {
344  std::vector<NumT> v(1, value);
345  this->writeData(name, v);
346 }
347 
348 void File::writeData(const string& name, const char* value) {
349  this->writeData(name, std::string(value));
350 }
351 
352 void File::writeData(const string& name, const string& value)
353 {
354  string my_value(value);
355  // Allow empty strings by defaulting to a space
356  if (my_value.empty())
357  my_value = " ";
358  vector<int> dims;
359  dims.push_back(static_cast<int>(my_value.size()));
360  this->makeData(name, CHAR, dims, true);
361 
362  this->putData(&(my_value[0]));
363 
364  this->closeData();
365 }
366 
367 
368 
369 template <typename NumT>
370 void File::writeData(const string& name, const vector<NumT>& value) {
371  vector<int64_t> dims(1, value.size());
372  this->writeData(name, value, dims);
373 }
374 
375 template <typename NumT>
376 void File::writeData(const string& name, const vector<NumT>& value,
377  const vector<int>& dims) {
378  this->makeData(name, getType<NumT>(), dims, true);
379  this->putData(value);
380  this->closeData();
381 }
382 
383 template <typename NumT>
384 void File::writeData(const string& name, const vector<NumT>& value,
385  const vector<int64_t>& dims) {
386  this->makeData(name, getType<NumT>(), dims, true);
387  this->putData(value);
388  this->closeData();
389 }
390 
391 
392 template <typename NumT>
393 void File::writeExtendibleData(const string& name, vector<NumT>& value)
394 {
395  // Use a default chunk size of 4096 bytes. TODO: Is this optimal?
396  writeExtendibleData(name, value, 4096);
397 }
398 
399 template <typename NumT>
400 void File::writeExtendibleData(const string& name, vector<NumT>& value, const int64_t chunk)
401 {
402  vector<int64_t> dims(1, NX_UNLIMITED);
403  vector<int64_t> chunk_dims(1, chunk);
404  // Use chunking without using compression
405  this->makeCompData(name, getType<NumT>(), dims, NONE, chunk_dims, true );
406  this->putSlab(value, int64_t(0), int64_t(value.size()));
407  this->closeData();
408 }
409 
410 template <typename NumT>
411 void File::writeExtendibleData(const string& name, vector<NumT>& value,
412  vector<int64_t>& dims, std::vector<int64_t> & chunk)
413 {
414  // Create the data with unlimited 0th dimensions
415  std::vector<int64_t> unlim_dims(dims);
416  unlim_dims[0] = NX_UNLIMITED;
417  // Use chunking without using compression
418  this->makeCompData(name, getType<NumT>(), unlim_dims, NONE, chunk, true );
419  // And put that slab of that of that given size in there
420  std::vector<int64_t> start( dims.size(), 0 );
421  this->putSlab(value, start, dims);
422  this->closeData();
423 
424 }
425 
426 
427 template <typename NumT>
428 void File::writeUpdatedData(const std::string& name, std::vector<NumT>& value)
429 {
430  this->openData(name);
431  this->putSlab(value, int64_t(0), int64_t(value.size()));
432  this->closeData();
433 }
434 
435 template <typename NumT>
436 void File::writeUpdatedData(const std::string& name, std::vector<NumT>& value,
437  std::vector<int64_t>& dims)
438 {
439  this->openData(name);
440  std::vector<int64_t> start( dims.size(), 0 );
441  this->putSlab(value, start, dims);
442  this->closeData();
443 }
444 
445 
446 void File::makeCompData(const string& name, const NXnumtype type,
447  const vector<int>& dims, const NXcompression comp,
448  const vector<int>& bufsize, bool open_data) {
449  this->makeCompData(name, type, toInt64(dims), comp, toInt64(bufsize), open_data);
450 }
451 
452 void File::makeCompData(const string& name, const NXnumtype type,
453  const vector<int64_t>& dims, const NXcompression comp,
454  const vector<int64_t>& bufsize, bool open_data) {
455  // error check the parameters
456  if (name.empty()) {
457  throw Exception("Supplied empty name to makeCompData");
458  }
459  if (dims.empty()) {
460  throw Exception("Supplied empty dimensions to makeCompData");
461  }
462  if (bufsize.empty()) {
463  throw Exception("Supplied empty bufsize to makeCompData");
464  }
465  if (dims.size() != bufsize.size()) {
466  stringstream msg;
467  msg << "Supplied dims rank=" << dims.size()
468  << " must match supplied bufsize rank=" << bufsize.size()
469  << "in makeCompData";
470  throw Exception(msg.str());
471  }
472 
473  // do the work
474  int i_type = static_cast<int>(type);
475  int i_comp = static_cast<int>(comp);
476  NXstatus status = NXcompmakedata64(this->m_file_id, name.c_str(), i_type,
477  dims.size(),
478  const_cast<int64_t *>(&(dims[0])), i_comp,
479  const_cast<int64_t *>(&(bufsize[0])));
480 
481  // report errors
482  if (status != NX_OK) {
483  stringstream msg;
484  msg << "NXcompmakedata64(" << name << ", " << type << ", " << dims.size()
485  << ", " << toString(dims) << ", " << comp << ", " << toString(bufsize)
486  << ") failed";
487  throw Exception(msg.str(), status);
488  }
489  if (open_data) {
490  this->openData(name);
491  }
492 }
493 
494 template <typename NumT>
495 void File::writeCompData(const string & name, const vector<NumT> & value,
496  const vector<int> & dims, const NXcompression comp,
497  const vector<int> & bufsize) {
498  this->writeCompData(name, value, toInt64(dims), comp, toInt64(bufsize));
499 }
500 
501 template <typename NumT>
502 void File::writeCompData(const string & name, const vector<NumT> & value,
503  const vector<int64_t> & dims, const NXcompression comp,
504  const vector<int64_t> & bufsize) {
505  this->makeCompData(name, getType<NumT>(), dims, comp, bufsize, true);
506  this->putData(value);
507  this->closeData();
508 }
509 
510 void File::compress(NXcompression comp) {
511  stringstream msg;
512  msg << "compress(" << comp << ") is depricated - use makeCompData()";
513  throw Exception(msg.str());
514 }
515 
516 void File::openData(const string & name) {
517  if (name.empty()) {
518  throw Exception("Supplied empty name to openData");
519  }
520  NXstatus status = NXopendata(this->m_file_id, name.c_str());
521  if (status != NX_OK) {
522  throw Exception("NXopendata(" + name + ") failed", status);
523  }
524 }
525 
527  NXstatus status = NXclosedata(this->m_file_id);
528  if (status != NX_OK) {
529  throw Exception("NXclosedata() failed", status);
530  }
531 }
532 
533 void File::putData(const void* data) {
534  if (data == NULL) {
535  throw Exception("Data specified as null in putData");
536  }
537  NXstatus status = NXputdata(this->m_file_id, const_cast<void *>(data));
538  if (status != NX_OK) {
539  throw Exception("NXputdata(void *) failed", status);
540  }
541 }
542 
543 template <typename NumT>
544 void File::putData(const vector<NumT> & data) {
545  if (data.empty()) {
546  throw Exception("Supplied empty data to putData");
547  }
548  this->putData(&(data[0]));
549 }
550 
551 void File::putAttr(const AttrInfo& info, const void* data) {
552  if (info.name == NULL_STR) {
553  throw Exception("Supplied bad attribute name \"" + NULL_STR + "\"");
554  }
555  if (info.name.empty()) {
556  throw Exception("Supplied empty name to putAttr");
557  }
558  NXstatus status = NXputattr(this->m_file_id, info.name.c_str(),
559  const_cast<void *>(data), info.length,
560  (int)(info.type));
561  if (status != NX_OK) {
562  stringstream msg;
563  msg << "NXputattr(" << info.name << ", data, " << info.length << ", "
564  << info.type << ") failed";
565  throw Exception(msg.str(), status);
566  }
567 }
568 
569 template <typename NumT>
570 void File::putAttr(const std::string& name, const NumT value) {
571  AttrInfo info;
572  info.name = name;
573  info.length = 1;
574  info.type = getType<NumT>();
575  this->putAttr(info, &value);
576 }
577 
578 void File::putAttr(const char* name, const char* value) {
579  if (name == NULL) {
580  throw Exception("Specified name as null to putAttr");
581  }
582  if (value == NULL) {
583  throw Exception("Specified value as null to putAttr");
584  }
585  string s_name(name);
586  string s_value(value);
587  this->putAttr(s_name, s_value);
588 }
589 
590 void File::putAttr(const std::string& name, const std::string value) {
591  string my_value(value);
592  if (my_value.empty())
593  my_value = " "; // Make a default "space" to avoid errors.
594  AttrInfo info;
595  info.name = name;
596  info.length = static_cast<int>(my_value.size());
597  info.type = CHAR;
598  this->putAttr(info, &(my_value[0]));
599 }
600 
601 void File::putSlab(void* data, vector<int>& start, vector<int>& size) {
602  vector<int64_t> start_big = toInt64(start);
603  vector<int64_t> size_big = toInt64(size);
604  this->putSlab(data, start_big, size_big);
605 }
606 
607 void File::putSlab(void* data, vector<int64_t>& start, vector<int64_t>& size) {
608  if (data == NULL) {
609  throw Exception("Data specified as null in putSlab");
610  }
611  if (start.empty()) {
612  throw Exception("Supplied empty start to putSlab");
613  }
614  if (size.empty()) {
615  throw Exception("Supplied empty size to putSlab");
616  }
617  if (start.size() != size.size()) {
618  stringstream msg;
619  msg << "Supplied start rank=" << start.size()
620  << " must match supplied size rank=" << size.size()
621  << "in putSlab";
622  throw Exception(msg.str());
623  }
624  NXstatus status = NXputslab64(this->m_file_id, data, &(start[0]), &(size[0]));
625  if (status != NX_OK) {
626  stringstream msg;
627  msg << "NXputslab64(data, " << toString(start) << ", " << toString(size)
628  << ") failed";
629  throw Exception(msg.str(), status);
630  }
631 }
632 
633 template <typename NumT>
634 void File::putSlab(vector<NumT>& data, vector<int>& start,
635  vector<int>& size) {
636  vector<int64_t> start_big = toInt64(start);
637  vector<int64_t> size_big = toInt64(size);
638  this->putSlab(data, start_big, size_big);
639 }
640 
641 template <typename NumT>
642 void File::putSlab(vector<NumT>& data, vector<int64_t>& start,
643  vector<int64_t>& size) {
644  if (data.empty()) {
645  throw Exception("Supplied empty data to putSlab");
646  }
647  this->putSlab(&(data[0]), start, size);
648 }
649 
650 template <typename NumT>
651 void File::putSlab(vector<NumT>& data, int start, int size) {
652  this->putSlab(data, static_cast<int64_t>(start), static_cast<int64_t>(size));
653 }
654 
655 template <typename NumT>
656 void File::putSlab(vector<NumT>& data, int64_t start, int64_t size) {
657  vector<int64_t> start_v;
658  start_v.push_back(start);
659  vector<int64_t> size_v;
660  size_v.push_back(size);
661  this->putSlab(data, start_v, size_v);
662 }
663 
664 NXlink File::getDataID() {
665  NXlink link;
666  NXstatus status = NXgetdataID(this->m_file_id, &link);
667  if (status != NX_OK) {
668  throw Exception("NXgetdataID failed", status);
669  }
670  return link;
671 }
672 
674 {
675  NXlink id;
676  if(NXgetdataID(this->m_file_id,&id) == NX_ERROR)
677  {
678  return false;
679  }
680  else
681  {
682  return true;
683  }
684 }
685 /*----------------------------------------------------------------------*/
686 
687 void File::makeLink(NXlink& link) {
688  NXstatus status = NXmakelink(this->m_file_id, &link);
689  if (status != NX_OK) {
690  throw Exception("NXmakelink failed", status);
691  }
692 }
693 
694 void File::makeNamedLink(const string& name, NXlink& link) {
695  if (name.empty()) {
696  throw Exception("Supplied empty name to makeNamedLink");
697  }
698  NXstatus status = NXmakenamedlink(this->m_file_id, name.c_str(), &link);
699  if (status != NX_OK) {
700  throw Exception("NXmakenamedlink(" + name + ", link)", status);
701  }
702 }
703 
705  NXstatus status = NXopensourcegroup(this->m_file_id);
706  if (status != NX_OK) {
707  throw Exception("NXopensourcegroup failed");
708  }
709 }
710 
711 void File::getData(void* data) {
712  if (data == NULL) {
713  throw Exception("Supplied null pointer to getData");
714  }
715  NXstatus status = NXgetdata(this->m_file_id, data);
716  if (status != NX_OK) {
717  throw Exception("NXgetdata failed", status);
718  }
719 }
720 
721 template <typename NumT>
722 std::vector<NumT> * File::getData() {
723  Info info = this->getInfo();
724  if (info.type != getType<NumT>()) {
725  throw Exception("NXgetdata failed - invalid vector type");
726  }
727 
728  // determine the number of elements
729  int64_t length=1;
730  for (vector<int64_t>::const_iterator it = info.dims.begin();
731  it != info.dims.end(); it++) {
732  length *= *it;
733  }
734 
735  // allocate memory to put the data into
736  void * temp;
737  inner_malloc(temp, info.dims, info.type);
738 
739  // fetch the data
740  this->getData(temp);
741 
742  // put it in the vector
743  vector<NumT> * result = new vector<NumT>(static_cast<NumT *>(temp),
744  static_cast<NumT *>(temp)
745  + static_cast<size_t>(length));
746 
747  inner_free(temp);
748  return result;
749 }
750 
751 template <typename NumT>
752 void File::getData(vector<NumT>& data) {
753  Info info = this->getInfo();
754 
755  if (info.type != getType<NumT>())
756  {
757  throw Exception("NXgetdata failed - invalid vector type");
758  }
759  // determine the number of elements
760  int64_t length=1;
761  for (vector<int64_t>::const_iterator it = info.dims.begin();
762  it != info.dims.end(); it++) {
763  length *= *it;
764  }
765 
766  // allocate memory to put the data into
767  // need to use resize() rather than reserve() so vector length gets set
768  data.resize(length);
769 
770  // fetch the data
771  this->getData(&(data[0]));
772 }
773 
774 
775 void File::getDataCoerce(vector<int> &data)
776 {
777  Info info = this->getInfo();
778  if (info.type == INT8)
779  {
780  vector<int8_t> result;
781  this->getData(result);
782  data.assign(result.begin(), result.end());
783  }
784  else if (info.type == UINT8)
785  {
786  vector<uint8_t> result;
787  this->getData(result);
788  data.assign(result.begin(), result.end());
789  }
790  else if (info.type == INT16)
791  {
792  vector<int16_t> result;
793  this->getData(result);
794  data.assign(result.begin(), result.end());
795  }
796  else if (info.type == UINT16)
797  {
798  vector<uint16_t> result;
799  this->getData(result);
800  data.assign(result.begin(), result.end());
801  }
802  else if (info.type == INT32)
803  {
804  vector<int32_t> result;
805  this->getData(result);
806  data.assign(result.begin(), result.end());
807  }
808  else if (info.type == UINT32)
809  {
810  vector<uint32_t> result;
811  this->getData(result);
812  data.assign(result.begin(), result.end());
813  }
814  else
815  {
816  throw Exception("NexusFile::getDataCoerce(): Could not coerce to int.");
817  }
818 }
819 
820 void File::getDataCoerce(vector<double> &data)
821 {
822  Info info = this->getInfo();
823  if (info.type == INT8)
824  {
825  vector<int8_t> result;
826  this->getData(result);
827  data.assign(result.begin(), result.end());
828  }
829  else if (info.type == UINT8)
830  {
831  vector<uint8_t> result;
832  this->getData(result);
833  data.assign(result.begin(), result.end());
834  }
835  else if (info.type == INT16)
836  {
837  vector<int16_t> result;
838  this->getData(result);
839  data.assign(result.begin(), result.end());
840  }
841  else if (info.type == UINT16)
842  {
843  vector<uint16_t> result;
844  this->getData(result);
845  data.assign(result.begin(), result.end());
846  }
847  else if (info.type == INT32)
848  {
849  vector<int32_t> result;
850  this->getData(result);
851  data.assign(result.begin(), result.end());
852  }
853  else if (info.type == UINT32)
854  {
855  vector<uint32_t> result;
856  this->getData(result);
857  data.assign(result.begin(), result.end());
858  }
859  else if (info.type == FLOAT32)
860  {
861  vector<float> result;
862  this->getData(result);
863  data.assign(result.begin(), result.end());
864  }
865  else if (info.type == FLOAT64)
866  {
867  this->getData(data);
868  }
869  else
870  {
871  throw Exception("NexusFile::getDataCoerce(): Could not coerce to double.");
872  }
873 }
874 
875 template <typename NumT>
876 void File::readData(const std::string & dataName, std::vector<NumT>& data)
877 {
878  this->openData(dataName);
879  this->getData(data);
880  this->closeData();
881 }
882 
883 template <typename NumT>
884 void File::readData(const std::string & dataName, NumT & data)
885 {
886  std::vector<NumT> dataVector;
887  this->openData(dataName);
888  this->getData(dataVector);
889  if (dataVector.size() > 0)
890  data = dataVector[0];
891  this->closeData();
892 }
893 
894 void File::readData(const std::string & dataName, std::string& data)
895 {
896  this->openData(dataName);
897  data = this->getStrData();
898  this->closeData();
899 }
900 
902 {
903  Info info = this->getInfo();
904  switch(info.type)
905  {
906  case INT8:
907  case UINT8:
908  case INT16:
909  case UINT16:
910  case INT32:
911  case UINT32:
912  return true;
913  default:
914  return false;
915  }
916 }
917 
918 
919 
921  string res;
922  Info info = this->getInfo();
923  if (info.type != NX_CHAR) {
924  stringstream msg;
925  msg << "Cannot use getStrData() on non-character data. Found type="
926  << info.type;
927  throw Exception(msg.str());
928  }
929  if (info.dims.size() != 1) {
930  stringstream msg;
931  msg << "getStrData() only understand rank=1 data. Found rank="
932  << info.dims.size();
933  throw Exception(msg.str());
934  }
935  char* value = new char[info.dims[0]+1]; // probably do not need +1, but being safe
936  try{
937  this->getData(value);
938  }
939  catch (const Exception& e)
940  {
941  delete[] value;
942  throw e;
943  }
944  res = string(value, info.dims[0]);
945  delete[] value;
946  return res;
947 }
948 
950  //vector<int> & dims, NXnumtype & type) {
951  int64_t dims[NX_MAXRANK];
952  int type;
953  int rank;
954  NXstatus status = NXgetinfo64(this->m_file_id, &rank, dims, &type);
955  if (status != NX_OK) {
956  throw Exception("NXgetinfo failed", status);
957  }
958  Info info;
959  info.type = static_cast<NXnumtype>(type);
960  for (int i = 0; i < rank; i++) {
961  info.dims.push_back(dims[i]);
962  }
963  return info;
964 }
965 
966 pair<string, string> File::getNextEntry() {
967  // set up temporary variables to get the information
968  char name[NX_MAXNAMELEN];
969  char class_name[NX_MAXNAMELEN];
970  int datatype;
971 
972  NXstatus status = NXgetnextentry(this->m_file_id, name, class_name,
973  &datatype);
974  if (status == NX_OK) {
975  string str_name(name);
976  string str_class(class_name);
977  return pair<string,string>(str_name, str_class);
978  }
979  else if (status == NX_EOD) {
980  return pair<string,string>(NULL_STR, NULL_STR); // TODO return the correct thing
981  }
982  else {
983  throw Exception("NXgetnextentry failed", status);
984  }
985 }
986 
987 map<string, string> File::getEntries()
988 {
989  map<string, string> result;
990  this->getEntries(result);
991  return result;
992 }
993 
994 void File::getEntries(std::map<std::string, std::string> & result)
995 {
996  result.clear();
997  this->initGroupDir();
998  pair<string,string> temp;
999  while (true) {
1000  temp = this->getNextEntry();
1001  if (temp.first == NULL_STR && temp.second == NULL_STR) { // TODO this needs to be changed when getNextEntry is fixed
1002  break;
1003  }
1004  else {
1005  result.insert(temp);
1006  }
1007  }
1008 }
1009 
1010 
1011 void File::getSlab(void* data, const vector<int>& start,
1012  const vector<int>& size) {
1013  this->getSlab(data, toInt64(start), toInt64(size));
1014 }
1015 
1016 void File::getSlab(void* data, const vector<int64_t>& start,
1017  const vector<int64_t>& size) {
1018  if (data == NULL) {
1019  throw Exception("Supplied null pointer to getSlab");
1020  }
1021  if (start.size() <= 0) {
1022  stringstream msg;
1023  msg << "Supplied empty start offset, rank = " << start.size()
1024  << " in getSlab";
1025  throw Exception(msg.str());
1026  }
1027  if (start.size() != size.size()) {
1028  stringstream msg;
1029  msg << "In getSlab start rank=" << start.size() << " must match size rank="
1030  << size.size();
1031  throw Exception(msg.str());
1032  }
1033 
1034  NXstatus status = NXgetslab64(this->m_file_id, data, &(start[0]), &(size[0]));
1035  if (status != NX_OK) {
1036  throw Exception("NXgetslab failed", status);
1037  }
1038 }
1039 
1041  //string & name, int & length, NXnumtype type) {
1042  char name[NX_MAXNAMELEN];
1043  int type;
1044  int length;
1045  NXstatus status = NXgetnextattr(this->m_file_id, name, &length, &type);
1046  if (status == NX_OK) {
1047  AttrInfo info;
1048  info.type = static_cast<NXnumtype>(type);
1049  info.length = length;
1050  info.name = string(name);
1051  return info;
1052  }
1053  else if (status == NX_EOD) {
1054  AttrInfo info;
1055  info.name = NULL_STR;
1056  info.length = 0;
1057  return info;
1058  }
1059  else {
1060  throw Exception("NXgetnextattr failed", status);
1061  }
1062 }
1063 
1064 void File::getAttr(const AttrInfo& info, void* data, int length) {
1065  char name[NX_MAXNAMELEN];
1066  strcpy(name, info.name.c_str());
1067  int type = info.type;
1068  if (length < 0)
1069  {
1070  length = info.length;
1071  }
1072  NXstatus status = NXgetattr(this->m_file_id, name, data, &length,
1073  &type);
1074  if (status != NX_OK) {
1075  throw Exception("NXgetattr(" + info.name + ") failed", status);
1076  }
1077  if (type != info.type) {
1078  stringstream msg;
1079  msg << "NXgetattr(" << info.name << ") changed type [" << info.type
1080  << "->" << type << "]";
1081  throw Exception(msg.str());
1082  }
1083  // char attributes are always NULL terminated and so may change length
1084  if (static_cast<unsigned>(length) != info.length && type != NX_CHAR) {
1085  stringstream msg;
1086  msg << "NXgetattr(" << info.name << ") change length [" << info.length
1087  << "->" << length << "]";
1088  throw Exception(msg.str());
1089  }
1090 }
1091 
1092 
1093 template <typename NumT>
1094 NumT File::getAttr(const AttrInfo& info) {
1095  NumT value;
1096  this->getAttr(info, &value);
1097  return value;
1098 }
1099 
1100 template <>
1101 NXDLL_EXPORT void File::getAttr(const std::string& name, std::string& value)
1102 {
1103  AttrInfo info;
1104  info.type = getType<char>();
1105  info.length = 2000;
1106  info.name = name;
1107  value = this->getStrAttr(info);
1108 }
1109 
1110 template <typename NumT>
1111 void File::getAttr(const std::string& name, NumT& value)
1112 {
1113  AttrInfo info;
1114  info.type = getType<NumT>();
1115  info.length = 1;
1116  info.name = name;
1117  value = this->getAttr<NumT>(info);
1118 }
1119 
1120 
1121 string File::getStrAttr(const AttrInfo & info) {
1122  string res;
1123  if (info.type != CHAR) {
1124  stringstream msg;
1125  msg << "getStrAttr only works with strings (type=" << CHAR
1126  << ") found type=" << info.type;
1127  throw Exception(msg.str());
1128  }
1129  char* value = new char[info.length + 1];
1130  try
1131  {
1132  this->getAttr(info, value, info.length+1);
1133  }
1134  catch (Exception& e)
1135  {
1136  //Avoid memory leak
1137  delete [] value;
1138  throw e; //re-throw
1139  }
1140 
1141  //res = string(value, info.length);
1142  //allow the constructor to find the ending point of the string. Janik Zikovsky, sep 22, 2010
1143  res = string(value);
1144  delete [] value;
1145 
1146  return res;
1147 }
1148 
1149 vector<AttrInfo> File::getAttrInfos() {
1150  vector<AttrInfo> infos;
1151  this->initAttrDir();
1152  AttrInfo temp;
1153  while(true) {
1154  temp = this->getNextAttr();
1155  if (temp.name == NULL_STR) {
1156  break;
1157  }
1158  infos.push_back(temp);
1159  }
1160  return infos;
1161 }
1162 
1163 bool File::hasAttr(const std::string & name)
1164 {
1165  this->initAttrDir();
1166  AttrInfo temp;
1167  while(true) {
1168  temp = this->getNextAttr();
1169  if (temp.name == NULL_STR) {
1170  break;
1171  }
1172  if (temp.name == name)
1173  return true;
1174  }
1175  return false;
1176 }
1177 
1178 
1180  NXlink link;
1181  NXstatus status = NXgetgroupID(this->m_file_id, &link);
1182  if (status != NX_OK) {
1183  throw Exception("NXgetgroupID failed", status);
1184  }
1185  return link;
1186 }
1187 
1188 bool File::sameID(NXlink& first, NXlink& second) {
1189  NXstatus status = NXsameID(this->m_file_id, &first, &second);
1190  return (status == NX_OK);
1191 }
1192 
1193 void File::printLink(NXlink & link) {
1194  NXstatus status = NXIprintlink(this->m_file_id, &link);
1195  if (status != NX_OK) {
1196  throw Exception("NXprintlink failed");
1197  }
1198 }
1199 
1200 void File::initGroupDir() {
1201  int status = NXinitgroupdir(this->m_file_id);
1202  if (status != NX_OK) {
1203  throw Exception("NXinitgroupdir failed", status);
1204  }
1205 }
1206 
1207 void File::initAttrDir() {
1208  int status = NXinitattrdir(this->m_file_id);
1209  if (status != NX_OK) {
1210  throw Exception("NXinitattrdir failed", status);
1211  }
1212 }
1213 
1214 void File::setNumberFormat(NXnumtype& type, const string& format) {
1215  if (format.empty()) {
1216  throw Exception("Supplied empty format to setNumberFormat");
1217  }
1218  char c_format[NX_MAXNAMELEN];
1219  strcpy(c_format, format.c_str());
1220  NXstatus status = NXsetnumberformat(this->m_file_id, type, c_format);
1221  if (status != NX_OK) {
1222  stringstream msg;
1223  msg << "NXsetnumberformat(" << format << ") failed";
1224  throw Exception(msg.str(), status);
1225  }
1226 }
1227 
1228 string File::inquireFile(const int buff_length) {
1229  string filename;
1230  char* c_filename = new char[buff_length];
1231  NXstatus status = NXinquirefile(this->m_file_id, c_filename, buff_length);
1232  if (status != NX_OK) {
1233  delete[] c_filename;
1234  stringstream msg;
1235  msg << "NXinquirefile(" << buff_length << ") failed";
1236  throw Exception(msg.str(), status);
1237  }
1238  filename = c_filename;
1239  delete[] c_filename;
1240  return filename;
1241 }
1242 
1243 string File::isExternalGroup(const string& name, const string& type,
1244  const unsigned buff_length) {
1245  string url;
1246  if (name.empty()) {
1247  throw Exception("Supplied empty name to isExternalGroup");
1248  }
1249  if (type.empty()) {
1250  throw Exception("Supplied empty type to isExternalGroup");
1251  }
1252  char* c_url = new char[buff_length];
1253  NXstatus status = NXisexternalgroup(this->m_file_id, name.c_str(),
1254  type.c_str(), c_url, buff_length);
1255  if (status != NX_OK) {
1256  delete[] c_url;
1257  stringstream msg;
1258  msg << "NXisexternalgroup(" << type << ", " << buff_length << ")";
1259  throw Exception(msg.str(), buff_length);
1260  }
1261  url = c_url;
1262  delete[] c_url;
1263  return url;
1264 }
1265 
1266 void File::linkExternal(const string& name, const string& type,
1267  const string& url) {
1268  if (name.empty()) {
1269  throw Exception("Supplied empty name to linkExternal");
1270  }
1271  if (type.empty()) {
1272  throw Exception("Supplied empty type to linkExternal");
1273  }
1274  if (url.empty()) {
1275  throw Exception("Supplied empty url to linkExternal");
1276  }
1277  NXstatus status = NXlinkexternal(this->m_file_id, name.c_str(), type.c_str(),
1278  url.c_str());
1279  if (status != NX_OK) {
1280  stringstream msg;
1281  msg << "NXlinkexternal(" << name << ", " << type << ", " << url
1282  << ") failed";
1283  throw Exception(msg.str(), status);
1284  }
1285 }
1286 
1287 const string File::makeCurrentPath(const string currpath, const string subpath) {
1288  std::ostringstream temp;
1289  temp << currpath << "/" << subpath;
1290  return temp.str();
1291 }
1292 
1293 void File::walkFileForTypeMap(const string path, const string class_name, TypeMap& tmap) {
1294  if (!path.empty()) {
1295  tmap.insert(std::make_pair(class_name, path));
1296  }
1297  map<string, string> dirents = this->getEntries();
1298  map<string, string>::iterator pos;
1299  for (pos = dirents.begin(); pos != dirents.end(); ++pos) {
1300  if (pos->second == "SDS") {
1301  tmap.insert(std::make_pair(pos->second, this->makeCurrentPath(path, pos->first)));
1302  }
1303  else if (pos->second == "CDF0.0") {
1304  // Do nothing with this
1305  ;
1306  }
1307  else {
1308  this->openGroup(pos->first, pos->second);
1309  this->walkFileForTypeMap(this->makeCurrentPath(path, pos->first), pos->second, tmap);
1310  }
1311  }
1312  this->closeGroup();
1313 }
1314 
1316  TypeMap *tmap = new TypeMap();
1317  // Ensure that we're at the top of the file.
1318  this->openPath("/");
1319  this->walkFileForTypeMap("", "", *tmap);
1320  return tmap;
1321 }
1322 
1323 template<typename NumT>
1324 void File::malloc(NumT*& data, const Info& info)
1325 {
1326  if (getType<NumT>() != info.type)
1327  {
1328  throw Exception("Type mismatch in malloc()");
1329  }
1330  inner_malloc((void*&)data, info.dims, info.type);
1331 }
1332 
1333 template<typename NumT>
1334 void File::free(NumT*& data)
1335 {
1336  inner_free((void*&)data);
1337 }
1338 
1339 }
1340 
1341 /* ---------------------------------------------------------------- */
1342 /* Concrete instantiations of template definitions. */
1343 /* ---------------------------------------------------------------- */
1344 template
1345 NXDLL_EXPORT void File::putAttr(const string& name, const float value);
1346 template
1347 NXDLL_EXPORT void File::putAttr(const string& name, const double value);
1348 template
1349 NXDLL_EXPORT void File::putAttr(const string& name, const int8_t value);
1350 template
1351 NXDLL_EXPORT void File::putAttr(const string& name, const uint8_t value);
1352 template
1353 NXDLL_EXPORT void File::putAttr(const string& name, const int16_t value);
1354 template
1355 NXDLL_EXPORT void File::putAttr(const string& name, const uint16_t value);
1356 template
1357 NXDLL_EXPORT void File::putAttr(const string& name, const int32_t value);
1358 template
1359 NXDLL_EXPORT void File::putAttr(const string& name, const uint32_t value);
1360 template
1361 NXDLL_EXPORT void File::putAttr(const string& name, const int64_t value);
1362 template
1363 NXDLL_EXPORT void File::putAttr(const string& name, const uint64_t value);
1364 template
1365 NXDLL_EXPORT void File::putAttr(const string& name, const char value);
1366 
1367 template
1368 NXDLL_EXPORT float File::getAttr(const AttrInfo& info);
1369 template
1370 NXDLL_EXPORT double File::getAttr(const AttrInfo& info);
1371 template
1372 NXDLL_EXPORT int8_t File::getAttr(const AttrInfo& info);
1373 template
1374 NXDLL_EXPORT uint8_t File::getAttr(const AttrInfo& info);
1375 template
1376 NXDLL_EXPORT int16_t File::getAttr(const AttrInfo& info);
1377 template
1378 NXDLL_EXPORT uint16_t File::getAttr(const AttrInfo& info);
1379 template
1380 NXDLL_EXPORT int32_t File::getAttr(const AttrInfo& info);
1381 template
1382 NXDLL_EXPORT uint32_t File::getAttr(const AttrInfo& info);
1383 template
1384 NXDLL_EXPORT int64_t File::getAttr(const AttrInfo& info);
1385 template
1386 NXDLL_EXPORT uint64_t File::getAttr(const AttrInfo& info);
1387 template
1388 NXDLL_EXPORT char File::getAttr(const AttrInfo& info);
1389 
1390 template
1391 NXDLL_EXPORT void File::makeData(const string & name, const NXnumtype type,
1392  const int length, bool open_data);
1393 template
1394 NXDLL_EXPORT void File::makeData(const string & name, const NXnumtype type,
1395  const int64_t length, bool open_data);
1396 
1397 template
1398 NXDLL_EXPORT void File::writeData(const string& name, const float& value);
1399 template
1400 NXDLL_EXPORT void File::writeData(const string& name, const double& value);
1401 template
1402 NXDLL_EXPORT void File::writeData(const string& name, const int8_t& value);
1403 template
1404 NXDLL_EXPORT void File::writeData(const string& name, const uint8_t& value);
1405 template
1406 NXDLL_EXPORT void File::writeData(const string& name, const int16_t& value);
1407 template
1408 NXDLL_EXPORT void File::writeData(const string& name, const uint16_t& value);
1409 template
1410 NXDLL_EXPORT void File::writeData(const string& name, const int32_t& value);
1411 template
1412 NXDLL_EXPORT void File::writeData(const string& name, const uint32_t& value);
1413 template
1414 NXDLL_EXPORT void File::writeData(const string& name, const int64_t& value);
1415 template
1416 NXDLL_EXPORT void File::writeData(const string& name, const uint64_t& value);
1417 template
1418 NXDLL_EXPORT void File::writeData(const string& name, const char& value);
1419 
1420 template
1421 NXDLL_EXPORT void File::writeData(const string& name, const vector<float>& value);
1422 template
1423 NXDLL_EXPORT void File::writeData(const string& name, const vector<double>& value);
1424 template
1425 NXDLL_EXPORT void File::writeData(const string& name, const vector<int8_t>& value);
1426 template
1427 NXDLL_EXPORT void File::writeData(const string& name, const vector<uint8_t>& value);
1428 template
1429 NXDLL_EXPORT void File::writeData(const string& name, const vector<int16_t>& value);
1430 template
1431 NXDLL_EXPORT void File::writeData(const string& name, const vector<uint16_t>& value);
1432 template
1433 NXDLL_EXPORT void File::writeData(const string& name, const vector<int32_t>& value);
1434 template
1435 NXDLL_EXPORT void File::writeData(const string& name, const vector<uint32_t>& value);
1436 template
1437 NXDLL_EXPORT void File::writeData(const string& name, const vector<int64_t>& value);
1438 template
1439 NXDLL_EXPORT void File::writeData(const string& name, const vector<uint64_t>& value);
1440 template
1441 NXDLL_EXPORT void File::writeData(const string& name, const vector<char>& value);
1442 
1443 template
1444 NXDLL_EXPORT void File::writeData(const string& name, const vector<float>& value, const std::vector<int>& dims);
1445 template
1446 NXDLL_EXPORT void File::writeData(const string& name, const vector<double>& value, const std::vector<int>& dims);
1447 template
1448 NXDLL_EXPORT void File::writeData(const string& name, const vector<int8_t>& value, const std::vector<int>& dims);
1449 template
1450 NXDLL_EXPORT void File::writeData(const string& name, const vector<uint8_t>& value, const std::vector<int>& dims);
1451 template
1452 NXDLL_EXPORT void File::writeData(const string& name, const vector<int16_t>& value, const std::vector<int>& dims);
1453 template
1454 NXDLL_EXPORT void File::writeData(const string& name, const vector<uint16_t>& value, const std::vector<int>& dims);
1455 template
1456 NXDLL_EXPORT void File::writeData(const string& name, const vector<int32_t>& value, const std::vector<int>& dims);
1457 template
1458 NXDLL_EXPORT void File::writeData(const string& name, const vector<uint32_t>& value, const std::vector<int>& dims);
1459 template
1460 NXDLL_EXPORT void File::writeData(const string& name, const vector<int64_t>& value, const std::vector<int>& dims);
1461 template
1462 NXDLL_EXPORT void File::writeData(const string& name, const vector<uint64_t>& value, const std::vector<int>& dims);
1463 
1464 template
1465 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<float>& value);
1466 template
1467 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<double>& value);
1468 template
1469 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<int8_t>& value);
1470 template
1471 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<uint8_t>& value);
1472 template
1473 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<int16_t>& value);
1474 template
1475 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<uint16_t>& value);
1476 template
1477 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<int32_t>& value);
1478 template
1479 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<uint32_t>& value);
1480 template
1481 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<int64_t>& value);
1482 template
1483 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<uint64_t>& value);
1484 template
1485 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<char>& value);
1486 
1487 template
1488 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<float>& value, const int64_t chunk);
1489 template
1490 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<double>& value, const int64_t chunk);
1491 template
1492 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<int8_t>& value, const int64_t chunk);
1493 template
1494 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<uint8_t>& value, const int64_t chunk);
1495 template
1496 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<int16_t>& value, const int64_t chunk);
1497 template
1498 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<uint16_t>& value, const int64_t chunk);
1499 template
1500 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<int32_t>& value, const int64_t chunk);
1501 template
1502 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<uint32_t>& value, const int64_t chunk);
1503 template
1504 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<int64_t>& value, const int64_t chunk);
1505 template
1506 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<uint64_t>& value, const int64_t chunk);
1507 template
1508 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<char>& value, const int64_t chunk);
1509 
1510 template
1511 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<float>& value, std::vector<int64_t> & dims, std::vector<int64_t> & chunk);
1512 template
1513 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<double>& value, std::vector<int64_t> & dims, std::vector<int64_t> & chunk);
1514 template
1515 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<int8_t>& value, std::vector<int64_t> & dims, std::vector<int64_t> & chunk);
1516 template
1517 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<uint8_t>& value, std::vector<int64_t> & dims, std::vector<int64_t> & chunk);
1518 template
1519 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<int16_t>& value, std::vector<int64_t> & dims, std::vector<int64_t> & chunk);
1520 template
1521 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<uint16_t>& value, std::vector<int64_t> & dims, std::vector<int64_t> & chunk);
1522 template
1523 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<int32_t>& value, std::vector<int64_t> & dims, std::vector<int64_t> & chunk);
1524 template
1525 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<uint32_t>& value, std::vector<int64_t> & dims, std::vector<int64_t> & chunk);
1526 template
1527 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<int64_t>& value, std::vector<int64_t> & dims, std::vector<int64_t> & chunk);
1528 template
1529 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<uint64_t>& value, std::vector<int64_t> & dims, std::vector<int64_t> & chunk);
1530 template
1531 NXDLL_EXPORT void File::writeExtendibleData(const string& name, std::vector<char>& value, std::vector<int64_t> & dims, std::vector<int64_t> & chunk);
1532 
1533 template
1534 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<float>& value);
1535 template
1536 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<double>& value);
1537 template
1538 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<int8_t>& value);
1539 template
1540 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<uint8_t>& value);
1541 template
1542 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<int16_t>& value);
1543 template
1544 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<uint16_t>& value);
1545 template
1546 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<int32_t>& value);
1547 template
1548 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<uint32_t>& value);
1549 template
1550 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<int64_t>& value);
1551 template
1552 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<uint64_t>& value);
1553 template
1554 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<char>& value);
1555 
1556 template
1557 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<float>& value, std::vector<int64_t> & dims);
1558 template
1559 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<double>& value, std::vector<int64_t> & dims);
1560 template
1561 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<int8_t>& value, std::vector<int64_t> & dims);
1562 template
1563 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<uint8_t>& value, std::vector<int64_t> & dims);
1564 template
1565 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<int16_t>& value, std::vector<int64_t> & dims);
1566 template
1567 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<uint16_t>& value, std::vector<int64_t> & dims);
1568 template
1569 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<int32_t>& value, std::vector<int64_t> & dims);
1570 template
1571 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<uint32_t>& value, std::vector<int64_t> & dims);
1572 template
1573 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<int64_t>& value, std::vector<int64_t> & dims);
1574 template
1575 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<uint64_t>& value, std::vector<int64_t> & dims);
1576 template
1577 NXDLL_EXPORT void File::writeUpdatedData(const string& name, vector<char>& value, std::vector<int64_t> & dims);
1578 
1579 template
1580 NXDLL_EXPORT void File::writeCompData(const string & name, const vector<float> & value,
1581  const vector<int> & dims, const NXcompression comp,
1582  const vector<int> & bufsize);
1583 template
1584 NXDLL_EXPORT void File::writeCompData(const string & name, const vector<float> & value,
1585  const vector<int64_t> & dims, const NXcompression comp,
1586  const vector<int64_t> & bufsize);
1587 template
1588 NXDLL_EXPORT void File::writeCompData(const string & name, const vector<double> & value,
1589  const vector<int> & dims, const NXcompression comp,
1590  const vector<int> & bufsize);
1591 template
1592 NXDLL_EXPORT void File::writeCompData(const string & name, const vector<double> & value,
1593  const vector<int64_t> & dims, const NXcompression comp,
1594  const vector<int64_t> & bufsize);
1595 template
1596 NXDLL_EXPORT void File::writeCompData(const string & name, const vector<int8_t> & value,
1597  const vector<int> & dims, const NXcompression comp,
1598  const vector<int> & bufsize);
1599 template
1600 NXDLL_EXPORT void File::writeCompData(const string & name, const vector<int8_t> & value,
1601  const vector<int64_t> & dims, const NXcompression comp,
1602  const vector<int64_t> & bufsize);
1603 template
1604 NXDLL_EXPORT void File::writeCompData(const string & name, const vector<uint8_t> & value,
1605  const vector<int> & dims, const NXcompression comp,
1606  const vector<int> & bufsize);
1607 template
1608 NXDLL_EXPORT void File::writeCompData(const string & name, const vector<uint8_t> & value,
1609  const vector<int64_t> & dims, const NXcompression comp,
1610  const vector<int64_t> & bufsize);
1611 template
1612 NXDLL_EXPORT void File::writeCompData(const string & name, const vector<int16_t> & value,
1613  const vector<int> & dims, const NXcompression comp,
1614  const vector<int> & bufsize);
1615 template
1616 NXDLL_EXPORT void File::writeCompData(const string & name, const vector<int16_t> & value,
1617  const vector<int64_t> & dims, const NXcompression comp,
1618  const vector<int64_t> & bufsize);
1619 template
1620 NXDLL_EXPORT void File::writeCompData(const string & name, const vector<uint16_t> & value,
1621  const vector<int> & dims, const NXcompression comp,
1622  const vector<int> & bufsize);
1623 template
1624 NXDLL_EXPORT void File::writeCompData(const string & name, const vector<uint16_t> & value,
1625  const vector<int64_t> & dims, const NXcompression comp,
1626  const vector<int64_t> & bufsize);
1627 template
1628 NXDLL_EXPORT void File::writeCompData(const string & name, const vector<int32_t> & value,
1629  const vector<int> & dims, const NXcompression comp,
1630  const vector<int> & bufsize);
1631 template
1632 NXDLL_EXPORT void File::writeCompData(const string & name, const vector<int32_t> & value,
1633  const vector<int64_t> & dims, const NXcompression comp,
1634  const vector<int64_t> & bufsize);
1635 template
1636 NXDLL_EXPORT void File::writeCompData(const string & name, const vector<uint32_t> & value,
1637  const vector<int> & dims, const NXcompression comp,
1638  const vector<int> & bufsize);
1639 template
1640 NXDLL_EXPORT void File::writeCompData(const string & name, const vector<uint32_t> & value,
1641  const vector<int64_t> & dims, const NXcompression comp,
1642  const vector<int64_t> & bufsize);
1643 template
1644 NXDLL_EXPORT void File::writeCompData(const string & name, const vector<int64_t> & value,
1645  const vector<int> & dims, const NXcompression comp,
1646  const vector<int> & bufsize);
1647 template
1648 NXDLL_EXPORT void File::writeCompData(const string & name, const vector<int64_t> & value,
1649  const vector<int64_t> & dims, const NXcompression comp,
1650  const vector<int64_t> & bufsize);
1651 template
1652 NXDLL_EXPORT void File::writeCompData(const string & name, const vector<uint64_t> & value,
1653  const vector<int> & dims, const NXcompression comp,
1654  const vector<int> & bufsize);
1655 template
1656 NXDLL_EXPORT void File::writeCompData(const string & name, const vector<uint64_t> & value,
1657  const vector<int64_t> & dims, const NXcompression comp,
1658  const vector<int64_t> & bufsize);
1659 
1660 template
1661 NXDLL_EXPORT vector<float> * File::getData();
1662 template
1663 NXDLL_EXPORT vector<double> * File::getData();
1664 template
1665 NXDLL_EXPORT vector<int8_t> * File::getData();
1666 template
1667 NXDLL_EXPORT vector<uint8_t> * File::getData();
1668 template
1669 NXDLL_EXPORT vector<int16_t> * File::getData();
1670 template
1671 NXDLL_EXPORT vector<uint16_t> * File::getData();
1672 template
1673 NXDLL_EXPORT vector<int32_t> * File::getData();
1674 template
1675 NXDLL_EXPORT vector<uint32_t> * File::getData();
1676 template
1677 NXDLL_EXPORT vector<int64_t> * File::getData();
1678 template
1679 NXDLL_EXPORT vector<uint64_t> * File::getData();
1680 template
1681 NXDLL_EXPORT vector<char> * File::getData();
1682 
1683 template
1684 NXDLL_EXPORT void File::getData(vector<float>& data);
1685 template
1686 NXDLL_EXPORT void File::getData(vector<double>& data);
1687 template
1688 NXDLL_EXPORT void File::getData(vector<int8_t>& data);
1689 template
1690 NXDLL_EXPORT void File::getData(vector<uint8_t>& data);
1691 template
1692 NXDLL_EXPORT void File::getData(vector<int16_t>& data);
1693 template
1694 NXDLL_EXPORT void File::getData(vector<uint16_t>& data);
1695 template
1696 NXDLL_EXPORT void File::getData(vector<int32_t>& data);
1697 template
1698 NXDLL_EXPORT void File::getData(vector<uint32_t>& data);
1699 template
1700 NXDLL_EXPORT void File::getData(vector<int64_t>& data);
1701 template
1702 NXDLL_EXPORT void File::getData(vector<uint64_t>& data);
1703 template
1704 NXDLL_EXPORT void File::getData(vector<char>& data);
1705 
1706 template
1707 NXDLL_EXPORT void File::readData(const std::string & dataName, vector<float>& data);
1708 template
1709 NXDLL_EXPORT void File::readData(const std::string & dataName, vector<double>& data);
1710 template
1711 NXDLL_EXPORT void File::readData(const std::string & dataName, vector<int8_t>& data);
1712 template
1713 NXDLL_EXPORT void File::readData(const std::string & dataName, vector<uint8_t>& data);
1714 template
1715 NXDLL_EXPORT void File::readData(const std::string & dataName, vector<int16_t>& data);
1716 template
1717 NXDLL_EXPORT void File::readData(const std::string & dataName, vector<uint16_t>& data);
1718 template
1719 NXDLL_EXPORT void File::readData(const std::string & dataName, vector<int32_t>& data);
1720 template
1721 NXDLL_EXPORT void File::readData(const std::string & dataName, vector<uint32_t>& data);
1722 template
1723 NXDLL_EXPORT void File::readData(const std::string & dataName, vector<int64_t>& data);
1724 template
1725 NXDLL_EXPORT void File::readData(const std::string & dataName, vector<uint64_t>& data);
1726 template
1727 NXDLL_EXPORT void File::readData(const std::string & dataName, vector<char>& data);
1728 
1729 template
1730 NXDLL_EXPORT void File::readData(const std::string & dataName, float& data);
1731 template
1732 NXDLL_EXPORT void File::readData(const std::string & dataName, double& data);
1733 template
1734 NXDLL_EXPORT void File::readData(const std::string & dataName, int8_t& data);
1735 template
1736 NXDLL_EXPORT void File::readData(const std::string & dataName, uint8_t& data);
1737 template
1738 NXDLL_EXPORT void File::readData(const std::string & dataName, int16_t& data);
1739 template
1740 NXDLL_EXPORT void File::readData(const std::string & dataName, uint16_t& data);
1741 template
1742 NXDLL_EXPORT void File::readData(const std::string & dataName, int32_t& data);
1743 template
1744 NXDLL_EXPORT void File::readData(const std::string & dataName, uint32_t& data);
1745 template
1746 NXDLL_EXPORT void File::readData(const std::string & dataName, int64_t& data);
1747 template
1748 NXDLL_EXPORT void File::readData(const std::string & dataName, uint64_t& data);
1749 
1750 template
1751 NXDLL_EXPORT void File::putSlab(std::vector<float>& data, int start, int size);
1752 template
1753 NXDLL_EXPORT void File::putSlab(std::vector<double>& data, int start, int size);
1754 template
1755 NXDLL_EXPORT void File::putSlab(std::vector<int8_t>& data, int start, int size);
1756 template
1757 NXDLL_EXPORT void File::putSlab(std::vector<uint8_t>& data, int start, int size);
1758 template
1759 NXDLL_EXPORT void File::putSlab(std::vector<int16_t>& data, int start, int size);
1760 template
1761 NXDLL_EXPORT void File::putSlab(std::vector<uint16_t>& data, int start, int size);
1762 template
1763 NXDLL_EXPORT void File::putSlab(std::vector<int32_t>& data, int start, int size);
1764 template
1765 NXDLL_EXPORT void File::putSlab(std::vector<uint32_t>& data, int start, int size);
1766 template
1767 NXDLL_EXPORT void File::putSlab(std::vector<int64_t>& data, int start, int size);
1768 template
1769 NXDLL_EXPORT void File::putSlab(std::vector<uint64_t>& data, int start, int size);
1770 
1771 template
1772 NXDLL_EXPORT void File::putSlab(std::vector<float>& data, std::vector<int64_t> & start, std::vector<int64_t> & size);
1773 template
1774 NXDLL_EXPORT void File::putSlab(std::vector<double>& data, std::vector<int64_t> & start, std::vector<int64_t> & size);
1775 template
1776 NXDLL_EXPORT void File::putSlab(std::vector<int8_t>& data, std::vector<int64_t> & start, std::vector<int64_t> & size);
1777 template
1778 NXDLL_EXPORT void File::putSlab(std::vector<uint8_t>& data, std::vector<int64_t> & start, std::vector<int64_t> & size);
1779 template
1780 NXDLL_EXPORT void File::putSlab(std::vector<int16_t>& data, std::vector<int64_t> & start, std::vector<int64_t> & size);
1781 template
1782 NXDLL_EXPORT void File::putSlab(std::vector<uint16_t>& data, std::vector<int64_t> & start, std::vector<int64_t> & size);
1783 template
1784 NXDLL_EXPORT void File::putSlab(std::vector<int32_t>& data, std::vector<int64_t> & start, std::vector<int64_t> & size);
1785 template
1786 NXDLL_EXPORT void File::putSlab(std::vector<uint32_t>& data, std::vector<int64_t> & start, std::vector<int64_t> & size);
1787 template
1788 NXDLL_EXPORT void File::putSlab(std::vector<int64_t>& data, std::vector<int64_t> & start, std::vector<int64_t> & size);
1789 template
1790 NXDLL_EXPORT void File::putSlab(std::vector<uint64_t>& data, std::vector<int64_t> & start, std::vector<int64_t> & size);
1791 
1792 template
1793 NXDLL_EXPORT void File::getAttr(const std::string& name, double& value);
1794 template
1795 NXDLL_EXPORT void File::getAttr(const std::string& name, int& value);
1796 
1797 template
1798 NXDLL_EXPORT void File::malloc(int*& data, const Info& info);
1799 template
1800 NXDLL_EXPORT void File::malloc(float*& data, const Info& info);
1801 template
1802 NXDLL_EXPORT void File::malloc(double*& data, const Info& info);
1803 
1804 template
1805 NXDLL_EXPORT void File::free(int*& data);
1806 template
1807 NXDLL_EXPORT void File::free(float*& data);
1808 template
1809 NXDLL_EXPORT void File::free(double*& data);
NXstatus NXputdata(NXhandle handle, const void *data)
NXstatus NXopengrouppath(NXhandle handle, CONSTCHAR *path)
void putData(const void *data)
Definition: NeXusFile.cpp:533
NXstatus NXflush(NXhandle *pHandle)
void putSlab(void *data, std::vector< int > &start, std::vector< int > &size)
Definition: NeXusFile.cpp:601
NXstatus NXinitattrdir(NXhandle handle)
std::map< std::string, std::string > getEntries()
Return the entries available in the current place in the file.
Definition: NeXusFile.cpp:987
bool isDataInt()
Return true if the data opened is of one of the int data types, 32 bits or less.
Definition: NeXusFile.cpp:901
NXstatus NXclosedata(NXhandle handle)
bool hasAttr(const std::string &name)
Definition: NeXusFile.cpp:1163
void openGroupPath(const std::string &path)
Open the group in which the NeXus object with the specified path exists.
Definition: NeXusFile.cpp:272
NXcompression
The available compression types.
Definition: NeXusFile.hpp:72
NXstatus NXmakelink(NXhandle handle, NXlink *pLink)
NXstatus NXisexternalgroup(NXhandle handle, CONSTCHAR *name, CONSTCHAR *nxclass, char *url, int urlLen)
NXstatus NXgetdata(NXhandle handle, void *data)
void makeLink(NXlink &link)
Create a link in the current location to the supplied id.
Definition: NeXusFile.cpp:687
void makeCompData(const std::string &name, const NXnumtype type, const std::vector< int > &dims, const NXcompression comp, const std::vector< int > &bufsize, bool open_data=false)
Definition: NeXusFile.cpp:446
NXstatus NXsetnumberformat(NXhandle handle, int type, char *format)
void writeCompData(const std::string &name, const std::vector< NumT > &value, const std::vector< int > &dims, const NXcompression comp, const std::vector< int > &bufsize)
Definition: NeXusFile.cpp:495
Definition of the NeXus C++ API.
void close()
Close the file before the constructor is called.
Definition: NeXusFile.cpp:208
void makeGroup(const std::string &name, const std::string &class_name, bool open_group=false)
Create a new group.
Definition: NeXusFile.cpp:225
std::string getStrAttr(const AttrInfo &info)
Get the value of a string attribute.
Definition: NeXusFile.cpp:1121
std::string inquireFile(const int buff_length=NX_MAXPATHLEN)
Find out the name of the file this object is holding onto.
Definition: NeXusFile.cpp:1228
void getAttr(const AttrInfo &info, void *data, int length=-1)
Get the value of the attribute specified by the AttrInfo supplied.
Definition: NeXusFile.cpp:1064
NXstatus NXmakenamedlink(NXhandle handle, CONSTCHAR *newname, NXlink *pLink)
NXstatus NXfree(void **data)
std::vector< AttrInfo > getAttrInfos()
Definition: NeXusFile.cpp:1149
NXstatus NXopen(CONSTCHAR *filename, NXaccess access_method, NXhandle *pHandle)
bool sameID(NXlink &first, NXlink &second)
Determine whether or not two links refer to the same data or group.
Definition: NeXusFile.cpp:1188
void readData(const std::string &dataName, std::vector< NumT > &data)
Put data into the supplied vector.
Definition: NeXusFile.cpp:876
void makeNamedLink(const std::string &name, NXlink &link)
Create a link with a new name.
Definition: NeXusFile.cpp:694
Header for a base NeXus::Exception.
std::vector< int64_t > dims
The dimensions of the file.
Definition: NeXusFile.hpp:92
AttrInfo getNextAttr()
Definition: NeXusFile.cpp:1040
NXnumtype
The primitive types published by this API.
Definition: NeXusFile.hpp:48
void openSourceGroup()
Open the original copy of this group or data as declared by the "target" attribute.
Definition: NeXusFile.cpp:704
void openData(const std::string &name)
Definition: NeXusFile.cpp:516
NXstatus NXsameID(NXhandle handle, NXlink *pFirstID, NXlink *pSecondID)
void writeData(const std::string &name, const std::string &value)
Create a 1D data field, insert the data, and close the data.
Definition: NeXusFile.cpp:352
Info getInfo()
Definition: NeXusFile.cpp:949
void makeData(const std::string &name, NXnumtype type, const std::vector< int > &dims, bool open_data=false)
Definition: NeXusFile.cpp:304
NXnumtype getType(NumT number)
This function returns the NXnumtype given a concrete number.
Definition: NeXusFile.cpp:57
void writeUpdatedData(const std::string &name, std::vector< NumT > &value)
Updates the data written into an already-created data vector.
Definition: NeXusFile.cpp:428
NXstatus NXgetgroupID(NXhandle handle, NXlink *pLink)
std::vector< NumT > * getData()
Allocate memory and return the data as a vector.
Definition: NeXusFile.cpp:722
File(const std::string &filename, const NXaccess access=NXACC_READ)
Create a new File.
Definition: NeXusFile.cpp:177
unsigned length
The length of the attribute.
Definition: NeXusFile.hpp:100
Information about an attribute.
Definition: NeXusFile.hpp:96
void closeGroup()
Close the currently open group.
Definition: NeXusFile.cpp:297
void closeData()
Close the currently open data.
Definition: NeXusFile.cpp:526
NXstatus NXinquirefile(NXhandle handle, char *filename, int filenameBufferLength)
NXlink getGroupID()
Definition: NeXusFile.cpp:1179
NXstatus NXmakegroup(NXhandle handle, CONSTCHAR *name, CONSTCHAR *NXclass)
NXstatus NXopenpath(NXhandle handle, CONSTCHAR *path)
#define NXDLL_EXPORT
Definition: NeXusFile.hpp:23
void free(NumT *&data)
Definition: NeXusFile.cpp:1334
NXstatus NXgetattr(NXhandle handle, char *name, void *data, int *iDataLen, int *iType)
void printLink(NXlink &link)
Diagnostic print of the link information.
Definition: NeXusFile.cpp:1193
This structure holds the type and dimensions of a primative field/array.
Definition: NeXusFile.hpp:88
void flush()
Flush the file.
Definition: NeXusFile.cpp:218
std::string isExternalGroup(const std::string &name, const std::string &type, const unsigned buff_length=NX_MAXNAMELEN)
Determine Whether or not a supplied group is external.
Definition: NeXusFile.cpp:1243
std::multimap< std::string, std::string > TypeMap
Type definition for a type-keyed multimap.
Definition: NeXusFile.hpp:83
std::string name
The name of the attribute.
Definition: NeXusFile.hpp:102
std::string getPath()
Get the path into the current file.
Definition: NeXusFile.cpp:284
Class that provides for a standard NeXus exception.
void linkExternal(const std::string &name, const std::string &type, const std::string &url)
Create a link to a group in an external file.
Definition: NeXusFile.cpp:1266
NXstatus NXopengroup(NXhandle handle, CONSTCHAR *name, CONSTCHAR *NXclass)
NXstatus NXclosegroup(NXhandle handle)
~File()
Destructor.
Definition: NeXusFile.cpp:198
void putAttr(const AttrInfo &info, const void *data)
Put the supplied data as an attribute into the currently open data.
Definition: NeXusFile.cpp:551
std::string getStrData()
Definition: NeXusFile.cpp:920
void malloc(NumT *&data, const Info &info)
Definition: NeXusFile.cpp:1324
void writeExtendibleData(const std::string &name, std::vector< NumT > &value)
Create a 1D data field with an unlimited dimension, insert the data, and close the data...
Definition: NeXusFile.cpp:393
NXstatus NXgetdataID(NXhandle handle, NXlink *pLink)
std::pair< std::string, std::string > getNextEntry()
Definition: NeXusFile.cpp:966
void openPath(const std::string &path)
Open the NeXus object with the path specified.
Definition: NeXusFile.cpp:260
NXnumtype type
The primative type for the field.
Definition: NeXusFile.hpp:90
void getSlab(void *data, const std::vector< int > &start, const std::vector< int > &size)
Definition: NeXusFile.cpp:1011
NXstatus NXclose(NXhandle *pHandle)
NXstatus NXgetnextattr(NXhandle handle, NXname pName, int *iLength, int *iType)
TypeMap * getTypeMap()
Create a multimap with the data types as keys and the associated paths as values. ...
Definition: NeXusFile.cpp:1315
NXstatus NXopendata(NXhandle handle, CONSTCHAR *label)
NXstatus NXopensourcegroup(NXhandle handle)
NXstatus NXputattr(NXhandle handle, CONSTCHAR *name, const void *data, int iDataLen, int iType)
bool isDataSetOpen()
This function checksi if we are in an open dataset.
Definition: NeXusFile.cpp:673
void getDataCoerce(std::vector< int > &data)
Get data and coerce into an int vector.
Definition: NeXusFile.cpp:775
NXstatus NXgetnextentry(NXhandle handle, NXname name, NXname nxclass, int *datatype)
NXstatus NXlinkexternal(NXhandle handle, CONSTCHAR *name, CONSTCHAR *nxclass, CONSTCHAR *url)
NXnumtype type
The primative type for the attribute.
Definition: NeXusFile.hpp:98
void openGroup(const std::string &name, const std::string &class_name)
Open an existing group.
Definition: NeXusFile.cpp:244
NXstatus NXgetpath(NXhandle handle, char *path, int pathlen)
NXstatus NXinitgroupdir(NXhandle handle)
NXlink getDataID()
Definition: NeXusFile.cpp:664
void setNumberFormat(NXnumtype &type, const std::string &format)
Set the number format used for a particular type when using the xml base.
Definition: NeXusFile.cpp:1214