Class: Elf::Writer2::StringTable
- Inherits:
-
BinData::Record
- Object
- BinData::Record
- Elf::Writer2::StringTable
- Defined in:
- lib/mithril/writer2.rb
Defined Under Namespace
Classes: OutputLayout
Instance Method Summary collapse
-
#add_string(string) ⇒ Object
table.
-
#initialize ⇒ StringTable
constructor
A new instance of StringTable.
Constructor Details
#initialize ⇒ StringTable
Returns a new instance of StringTable.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/mithril/writer2.rb', line 8 def initialize @strings = {} #TODO: Do substring matching, compress the string #table. def add_string(string) unless @strings.include? string @strings[string] = self.strtab.num_bytes self.strtab << BinData::Stringz(string) end @strings[string] end end |
Instance Method Details
#add_string(string) ⇒ Object
table.
11 12 13 14 15 16 17 |
# File 'lib/mithril/writer2.rb', line 11 def add_string(string) unless @strings.include? string @strings[string] = self.strtab.num_bytes self.strtab << BinData::Stringz(string) end @strings[string] end |