| 1 | |
| 2 | // |
| 3 | // Copyright (c) Microsoft. All rights reserved. |
| 4 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| 5 | // |
| 6 | |
| 7 | //---------------------------------------------------------- |
| 8 | // TOCFile.h - Abstraction for reading a TOC file |
| 9 | //---------------------------------------------------------- |
| 10 | #ifndef _TOCFile |
| 11 | #define _TOCFile |
| 12 | |
| 13 | #include "methodcontext.h" |
| 14 | |
| 15 | class TOCElement |
| 16 | { |
| 17 | public: |
| 18 | __int64 Offset; |
| 19 | int Number; |
| 20 | char Hash[MD5_HASH_BUFFER_SIZE]; |
| 21 | |
| 22 | TOCElement() |
| 23 | { |
| 24 | } |
| 25 | |
| 26 | TOCElement(int number, __int64 offset) : Offset(offset), Number(number) |
| 27 | { |
| 28 | } |
| 29 | }; |
| 30 | |
| 31 | class TOCFile |
| 32 | { |
| 33 | private: |
| 34 | TOCElement* m_tocArray; |
| 35 | size_t m_tocCount; |
| 36 | |
| 37 | public: |
| 38 | TOCFile() : m_tocArray(nullptr), m_tocCount(0) |
| 39 | { |
| 40 | } |
| 41 | |
| 42 | ~TOCFile() |
| 43 | { |
| 44 | Clear(); |
| 45 | } |
| 46 | |
| 47 | void Clear() |
| 48 | { |
| 49 | delete[] m_tocArray; |
| 50 | m_tocArray = nullptr; |
| 51 | m_tocCount = 0; |
| 52 | } |
| 53 | |
| 54 | void LoadToc(const char* inputFileName, bool validate = true); |
| 55 | |
| 56 | size_t GetTocCount() |
| 57 | { |
| 58 | return m_tocCount; |
| 59 | } |
| 60 | |
| 61 | const TOCElement* GetElementPtr(size_t i) |
| 62 | { |
| 63 | if (i >= m_tocCount) |
| 64 | { |
| 65 | // error! |
| 66 | return nullptr; |
| 67 | } |
| 68 | return &m_tocArray[i]; |
| 69 | } |
| 70 | }; |
| 71 | |
| 72 | #endif |
| 73 | |