Struct kerbalobjects::ko::sections::SymbolTable
source · pub struct SymbolTable { /* private fields */ }
Expand description
A symbol table section in a KerbalObject file.
This section stores a list of all symbols that this object file stores and references.
Implementations§
source§impl SymbolTable
impl SymbolTable
sourcepub fn new(section_index: SectionIdx) -> Self
pub fn new(section_index: SectionIdx) -> Self
Creates a new symbol table section with the provided section index
sourcepub fn with_capacity(amount: usize, section_index: SectionIdx) -> Self
pub fn with_capacity(amount: usize, section_index: SectionIdx) -> Self
Creates a new symbol table section with the provided section index, with internal data structures pre-allocated for the provided amount of symbols
sourcepub fn get(&self, index: SymbolIdx) -> Option<&KOSymbol>
pub fn get(&self, index: SymbolIdx) -> Option<&KOSymbol>
Gets the symbol at the provided index into this symbol table, or None if it doesn’t exist.
sourcepub fn find_by_name(&self, name_idx: StringIdx) -> Option<&KOSymbol>
pub fn find_by_name(&self, name_idx: StringIdx) -> Option<&KOSymbol>
Returns the KOSymbol by the provided name index (from the .symstrtab), or None if it doesn’t exist
sourcepub fn position_by_name(&self, name_idx: StringIdx) -> Option<SymbolIdx>
pub fn position_by_name(&self, name_idx: StringIdx) -> Option<SymbolIdx>
Returns the position/index in this symbol table of the symbol of the provided name index (from the .symstrtab), or None if it doesn’t exist
sourcepub fn find(&self, symbol: &KOSymbol) -> Option<SymbolIdx>
pub fn find(&self, symbol: &KOSymbol) -> Option<SymbolIdx>
Returns the position/index in this symbol table of the provided symbol, or None if it doesn’t exist
sourcepub fn add(&mut self, symbol: KOSymbol) -> SymbolIdx
pub fn add(&mut self, symbol: KOSymbol) -> SymbolIdx
Adds a new symbol to this symbol table, returning the index of the symbol into this section. Doesn’t do anything like checking if a symbol with that name already exists in the table
sourcepub fn add_checked(&mut self, symbol: KOSymbol) -> SymbolIdx
pub fn add_checked(&mut self, symbol: KOSymbol) -> SymbolIdx
Adds a new symbol to this symbol table, returning the index of the symbol into this section. Checks if a symbol with the same name is already in the table, and in that case just returns the index of that symbol
sourcepub fn symbols(&self) -> Iter<'_, KOSymbol>
pub fn symbols(&self) -> Iter<'_, KOSymbol>
Returns an iterator over all symbols in this symbol table
sourcepub fn section_index(&self) -> SectionIdx
pub fn section_index(&self) -> SectionIdx
The index of this section’s section header
sourcepub fn parse(
source: &mut BufferIterator<'_>,
size: u32,
section_index: SectionIdx
) -> Result<Self, SymbolTableParseError>
pub fn parse( source: &mut BufferIterator<'_>, size: u32, section_index: SectionIdx ) -> Result<Self, SymbolTableParseError>
Parses a symbol table from the provided byte buffer
sourcepub fn write(&self, buf: &mut impl WritableBuffer)
pub fn write(&self, buf: &mut impl WritableBuffer)
Converts this symbol table to its binary representation and appends it to the provided buffer