Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JDB::JDatalogs_t Struct Reference

Container for datalog strings. More...

#include <JDatalogString.hh>

Inheritance diagram for JDB::JDatalogs_t:
std::vector< JDatalogString >

Public Member Functions

 JDatalogs_t (const std::initializer_list< std::string > &buffer={})
 Constructor.
 
 JDatalogs_t (const std::set< std::string > &buffer)
 Constructor.
 
void load (const std::string &file_name)
 Load message from input file.
 

Protected Attributes

std::set< std::string > sources
 

Friends

std::istream & operator>> (std::istream &in, JDatalogs_t &object)
 Read message from input.
 

Detailed Description

Container for datalog strings.

Definition at line 173 of file JDatalogString.hh.

Constructor & Destructor Documentation

◆ JDatalogs_t() [1/2]

JDB::JDatalogs_t::JDatalogs_t ( const std::initializer_list< std::string > & buffer = {})
inline

Constructor.

Parameters
bufferlist of valid source names

Definition at line 181 of file JDatalogString.hh.

181 {}) :
182 sources(buffer)
183 {}
std::set< std::string > sources

◆ JDatalogs_t() [2/2]

JDB::JDatalogs_t::JDatalogs_t ( const std::set< std::string > & buffer)
inline

Constructor.

Parameters
bufferlist of valid source names

Definition at line 191 of file JDatalogString.hh.

191 :
192 sources(buffer)
193 {}

Member Function Documentation

◆ load()

void JDB::JDatalogs_t::load ( const std::string & file_name)
inline

Load message from input file.

Parameters
file_namefile name

Definition at line 201 of file JDatalogString.hh.

202 {
203 using namespace std;
204 using namespace JPP;
205
206 if (getFilenameExtension(file_name) == "log" ||
207 getFilenameExtension(file_name) == "txt") {
208
209 ifstream in(file_name.c_str());
210
211 in.ignore(numeric_limits<std::streamsize>::max(), '\n');
212
213 in >> *this;
214
215 in.close();
216
217 } else if (getFilenameExtension(file_name) == "gz") {
218
219 igzstream in(file_name.c_str());
220
221 in.ignore(numeric_limits<std::streamsize>::max(), '\n');
222
223 in >> *this;
224
225 in.close();
226
227 } else {
228
229 THROW(JFileOpenException, "Invalid file name extension " << file_name);
230 }
231 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Exception for opening of file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).

Friends And Related Symbol Documentation

◆ operator>>

std::istream & operator>> ( std::istream & in,
JDatalogs_t & object )
friend

Read message from input.

Parameters
ininput stream
objectmessages
Returns
input stream

Definition at line 241 of file JDatalogString.hh.

242 {
243 using namespace std;
244
245 JDatalogString datalog;
246
247 bool append = false;
248
249 for (string buffer; getline(in, buffer); ) {
250
251 istringstream is(buffer);
252
253 if (is >> datalog.run >> datalog.utc >> datalog.source >> datalog.parameter) {
254
255 append = false;
256
257 if (SOURCE_NAMES(datalog.source) && !IGNORED_PARAMETER_NAMES(datalog.parameter)) {
258
259 while (is.peek() != EOF && isspace((char) is.peek())) { is.ignore(1); }
260
261 getline(is, datalog.data);
262
263 // new datalog
264
265 if (object.sources.empty() || object.sources.count(datalog.source) != 0) {
266
267 object.push_back(datalog);
268
269 append = true;
270 }
271 }
272
273 } else if (append) {
274
275 // append traling data to latest datalog
276
277 if (!object.empty()) {
278 object.rbegin()->data.append(" " + buffer);
279 }
280 }
281 }
282 return in;
283 }
const JKeywords IGNORED_PARAMETER_NAMES
Ignored parameter names.
const JKeywords SOURCE_NAMES
Valid source names.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition JString.hh:478

Member Data Documentation

◆ sources

std::set<std::string> JDB::JDatalogs_t::sources
protected

Definition at line 286 of file JDatalogString.hh.


The documentation for this struct was generated from the following file: