use crate::prelude::*;

/// the builder of [super::RawElf64ProgramHeader].
#[derive(Default, Debug)]
pub struct RawElf64ProgramHeaderBuilder {
    inner: super::RawElf64ProgramHeader,
}

impl RawElf64ProgramHeaderBuilder {
    /// set the given p_type into itself for building.
    pub fn header_type(mut self, p_type: Elf64Word) -> Self {
        self.inner.p_type = p_type;
        self
    }

    /// set the given p_flags nto itself for building.
    pub fn flags(mut self, p_flags: Elf64Word) -> Self {
        self.inner.p_flags = p_flags;
        self
    }

    /// set the given p_offset into itself for building.
    pub fn offset(mut self, p_offset: Elf64Off) -> Self {
        self.inner.p_offset = p_offset;
        self
    }

    /// set the given p_vaddr into itself for building.
    pub fn vaddr(mut self, p_vaddr: Elf64Addr) -> Self {
        self.inner.p_vaddr = p_vaddr;
        self
    }

    /// set the given p_paddr into itself for building.
    pub fn paddr(mut self, p_paddr: Elf64Addr) -> Self {
        self.inner.p_paddr = p_paddr;
        self
    }

    /// set the given p_filesz into itself for building.
    pub fn filesz(mut self, p_filesz: Elf64Xword) -> Self {
        self.inner.p_filesz = p_filesz;
        self
    }

    /// set the given p_memsz into itself for building.
    pub fn memsz(mut self, p_memsz: Elf64Xword) -> Self {
        self.inner.p_memsz = p_memsz;
        self
    }

    /// set the given p_align into itself for building.
    pub fn align(mut self, p_align: Elf64Xword) -> Self {
        self.inner.p_align = p_align;
        self
    }

    pub fn build(self) -> super::RawElf64ProgramHeader {
        self.inner
    }
}
