6 #include "napiconfig.h" 10 using namespace NeXus;
14 using std::stringstream;
22 static const string NULL_STR =
"NULL";
25 template <
typename NumT>
26 static string toString(
const vector<NumT>& data) {
29 size_t size = data.size();
30 for (
size_t i = 0; i < size; i++) {
40 static vector<int64_t> toInt64(
const vector<int> & small_v) {
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)
46 big_v.push_back(static_cast<int64_t>(*it));
56 template <
typename NumT>
59 msg <<
"NeXus::getType() does not know type of " <<
typeid(number).name();
136 #define ARRAY_OFFSET 1 138 #define ARRAY_OFFSET 0 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++) {
157 NXstatus status = NXmalloc64(&data, rank, c_dims, type);
158 if (status != NX_OK) {
159 throw Exception(
"NXmalloc failed", status);
164 static void inner_free(
void* & data) {
165 NXstatus status =
NXfree(&data);
166 if (status != NX_OK) {
167 throw Exception(
"NXfree failed", status);
174 File::File(NXhandle handle,
bool close_handle) : m_file_id(handle), m_close_handle(close_handle) {
177 File::File(
const string& filename,
const NXaccess access) : m_close_handle (true) {
178 this->initOpenFile(filename, access);
181 File::File(
const char *filename,
const NXaccess access) : m_close_handle (true) {
182 this->initOpenFile(
string(filename), access);
185 void File::initOpenFile(
const string& filename,
const NXaccess access) {
186 if (filename.empty()) {
187 throw Exception(
"Filename specified is empty constructor");
190 NXstatus status =
NXopen(filename.c_str(), access, &(this->m_file_id));
191 if (status != NX_OK) {
193 msg <<
"NXopen(" << filename <<
", " << access <<
") failed";
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);
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);
219 NXstatus status =
NXflush(&(this->m_file_id));
220 if (status != NX_OK) {
221 throw Exception(
"NXflush failed", status);
227 throw Exception(
"Supplied empty name to makeGroup");
229 if (class_name.empty()) {
230 throw Exception(
"Supplied empty class name to makeGroup");
232 NXstatus status =
NXmakegroup(this->m_file_id, name.c_str(),
234 if (status != NX_OK) {
236 msg <<
"NXmakegroup(" << name <<
", " << class_name <<
") failed";
246 throw Exception(
"Supplied empty name to openGroup");
248 if (class_name.empty()) {
249 throw Exception(
"Supplied empty class name to openGroup");
251 NXstatus status =
NXopengroup(this->m_file_id, name.c_str(),
253 if (status != NX_OK) {
255 msg <<
"NXopengroup(" << name <<
", " << class_name <<
") failed";
262 throw Exception(
"Supplied empty path to openPath");
264 NXstatus status =
NXopenpath(this->m_file_id, path.c_str());
265 if (status != NX_OK) {
267 msg <<
"NXopenpath(" << path <<
") failed";
274 throw Exception(
"Supplied empty path to openGroupPath");
277 if (status != NX_OK) {
279 msg <<
"NXopengrouppath(" << path <<
") failed";
287 memset(cPath,0,
sizeof(cPath));
288 NXstatus status =
NXgetpath(this->m_file_id,cPath,
sizeof(cPath)-1);
289 if (status != NX_OK) {
291 msg <<
"NXgetpath() failed";
294 return std::string(cPath);
299 if (status != NX_OK) {
300 throw Exception(
"NXclosegroup failed", status);
305 const vector<int>& dims,
bool open_data) {
306 this->
makeData(name, type, toInt64(dims), open_data);
310 const vector<int64_t>& dims,
bool open_data) {
313 throw Exception(
"Supplied empty label to makeData");
316 throw Exception(
"Supplied empty dimensions to makeData");
320 NXstatus status = NXmakedata64(this->m_file_id, name.c_str(), (int)type,
321 dims.size(),
const_cast<int64_t*
>(&(dims[0])));
323 if (status != NX_OK) {
325 msg <<
"NXmakedata(" << name <<
", " << type <<
", " << dims.size()
326 <<
", " << toString(dims) <<
") failed";
334 template <
typename NumT>
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);
342 template <
typename NumT>
344 std::vector<NumT> v(1, value);
349 this->
writeData(name, std::string(value));
354 string my_value(value);
356 if (my_value.empty())
359 dims.push_back(static_cast<int>(my_value.size()));
369 template <
typename NumT>
371 vector<int64_t> dims(1, value.size());
375 template <
typename NumT>
377 const vector<int>& dims) {
378 this->
makeData(name, getType<NumT>(), dims,
true);
383 template <
typename NumT>
385 const vector<int64_t>& dims) {
386 this->
makeData(name, getType<NumT>(), dims,
true);
392 template <
typename NumT>
399 template <
typename NumT>
402 vector<int64_t> dims(1, NX_UNLIMITED);
403 vector<int64_t> chunk_dims(1, chunk);
406 this->
putSlab(value, int64_t(0), int64_t(value.size()));
410 template <
typename NumT>
412 vector<int64_t>& dims, std::vector<int64_t> & chunk)
415 std::vector<int64_t> unlim_dims(dims);
416 unlim_dims[0] = NX_UNLIMITED;
420 std::vector<int64_t> start( dims.size(), 0 );
421 this->
putSlab(value, start, dims);
427 template <
typename NumT>
431 this->
putSlab(value, int64_t(0), int64_t(value.size()));
435 template <
typename NumT>
437 std::vector<int64_t>& dims)
440 std::vector<int64_t> start( dims.size(), 0 );
441 this->
putSlab(value, start, dims);
448 const vector<int>& bufsize,
bool open_data) {
449 this->
makeCompData(name, type, toInt64(dims), comp, toInt64(bufsize), open_data);
454 const vector<int64_t>& bufsize,
bool open_data) {
457 throw Exception(
"Supplied empty name to makeCompData");
460 throw Exception(
"Supplied empty dimensions to makeCompData");
462 if (bufsize.empty()) {
463 throw Exception(
"Supplied empty bufsize to makeCompData");
465 if (dims.size() != bufsize.size()) {
467 msg <<
"Supplied dims rank=" << dims.size()
468 <<
" must match supplied bufsize rank=" << bufsize.size()
469 <<
"in makeCompData";
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,
478 const_cast<int64_t *
>(&(dims[0])), i_comp,
479 const_cast<int64_t *
>(&(bufsize[0])));
482 if (status != NX_OK) {
484 msg <<
"NXcompmakedata64(" << name <<
", " << type <<
", " << dims.size()
485 <<
", " << toString(dims) <<
", " << comp <<
", " << toString(bufsize)
494 template <
typename NumT>
497 const vector<int> & bufsize) {
498 this->
writeCompData(name, value, toInt64(dims), comp, toInt64(bufsize));
501 template <
typename NumT>
504 const vector<int64_t> & bufsize) {
505 this->
makeCompData(name, getType<NumT>(), dims, comp, bufsize,
true);
512 msg <<
"compress(" << comp <<
") is depricated - use makeCompData()";
518 throw Exception(
"Supplied empty name to openData");
520 NXstatus status =
NXopendata(this->m_file_id, name.c_str());
521 if (status != NX_OK) {
522 throw Exception(
"NXopendata(" + name +
") failed", status);
528 if (status != NX_OK) {
529 throw Exception(
"NXclosedata() failed", status);
535 throw Exception(
"Data specified as null in putData");
537 NXstatus status =
NXputdata(this->m_file_id, const_cast<void *>(data));
538 if (status != NX_OK) {
539 throw Exception(
"NXputdata(void *) failed", status);
543 template <
typename NumT>
546 throw Exception(
"Supplied empty data to putData");
552 if (info.
name == NULL_STR) {
553 throw Exception(
"Supplied bad attribute name \"" + NULL_STR +
"\"");
555 if (info.
name.empty()) {
556 throw Exception(
"Supplied empty name to putAttr");
558 NXstatus status =
NXputattr(this->m_file_id, info.
name.c_str(),
559 const_cast<void *
>(data), info.
length,
561 if (status != NX_OK) {
563 msg <<
"NXputattr(" << info.
name <<
", data, " << info.
length <<
", " 564 << info.
type <<
") failed";
569 template <
typename NumT>
574 info.
type = getType<NumT>();
580 throw Exception(
"Specified name as null to putAttr");
583 throw Exception(
"Specified value as null to putAttr");
586 string s_value(value);
587 this->
putAttr(s_name, s_value);
591 string my_value(value);
592 if (my_value.empty())
596 info.
length =
static_cast<int>(my_value.size());
598 this->
putAttr(info, &(my_value[0]));
602 vector<int64_t> start_big = toInt64(start);
603 vector<int64_t> size_big = toInt64(size);
604 this->
putSlab(data, start_big, size_big);
607 void File::putSlab(
void* data, vector<int64_t>& start, vector<int64_t>& size) {
609 throw Exception(
"Data specified as null in putSlab");
612 throw Exception(
"Supplied empty start to putSlab");
615 throw Exception(
"Supplied empty size to putSlab");
617 if (start.size() != size.size()) {
619 msg <<
"Supplied start rank=" << start.size()
620 <<
" must match supplied size rank=" << size.size()
624 NXstatus status = NXputslab64(this->m_file_id, data, &(start[0]), &(size[0]));
625 if (status != NX_OK) {
627 msg <<
"NXputslab64(data, " << toString(start) <<
", " << toString(size)
633 template <
typename NumT>
636 vector<int64_t> start_big = toInt64(start);
637 vector<int64_t> size_big = toInt64(size);
638 this->
putSlab(data, start_big, size_big);
641 template <
typename NumT>
643 vector<int64_t>& size) {
645 throw Exception(
"Supplied empty data to putSlab");
647 this->
putSlab(&(data[0]), start, size);
650 template <
typename NumT>
652 this->
putSlab(data, static_cast<int64_t>(start), static_cast<int64_t>(size));
655 template <
typename NumT>
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);
666 NXstatus status =
NXgetdataID(this->m_file_id, &link);
667 if (status != NX_OK) {
668 throw Exception(
"NXgetdataID failed", status);
688 NXstatus status =
NXmakelink(this->m_file_id, &link);
689 if (status != NX_OK) {
690 throw Exception(
"NXmakelink failed", status);
696 throw Exception(
"Supplied empty name to makeNamedLink");
698 NXstatus status =
NXmakenamedlink(this->m_file_id, name.c_str(), &link);
699 if (status != NX_OK) {
700 throw Exception(
"NXmakenamedlink(" + name +
", link)", status);
706 if (status != NX_OK) {
707 throw Exception(
"NXopensourcegroup failed");
713 throw Exception(
"Supplied null pointer to getData");
715 NXstatus status =
NXgetdata(this->m_file_id, data);
716 if (status != NX_OK) {
717 throw Exception(
"NXgetdata failed", status);
721 template <
typename NumT>
724 if (info.
type != getType<NumT>()) {
725 throw Exception(
"NXgetdata failed - invalid vector type");
730 for (vector<int64_t>::const_iterator it = info.
dims.begin();
731 it != info.
dims.end(); it++) {
737 inner_malloc(temp, info.
dims, info.
type);
743 vector<NumT> * result =
new vector<NumT>(
static_cast<NumT *
>(temp),
744 static_cast<NumT *>(temp)
745 +
static_cast<size_t>(length));
751 template <
typename NumT>
755 if (info.
type != getType<NumT>())
757 throw Exception(
"NXgetdata failed - invalid vector type");
761 for (vector<int64_t>::const_iterator it = info.
dims.begin();
762 it != info.
dims.end(); it++) {
780 vector<int8_t> result;
782 data.assign(result.begin(), result.end());
786 vector<uint8_t> result;
788 data.assign(result.begin(), result.end());
792 vector<int16_t> result;
794 data.assign(result.begin(), result.end());
798 vector<uint16_t> result;
800 data.assign(result.begin(), result.end());
804 vector<int32_t> result;
806 data.assign(result.begin(), result.end());
810 vector<uint32_t> result;
812 data.assign(result.begin(), result.end());
816 throw Exception(
"NexusFile::getDataCoerce(): Could not coerce to int.");
825 vector<int8_t> result;
827 data.assign(result.begin(), result.end());
831 vector<uint8_t> result;
833 data.assign(result.begin(), result.end());
837 vector<int16_t> result;
839 data.assign(result.begin(), result.end());
843 vector<uint16_t> result;
845 data.assign(result.begin(), result.end());
849 vector<int32_t> result;
851 data.assign(result.begin(), result.end());
855 vector<uint32_t> result;
857 data.assign(result.begin(), result.end());
861 vector<float> result;
863 data.assign(result.begin(), result.end());
871 throw Exception(
"NexusFile::getDataCoerce(): Could not coerce to double.");
875 template <
typename NumT>
883 template <
typename NumT>
886 std::vector<NumT> dataVector;
889 if (dataVector.size() > 0)
890 data = dataVector[0];
923 if (info.
type != NX_CHAR) {
925 msg <<
"Cannot use getStrData() on non-character data. Found type=" 929 if (info.
dims.size() != 1) {
931 msg <<
"getStrData() only understand rank=1 data. Found rank=" 935 char* value =
new char[info.
dims[0]+1];
944 res = string(value, info.
dims[0]);
951 int64_t dims[NX_MAXRANK];
954 NXstatus status = NXgetinfo64(this->m_file_id, &rank, dims, &type);
955 if (status != NX_OK) {
956 throw Exception(
"NXgetinfo failed", status);
960 for (
int i = 0; i < rank; i++) {
961 info.
dims.push_back(dims[i]);
968 char name[NX_MAXNAMELEN];
969 char class_name[NX_MAXNAMELEN];
972 NXstatus status =
NXgetnextentry(this->m_file_id, name, class_name,
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);
979 else if (status == NX_EOD) {
980 return pair<string,string>(NULL_STR, NULL_STR);
983 throw Exception(
"NXgetnextentry failed", status);
989 map<string, string> result;
997 this->initGroupDir();
998 pair<string,string> temp;
1001 if (temp.first == NULL_STR && temp.second == NULL_STR) {
1005 result.insert(temp);
1012 const vector<int>& size) {
1013 this->
getSlab(data, toInt64(start), toInt64(size));
1017 const vector<int64_t>& size) {
1019 throw Exception(
"Supplied null pointer to getSlab");
1021 if (start.size() <= 0) {
1023 msg <<
"Supplied empty start offset, rank = " << start.size()
1027 if (start.size() != size.size()) {
1029 msg <<
"In getSlab start rank=" << start.size() <<
" must match size rank=" 1034 NXstatus status = NXgetslab64(this->m_file_id, data, &(start[0]), &(size[0]));
1035 if (status != NX_OK) {
1036 throw Exception(
"NXgetslab failed", status);
1042 char name[NX_MAXNAMELEN];
1045 NXstatus status =
NXgetnextattr(this->m_file_id, name, &length, &type);
1046 if (status == NX_OK) {
1050 info.
name = string(name);
1053 else if (status == NX_EOD) {
1055 info.
name = NULL_STR;
1060 throw Exception(
"NXgetnextattr failed", status);
1065 char name[NX_MAXNAMELEN];
1066 strcpy(name, info.
name.c_str());
1067 int type = info.
type;
1072 NXstatus status =
NXgetattr(this->m_file_id, name, data, &length,
1074 if (status != NX_OK) {
1075 throw Exception(
"NXgetattr(" + info.
name +
") failed", status);
1077 if (type != info.
type) {
1079 msg <<
"NXgetattr(" << info.
name <<
") changed type [" << info.
type 1080 <<
"->" << type <<
"]";
1084 if (static_cast<unsigned>(length) != info.
length && type != NX_CHAR) {
1086 msg <<
"NXgetattr(" << info.
name <<
") change length [" << info.
length 1087 <<
"->" << length <<
"]";
1093 template <
typename NumT>
1104 info.
type = getType<char>();
1110 template <
typename NumT>
1114 info.
type = getType<NumT>();
1117 value = this->getAttr<NumT>(info);
1125 msg <<
"getStrAttr only works with strings (type=" <<
CHAR 1126 <<
") found type=" << info.
type;
1129 char* value =
new char[info.
length + 1];
1143 res = string(value);
1150 vector<AttrInfo> infos;
1151 this->initAttrDir();
1155 if (temp.
name == NULL_STR) {
1158 infos.push_back(temp);
1165 this->initAttrDir();
1169 if (temp.
name == NULL_STR) {
1172 if (temp.
name == name)
1181 NXstatus status =
NXgetgroupID(this->m_file_id, &link);
1182 if (status != NX_OK) {
1183 throw Exception(
"NXgetgroupID failed", status);
1189 NXstatus status =
NXsameID(this->m_file_id, &first, &second);
1190 return (status == NX_OK);
1194 NXstatus status = NXIprintlink(this->m_file_id, &link);
1195 if (status != NX_OK) {
1200 void File::initGroupDir() {
1202 if (status != NX_OK) {
1203 throw Exception(
"NXinitgroupdir failed", status);
1207 void File::initAttrDir() {
1209 if (status != NX_OK) {
1210 throw Exception(
"NXinitattrdir failed", status);
1215 if (format.empty()) {
1216 throw Exception(
"Supplied empty format to setNumberFormat");
1218 char c_format[NX_MAXNAMELEN];
1219 strcpy(c_format, format.c_str());
1221 if (status != NX_OK) {
1223 msg <<
"NXsetnumberformat(" << format <<
") failed";
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;
1235 msg <<
"NXinquirefile(" << buff_length <<
") failed";
1238 filename = c_filename;
1239 delete[] c_filename;
1244 const unsigned buff_length) {
1247 throw Exception(
"Supplied empty name to isExternalGroup");
1250 throw Exception(
"Supplied empty type to isExternalGroup");
1252 char* c_url =
new char[buff_length];
1254 type.c_str(), c_url, buff_length);
1255 if (status != NX_OK) {
1258 msg <<
"NXisexternalgroup(" << type <<
", " << buff_length <<
")";
1259 throw Exception(msg.str(), buff_length);
1267 const string& url) {
1269 throw Exception(
"Supplied empty name to linkExternal");
1272 throw Exception(
"Supplied empty type to linkExternal");
1275 throw Exception(
"Supplied empty url to linkExternal");
1277 NXstatus status =
NXlinkexternal(this->m_file_id, name.c_str(), type.c_str(),
1279 if (status != NX_OK) {
1281 msg <<
"NXlinkexternal(" << name <<
", " << type <<
", " << url
1287 const string File::makeCurrentPath(
const string currpath,
const string subpath) {
1288 std::ostringstream temp;
1289 temp << currpath <<
"/" << subpath;
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));
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)));
1303 else if (pos->second ==
"CDF0.0") {
1308 this->
openGroup(pos->first, pos->second);
1309 this->walkFileForTypeMap(this->makeCurrentPath(path, pos->first), pos->second, tmap);
1319 this->walkFileForTypeMap(
"",
"", *tmap);
1323 template<
typename NumT>
1326 if (getType<NumT>() != info.
type)
1328 throw Exception(
"Type mismatch in malloc()");
1330 inner_malloc((
void*&)data, info.
dims, info.
type);
1333 template<
typename NumT>
1336 inner_free((
void*&)data);
1392 const int length,
bool open_data);
1395 const int64_t length,
bool open_data);
1582 const vector<int> & bufsize);
1586 const vector<int64_t> & bufsize);
1590 const vector<int> & bufsize);
1594 const vector<int64_t> & bufsize);
1598 const vector<int> & bufsize);
1602 const vector<int64_t> & bufsize);
1606 const vector<int> & bufsize);
1610 const vector<int64_t> & bufsize);
1614 const vector<int> & bufsize);
1618 const vector<int64_t> & bufsize);
1622 const vector<int> & bufsize);
1626 const vector<int64_t> & bufsize);
1630 const vector<int> & bufsize);
1634 const vector<int64_t> & bufsize);
1638 const vector<int> & bufsize);
1642 const vector<int64_t> & bufsize);
1646 const vector<int> & bufsize);
1650 const vector<int64_t> & bufsize);
1654 const vector<int> & bufsize);
1658 const vector<int64_t> & bufsize);
1782 NXDLL_EXPORT void File::putSlab(std::vector<uint16_t>& data, std::vector<int64_t> & start, std::vector<int64_t> & size);
1786 NXDLL_EXPORT void File::putSlab(std::vector<uint32_t>& data, std::vector<int64_t> & start, std::vector<int64_t> & size);
1790 NXDLL_EXPORT void File::putSlab(std::vector<uint64_t>& data, std::vector<int64_t> & start, std::vector<int64_t> & size);
NXstatus NXputdata(NXhandle handle, const void *data)
NXstatus NXopengrouppath(NXhandle handle, CONSTCHAR *path)
void putData(const void *data)
NXstatus NXflush(NXhandle *pHandle)
void putSlab(void *data, std::vector< int > &start, std::vector< int > &size)
NXstatus NXinitattrdir(NXhandle handle)
std::map< std::string, std::string > getEntries()
Return the entries available in the current place in the file.
bool isDataInt()
Return true if the data opened is of one of the int data types, 32 bits or less.
NXstatus NXclosedata(NXhandle handle)
bool hasAttr(const std::string &name)
void openGroupPath(const std::string &path)
Open the group in which the NeXus object with the specified path exists.
NXcompression
The available compression types.
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.
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)
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 of the NeXus C++ API.
void close()
Close the file before the constructor is called.
void makeGroup(const std::string &name, const std::string &class_name, bool open_group=false)
Create a new group.
std::string getStrAttr(const AttrInfo &info)
Get the value of a string attribute.
std::string inquireFile(const int buff_length=NX_MAXPATHLEN)
Find out the name of the file this object is holding onto.
void getAttr(const AttrInfo &info, void *data, int length=-1)
Get the value of the attribute specified by the AttrInfo supplied.
NXstatus NXmakenamedlink(NXhandle handle, CONSTCHAR *newname, NXlink *pLink)
NXstatus NXfree(void **data)
std::vector< AttrInfo > getAttrInfos()
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.
void readData(const std::string &dataName, std::vector< NumT > &data)
Put data into the supplied vector.
void makeNamedLink(const std::string &name, NXlink &link)
Create a link with a new name.
Header for a base NeXus::Exception.
std::vector< int64_t > dims
The dimensions of the file.
NXnumtype
The primitive types published by this API.
void openSourceGroup()
Open the original copy of this group or data as declared by the "target" attribute.
void openData(const std::string &name)
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.
void makeData(const std::string &name, NXnumtype type, const std::vector< int > &dims, bool open_data=false)
NXnumtype getType(NumT number)
This function returns the NXnumtype given a concrete number.
void writeUpdatedData(const std::string &name, std::vector< NumT > &value)
Updates the data written into an already-created data vector.
NXstatus NXgetgroupID(NXhandle handle, NXlink *pLink)
std::vector< NumT > * getData()
Allocate memory and return the data as a vector.
File(const std::string &filename, const NXaccess access=NXACC_READ)
Create a new File.
unsigned length
The length of the attribute.
Information about an attribute.
void closeGroup()
Close the currently open group.
void closeData()
Close the currently open data.
NXstatus NXmakegroup(NXhandle handle, CONSTCHAR *name, CONSTCHAR *NXclass)
NXstatus NXopenpath(NXhandle handle, CONSTCHAR *path)
NXstatus NXgetattr(NXhandle handle, char *name, void *data, int *iDataLen, int *iType)
void printLink(NXlink &link)
Diagnostic print of the link information.
This structure holds the type and dimensions of a primative field/array.
void flush()
Flush the file.
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.
std::multimap< std::string, std::string > TypeMap
Type definition for a type-keyed multimap.
std::string name
The name of the attribute.
std::string getPath()
Get the path into the current file.
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.
NXstatus NXopengroup(NXhandle handle, CONSTCHAR *name, CONSTCHAR *NXclass)
NXstatus NXclosegroup(NXhandle handle)
void putAttr(const AttrInfo &info, const void *data)
Put the supplied data as an attribute into the currently open data.
void malloc(NumT *&data, const Info &info)
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...
NXstatus NXgetdataID(NXhandle handle, NXlink *pLink)
std::pair< std::string, std::string > getNextEntry()
void openPath(const std::string &path)
Open the NeXus object with the path specified.
NXnumtype type
The primative type for the field.
void getSlab(void *data, const std::vector< int > &start, const std::vector< int > &size)
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. ...
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.
void getDataCoerce(std::vector< int > &data)
Get data and coerce into an int vector.
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.
void openGroup(const std::string &name, const std::string &class_name)
Open an existing group.
NXstatus NXgetpath(NXhandle handle, char *path, int pathlen)
NXstatus NXinitgroupdir(NXhandle handle)
void setNumberFormat(NXnumtype &type, const std::string &format)
Set the number format used for a particular type when using the xml base.