Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /acts/Examples/Io/HepMC3/src/CompressedIO.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 // This file was adapted from https://gitlab.cern.ch/hepmc/HepMC3/-/blob/0a6bd242747a53692ee66cb7332354cae8d25c4c/include/HepMC3/CompressedIO.h to work around an issue with HepMC3 version 3.2.7
0010 
0011 /////////
0012 
0013 ///
0014 // -*- C++ -*-
0015 //
0016 // This file is part of HepMC
0017 // Copyright (C) 2014-2023 The HepMC collaboration (see AUTHORS for details)
0018 //
0019 /**
0020  *  @file CompressedIO.h
0021  *  @brief HepMC3 interface to bxzstr library and some routines
0022  *
0023  */
0024 #ifndef HEPMC3_COMPRESSEDIO_H
0025 #define HEPMC3_COMPRESSEDIO_H
0026 #if HEPMC3_USE_COMPRESSION
0027 #if HEPMC3_Z_SUPPORT
0028 #define BXZSTR_Z_SUPPORT 1
0029 #endif
0030 #if HEPMC3_LZMA_SUPPORT
0031 #define BXZSTR_LZMA_SUPPORT 1
0032 #endif
0033 #if HEPMC3_BZ2_SUPPORT
0034 #define BXZSTR_BZ2_SUPPORT 1
0035 #endif
0036 #if HEPMC3_ZSTD_SUPPORT
0037 #define BXZSTR_ZSTD_SUPPORT 1
0038 #endif
0039 #endif
0040 #include "HepMC3/bxzstr/bxzstr.hpp"
0041 
0042 #include <array>
0043 
0044 namespace HepMC3
0045 {
0046 using ofstream = bxz::ofstream; //!< ofstream
0047 using ostream = bxz::ostream; //!< ostream
0048 using ifstream = bxz::ifstream;  //!< ifstream
0049 using istream = bxz::istream;  //!< istream
0050 
0051 using Compression = bxz::Compression; //!< Compression types from bxzstr
0052 /** @brief Function to detect compression type */
0053 inline Compression detect_compression_type(char* in_buff_start, char* in_buff_end) {
0054     return bxz::detect_type(in_buff_start,in_buff_end);
0055 }
0056 /** @brief Number of supported compression types */
0057 constexpr int num_supported_compression_types = 0
0058 #if HEPMC3_Z_SUPPORT
0059         +1
0060 #endif
0061 #if HEPMC3_LZMA_SUPPORT
0062         +1
0063 #endif
0064 #if HEPMC3_BZ2_SUPPORT
0065         +1
0066 #endif
0067 #if HEPMC3_ZSTD_SUPPORT
0068         +1
0069 #endif
0070         ;
0071 /** @brief Array of supported compression types */
0072 constexpr std::array<Compression,num_supported_compression_types> supported_compression_types{
0073 #if HEPMC3_Z_SUPPORT
0074     Compression::z,
0075 #endif
0076 #if HEPMC3_LZMA_SUPPORT
0077     Compression::lzma,
0078 #endif
0079 #if HEPMC3_BZ2_SUPPORT
0080     Compression::bz2,
0081 #endif
0082 #if HEPMC3_ZSTD_SUPPORT
0083     Compression::zstd,
0084 #endif
0085 };
0086 /** @brief Array of known compression types */
0087 constexpr std::array<Compression, 4> known_compression_types{
0088     Compression::z,
0089     Compression::lzma,
0090     Compression::bz2,
0091     Compression::zstd,
0092 };
0093 
0094 /** @brief Convert from the compression type to string */
0095 inline std::string to_string(HepMC3::Compression & c) {
0096     switch (c) {
0097     case HepMC3::Compression::z:
0098         return std::string("z");
0099     case HepMC3::Compression::lzma:
0100         return std::string("lzma");
0101     case HepMC3::Compression::bz2:
0102         return std::string("bz2");
0103     case HepMC3::Compression::zstd:
0104         return std::string("zstd");
0105     default:
0106         break;
0107     }
0108     return std::string("plaintext");
0109 }
0110 
0111 }
0112 
0113 inline std::ostream& operator<<(std::ostream& os, HepMC3::Compression & c) {
0114     return os << HepMC3::to_string(c);
0115 }
0116 
0117 
0118 #endif