Grok  7.6.0
mem_stream.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2020 Grok Image Compression Inc.
3  *
4  * This source code is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Affero General Public License, version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This source code is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Affero General Public License for more details.
12  *
13  * You should have received a copy of the GNU Affero General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  */
17 
18 #pragma once
19 namespace grk {
20 
21 #ifdef _WIN32
22  typedef void* grk_handle;
23 #else
24 typedef int32_t grk_handle;
25 #endif
26 
27 struct buf_info {
29  buf_info(nullptr, 0, 0, false) {
30  }
31  buf_info(uint8_t *buffer, size_t offset, size_t length, bool owns) :
32  buf(buffer), off(offset), len(length), fd(0), ownsBuffer(owns) {
33  }
35  if (ownsBuffer)
36  delete[] buf;
37  }
38  uint8_t *buf;
39  size_t off;
40  size_t len;
41  grk_handle fd; // for file mapping
42  bool ownsBuffer;
43 };
44 
45  grk_stream * create_mem_stream(uint8_t *buf, size_t len, bool ownsBuffer,
46  bool is_read_stream);
48 
50 
51 }
grk::buf_info::off
size_t off
Definition: mem_stream.h:39
grk::buf_info::buf_info
buf_info(uint8_t *buffer, size_t offset, size_t length, bool owns)
Definition: mem_stream.h:31
grk::buf_info::buf_info
buf_info()
Definition: mem_stream.h:28
grk::create_mem_stream
grk_stream * create_mem_stream(uint8_t *buf, size_t len, bool ownsBuffer, bool is_read_stream)
grk::get_mem_stream_offset
size_t get_mem_stream_offset(grk_stream *stream)
grk::buf_info::len
size_t len
Definition: mem_stream.h:40
grk::grk_handle
int32_t grk_handle
Definition: mem_stream.h:24
grk::buf_info
Definition: mem_stream.h:27
grk::buf_info::ownsBuffer
bool ownsBuffer
Definition: mem_stream.h:42
grk::create_mapped_file_read_stream
grk_stream * create_mapped_file_read_stream(const char *fname)
grk
Copyright (C) 2016-2020 Grok Image Compression Inc.
Definition: BitIO.h:27
grk::buf_info::fd
grk_handle fd
Definition: mem_stream.h:41
grk::buf_info::~buf_info
~buf_info()
Definition: mem_stream.h:34
grk::buf_info::buf
uint8_t * buf
Definition: mem_stream.h:38
grk_stream
void * grk_stream
Definition: grok.h:819