Binary Ninja API C++: TypeParser
Classes | |
| struct | BinaryNinja::ParsedType |
| struct | BinaryNinja::TypeParserResult |
| struct | BinaryNinja::TypeParserError |
| class | BinaryNinja::TypeParser |
| class | BinaryNinja::CoreTypeParser |
◆ BinaryNinja::ParsedType
struct BinaryNinja::ParsedType
Public Member Functions | |
| ParsedType ()=default | |
| ParsedType (const std::string &name, const Ref< Type > &type, bool isUser) | |
| ParsedType (const QualifiedName &name, const Ref< Type > &type, bool isUser) | |
| bool | operator< (const ParsedType &other) const |
Public Attributes | |
| QualifiedName | name |
| Ref< Type > | type |
| bool | isUser |
◆ ParsedType() [1/3]
|
default |
◆ ParsedType() [2/3]
|
inline |
◆ ParsedType() [3/3]
|
inline |
◆ operator<()
|
inline |
◆ name
◆ type
◆ isUser
bool BinaryNinja::ParsedType::isUser
◆ BinaryNinja::TypeParserResult
struct BinaryNinja::TypeParserResult
| Class Members | ||
|---|---|---|
| vector< ParsedType > | types | |
| vector< ParsedType > | variables | |
| vector< ParsedType > | functions | |
◆ BinaryNinja::TypeParserError
struct BinaryNinja::TypeParserError
Public Member Functions | |
| TypeParserError ()=default | |
| TypeParserError (BNTypeParserErrorSeverity severity, const std::string &message) | |
Public Attributes | |
| BNTypeParserErrorSeverity | severity |
| std::string | message |
| std::string | fileName |
| uint64_t | line |
| uint64_t | column |
◆ TypeParserError() [1/2]
|
default |
◆ TypeParserError() [2/2]
◆ severity
◆ message
std::string BinaryNinja::TypeParserError::message
◆ fileName
std::string BinaryNinja::TypeParserError::fileName
◆ line
uint64_t BinaryNinja::TypeParserError::line
◆ column
uint64_t BinaryNinja::TypeParserError::column
◆ BinaryNinja::TypeParser
class BinaryNinja::TypeParser
Public Member Functions | |
| std::string | GetName () const |
| Get the Type Parser's registered name. | |
| virtual bool | GetOptionText (BNTypeParserOption option, std::string value, std::string &result) const |
| virtual bool | PreprocessSource (const std::string &source, const std::string &fileName, Ref< Platform > platform, std::optional< TypeContainer > existingTypes, const std::vector< std::string > &options, const std::vector< std::string > &includeDirs, std::string &output, std::vector< TypeParserError > &errors)=0 |
| Preprocess a block of source, returning the source that would be parsed. | |
| virtual bool | ParseTypesFromSource (const std::string &source, const std::string &fileName, Ref< Platform > platform, std::optional< TypeContainer > existingTypes, const std::vector< std::string > &options, const std::vector< std::string > &includeDirs, const std::string &autoTypeSource, TypeParserResult &result, std::vector< TypeParserError > &errors)=0 |
| Parse an entire block of source into types, variables, and functions. | |
| bool | ParseTypesFromSourceFile (const std::string &fileName, Ref< Platform > platform, std::optional< TypeContainer > existingTypes, const std::vector< std::string > &options, const std::vector< std::string > &includeDirs, const std::string &autoTypeSource, TypeParserResult &result, std::vector< TypeParserError > &errors) |
| Parse an entire source file into types, variables, and functions. | |
| virtual bool | ParseTypeString (const std::string &source, Ref< Platform > platform, std::optional< TypeContainer > existingTypes, QualifiedNameAndType &result, std::vector< TypeParserError > &errors)=0 |
| Parse a single type and name from a string containing their definition. | |
| Public Member Functions inherited from BinaryNinja::StaticCoreRefCountObject< BNTypeParser > | |
| StaticCoreRefCountObject () | |
| virtual | ~StaticCoreRefCountObject () |
| BNTypeParser * | GetObject () const |
| void | AddRef () |
| void | Release () |
| void | AddRefForRegistration () |
| void | AddRefForCallback () |
| void | ReleaseForCallback () |
Static Public Member Functions | |
| static void | Register (TypeParser *parser) |
| static std::vector< Ref< TypeParser > > | GetList () |
| static Ref< TypeParser > | GetByName (const std::string &name) |
| static Ref< TypeParser > | GetDefault () |
| static std::vector< std::string > | ParseOptionsText (const std::string &optionsText) |
| Parse a space-separated string of options into a list. | |
| static std::string | FormatParseErrors (const std::vector< TypeParserError > &errors) |
| Format a list of parser errors into a big string. | |
Protected Member Functions | |
| TypeParser (const std::string &name) | |
| TypeParser (BNTypeParser *parser) | |
Static Protected Member Functions | |
| static bool | GetOptionTextCallback (void *ctxt, BNTypeParserOption option, const char *value, char **result) |
| static bool | PreprocessSourceCallback (void *ctxt, const char *source, const char *fileName, BNPlatform *platform, BNTypeContainer *existingTypes, const char *const *options, size_t optionCount, const char *const *includeDirs, size_t includeDirCount, char **output, BNTypeParserError **errors, size_t *errorCount) |
| static bool | ParseTypesFromSourceCallback (void *ctxt, const char *source, const char *fileName, BNPlatform *platform, BNTypeContainer *existingTypes, const char *const *options, size_t optionCount, const char *const *includeDirs, size_t includeDirCount, const char *autoTypeSource, BNTypeParserResult *result, BNTypeParserError **errors, size_t *errorCount) |
| static bool | ParseTypeStringCallback (void *ctxt, const char *source, BNPlatform *platform, BNTypeContainer *existingTypes, BNQualifiedNameAndType *result, BNTypeParserError **errors, size_t *errorCount) |
| static void | FreeStringCallback (void *ctxt, char *result) |
| static void | FreeResultCallback (void *ctxt, BNTypeParserResult *result) |
| static void | FreeErrorListCallback (void *ctxt, BNTypeParserError *errors, size_t errorCount) |
|
explicitprotected |
◆ TypeParser() [2/2]
◆ GetOptionTextCallback()
|
staticprotected |
◆ PreprocessSourceCallback()
|
staticprotected |
◆ ParseTypesFromSourceCallback()
|
staticprotected |
◆ ParseTypeStringCallback()
◆ FreeStringCallback()
|
staticprotected |
◆ FreeResultCallback()
◆ FreeErrorListCallback()
|
staticprotected |
◆ Register()
|
static |
◆ GetList()
|
static |
◆ GetByName()
|
static |
◆ GetDefault()
|
static |
◆ ParseOptionsText()
|
static |
Parse a space-separated string of options into a list.
- Parameters
-
optionsText Space-separated options text
- Returns
- List of options
◆ FormatParseErrors()
|
static |
Format a list of parser errors into a big string.
- Parameters
- Returns
- String of formatted errors
◆ GetName()
| std::string TypeParser::GetName | ( | ) | const |
Get the Type Parser's registered name.
- Returns
- Parser name
◆ GetOptionText()
|
virtual |
Get the string representation of an option for passing to ParseTypes*
- Parameters
-
option Option type value Option value result String representing the option
- Returns
- True if the parser supports the option
Reimplemented in BinaryNinja::CoreTypeParser.
◆ PreprocessSource()
|
pure virtual |
Preprocess a block of source, returning the source that would be parsed.
- Parameters
-
source Source code to process fileName Name of the file containing the source (does not need to exist on disk) platform Platform to assume the source is relevant to existingTypes Container of all existing types to use for parsing context options String arguments to pass as options, e.g. command line arguments includeDirs List of directories to include in the header search path output Reference to a string into which the preprocessed source will be written errors Reference to a list into which any parse errors will be written
- Returns
- True if preprocessing was successful
Implemented in BinaryNinja::CoreTypeParser.
◆ ParseTypesFromSource()
|
pure virtual |
Parse an entire block of source into types, variables, and functions.
- Parameters
-
source Source code to parse fileName Name of the file containing the source (optional: exists on disk) platform Platform to assume the types are relevant to existingTypes Container of all existing types to use for parsing context options String arguments to pass as options, e.g. command line arguments includeDirs List of directories to include in the header search path autoTypeSource Optional source of types if used for automatically generated types result Reference to structure into which the results will be written errors Reference to a list into which any parse errors will be written
- Returns
- True if parsing was successful
Implemented in BinaryNinja::CoreTypeParser.
◆ ParseTypesFromSourceFile()
| bool TypeParser::ParseTypesFromSourceFile | ( | const std::string & | fileName, |
| Ref< Platform > | platform, | ||
| std::optional< TypeContainer > | existingTypes, | ||
| const std::vector< std::string > & | options, | ||
| const std::vector< std::string > & | includeDirs, | ||
| const std::string & | autoTypeSource, | ||
| TypeParserResult & | result, | ||
| std::vector< TypeParserError > & | errors ) |
Parse an entire source file into types, variables, and functions.
- Parameters
-
fileName Name of the file on disk containing the source platform Platform to assume the types are relevant to existingTypes Container of all existing types to use for parsing context options String arguments to pass as options, e.g. command line arguments includeDirs List of directories to include in the header search path autoTypeSource Optional source of types if used for automatically generated types result Reference to structure into which the results will be written errors Reference to a list into which any parse errors will be written
- Returns
- True if parsing was successful
◆ ParseTypeString()
Parse a single type and name from a string containing their definition.
- Parameters
-
source Source code to parse platform Platform to assume the types are relevant to existingTypes Container of all existing types to use for parsing context result Reference into which the resulting type and name will be written errors Reference to a list into which any parse errors will be written
- Returns
- True if parsing was successful
Implemented in BinaryNinja::CoreTypeParser.
◆ BinaryNinja::CoreTypeParser
class BinaryNinja::CoreTypeParser
Public Member Functions | |
| CoreTypeParser (BNTypeParser *parser) | |
| virtual | ~CoreTypeParser () |
| virtual bool | GetOptionText (BNTypeParserOption option, std::string value, std::string &result) const override |
| virtual bool | PreprocessSource (const std::string &source, const std::string &fileName, Ref< Platform > platform, std::optional< TypeContainer > existingTypes, const std::vector< std::string > &options, const std::vector< std::string > &includeDirs, std::string &output, std::vector< TypeParserError > &errors) override |
| Preprocess a block of source, returning the source that would be parsed. | |
| virtual bool | ParseTypesFromSource (const std::string &source, const std::string &fileName, Ref< Platform > platform, std::optional< TypeContainer > existingTypes, const std::vector< std::string > &options, const std::vector< std::string > &includeDirs, const std::string &autoTypeSource, TypeParserResult &result, std::vector< TypeParserError > &errors) override |
| Parse an entire block of source into types, variables, and functions. | |
| virtual bool | ParseTypeString (const std::string &source, Ref< Platform > platform, std::optional< TypeContainer > existingTypes, QualifiedNameAndType &result, std::vector< TypeParserError > &errors) override |
| Parse a single type and name from a string containing their definition. | |
| Public Member Functions inherited from BinaryNinja::TypeParser | |
| std::string | GetName () const |
| Get the Type Parser's registered name. | |
| bool | ParseTypesFromSourceFile (const std::string &fileName, Ref< Platform > platform, std::optional< TypeContainer > existingTypes, const std::vector< std::string > &options, const std::vector< std::string > &includeDirs, const std::string &autoTypeSource, TypeParserResult &result, std::vector< TypeParserError > &errors) |
| Parse an entire source file into types, variables, and functions. | |
| Public Member Functions inherited from BinaryNinja::StaticCoreRefCountObject< BNTypeParser > | |
| StaticCoreRefCountObject () | |
| virtual | ~StaticCoreRefCountObject () |
| BNTypeParser * | GetObject () const |
| void | AddRef () |
| void | Release () |
| void | AddRefForRegistration () |
| void | AddRefForCallback () |
| void | ReleaseForCallback () |
Additional Inherited Members | |
| Static Public Member Functions inherited from BinaryNinja::TypeParser | |
| static void | Register (TypeParser *parser) |
| static std::vector< Ref< TypeParser > > | GetList () |
| static Ref< TypeParser > | GetByName (const std::string &name) |
| static Ref< TypeParser > | GetDefault () |
| static std::vector< std::string > | ParseOptionsText (const std::string &optionsText) |
| Parse a space-separated string of options into a list. | |
| static std::string | FormatParseErrors (const std::vector< TypeParserError > &errors) |
| Format a list of parser errors into a big string. | |
| Public Attributes inherited from BinaryNinja::StaticCoreRefCountObject< BNTypeParser > | |
| std::atomic< int > | m_refs |
| BNTypeParser * | m_object |
| Protected Member Functions inherited from BinaryNinja::TypeParser | |
| TypeParser (const std::string &name) | |
| TypeParser (BNTypeParser *parser) | |
| Static Protected Member Functions inherited from BinaryNinja::TypeParser | |
| static bool | GetOptionTextCallback (void *ctxt, BNTypeParserOption option, const char *value, char **result) |
| static bool | PreprocessSourceCallback (void *ctxt, const char *source, const char *fileName, BNPlatform *platform, BNTypeContainer *existingTypes, const char *const *options, size_t optionCount, const char *const *includeDirs, size_t includeDirCount, char **output, BNTypeParserError **errors, size_t *errorCount) |
| static bool | ParseTypesFromSourceCallback (void *ctxt, const char *source, const char *fileName, BNPlatform *platform, BNTypeContainer *existingTypes, const char *const *options, size_t optionCount, const char *const *includeDirs, size_t includeDirCount, const char *autoTypeSource, BNTypeParserResult *result, BNTypeParserError **errors, size_t *errorCount) |
| static bool | ParseTypeStringCallback (void *ctxt, const char *source, BNPlatform *platform, BNTypeContainer *existingTypes, BNQualifiedNameAndType *result, BNTypeParserError **errors, size_t *errorCount) |
| static void | FreeStringCallback (void *ctxt, char *result) |
| static void | FreeResultCallback (void *ctxt, BNTypeParserResult *result) |
| static void | FreeErrorListCallback (void *ctxt, BNTypeParserError *errors, size_t errorCount) |
◆ CoreTypeParser()
◆ ~CoreTypeParser()
|
inlinevirtual |
◆ GetOptionText()
|
overridevirtual |
Get the string representation of an option for passing to ParseTypes*
- Parameters
-
option Option type value Option value result String representing the option
- Returns
- True if the parser supports the option
Reimplemented from BinaryNinja::TypeParser.
◆ PreprocessSource()
|
overridevirtual |
Preprocess a block of source, returning the source that would be parsed.
- Parameters
-
source Source code to process fileName Name of the file containing the source (does not need to exist on disk) platform Platform to assume the source is relevant to existingTypes Container of all existing types to use for parsing context options String arguments to pass as options, e.g. command line arguments includeDirs List of directories to include in the header search path output Reference to a string into which the preprocessed source will be written errors Reference to a list into which any parse errors will be written
- Returns
- True if preprocessing was successful
Implements BinaryNinja::TypeParser.
◆ ParseTypesFromSource()
|
overridevirtual |
Parse an entire block of source into types, variables, and functions.
- Parameters
-
source Source code to parse fileName Name of the file containing the source (optional: exists on disk) platform Platform to assume the types are relevant to existingTypes Container of all existing types to use for parsing context options String arguments to pass as options, e.g. command line arguments includeDirs List of directories to include in the header search path autoTypeSource Optional source of types if used for automatically generated types result Reference to structure into which the results will be written errors Reference to a list into which any parse errors will be written
- Returns
- True if parsing was successful
Implements BinaryNinja::TypeParser.
◆ ParseTypeString()
Parse a single type and name from a string containing their definition.
- Parameters
-
source Source code to parse platform Platform to assume the types are relevant to existingTypes Container of all existing types to use for parsing context result Reference into which the resulting type and name will be written errors Reference to a list into which any parse errors will be written
- Returns
- True if parsing was successful
Implements BinaryNinja::TypeParser.