Class StringTable
java.lang.Object
ghidra.app.util.bin.format.dwarf4.next.StringTable
A offset-to-String string table backed by a simple byte array (encoded as UTF-8).
Requested strings are instantiated when requested.
-
Constructor Summary
ConstructorsConstructorDescriptionStringTable
(byte[] bytes) Creates a StringTable using the bytes contained in the supplied array. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Modifies the string table to add a string at a specified offset, growing the internal byte[] storage as necessary to accommodate the string at the offset.void
clear()
int
getStringAtOffset
(long offset) Returns the string found atoffset
, or throws anIOException
if the offset is out of bounds.boolean
isValid
(long offset) Returns true if the specified offset is a valid offset for this string table.static StringTable
Create aStringTable
by reading the entire contents of aByteProvider
into memory.
-
Constructor Details
-
StringTable
public StringTable(byte[] bytes) Creates a StringTable using the bytes contained in the supplied array.
-
-
Method Details
-
readStringTable
Create aStringTable
by reading the entire contents of aByteProvider
into memory.If the specified
ByteProvider
is null, an empty string table will be constructed.- Parameters:
bp
-- Returns:
- Throws:
IOException
-
isValid
public boolean isValid(long offset) Returns true if the specified offset is a valid offset for this string table.- Parameters:
offset
-- Returns:
-
clear
public void clear() -
getStringAtOffset
Returns the string found atoffset
, or throws anIOException
if the offset is out of bounds.- Parameters:
offset
-- Returns:
- a string, never null.
- Throws:
IOException
- if not found
-
getByteCount
public int getByteCount() -
add
Modifies the string table to add a string at a specified offset, growing the internal byte[] storage as necessary to accommodate the string at the offset.Used for unit tests to construct a custom string table for test cases.
- Parameters:
offset
- where to place the string in the tables
- string to insert into table
-