![]() |
Kinetis Bootloader Host
2.0.0
Host Tools for Kinetis devices
|
Abstract base class for a source file containing executable code. More...
#include <SourceFile.h>
Inheritance diagram for elftosb::SourceFile:
Collaboration diagram for elftosb::SourceFile:Public Member Functions | |
| SourceFile (const std::string &path) | |
| Default constructor. | |
| virtual | ~SourceFile () |
| Destructor. More... | |
| void | setOptions (OptionContext *context) |
| Set the option context. More... | |
| const OptionContext * | getOptions () const |
| Return the option context. | |
| const std::string & | getPath () const |
| Returns the path to the file. | |
| unsigned | getSize () |
| Get the size in bytes of the file. | |
Opening and closing | |
| virtual void | open () |
| Opens the file. More... | |
| virtual void | close () |
| Closes the file. | |
| virtual bool | isOpen () const |
| Returns whether the file is already open. | |
Format capabilities | |
| virtual bool | supportsNamedSections () const =0 |
| virtual bool | supportsNamedSymbols () const =0 |
Data source creation | |
| virtual DataSource * | createDataSource ()=0 |
| Creates a data source from the entire file. | |
| virtual DataSource * | createDataSource (StringMatcher &matcher) |
| Creates a data source out of one or more sections of the file. More... | |
| virtual DataSource * | createDataSource (const std::string §ion) |
| Creates a data source out of one section of the file. More... | |
Entry point | |
| virtual bool | hasEntryPoint ()=0 |
| Returns true if an entry point was set in the file. | |
| virtual uint32_t | getEntryPointAddress () |
| Returns the entry point address. | |
Data target creation | |
| virtual DataTarget * | createDataTargetForSection (const std::string §ion) |
| virtual DataTarget * | createDataTargetForSymbol (const std::string &symbol) |
| virtual DataTarget * | createDataTargetForEntryPoint () |
Symbols | |
| virtual bool | hasSymbol (const std::string &name) |
| Returns whether a symbol exists in the source file. | |
| virtual uint32_t | getSymbolValue (const std::string &name) |
| Returns the value of a symbol. | |
| virtual unsigned | getSymbolSize (const std::string &name) |
| Returns the size of a symbol. | |
Static Public Member Functions | |
| static SourceFile * | openFile (const std::string &path) |
Protected Member Functions | |
| std::ifstream * | getStream () |
| Internal access to the input stream object. | |
Protected Attributes | |
| std::string | m_path |
| Path to the file. | |
| smart_ptr< std::ifstream > | m_stream |
| File stream, or NULL if file is closed. | |
| smart_ptr< OptionContext > | m_options |
| Table of option values. | |
Abstract base class for a source file containing executable code.
The purpose of this class cluster is to provide a common interface for accessing the contents of different file formats. This is accomplished through several small sets of methods along with the DataSource and DataTarget classes.
The primary interface for creating instances of SourceFile is the static SourceFile::openFile() function. It will create the correct subclass of SourceFile by inspecting the file to determine its type.
|
virtual |
Destructor.
The file is closed if it had been left opened.
|
inlinevirtual |
Creates a data source out of one or more sections of the file.
The selector object is used to perform the section name comparison. If the file does not support named sections, or if there is not a section with the given name, this method may return NULL.
Reimplemented in elftosb::ELFSourceFile.
|
virtual |
Creates a data source out of one section of the file.
If the file does not support named sections, or if there is not a section with the given name, this method may return NULL.
This method is just a small wrapper that creates an FixedMatcher string matcher instance and uses the createDataSource() that takes a reference to a StringMatcher.
|
virtual |
Opens the file.
| std::runtime_error | Raised if the file could not be opened successfully. |
Reimplemented in elftosb::ELFSourceFile, and elftosb::SRecordSourceFile.
|
static |
The supported file types are currently:
Any file that is not picked up by the other subclasses will result in a an instance of BinaryDataFile.
| std::runtime_error | Thrown if the file cannot be opened. |
|
inline |
Set the option context.
The source file will take ownership of the context and delete it when the source file is itself deleted.