Otawa
0.10
|
This class provides a simple way to implement OTAWA script. More...
#include <otawa/util/XSLTScript.h>
Public Member Functions | |
XSLTScript (const elm::system::Path &path, Monitor &monitor=elm::monitor, bool verbosity=false) throw (otawa::Exception) | |
virtual | ~XSLTScript (void) |
xom::Document * | document (void) const |
void | setConfiguration (cstring name="configuration") |
Prepare the configuration of the script (in term of XSLT parameters). More... | |
void | setConfiguration (xom::Element *element) |
Prepare the configuration of the script (in term of XSLT parameters). More... | |
void | addParam (string name, String value) |
Add a parameter to the script. More... | |
void | addParams (const PropList &props, Identifier< string > &id) |
Look for parameter in the given property list. More... | |
void | addParams (const PropList &props, Identifier< Pair< string, string > > &id) |
Look for parameter in the given property list. More... | |
void | transform (void) throw (otawa::Exception) |
Perform the transformation. More... | |
void | fillProps (PropList &props, xom::Element *element) |
Fill the given property list with the property definitions found in the given element. More... | |
void | fillProps (PropList &props, cstring name) |
Fill the given property list with the property definitions found in the named element (at the top level). More... | |
Private Types | |
enum | { ERROR, OPENED, TRANSFORMED } |
Private Member Functions | |
void | onWarning (xom::Node *node, const string &msg) |
Handle an error. More... | |
void | onError (xom::Node *node, const string &msg) |
Handle an error. More... | |
virtual void | info (const string &message) |
virtual void | error (const string &message) |
virtual void | warn (const string &message) |
void | setOut (OutStream &out) |
void | setErr (OutStream &err) |
void | setLog (OutStream &log) |
Private Attributes | |
xom::Document * | doc |
xom::Document * | xsl |
xom::Element * | temp |
enum otawa::XSLTScript:: { ... } | state |
genstruct::Vector< Pair < string, string > > | params |
bool | configured |
bool | verbose |
Output | out |
Output | err |
Output | log |
This class provides a simple way to implement OTAWA script.
Its behaviour may be easily customized to use the whole or a part of the OTAWA script format.
path | Path of the script. |
monitor | Monitor for IO. |
verbosity | Verbose messages if true. |
otawa::XSLTScript::XSLTScript | ( | const elm::system::Path & | path, |
Monitor & | monitor = elm::monitor , |
||
bool | verbosity = false |
||
) | |||
throw | ( | otawa::Exception | |
) |
Add a parameter to the script.
name | Parameter name. |
value | Paramater value. |
References OPENED, elm::pair(), params, and state.
void otawa::XSLTScript::addParams | ( | const PropList & | props, |
Identifier< string > & | id | ||
) |
Look for parameter in the given property list.
The parameters are retrieved from the property list using the identifier id that must be of type Identifier<string>. The parameter is represented in the form ID=VALUE.
References _, elm::String::indexOf(), OPENED, elm::pair(), params, state, and elm::String::substring().
Referenced by otawa::Manager::loadBin().
void otawa::XSLTScript::addParams | ( | const PropList & | props, |
Identifier< Pair< string, string > > & | id | ||
) |
Look for parameter in the given property list.
The parameters are retrieved from the property list using the identifier id that must be of type Identifier<Pair<string, string> >. First member of the pair is the identifier, the second the value.
|
inline |
void otawa::XSLTScript::fillProps | ( | PropList & | props, |
xom::Element * | element | ||
) |
Fill the given property list with the property definitions found in the given element.
props | Property list to fill. |
element | Element to look property definition nin. |
References _, otawa::p::config, elm::xom::Elements::get(), elm::xom::Element::getAttributeValue(), elm::xom::Element::getChildElements(), otawa::ProcessorPlugin::getIdentifier(), elm::io::Monitor::log, elm::Exception::message(), name, onError(), onWarning(), elm::xom::Elements::size(), state, TRANSFORMED, elm::Option< T >::value(), elm::value(), and verbose.
Referenced by fillProps(), and otawa::Manager::loadBin().
Fill the given property list with the property definitions found in the named element (at the top level).
If the element does not exist, do nothing.
props | Property list to fill. |
name | Element name to look property definition nin. |
References _, doc, fillProps(), elm::xom::Element::getFirstChildElement(), elm::xom::Document::getRootElement(), elm::io::Monitor::info(), state, TRANSFORMED, and verbose.
Handle an error.
node | Node causing the error. |
msg | Message to display. |
References _.
Referenced by fillProps().
Handle an error.
node | Node causing the error. |
msg | Message to display. |
References elm::io::Monitor::err.
Referenced by fillProps(), and setConfiguration().
void otawa::XSLTScript::setConfiguration | ( | cstring | name = "configuration" | ) |
Prepare the configuration of the script (in term of XSLT parameters).
Only allowed when the script document is opened but not transformed. Fails silently if no configuration is found.
name | Name of the top-level tag containing the configuration. |
References configured, doc, elm::xom::Element::getFirstChildElement(), elm::xom::Document::getRootElement(), OPENED, and state.
Referenced by otawa::Manager::loadBin().
void otawa::XSLTScript::setConfiguration | ( | xom::Element * | element | ) |
Prepare the configuration of the script (in term of XSLT parameters).
element | Element to look in for items. |
References _, elm::xom::Element::addAttribute(), elm::xom::Element::appendChild(), configured, elm::xom::Elements::get(), elm::xom::Element::getAttributeValue(), elm::xom::Element::getChildElements(), elm::xom::Document::getRootElement(), elm::io::Monitor::log, name, onWarning(), OPENED, elm::xom::Elements::size(), state, elm::value(), verbose, and xsl.
void otawa::XSLTScript::transform | ( | void | ) | ||
throw | ( | otawa::Exception | |||
) |
Perform the transformation.
References _, elm::xom::Element::appendChild(), doc, elm::dtd::empty, elm::xom::Document::getRootElement(), elm::io::Monitor::log, elm::MessageException::message(), OPENED, params, elm::xom::Document::removeChild(), elm::ErrorBase::setErrorHandler(), elm::xom::XSLTransform::setParameter(), state, temp, elm::xom::XSLTransform::transformDocument(), TRANSFORMED, verbose, and xsl.
Referenced by otawa::Manager::loadBin().
|
private |
Referenced by setConfiguration().
|
private |
Referenced by fillProps(), setConfiguration(), transform(), and ~XSLTScript().
|
private |
Referenced by addParam(), addParams(), and transform().
enum { ... } otawa::XSLTScript::state |
Referenced by addParam(), addParams(), fillProps(), setConfiguration(), and transform().
|
private |
Referenced by transform().
|
private |
Referenced by fillProps(), setConfiguration(), and transform().
|
private |
Referenced by setConfiguration(), transform(), and ~XSLTScript().