Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:11

0001 // -*- C++ -*-
0002 //
0003 // This file is part of HepMC
0004 // Copyright (C) 2014-2023 The HepMC collaboration (see AUTHORS for details)
0005 //
0006 /**
0007  *  @file CompressedIO.h
0008  *  @brief HepMC3 interface to bxzstr library and some routines
0009  *
0010  */
0011 #ifndef HEPMC3_COMPRESSEDIO_H
0012 #define HEPMC3_COMPRESSEDIO_H
0013 #if HEPMC3_USE_COMPRESSION
0014 #if HEPMC3_Z_SUPPORT
0015 #define BXZSTR_Z_SUPPORT 1
0016 #endif
0017 #if HEPMC3_LZMA_SUPPORT
0018 #define BXZSTR_LZMA_SUPPORT 1
0019 #endif
0020 #if HEPMC3_BZ2_SUPPORT
0021 #define BXZSTR_BZ2_SUPPORT 1
0022 #endif
0023 #if HEPMC3_ZSTD_SUPPORT
0024 #define BXZSTR_ZSTD_SUPPORT 1
0025 #endif
0026 #endif
0027 #include "HepMC3/bxzstr/bxzstr.hpp"
0028 
0029 #include <array>
0030 
0031 namespace HepMC3
0032 {
0033 using ofstream = bxz::ofstream; //!< ofstream
0034 using ostream = bxz::ostream; //!< ostream
0035 using ifstream = bxz::ifstream;  //!< ifstream
0036 using istream = bxz::istream;  //!< istream
0037 
0038 using Compression = bxz::Compression; //!< Compression types from bxzstr
0039 /** @brief Function to detect compression type */
0040 inline Compression detect_compression_type(const char* in_buff_start, const char* in_buff_end) {
0041     return bxz::detect_type(in_buff_start,in_buff_end);
0042 }
0043 /** @brief Number of supported compression types */
0044 constexpr int num_supported_compression_types = 0
0045 #if HEPMC3_Z_SUPPORT
0046         +1
0047 #endif
0048 #if HEPMC3_LZMA_SUPPORT
0049         +1
0050 #endif
0051 #if HEPMC3_BZ2_SUPPORT
0052         +1
0053 #endif
0054 #if HEPMC3_ZSTD_SUPPORT
0055         +1
0056 #endif
0057         ;
0058 /** @brief Array of supported compression types */
0059 constexpr std::array<Compression,num_supported_compression_types> supported_compression_types{
0060 #if HEPMC3_Z_SUPPORT
0061     Compression::z,
0062 #endif
0063 #if HEPMC3_LZMA_SUPPORT
0064     Compression::lzma,
0065 #endif
0066 #if HEPMC3_BZ2_SUPPORT
0067     Compression::bz2,
0068 #endif
0069 #if HEPMC3_ZSTD_SUPPORT
0070     Compression::zstd,
0071 #endif
0072 };
0073 /** @brief Array of known compression types */
0074 constexpr std::array<Compression, 4> known_compression_types{
0075     Compression::z,
0076     Compression::lzma,
0077     Compression::bz2,
0078     Compression::zstd,
0079 };
0080 
0081 /** @brief Convert from the compression type to string */
0082 inline std::string to_string(HepMC3::Compression & c) {
0083     switch (c) {
0084     case HepMC3::Compression::z:
0085         return std::string("z");
0086     case HepMC3::Compression::lzma:
0087         return std::string("lzma");
0088     case HepMC3::Compression::bz2:
0089         return std::string("bz2");
0090     case HepMC3::Compression::zstd:
0091         return std::string("zstd");
0092     default:
0093         break;
0094     }
0095     return std::string("plaintext");
0096 }
0097 
0098 }
0099 
0100 inline std::ostream& operator<<(std::ostream& os, HepMC3::Compression & c) {
0101     return os << HepMC3::to_string(c);
0102 }
0103 
0104 
0105 #endif