HepMC3 event record library
CompressedIO.h
1// -*- C++ -*-
2//
3// This file is part of HepMC
4// Copyright (C) 2014-2023 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#if HEPMC3_ZSTD_SUPPORT
19#define BXZSTR_ZSTD_SUPPORT 1
20#endif
21#include "HepMC3/bxzstr/bxzstr.hpp"
22namespace HepMC3
23{
24using ofstream = bxz::ofstream;
25using ostream = bxz::ostream;
26using ifstream = bxz::ifstream;
27using istream = bxz::istream;
28
29using Compression = bxz::Compression;
30inline Compression detect_compression_type(char* in_buff_start, char* in_buff_end) {
31 return bxz::detect_type(in_buff_start,in_buff_end);
32}
33const std::vector<Compression> supported_compression_types = {
34#if HEPMC3_Z_SUPPORT
35 Compression::z,
36#endif
37#if HEPMC3_LZMA_SUPPORT
38 Compression::lzma,
39#endif
40#if HEPMC3_BZ2_SUPPORT
41 Compression::bz2,
42#endif
43#if HEPMC3_ZSTD_SUPPORT
44 Compression::zstd,
45#endif
46};
47std::vector<Compression> known_compression_types = {
48 Compression::z,
49 Compression::lzma,
50 Compression::bz2,
51 Compression::zstd,
52};
53}
54namespace std
55{
56string to_string(HepMC3::Compression & c) {
57 switch (c) {
58 case HepMC3::Compression::z:
59 return string("z");
60 case HepMC3::Compression::lzma:
61 return string("lzma");
62 case HepMC3::Compression::bz2:
63 return string("bz2");
64 case HepMC3::Compression::zstd:
65 return string("zstd");
66 default:
67 break;
68 }
69 return string("plaintext");
70}
71}
72
73#endif
74#endif
HepMC3 main namespace.