Import Geant4 11.4.0 source tree
This commit is contained in:
+2
-145
@@ -18,23 +18,17 @@
|
||||
#include <istream>
|
||||
#include <sstream>
|
||||
|
||||
#include "vfind"
|
||||
#include "vmanip"
|
||||
#include "words"
|
||||
#include "tokenize"
|
||||
#include "snums"
|
||||
#include "sto"
|
||||
#include "s2time"
|
||||
#include "chars"
|
||||
#include "charmanip"
|
||||
#include "strip"
|
||||
#include "cids"
|
||||
#include "ntuple_binding"
|
||||
#include "sout"
|
||||
#include "num2s"
|
||||
//#include "srep"
|
||||
|
||||
#ifdef TOOLS_MEM
|
||||
#include "mem"
|
||||
#endif
|
||||
|
||||
#include <utility>
|
||||
|
||||
@@ -151,13 +145,6 @@ public:
|
||||
T* m_user_var;
|
||||
};
|
||||
|
||||
#ifdef TOOLS_MEM
|
||||
public:
|
||||
static const std::string& s_class() {
|
||||
static const std::string s_v("tools::rcsv::ntuple");
|
||||
return s_v;
|
||||
}
|
||||
#endif
|
||||
public:
|
||||
ntuple(std::istream& a_reader)
|
||||
:m_reader(a_reader)
|
||||
@@ -168,15 +155,9 @@ public:
|
||||
,m_rows(-1)
|
||||
,m_hippo(false)
|
||||
{
|
||||
#ifdef TOOLS_MEM
|
||||
mem::increment(s_class().c_str());
|
||||
#endif
|
||||
}
|
||||
virtual ~ntuple() {
|
||||
safe_clear<read::icol>(m_cols);
|
||||
#ifdef TOOLS_MEM
|
||||
mem::decrement(s_class().c_str());
|
||||
#endif
|
||||
}
|
||||
protected:
|
||||
ntuple(const ntuple& a_from)
|
||||
@@ -189,9 +170,6 @@ protected:
|
||||
,m_rows(-1)
|
||||
,m_hippo(a_from.m_hippo)
|
||||
{
|
||||
#ifdef TOOLS_MEM
|
||||
mem::increment(s_class().c_str());
|
||||
#endif
|
||||
}
|
||||
ntuple& operator=(const ntuple& a_from){
|
||||
m_title = a_from.m_title;
|
||||
@@ -208,34 +186,6 @@ public:
|
||||
|
||||
std::istream& istrm() {return m_reader;}
|
||||
|
||||
/* use file::is_hippo for that.
|
||||
static bool is_hippo(std::ostream& a_out,std::istream& a_reader) {
|
||||
// analyse two first data line.
|
||||
|
||||
a_reader.clear();
|
||||
a_reader.seekg(0,std::ios::end);
|
||||
std::streampos sz = a_reader.tellg();
|
||||
a_reader.seekg(0,std::ios::beg);
|
||||
if(!sz) {
|
||||
a_out << "tools::rcsv::ntuple::is_hippo :"
|
||||
<< " stream is empty."
|
||||
<< std::endl;
|
||||
return false;
|
||||
} //file empty.
|
||||
|
||||
std::string _title;
|
||||
if(!read_line(a_reader,sz,_title)) return false;
|
||||
std::string _s;
|
||||
if(!read_line(a_reader,sz,_s)) return false;
|
||||
if(_s.find('\t')==std::string::npos) return false;
|
||||
|
||||
//std::vector<std::string> labels;
|
||||
//words(s,"\t",false,labels);
|
||||
//return labels.size()?true:false;
|
||||
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
static bool find_sep(std::ostream& a_out,
|
||||
std::istream& a_reader,bool a_hippo,
|
||||
bool a_verbose,
|
||||
@@ -427,26 +377,6 @@ public:
|
||||
std::vector<std::string>::iterator it;
|
||||
for(it=ws.begin();it!=ws.end();++it,index++) {
|
||||
if(a_verbose) a_out << "word " << sout(*it) << "" << std::endl;
|
||||
/* with glast.tnt there is trailing \t that will induce an extra empty column.
|
||||
if((*it).empty()) {
|
||||
// do not accept :
|
||||
// <num><sep><num><sep><sep><num>...
|
||||
// but accept a trailing <sep> (glast.tnt) :
|
||||
// <num><sep><num>....<sep><num><sep>
|
||||
if(index==(ws.size()-1)) {
|
||||
break;
|
||||
} else {
|
||||
a_out << "tools::rcsv::ntuple::initialize :"
|
||||
<< " empty word."
|
||||
<< std::endl;
|
||||
safe_clear<read::icol>(m_cols);
|
||||
m_sep = 0;
|
||||
m_sz = 0;
|
||||
m_rows = -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
std::string name = a_suffix;
|
||||
if(!numas<uint64>(m_cols.size(),name)){}
|
||||
if(m_hippo) {
|
||||
@@ -594,7 +524,6 @@ public:
|
||||
<< std::endl;
|
||||
return false; //file empty.
|
||||
}
|
||||
//if(a_verbose) a_out << "file size " << m_sz << std::endl;
|
||||
|
||||
std::string _title;
|
||||
char _sep,_vec_sep;
|
||||
@@ -686,10 +615,6 @@ public:
|
||||
}
|
||||
}}
|
||||
|
||||
//a_out << "tools::rroot::ntuple::initialize :"
|
||||
// << " number of columns " << num << "."
|
||||
// << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -826,16 +751,9 @@ protected:
|
||||
<< " syntax error in " << sout(line)
|
||||
<< ", unknown keyword " << sout(_words[0])
|
||||
<< std::endl;
|
||||
//return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
a_out << "class " << _class << std::endl;
|
||||
a_out << "title " << _title << std::endl;
|
||||
a_out << "separator " << _separator << std::endl;
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -892,7 +810,6 @@ protected:
|
||||
static bool _read(std::istream& a_reader,std::streampos,char,T& a_v) {
|
||||
a_reader >> a_v;
|
||||
if(a_reader.tellg()==std::streampos(-1)) {a_v = 0;return false;}
|
||||
//std::cout << "debug : _read(double) " << a_v << std::endl;
|
||||
return true;
|
||||
}
|
||||
static bool _read_time(std::istream& a_reader,std::streampos a_sz,char a_sep,time_t& a_v) {
|
||||
@@ -931,9 +848,7 @@ protected:
|
||||
std::vector<std::string>& a_v) {
|
||||
std::string _s;
|
||||
if(!_read(a_reader,a_sz,a_sep,_s)) return false;
|
||||
//replace(_s,"\\"+a_vec_sep,"@@");
|
||||
words(_s,a_vec_sep,true,a_v);
|
||||
//tools_vforit(std::string,a_v,it) replace(*it,"@@",a_vec_sep);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1046,7 +961,6 @@ protected:
|
||||
#undef TOOLS_RCSV_NTUPLE_IF_VEC_COL
|
||||
|
||||
else {
|
||||
//std::cout << "column cast failed." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1077,61 +991,4 @@ protected:
|
||||
|
||||
}}
|
||||
|
||||
|
||||
#include <fstream>
|
||||
|
||||
namespace tools {
|
||||
namespace rcsv {
|
||||
|
||||
class fntuple : public ntuple {
|
||||
typedef ntuple parent;
|
||||
public:
|
||||
static const std::string& s_class() {
|
||||
static const std::string s_v("tools::rcsv::fntuple");
|
||||
return s_v;
|
||||
}
|
||||
public:
|
||||
fntuple(const std::string& a_file)
|
||||
:parent(m_freader)
|
||||
,m_file(a_file)
|
||||
{}
|
||||
virtual ~fntuple() {m_freader.close();}
|
||||
protected:
|
||||
fntuple(const fntuple& a_from)
|
||||
:read::intuple(a_from)
|
||||
,parent(a_from)
|
||||
,m_file(a_from.m_file)
|
||||
{}
|
||||
fntuple& operator=(const fntuple& a_from){
|
||||
parent::operator=(a_from);
|
||||
m_file = a_from.m_file;
|
||||
return *this;
|
||||
}
|
||||
public:
|
||||
bool open(){
|
||||
m_freader.open(m_file.c_str());
|
||||
return m_freader.fail()?false:true;
|
||||
}
|
||||
bool initialize(std::ostream& a_out,
|
||||
char a_sep = 0, //guessed
|
||||
const std::string& a_suffix = "x", //col suffix
|
||||
bool a_verbose = false) {
|
||||
if(!m_freader.is_open()) {
|
||||
m_freader.open(m_file.c_str());
|
||||
if(m_freader.fail()) {
|
||||
a_out << "tools::rcsv::fntuple::initialize :"
|
||||
<< " can't open " << m_file << "."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return parent::initialize(a_out,a_sep,a_suffix,a_verbose);
|
||||
}
|
||||
protected:
|
||||
std::string m_file;
|
||||
std::ifstream m_freader;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user