-
Notifications
You must be signed in to change notification settings - Fork 41
/
compression.hpp
78 lines (67 loc) · 2.57 KB
/
compression.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* Copyright 2014-2017 EMBL - European Bioinformatics Institute
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef COMPRESSION_HPP
#define COMPRESSION_HPP
#include <iostream>
#include <set>
#include <string>
#include <vector>
#include <boost/filesystem.hpp>
#include <boost/log/trivial.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/filter/zlib.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include "vcf/string_constants.hpp"
namespace ebi
{
namespace vcf
{
/**
* Computes which compression a file has.
* @param source - this can be the file path, which may contain the file extension.
* @param line - vector of first 5 characters or first line (if length of first line < 5) of file.
*/
std::string get_compression(std::string const & source,
const std::vector<char> &line);
/**
* Checks if the given extension is readable or not
* @throws std::invalid_argument exception if not readable
*/
void check_readability_of_file(const std::string & file_ext);
/**
* Checks if the given stream is readable or not
* @throws std::invalid_argument exception if not readable
*/
void check_readability_of_stream(const std::vector<char> & line);
/**
* Creates uncompressed boost::iostream from given input istream
* @param input - compressed stream
* @param file_extension - format of compression
* @param uncompressed_input - boost::iostream that will be inflated with uncompressed data
*/
void create_uncompressed_stream(std::istream & input,
const std::string & file_extension,
boost::iostreams::filtering_istream & uncompressed_input);
/**
* Gets magic number from a file.
*
* The magic number is the first few characters of a file from which we can detect the compression type.
*/
void get_magic_num(std::istream & stream, std::vector<char> & container);
}
}
#endif // COMPRESSION_HPP