All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RootCompressionSettings.cpp
Go to the documentation of this file.
1 
2 // STD
3 #include <stdexcept>
4 
5 // local
7 
8 // ROOT
9 #include "Compression.h"
10 
11 // boost
12 #include "boost/lexical_cast.hpp"
13 
14 //-----------------------------------------------------------------------------
15 // Implementation file for class : RootCompressionSettings
16 //
17 // 2013-10-24 : Chris Jones
18 //-----------------------------------------------------------------------------
19 
20 //=============================================================================
21 // Standard constructor, initializes variables
22 //=============================================================================
24 RootCompressionSettings( const std::string & settings )
25  : m_compSettings ( settings ),
26  m_level ( ROOT::CompressionSettings(ROOT::kZLIB,1) )
27 {
28 
29  const std::string::size_type idx = m_compSettings.find(':');
30  if ( idx != std::string::npos )
31  {
32  // Get compression algorithm type
33  const std::string alg = m_compSettings.substr(0,idx);
34  ROOT::ECompressionAlgorithm alg_code = ROOT::kUseGlobalSetting;
35  if ( alg == "ZLIB" ) { alg_code = ROOT::kZLIB; }
36  else if ( alg == "LZMA" ) { alg_code = ROOT::kLZMA; }
37  else
38  {
39  throw std::runtime_error("ERROR: Unknown ROOT compression algorithm:"+alg);
40  }
41 
42  // get compression level
43  const std::string slev = m_compSettings.substr(idx+1);
44  const int ilev = boost::lexical_cast<int>(slev);
45 
46  // set the level
47  m_level = ROOT::CompressionSettings(alg_code,ilev);
48  }
49 
50 }
51 
52 //=============================================================================
53 
std::string m_compSettings
The compression settings string.
RootCompressionSettings(const std::string &settings)
Standard constructor.
int m_level
The cached ROOT compression level int.