Bayeux  3.4.1
Core Foundation library for SuperNEMO
io_factory.h
Go to the documentation of this file.
1 /*
3  * Description :
4  *
5  * Some generic reader and writer based on Boost archives.
6  *
7  * Copyright (C) 2011-2019 Francois Mauger <mauger@lpccaen.in2p3.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or (at
12  * your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  * Boston, MA 02110-1301, USA.
23  *
24  */
25 
26 #ifndef DATATOOLS_IO_FACTORY_H
27 #define DATATOOLS_IO_FACTORY_H
28 
29 // Standard Library:
30 #include <stdexcept>
31 #include <iostream>
32 #include <string>
33 #include <sstream>
34 #include <fstream>
35 #include <locale>
36 // #include <typeinfo>
37 
38 // Third Party:
39 // - Boost:
40 // 2012-01-09 FM : now use the Boost >=1.47 header :
41 //#include <boost/math/nonfinite_num_facets.hpp>
42 //#include <boost/math/special_functions/nonfinite_num_facets.hpp>
43 
44 #ifdef __clang__
45 #pragma clang diagnostic push
46 #pragma clang diagnostic ignored "-Wshadow"
47 #endif
48 #ifdef __GNUC__
49 #pragma GCC diagnostic push
50 #pragma GCC diagnostic ignored "-Wshadow"
51 #endif
52 #include <boost/iostreams/filtering_stream.hpp>
53 #ifdef __GNUC__
54 #pragma GCC diagnostic pop
55 #endif
56 #ifdef __clang__
57 #pragma clang diagnostic pop
58 #endif
59 
60 // Wrap Boost's iostreams/filter/gzip header
61 // This header, causes "unused parameter" warnings from its
62 // static void write_long(long n, Sink& next, boost::mpl::false_)
63 // function.
64 // This should be an innocuous warning, so remove diagnostic for this
65 // header only.
66 // We only use clang pragmas for now because GCC's are highly version
67 // dependent - so need a bit more thought.
68 // To be removed when Boost fix their headers...
69 // #ifdef __clang__
70 // #pragma clang diagnostic push
71 // #pragma clang diagnostic ignored "-Wunused-parameter"
72 // #pragma clang diagnostic ignored "-Wshadow"
73 // #endif
74 // #ifdef __GNUC__
75 // #pragma GCC diagnostic push
76 // // #pragma GCC diagnostic ignored "-Wunused-parameter" // Bug in GCC
77 // #pragma GCC diagnostic ignored "-Wshadow"
78 // #endif
79 // #include <boost/iostreams/filter/gzip.hpp>
80 // #ifdef __GNUC__
81 // #pragma GCC diagnostic pop
82 // #endif
83 // #ifdef __clang__
84 // #pragma clang diagnostic pop
85 // #endif
86 
87 // #include <boost/iostreams/filter/bzip2.hpp>
88 #include <boost/serialization/string.hpp>
89 
90 // Wrap Boost's tokenizer header
91 // This header, causes "unused parameter" warnings from its
92 // static void assign(Iterator b, Iterator e, Token &t)
93 // function.
94 // This should be an innocuous warning, so remove diagnostic for this
95 // header only.
96 // We only use clang pragmas for now because GCC's are highly version
97 // dependent - so need a bit more thought.
98 // To be removed when Boost fix their headers...
99 // #ifdef __clang__
100 // #pragma clang diagnostic push
101 // #pragma clang diagnostic ignored "-Wunused-parameter"
102 // #endif
103 // #include <boost/tokenizer.hpp>
104 // #ifdef __clang__
105 // #pragma clang diagnostic pop
106 // #endif
107 
108 // Datatools
109 #include <datatools/archives_list.h>
111 #include <datatools/i_tree_dump.h>
112 #include <datatools/logger.h>
113 #include <datatools/exception.h>
114 #include <datatools/logger.h>
115 
116 namespace datatools {
117 
121  {
122  public:
123  static const int SUCCESS = 0;
124  static const int ERROR = 1;
125 
126  static const unsigned int MASK_RW = 0x1;
127  static const unsigned int MASK_FORMAT = 0xE;
128  static const unsigned int MASK_COMPRESSION = 0x30;
129  static const unsigned int MASK_MULTIARCHIVE = 0x80;
130  static const unsigned int MASK_APPEND = 0x100;
131 
133  MODE_READ = 0x0,
134  MODE_WRITE = 0x1,
137 
138  MODE_TEXT = 0x0,
139  MODE_BINARY = 0x2,
140  MODE_XML = 0x4,
144 
146  MODE_GZIP = 0x10,
147  MODE_BZIP2 = 0x20,
151 
156 
158  MODE_APPEND = 0x100,
161 
163  MODE_READ |
164  MODE_TEXT |
168  };
169 
170  struct format {
171  static const std::string & text_extension();
172  static const std::string & xml_extension();
173  static const std::string & binary_extension();
174  static const std::string & gzip_extension();
175  static const std::string & bzip2_extension();
176  };
177 
178  static int guess_mode_from_filename(const std::string & filename_,
179  int & mode_);
180 
182 
184 
187 
189  io_factory(const std::string & stream_name_,
190  int mode_ = io_factory::MODE_DEFAULT);
191 
193  virtual ~io_factory();
194 
195  bool eof() const;
196 
197  bool is_read() const;
198 
199  bool is_write() const;
200 
201  bool is_compressed() const;
202 
203  bool is_uncompressed() const;
204 
205  bool is_gzip() const;
206 
207  bool is_bzip2() const;
208 
209  bool is_text() const;
210 
211  bool is_binary() const;
212 
213  bool is_portable_binary() const;
214 
215  bool is_xml() const;
216 
217  bool is_append() const;
218 
219  bool is_no_append() const;
220 
221  bool is_single_archive() const;
222 
223  bool is_multi_archives() const;
224 
225  void start_archive();
226 
227  void stop_archive();
228 
229  private:
230 
231  void init_read_archive();
232 
233  void init_read(const std::string & stream_name_);
234 
235  void reset_read_archive();
236 
237  void reset_read();
238 
239  void init_write_archive();
240 
241  void init_write(const std::string & stream_name_);
242 
243  void reset_write_archive();
244 
245  void reset_write();
246 
247  void init(const std::string& stream_name_, int mode_);
248 
249  void ctor_defaults();
250 
251  void reset();
252 
253  public:
254 
255  template <typename Data>
256  void store(const Data & data_)
257  {
258  DT_THROW_IF (!this->is_write(),
259  std::logic_error,
260  "Not a writer factory!");
261  if (_otar_ptr_ != nullptr) {
262  this->store_text<Data>(*_otar_ptr_, data_);
263  } else if (_oxar_ptr_ != nullptr) {
264  this->store_xml<Data>(*_oxar_ptr_, data_);
265  } else if (_obar_ptr_ != nullptr) {
266  this->store_binary<Data>(*_obar_ptr_, data_);
267  }
268  }
269 
270  template <typename Data>
271  void load(Data & data_)
272  {
273  DT_THROW_IF (!this->is_read(),
274  std::logic_error,
275  "Not a reader factory!");
276  DT_THROW_IF (_in_fs_ == nullptr,
277  std::runtime_error,
278  "No input stream!");
279 
280  if (*_in_fs_) {
281  // 2008-10-03 FM: add EOF check code
282  // 2009-03-08 FM: Is it possible to have better EOF check code
283  // here for unzipped text and XML archives?
284  char c = 0;
285  _in_fs_->get(c);
286  if (_in_fs_) {
287  _in_fs_->putback(c);
288  }
289  }
290 
291  if (! *_in_fs_) {
292  DT_THROW_IF (_in_fs_->eof(),
293  std::runtime_error,
294  "Input stream at EOF!");
295  DT_THROW_IF (_in_fs_->fail(),
296  std::runtime_error,
297  "Input stream in fail status!");
298  DT_THROW_IF (_in_fs_->bad(),
299  std::runtime_error,
300  "Input stream in bad status!");
301  }
302 
303  try {
304  if (_itar_ptr_ != nullptr) {
305  this->load_text<Data>(*_itar_ptr_, data_);
306  *_in_fs_ >> std::ws;
307  } else if (_ixar_ptr_ != nullptr) {
308  this->load_xml<Data>(*_ixar_ptr_, data_);
309  *_in_fs_ >> std::ws;
310  } else if (_ibar_ptr_ != nullptr) {
311  this->load_binary<Data>(*_ibar_ptr_, data_);
312  }
313  } catch (boost::archive::archive_exception & x) {
314  throw;
315  } catch (std::exception & x) {
316  throw;
317  } catch (...) {
319  "Cannot load data from archive: "
320  << "unexpected exception" << "!");
321  DT_THROW(std::runtime_error, "Internal exception!");
322  }
323 
324  if (! *_in_fs_) {
325  if (_in_fs_->fail()) {
327  "Input stream is now in fail status!");
328  }
329  if (_in_fs_->eof()) {
331  "Input stream is now in EOF status!");
332  }
333  if (_in_fs_->bad()) {
335  "Input stream is now in bad status!");
336  }
337  }
338  }
339 
340  template <typename Data>
341  friend io_factory & operator<<(io_factory & iof_, const Data & data_)
342  {
343  iof_.store(data_);
344  return iof_;
345  }
346 
347  template <typename Data>
348  friend io_factory & operator>>(io_factory & iof_, Data & data_)
349  {
350  iof_.load(data_);
351  return iof_;
352  }
353 
354  virtual void tree_dump(std::ostream & out_ = std::clog,
355  const std::string & title_ = "",
356  const std::string & indent_ = "",
357  bool inherit_ = false) const;
358 
359  void dump(std::ostream & out_) const;
360 
361  private:
362 
363  template <typename Data>
364  void store_text(boost::archive::text_oarchive & archive_,
365  const Data & data_)
366  {
367  const Data & b = data_;
368  archive_ << b;
369  return;
370  }
371 
372  template <typename Data>
373  void store_xml(boost::archive::xml_oarchive & archive_,
374  const Data & data_)
375  {
376  const Data & b = data_;
377  archive_ << boost::serialization::make_nvp("record", b);
378  return;
379  }
380 
381  template <typename Data>
382  void store_binary(datatools::portable_oarchive & archive_,
383  const Data & data_)
384  {
385  const Data & b = data_;
386  archive_ << b;
387  return;
388  }
389 
390  template <typename Data>
391  void load_text(boost::archive::text_iarchive & archive_,
392  Data & data_) {
393  Data & b = data_;
394  archive_ >> b;
395  return;
396  }
397 
398  template <typename Data>
399  void load_xml(boost::archive::xml_iarchive & archive_,
400  Data & data_)
401  {
402  Data & b = data_;
403  archive_ >> boost::serialization::make_nvp("record", b);
404  return;
405  }
406 
407  template <typename Data>
408  void load_binary(datatools::portable_iarchive & archive_,
409  Data & data_)
410  {
411  Data & b = data_;
412  archive_ >> b;
413  return;
414  }
415 
416  private:
417 
418 
420  unsigned int _mode_ = 0;
421 
422  std::istream * _in_ = nullptr;
423  std::ostream * _out_ = nullptr;
424 
425  std::ifstream * _fin_ = nullptr;
426  std::ofstream * _fout_ = nullptr;
427 
428  boost::iostreams::filtering_istream * _in_fs_ = nullptr;
429  boost::iostreams::filtering_ostream * _out_fs_ = nullptr;
430 
431  std::locale * _default_locale_ = nullptr;
432  std::locale * _locale_ = nullptr;
433 
434  bool _read_archive_is_initialized_ = false;
435  bool _write_archive_is_initialized_ = false;
436 
437  boost::archive::text_iarchive * _itar_ptr_ = nullptr;
438  boost::archive::text_oarchive * _otar_ptr_ = nullptr;
439 
440  boost::archive::xml_iarchive * _ixar_ptr_ = nullptr;
441  boost::archive::xml_oarchive * _oxar_ptr_ = nullptr;
442 
443  datatools::portable_iarchive * _ibar_ptr_ = nullptr;
444  datatools::portable_oarchive * _obar_ptr_ = nullptr;
445 
446  }; // end of class io_factory
447 
448  //----------------------------------------------------------------------
449  // Reader factory tag type
450  //
455  class io_reader
456  : public io_factory
457  {
458  public:
459  io_reader(int mode_ = io_factory::MODE_DEFAULT);
460 
461  io_reader(const std::string & stream_name_,
462  int mode_ = io_factory::MODE_DEFAULT);
463 
464  virtual ~io_reader();
465  };
466 
467 
468  //----------------------------------------------------------------------
469  // Writer factory tag type
470  //
475  class io_writer
476  : public io_factory
477  {
478  public:
479  io_writer(int mode_ = io_factory::MODE_DEFAULT);
480  io_writer(const std::string & stream_name_,
481  int mode_ = io_factory::MODE_DEFAULT);
482 
483  virtual ~io_writer();
484  };
485 
486  //----------------------------------------------------------------------
487  // user friendly constants used in ctors
488  // for data_reader/data_writer:
489  static const bool using_multi_archives = true;
490  static const bool using_multiple_archives = using_multi_archives;
491  static const bool using_single_archive = false;
492  static const bool append_mode = true;
493  static const bool no_append_mode = false;
494 
495  //----------------------------------------------------------------------
496  // data_reader class
497  //
524  {
525 
526  public:
527 
528  enum status_type {
532  };
533 
534  static const std::string & empty_record_tag();
535 
537  data_reader();
538 
540  data_reader(const std::string & filename_,
541  bool use_multiple_archives_ = using_single_archive);
542 
544  data_reader(const std::string & filename_, int mode_);
545 
547  virtual ~data_reader();
548 
549  bool is_error() const;
550 
551  bool is_eof() const;
552 
553  const std::string & get_record_tag() const;
554 
555  bool has_record_tag() const;
556 
557  bool record_tag_is(const std::string & tag_) const;
558 
559  void reset();
560 
561  bool is_initialized() const;
562 
563  bool is_multi_archives() const;
564 
565  bool is_single_archive() const;
566 
567  bool is_compressed() const;
568 
569  bool is_uncompressed() const;
570 
571  bool is_gzip() const;
572 
573  bool is_bzip2() const;
574 
575  bool is_text() const;
576 
577  bool is_binary() const;
578 
579  bool is_portable_binary() const;
580 
581  bool is_xml() const;
582 
583  void init(const std::string & filename_,
584  bool use_multiple_archives_ = using_single_archive);
585 
586  void init_multi(const std::string & filename_)
587  {
588  this->init(filename_, using_multiple_archives);
589  return;
590  }
591 
592  void init_single(const std::string & filename_)
593  {
594  this->init(filename_, using_single_archive);
595  }
596 
597  void init(const std::string & filename_, int mode_);
598 
599  void dump(std::ostream & out_ = std::clog) const;
600 
601  template <typename Data>
602  void load(const std::string & tag_, Data & data_)
603  {
604  DT_THROW_IF (!this->has_record_tag(),
605  std::logic_error,
606  "No more record tag!");
607  DT_THROW_IF(this->get_record_tag() != tag_,
608  std::logic_error,
609  "Unexpected tag ('" << this->get_record_tag()
610  << " != " << tag_ << "')!");
611  this->basic_load(data_);
612  if (_reader_->is_multi_archives()) _reader_->stop_archive();
613  this->read_next_tag();
614  return;
615  }
616 
617  template <typename Data>
618  void load_alt(const std::string & tag_, const std::string & alt_tag_, Data & data_)
619  {
620  DT_THROW_IF (!this->has_record_tag(),
621  std::logic_error,
622  "No more record tag!");
623  if (this->get_record_tag() != tag_) {
624  DT_THROW_IF (this->get_record_tag() != alt_tag_,
625  std::logic_error,
626  "Unexpected tag ('"
627  << this->get_record_tag()
628  << " != " << tag_ << "')!");
629  }
630  this->basic_load(data_);
631  if (_reader_->is_multi_archives()) _reader_->stop_archive();
632  this->read_next_tag();
633  return;
634  }
635 
636  template <typename Data>
637  void load_serializable(Data & data_,
638  typename boost::disable_if< has_bsts<Data> >::type * dummy_ = 0)
639  {
640  if(!dummy_) dummy_ = 0;
641  this->load(data_.get_serial_tag(), data_);
642  return;
643  }
644 
645  template <typename Data>
646  void load_serializable(Data & data_,
647  typename boost::enable_if< has_bsts<Data> >::type * dummy_ = 0)
648  {
649  if(!dummy_) dummy_ = 0;
650  this->load_alt(data_.get_serial_tag(),
651  ::datatools::backward_serial_tag<Data> (0),
652  data_);
653  return;
654  }
655 
656  template <typename Data>
657  void load(Data & data_)
658  {
659  load_serializable(data_);
660  return;
661  }
662 
663  protected:
664  template <typename Data>
665  void basic_load(Data & data_)
666  {
667  DT_THROW_IF (_reader_ == nullptr,
668  std::logic_error,
669  "Not initialized!");
670  try {
671  _reader_->load(data_);
672  } catch (std::exception & x) {
673  _status_ = STATUS_ERROR;
674  bool warn = false;
675  //>>> 2008-11-13 FM: skip EOF message printing
676  std::string msg = x.what();
677  if (msg.find("EOF") != msg.npos) {
678  _status_ = STATUS_EOF;
679  warn = false;
680  }
681  if (warn) {
683  "Cannot read data: exception="
684  << x.what() << " !");
685  }
686  //<<<
687  _next_tag_ = empty_record_tag();
688  DT_THROW_IF(true, std::logic_error, x.what());
689  } catch (...) {
691  "Cannot read data: "
692  << "Unexpected exception" << " !");
693  _status_ = STATUS_ERROR;
694  _next_tag_ = empty_record_tag();
695  DT_THROW_IF(true, std::logic_error, "Unexpected error!");
696  }
697  return;
698  }
699 
700 
701  private:
702 
703  void read_next_tag();
704 
705  void init_reader(const std::string & filename_, int mode_);
706 
707  void reset_reader();
708 
709  private:
710 
711  int _status_ = STATUS_OK;
712  io_reader * _reader_ = nullptr;
713  std::string _next_tag_;
714 
715  };
716 
717  //----------------------------------------------------------------------
718  // data_writer class
719  //
741  {
742  public:
744  data_writer();
745 
747  data_writer(const std::string & filename_, int mode_);
748 
750  data_writer(const std::string & filename_,
751  bool use_multiple_archives_ = using_single_archive,
752  bool append_mode_ = no_append_mode);
753 
755  virtual ~data_writer();
756 
757  bool is_initialized() const;
758 
759  bool is_multi_archives() const;
760 
761  bool is_single_archive() const;
762 
763  bool is_compressed() const;
764 
765  bool is_uncompressed() const;
766 
767  bool is_gzip() const;
768 
769  bool is_bzip2() const;
770 
771  bool is_text() const;
772 
773  bool is_binary() const;
774 
775  bool is_portable_binary() const;
776 
777  bool is_xml() const;
778 
779  void reset();
780 
781  void init(const std::string & filename_,
782  bool a_multiple_archives_ = using_single_archive,
783  bool a_append_mode_ = no_append_mode);
784 
785  void init_multi(const std::string & filename_);
786 
787  void init_single(const std::string & filename_);
788 
789  void init(const std::string & filename_, int mode_);
790 
791  public:
792 
793  template <typename Data>
794  void store(const std::string & tag_, const Data & data_)
795  {
796  if (_writer_->is_multi_archives()) {
797  _writer_->start_archive();
798  }
799  this->basic_store<std::string>(tag_);
800  this->basic_store<Data>(data_);
801  if (_writer_->is_multi_archives()) {
802  _writer_->stop_archive();
803  }
804  return;
805  }
806 
807  template <typename Data>
808  void store(const Data & data_)
809  {
810  const datatools::i_serializable& i_ser =
811  static_cast<const datatools::i_serializable &>(data_);
812  this->store<Data>(i_ser.get_serial_tag(), data_);
813  return;
814  }
815 
816  protected:
817 
818  template <typename Data>
819  void basic_store(const Data & data_)
820  {
821  DT_THROW_IF(_writer_ == nullptr,
822  std::logic_error,
823  "Not initialized!");
824  _writer_->store<Data>(data_);
825  return;
826  }
827 
828  private:
829 
830  void init_writer(const std::string & filename_, int mode_);
831 
832  void reset_writer();
833 
834  private:
835 
836  io_writer * _writer_ = nullptr;
837 
838  };
839 
840 } // end of namespace datatools
841 
842 #endif // DATATOOLS_IO_FACTORY_H
843 
844 // Local Variables: --
845 // mode: c++ --
846 // c-file-style: "gnu" --
847 // tab-width: 2 --
848 // End: --
virtual ~data_writer()
Destructor.
bool is_multi_archives() const
bool is_gzip() const
bool is_portable_binary() const
Definition: io_factory.h:530
Definition: io_factory.h:531
#define DT_THROW(ExceptionType, Message)
Definition: exception.h:121
void load(Data &data_)
Definition: io_factory.h:657
Base abstract class of all serializable (and possibly introspectable) classes.
Definition: i_serializable.h:51
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
io_reader(int mode_=io_factory::MODE_DEFAULT)
io_factory(int mode_=io_factory::MODE_DEFAULT)
Constructor.
Definition: io_factory.h:133
bool is_binary() const
friend io_factory & operator<<(io_factory &iof_, const Data &data_)
Definition: io_factory.h:341
bool is_binary() const
Definition: io_factory.h:149
#define DT_LOG_WARNING(Priority, Message)
Definition: logger_macros.h:100
bool is_no_append() const
Definition: io_factory.h:170
Definition: io_factory.h:153
Definition: io_factory.h:159
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
A fatal error. The application will most likely terminate. This is the highest priority.
Definition: logger.h:85
Definition: io_factory.h:139
static const std::string & bzip2_extension()
static const unsigned int MASK_RW
Definition: io_factory.h:126
Definition: io_factory.h:142
An error. An operation did not complete successfully, but the application as a whole is not affected.
Definition: logger.h:87
bool is_binary() const
bool is_initialized() const
bool is_portable_binary() const
Definition: io_factory.h:150
void set_logging_priority(datatools::logger::priority)
virtual ~io_factory()
Destructor.
Definition: io_factory.h:148
bool is_read() const
bool is_uncompressed() const
static int guess_mode_from_filename(const std::string &filename_, int &mode_)
void init(const std::string &filename_, bool use_multiple_archives_=using_single_archive)
Utility macros for exception handling.
Definition: io_factory.h:154
Definition: io_factory.h:138
static const unsigned int MASK_FORMAT
Definition: io_factory.h:127
data_reader()
Constructor.
bool is_bzip2() const
static const std::string & text_extension()
Definition: io_factory.h:136
bool is_uncompressed() const
Definition: io_factory.h:146
static const std::string & empty_record_tag()
void init_multi(const std::string &filename_)
Definition: io_factory.h:586
bool is_append() const
datatools::logger::priority get_logging_priority() const
static const int SUCCESS
Definition: io_factory.h:123
void store(const Data &data_)
Definition: io_factory.h:808
Definition: io_factory.h:141
static const unsigned int MASK_MULTIARCHIVE
Definition: io_factory.h:129
void basic_store(const Data &data_)
Definition: io_factory.h:819
io_writer(int mode_=io_factory::MODE_DEFAULT)
bool is_multi_archives() const
static const std::string & gzip_extension()
Definition: io_factory.h:145
Definition: io_factory.h:147
void init_single(const std::string &filename_)
void init(const std::string &filename_, bool a_multiple_archives_=using_single_archive, bool a_append_mode_=no_append_mode)
#define DT_LOG_ERROR(Priority, Message)
Definition: logger_macros.h:82
Definition: io_factory.h:143
void basic_load(Data &data_)
Definition: io_factory.h:665
virtual const std::string & get_serial_tag() const =0
Return the serialization string identifier of the class.
friend io_factory & operator>>(io_factory &iof_, Data &data_)
Definition: io_factory.h:348
data_writer()
Default constructor.
bool is_single_archive() const
A generic data writer based on Boost/Serialization.
Definition: io_factory.h:740
bool has_record_tag() const
void load_alt(const std::string &tag_, const std::string &alt_tag_, Data &data_)
Definition: io_factory.h:618
Definition: io_factory.h:134
static const unsigned int MASK_APPEND
Definition: io_factory.h:130
Definition: io_factory.h:158
#define DT_THROW_IF(Condition, ExceptionType, Message)
Definition: exception.h:76
bool is_portable_binary() const
bool is_single_archive() const
A generic base reader/writer class based on Boost/Serialization.
Definition: io_factory.h:119
void store(const std::string &tag_, const Data &data_)
Definition: io_factory.h:794
bool is_compressed() const
bool is_compressed() const
void init_multi(const std::string &filename_)
Definition: io_factory.h:162
bool record_tag_is(const std::string &tag_) const
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
bool is_uncompressed() const
status_type
Definition: io_factory.h:528
Utilities for logging information.
A generic reader class inherited from the io_factory class.
Definition: io_factory.h:455
const std::string & get_record_tag() const
bool is_single_archive() const
void load(Data &data_)
Definition: io_factory.h:271
virtual ~data_reader()
Destructor.
Definition: io_factory.h:155
bool is_multi_archives() const
bool is_write() const
static const int ERROR
Definition: io_factory.h:124
void init_single(const std::string &filename_)
Definition: io_factory.h:592
Definition: io_factory.h:135
void load_serializable(Data &data_, typename boost::enable_if< has_bsts< Data > >::type *dummy_=0)
Definition: io_factory.h:646
void store(const Data &data_)
Definition: io_factory.h:256
Definition: io_factory.h:529
Definition: io_factory.h:157
Definition: io_factory.h:152
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Main old interface method for printing.
void dump(std::ostream &out_) const
static const unsigned int MASK_COMPRESSION
Definition: io_factory.h:128
static const std::string & binary_extension()
Definition: io_factory.h:140
static const std::string & xml_extension()
A generic writer class inherited from the io_factory class.
Definition: io_factory.h:475
bool is_text() const
void dump(std::ostream &out_=std::clog) const
Definition: io_factory.h:160
mode_flag_type
Definition: io_factory.h:132
A generic data reader based on Boost/Serialization.
Definition: io_factory.h:523
void load_serializable(Data &data_, typename boost::disable_if< has_bsts< Data > >::type *dummy_=0)
Definition: io_factory.h:637
bool is_initialized() const
bool is_compressed() const
void load(const std::string &tag_, Data &data_)
Definition: io_factory.h:602