/src/gdal/frmts/mrf/Packer.h
Line | Count | Source |
1 | | /* |
2 | | Copyright 2016-2017 Esri |
3 | | Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | you may not use this file except in compliance with the License. |
5 | | You may obtain a copy of the License at |
6 | | http://www.apache.org/licenses/LICENSE-2.0 |
7 | | Unless required by applicable law or agreed to in writing, software |
8 | | distributed under the License is distributed on an "AS IS" BASIS, |
9 | | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
10 | | See the License for the specific language governing permissions and |
11 | | limitations under the License. |
12 | | |
13 | | Contributors: Lucian Plesea |
14 | | */ |
15 | | |
16 | | #if !defined(PACKER_H) |
17 | | #define PACKER_H |
18 | | #include <cstring> |
19 | | #include "marfa.h" |
20 | | |
21 | | NAMESPACE_MRF_START |
22 | | |
23 | | typedef struct storage_manager |
24 | | { |
25 | | char *buffer; |
26 | | size_t size; |
27 | | } storage_manager; |
28 | | |
29 | | // A base class that provides import and export functions based on storage |
30 | | // managers Default implementation is a straight copy |
31 | | class Packer /* non final */ |
32 | | { |
33 | | public: |
34 | | virtual ~Packer(); |
35 | | |
36 | | virtual int load(storage_manager *src, storage_manager *dst) |
37 | 0 | { |
38 | 0 | if (dst->size < src->size) |
39 | 0 | return false; |
40 | 0 | std::memcpy(dst->buffer, src->buffer, src->size); |
41 | 0 | dst->size -= src->size; // Adjust the destination size |
42 | 0 | return true; |
43 | 0 | } |
44 | | |
45 | | virtual int store(storage_manager *src, storage_manager *dst) |
46 | 0 | { |
47 | 0 | return load(src, dst); |
48 | 0 | } |
49 | | }; |
50 | | |
51 | | NAMESPACE_MRF_END |
52 | | #endif |