nom_mpq/parser/
mpq_file_header_ext.rs1use super::LITTLE_ENDIAN;
6use crate::dbg_dmp;
7use nom::number::complete::{i16, i64};
8use nom::*;
9
10#[derive(Debug, PartialEq, Default, Clone, Copy)]
12pub struct MPQFileHeaderExt {
13 extended_block_table_offset: i64,
15 hash_table_offset_high: i16,
17 block_table_offset_high: i16,
19}
20
21impl MPQFileHeaderExt {
22 pub fn parse(input: &[u8]) -> IResult<&[u8], MPQFileHeaderExt> {
24 let (input, extended_block_table_offset) = Self::parse_extended_block_table_offset(input)?;
25 let (input, hash_table_offset_high) = Self::parse_hash_table_offset_high(input)?;
26 let (input, block_table_offset_high) = Self::parse_block_table_offset_high(input)?;
27 Ok((
28 input,
29 MPQFileHeaderExt {
30 extended_block_table_offset,
31 hash_table_offset_high,
32 block_table_offset_high,
33 },
34 ))
35 }
36
37 pub fn parse_extended_block_table_offset(input: &[u8]) -> IResult<&[u8], i64> {
41 dbg_dmp(i64(LITTLE_ENDIAN), "extended_block_table_offset")(input)
42 }
43
44 pub fn parse_hash_table_offset_high(input: &[u8]) -> IResult<&[u8], i16> {
48 dbg_dmp(i16(LITTLE_ENDIAN), "hash_table_offset_high")(input)
49 }
50
51 pub fn parse_block_table_offset_high(input: &[u8]) -> IResult<&[u8], i16> {
55 dbg_dmp(i16(LITTLE_ENDIAN), "block_table_offset_high")(input)
56 }
57}