HepMC3 event record library
CompressedIO.h
1 // -*- C++ -*-
2 //
3 // This file is part of HepMC
4 // Copyright (C) 2014-2020 The HepMC collaboration (see AUTHORS for details)
5 //
6 #ifndef HEPMC3_COMPRESSEDIO_H
7 #define HEPMC3_COMPRESSEDIO_H
8 #if HEPMC3_USE_COMPRESSION
9 #if HEPMC3_Z_SUPPORT
10 #define BXZSTR_Z_SUPPORT 1
11 #endif
12 #if HEPMC3_LZMA_SUPPORT
13 #define BXZSTR_LZMA_SUPPORT 1
14 #endif
15 #if HEPMC3_BZ2_SUPPORT
16 #define BXZSTR_BZ2_SUPPORT 1
17 #endif
18 #include "HepMC3/bxzstr/bxzstr.hpp"
19 namespace HepMC3
20 {
21 using ofstream = bxz::ofstream;
22 using ostream = bxz::ostream;
23 using ifstream = bxz::ifstream;
24 using istream = bxz::istream;
25 
26 using Compression = bxz::Compression;
27 inline Compression detect_compression_type(char* in_buff_start, char* in_buff_end) {
28  return bxz::detect_type(in_buff_start,in_buff_end);
29 }
30 const std::vector<Compression> supported_compression_types = {
31 #if HEPMC3_Z_SUPPORT
32  Compression::z,
33 #endif
34 #if HEPMC3_LZMA_SUPPORT
35  Compression::lzma,
36 #endif
37 #if HEPMC3_BZ2_SUPPORT
38  Compression::bz2,
39 #endif
40 };
41 std::vector<Compression> known_compression_types = {
42  Compression::z,
43  Compression::lzma,
44  Compression::bz2
45 };
46 }
47 namespace std
48 {
49 string to_string(HepMC3::Compression & c) {
50  switch (c) {
51  case HepMC3::Compression::z:
52  return string("z");
53  case HepMC3::Compression::lzma:
54  return string("lzma");
55  case HepMC3::Compression::bz2:
56  return string("bz2");
57  default:
58  break;
59  }
60  return string("plaintext");
61 }
62 }
63 
64 #endif
65 #endif
HepMC3 main namespace.