Google OR-Tools
v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
gzipfile.h
Go to the documentation of this file.
1
// Copyright 2010-2024 Google LLC
2
// Licensed under the Apache License, Version 2.0 (the "License");
3
// you may not use this file except in compliance with the License.
4
// You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software
9
// distributed under the License is distributed on an "AS IS" BASIS,
10
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
// See the License for the specific language governing permissions and
12
// limitations under the License.
13
14
#ifndef OR_TOOLS_BASE_GZIPFILE_H_
15
#define OR_TOOLS_BASE_GZIPFILE_H_
16
17
#include "absl/strings/string_view.h"
18
#include "
ortools/base/basictypes.h
"
// for Ownership enum
19
#include "zlib.h"
// for Z_DEFAULT_COMPRESSION
20
21
class
File
;
22
23
// Argument type used in interfaces that can optionally accept appended
24
// compressed streams. If kConcatenateStreams is passed, the output will
25
// include all streams. Otherwise only the first stream is output.
26
enum class
AppendedStreams
{
27
kConcatenateStreams
,
28
kIgnoreAppendedData
,
29
};
30
31
// Return a readonly file that contains a uncompressed version of
32
// another File.
33
//
34
// If "ownership == TAKE_OWNERSHIP", the file takes ownership of
35
// "compressed_file". "compressed_file" will be deleted when the file is
36
// closed.
37
//
38
// If "ownership == "DO_NOT_TAKE_OWNERSHIP", the file does not take
39
// ownership of "compressed_file". The client must guarantee that
40
// "compressed_file" remains live while the file is being accessed and
41
// that operations on "compressed_file" do not interfere (e.g., move
42
// the read pointer) with the file.
43
//
44
// If "appended_streams" == "kConcatenateStreams" decompression will process
45
// and output each compressed stream present in the input.
46
//
47
// If "appended_streams" == "kIgnoreAppendedData" decompression will stop
48
// after the first stream.
49
//
50
// The compressed file may be either a gzip format file, a zlib compressed
51
// file, or a unix compress format file. The only difference between gzip
52
// and zlib is whether the file has a gzip header and trailer. If the file
53
// consists of multiple gzip files concatenated together, then we will
54
// decompress them into a single concatenated output. This may seem weird
55
// but that's what the gzip commandline tool does. If we didn't do this
56
// we would silently truncate some input files upon decompression.
57
// Otherwise we signal an error for any invalid data after the compressed
58
// stream.
59
File
*
GZipFileReader
(absl::string_view
name
,
File
* compressed_file,
60
Ownership
ownership,
AppendedStreams
appended_streams);
61
// appended_streams defaults to kConcatenateStreams if not specified.
62
inline
File
*
GZipFileReader
(absl::string_view
name
,
File
* compressed_file,
63
Ownership
ownership) {
64
return
GZipFileReader
(
name
, compressed_file, ownership,
65
AppendedStreams::kConcatenateStreams
);
66
}
67
68
#endif
// OR_TOOLS_BASE_GZIPFILE_H_
basictypes.h
Ownership
Ownership
Definition
basictypes.h:22
File
Definition
file.h:30
name
const std::string name
A name for logging purposes.
Definition
default_search.cc:824
AppendedStreams
AppendedStreams
Definition
gzipfile.h:26
AppendedStreams::kIgnoreAppendedData
@ kIgnoreAppendedData
AppendedStreams::kConcatenateStreams
@ kConcatenateStreams
GZipFileReader
File * GZipFileReader(absl::string_view name, File *compressed_file, Ownership ownership, AppendedStreams appended_streams)
public entry points
Definition
gzipfile.cc:25
ortools
base
gzipfile.h
Generated by
1.12.0