HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_CompressedBlockIndex.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_CompressedBlockIndex.h
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef UT_COMPRESSEDBLOCKINDEX_H_
12 #define UT_COMPRESSEDBLOCKINDEX_H_
13 
14 #include "UT_API.h"
15 #include "UT_Array.h"
16 #include "UT_IntrusivePtr.h"
17 
18 class UT_IStream;
19 
20 typedef int64 BlockLocationType;
21 
23  : public UT_IntrusiveRefCounter<UT_CompressedBlockIndex>
24 {
25 public:
27 
28  /// Sets the blocksize and the size of the last block.
29  /// Last block size used for end of stream calculations.
30  void setBlockSize(exint blockSize, exint lastBlockSize);
31 
32  /// Adds entry to the end of the index
33  void append(BlockLocationType entry);
34 
35  /// Removes the last entry
36  void removeLast();
37 
38  /// Get's the total uncompressed size of the stream with this block index
39  exint getTotalUncompressedSize() const;
40 
41  /// Retrieves the location of the start of the block containing
42  /// the given offset in uncompressed file
43  BlockLocationType getCompressedBlockOffset(exint uncompressedOffset) const;
44 
45  /// Retrieves the location of the start of the block containing
46  /// the given offset (given from the end of the file) in uncompressed file
47  BlockLocationType getCompressedBlockOffsetFromEnd(
48  exint uncompressedOffsetFromEnd) const;
49 
50  /// Get the block number given offset in compressed file
51  exint getBlockNumberCompressedOffset(
52  BlockLocationType compressedOffset) const;
53 
54  /// Get the length in the file of the entire index section (for seeking)
55  int64 getLength() const;
56 
57  /// Get the block size of the compressed blocks
58  exint getBlockSize() const;
59 
60  /// Get the size of the last compressed block
61  exint getLastBlockSize() const;
62 
63 
64  /// Write index to stream
65  void writeToStream(std::ostream* out) const;
66 
67  /// Read index from stream
68  void readFromStream(UT_IStream* in, int64 indexLength);
69 
70  /// Dump information
71  void dump(const char *msg="") const;
72 
73 private:
75 
76  exint myBlockSize;
77 
78  exint myLastBlockSize;
79 };
80 
82 
83 #endif // UT_COMPRESSEDBLOCKINDEX_H_
UT_IntrusivePtr< UT_CompressedBlockIndex > UT_CompressedBlockIndexPtr
int64 exint
Definition: SYS_Types.h:125
#define UT_API
Definition: UT_API.h:14
A reference counter base class for use with UT_IntrusivePtr.
long long int64
Definition: SYS_Types.h:116
int64 BlockLocationType
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_14 uint8_t blockSize(VULKAN_HPP_NAMESPACE::Format format)