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