Otawa  0.10
otawa::XSLTScript Class Reference

This class provides a simple way to implement OTAWA script. More...

#include <otawa/util/XSLTScript.h>

Inheritance diagram for otawa::XSLTScript:
elm::io::Monitor

Public Member Functions

 XSLTScript (const elm::system::Path &path, Monitor &monitor=elm::monitor, bool verbosity=false) throw (otawa::Exception)
 
virtual ~XSLTScript (void)
 
xom::Documentdocument (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::Documentdoc
 
xom::Documentxsl
 
xom::Elementtemp
 
enum otawa::XSLTScript:: { ... }  state
 
genstruct::Vector< Pair
< string, string > > 
params
 
bool configured
 
bool verbose
 
Output out
 
Output err
 
Output log
 

Detailed Description

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.

Parameters
pathPath of the script.
monitorMonitor for IO.
verbosityVerbose messages if true.

Member Enumeration Documentation

anonymous enum
private
Enumerator
ERROR 
OPENED 
TRANSFORMED 

Constructor & Destructor Documentation

otawa::XSLTScript::XSLTScript ( const elm::system::Path &  path,
Monitor monitor = elm::monitor,
bool  verbosity = false 
)
throw (otawa::Exception
)
otawa::XSLTScript::~XSLTScript ( void  )
virtual

References doc, and xsl.

Member Function Documentation

void otawa::XSLTScript::addParam ( string  name,
String  value 
)

Add a parameter to the script.

Parameters
nameParameter name.
valueParamater 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.

Parameters
propsProperty list to look in.
idProperty identifier.

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.

Parameters
propsProperty list to look in.
idProperty identifier.

References OPENED, params, and state.

xom::Document* otawa::XSLTScript::document ( void  ) const
inline
void otawa::XSLTScript::fillProps ( PropList props,
xom::Element element 
)

Fill the given property list with the property definitions found in the given element.

Parameters
propsProperty list to fill.
elementElement 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().

void otawa::XSLTScript::fillProps ( PropList props,
cstring  name 
)

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.

Parameters
propsProperty list to fill.
nameElement 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.

void otawa::XSLTScript::onError ( xom::Node node,
const string msg 
)
private

Handle an error.

Parameters
nodeNode causing the error.
msgMessage to display.

References _.

Referenced by fillProps().

void otawa::XSLTScript::onWarning ( xom::Node node,
const string msg 
)
private

Handle an error.

Parameters
nodeNode causing the error.
msgMessage 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.

Parameters
nameName 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)

Member Data Documentation

bool otawa::XSLTScript::configured
private

Referenced by setConfiguration().

xom::Document* otawa::XSLTScript::doc
private
genstruct::Vector<Pair<string, string> > otawa::XSLTScript::params
private

Referenced by addParam(), addParams(), and transform().

enum { ... } otawa::XSLTScript::state
xom::Element* otawa::XSLTScript::temp
private

Referenced by transform().

bool otawa::XSLTScript::verbose
private
xom::Document * otawa::XSLTScript::xsl
private

The documentation for this class was generated from the following files: