libopenraw  0.3.7
heap.hpp
1 /* -*- Mode: C++; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil; -*- */
2 /*
3  * libopenraw - ciff/heap.hpp
4  *
5  * Copyright (C) 2006-2020 Hubert Figuière
6  *
7  * This library is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation, either version 3 of
10  * the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library. If not, see
19  * <http://www.gnu.org/licenses/>.
20  */
21 
22 #pragma once
23 
24 #include <memory>
25 
26 #include "rawcontainer.hpp"
27 #include "ciff/recordentry.hpp"
28 
29 namespace OpenRaw {
30 namespace Internals {
31 
32 class CIFFContainer;
33 
34 namespace CIFF {
38 class Heap;
39 
41 typedef std::shared_ptr<Heap> HeapRef;
42 
44 class Heap
45 {
46 public:
47 
53  Heap(off_t start, off_t length, const CIFFContainer* container);
54 
55  Heap(const Heap &) = delete;
57  Heap(Heap&&) = default;
58  Heap & operator=(const Heap &) = delete;
59 
63  const CIFFContainer* container() const
64  {
65  return m_container;
66  }
68  off_t offset() const
69  {
70  return m_start;
71  }
72 private:
74  bool _loadRecords();
75 
76  off_t m_start;
77  off_t m_length;
78  const CIFFContainer* m_container;
79  RecordEntries m_records;
80 };
81 
85 {
86 public:
90  bool readFrom(CIFFContainer *);
91  char byteOrder[2];
92  uint32_t headerLength;
93  char type[4];
94  char subType[4];
95  uint32_t version;
96  /* uint32_t reserved1; */
97  /* uint32_t reserved2; */
99 };
100 
102 }
103 }
104 }
Header of heap CIFF file.
Definition: heap.hpp:85
bool readFrom(CIFFContainer *)
Read the header from the container.
Definition: heap.cpp:78
RawContainer::EndianType endian
Definition: heap.hpp:98
Heap(off_t start, off_t length, const CIFFContainer *container)
Construct a heap from a location in the container.
Definition: heap.cpp:29
RecordEntries & records()
Return the records from the heap. Load them as needed.
Definition: heap.cpp:38
Heap(Heap &&)=default
Move constructor.
const CIFFContainer * container() const
Return the containing container.
Definition: heap.hpp:63
off_t offset() const
Return the offset from the begining of the container.
Definition: heap.hpp:68
EndianType
Define the endian of the container.
std::shared_ptr< Heap > HeapRef
Shared ptr to Heap.
Definition: heap.hpp:38
std::map< uint16_t, RecordEntry > RecordEntries
Definition: recordentry.hpp:65
Global namespace for libopenraw.
Definition: arwfile.cpp:29