54
54
flx_iface.add_obj("stat_cdf_new", new FlxObjReadStat_CDF_new());
55
55
flx_iface.add_obj("stat_cdf_append", new FlxObjReadStat_CDF_append());
56
56
flx_iface.add_obj("stat_cdf_plot", new FlxObjReadStat_CDF_plot());
57
flx_iface.add_obj("stat_cdf_save", new FlxObjReadStat_CDF_save());
58
flx_iface.add_obj("stat_cdf_load", new FlxObjReadStat_CDF_load());
58
60
flxdata_ref = dataBox;
350
void flx_cdf::save(const std::string& fileS)
352
std::ofstream file(fileS.c_str(), std::ios::out | std::ios::binary);
353
if (file.is_open()==false) {
354
throw FlxException("flx_cdf::save", "File '" + fileS + "' could not be opened.");
356
file.write((char*)&(list[0]),sizeof(flx_cdf_entry)*list.size());
360
void flx_cdf::load(const std::string& fileS)
362
if (N>0) throw FlxException("flx_cdf::load_01", "A stored data-CDF can only be loaded to an empty data-CDF.");
363
std::ifstream file(fileS.c_str(), std::ios::in | std::ios::binary | std::ios::ate );
364
if (file.is_open()==false || file.good()==false) {
365
throw FlxException("flx_cdf::load_02", "File '" + fileS + "' could not be opened.");
367
std::streampos size = file.tellg();
368
size_t sizeN = size/sizeof(flx_cdf_entry);
369
if ( (size_t)size != sizeN*sizeof(flx_cdf_entry) ) {
370
throw FlxException("flx_cdf::load_03", "The file '" + fileS + "' seems to be either corrupt or does not contain a data-CDF.");
373
file.seekg (0, std::ios::beg);
374
file.read((char*)&(list[0]),size);
377
size_t Nlist = list.size();
378
for (size_t i=0;i<Nlist;++i) {
348
383
void FlxObjStat_CDF_new::task()
350
385
const size_t Nreserve = Nreservef->cast2tulong(false);
491
void FlxObjStat_CDF_save::task()
493
const std::string name = fname->eval_word(true);
494
const std::string fileS = fileF->eval(false);
495
flx_cdf& dcdf = CDFbox.get(name);
497
GlobalVar.slog(4) << "stat: stored data-CDF '" << name << "' in file '" << fileS << "'." << std::endl;
500
FlxObjBase* FlxObjReadStat_CDF_save::read()
502
FlxString* fname = new FlxString(false,false);
503
FlxString* fileF = NULL;
505
reader->getChar('(');
506
fileF = new FlxString(false,false);
507
reader->getChar(')');
508
read_optionalPara(false);
509
return new FlxObjStat_CDF_save(get_doLog(),fname,fileF);
510
} catch (FlxException& e) {
511
FLXMSG("FlxObjReadStat_CDF_save::read",1);
513
if (fileF) delete fileF;
518
void FlxObjStat_CDF_load::task()
520
const std::string name = fname->eval_word(true);
521
const std::string fileS = fileF->eval(false);
522
flx_cdf& dcdf = CDFbox.get(name);
524
GlobalVar.slog(4) << "stat: loaded data-CDF '" << name << "' from file '" << fileS << "'." << std::endl;
527
FlxObjBase* FlxObjReadStat_CDF_load::read()
529
FlxString* fname = new FlxString(false,false);
530
FlxString* fileF = NULL;
532
reader->getChar('(');
533
fileF = new FlxString(false,false);
534
reader->getChar(')');
535
read_optionalPara(false);
536
return new FlxObjStat_CDF_load(get_doLog(),fname,fileF);
537
} catch (FlxException& e) {
538
FLXMSG("FlxObjReadStat_CDF_load::read",1);
540
if (fileF) delete fileF;