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