Commit d09a925f authored by Florian Lesaint's avatar Florian Lesaint
Browse files

Add support of writingData for typeValue and monoid:

  - plusSym
  - timesSym
  - ...

  * data/vaucanson.xsd: Here.
  * include/vaucanson/algebra/implementation/monoid/free_monoid.hh:
  Since we need to create the monoid before parsing its content, we need
  to update the representation after its creation. So set_representation
  should be public (or friendly)
  * include/vaucanson/xml/builders.hh: Here.
  * include/vaucanson/xml/builders.hxx: Here.
  * include/vaucanson/xml/handlers.hh: Here.
  * include/vaucanson/xml/handlers.hxx: Here.
  * include/vaucanson/xml/printers.hxx: Here.
  * include/vaucanson/xml/xmleq.hh: Here.
  * include/vaucanson/xml/xmleq.hxx: Here.
parent 5db96704
2008-11-10 Florian Lesaint <florian.lesaint@lrde.epita.fr>
Add support of writingData for typeValue and monoid:
- plusSym
- timesSym
- ...
* data/vaucanson.xsd: Here.
* include/vaucanson/algebra/implementation/monoid/free_monoid.hh:
Since we need to create the monoid before parsing its content, we need
to update the representation after its creation. So set_representation
should be public (or friendly)
* include/vaucanson/xml/builders.hh: Here.
* include/vaucanson/xml/builders.hxx: Here.
* include/vaucanson/xml/handlers.hh: Here.
* include/vaucanson/xml/handlers.hxx: Here.
* include/vaucanson/xml/printers.hxx: Here.
* include/vaucanson/xml/xmleq.hh: Here.
* include/vaucanson/xml/xmleq.hxx: Here.
2008-11-10 Jerome Galtier <jerome.galtier@lrde.epita.fr>
 
Add an operator== for series_rep (uniqueness constraints).
......
......@@ -155,7 +155,8 @@ Can be a "unit", a "free" or a "product" monoid.
<xs:sequence>
<xs:element name="writingData" minOccurs="0">
<xs:complexType>
<xs:attribute name="identitySymbol" use="required"/>
<xs:attribute name="identitySym"/>
<xs:attribute name="timesSym"/>
</xs:complexType>
</xs:element>
<xs:element name="genSort" type="genSort" minOccurs="0"/>
......@@ -201,8 +202,8 @@ Writing data can be added.
<xs:sequence>
<xs:element name="writingData" minOccurs="0">
<xs:complexType>
<xs:attribute name="identitySymbol" use="required"/>
<xs:attribute name="zeroSymbol" use="required"/>
<xs:attribute name="identitySym"/>
<xs:attribute name="zeroSym"/>
</xs:complexType>
</xs:element>
<xs:element name="semiring" type="semiring" minOccurs="0"/>
......@@ -239,6 +240,19 @@ Writing data can be added.
-->
<xs:complexType name="valueType">
<xs:sequence>
<xs:element name="writingData" minOccurs="0">
<xs:complexType>
<xs:attribute name="plusSym"/>
<xs:attribute name="timesSym"/>
<xs:attribute name="starSym"/>
<xs:attribute name="zeroSym"/>
<xs:attribute name="spacesSym"/>
<xs:attribute name="weightOpening"/>
<xs:attribute name="weightClosing"/>
<xs:attribute name="openPar"/>
<xs:attribute name="closePar"/>
</xs:complexType>
</xs:element>
<xs:element name="semiring" type="semiring"/>
<xs:element name="monoid" type="monoid"/>
</xs:sequence>
......
......@@ -93,13 +93,13 @@ namespace vcsn
/// Alphabet's accessor
const A& alphabet() const;
private:
public:
/// This function is here for xml that doesn't know the
/// representation when constructing the monoid
void set_representation(monoid_rep_t mr);
protected:
const shared_monoid_rep_t rep_;
shared_monoid_rep_t rep_;
A alph_;
};
......
......@@ -304,6 +304,12 @@ namespace vcsn
xercesc::DOMDocument* doc,
xercesc::DOMElement* root);
template <typename T>
void
create_type_writingData_node(const T&,
xercesc::DOMDocument* doc,
xercesc::DOMElement* root);
// Functor to allow partial specialization.
template <typename T>
struct
......
......@@ -24,6 +24,7 @@
# include <vaucanson/design_pattern/element.hh>
# include <vaucanson/xml/xml_exp_visitor.hh>
# include <vaucanson/algebra/concept/monoid_base.hh>
# include <vaucanson/algebra/implementation/monoid/monoid_rep.hh>
namespace vcsn
{
......@@ -232,7 +233,15 @@ namespace vcsn
parser_->setContentHandler(&unsuph_);
}
else if (XMLString::equals(eq_.writingData, localname))
{
algebra::monoid_rep<T> rep;
if (tools::has_attribute(attrs, eq_.identitySymbol))
rep.empty = xmlstr(tools::get_attribute(attrs, eq_.identitySymbol));
if (tools::has_attribute(attrs, eq_.concat))
rep.concat = xmlstr(tools::get_attribute(attrs, eq_.concat));
monoid_.set_representation(rep);
parser_->setContentHandler(&unsuph_);
}
else
error::token(localname);
}
......@@ -493,6 +502,11 @@ namespace vcsn
tools::set_attribute(node, "genKind", letter_kind);
root->appendChild(node);
xercesc::DOMElement* writingData = tools::create_element(doc, "writingData");
tools::set_attribute(writingData, "identitySym", aut.series().monoid().representation()->empty);
tools::set_attribute(writingData, "timesSym", aut.series().monoid().representation()->concat);
node->appendChild(writingData);
typedef typename T::monoid_t::alphabet_t::const_iterator alphabet_iterator;
if (letter_kind == "simple")
......@@ -555,10 +569,28 @@ namespace vcsn
for (typename U::const_iterator i = word.begin(); i != word.end(); ++i)
monGen_maker(*i, doc, node);
}
root->appendChild(node);
}
template <typename T>
void
create_type_writingData_node(const T& aut,
xercesc::DOMDocument* doc,
xercesc::DOMElement* root)
{
xercesc::DOMElement* writingData = tools::create_element(doc, "writingData");
tools::set_attribute(writingData, "plusSym", aut.series().representation()->plus);
tools::set_attribute(writingData, "timesSym", aut.series().representation()->times);
tools::set_attribute(writingData, "starSym", aut.series().representation()->star);
tools::set_attribute(writingData, "zeroSym", aut.series().representation()->zero);
tools::set_attribute(writingData, "weightOpening", aut.series().representation()->open_weight);
tools::set_attribute(writingData, "weightClosing", aut.series().representation()->close_weight);
tools::set_attribute(writingData, "openPar", aut.series().representation()->open_par);
tools::set_attribute(writingData, "closePar", aut.series().representation()->close_par);
tools::set_attribute(writingData, "spacesSym", aut.series().representation()->spaces.front());
root->appendChild(writingData);
}
// FIXME: We should be able to specialize for all type U,
// whose letter_traits::kind() is "simple".
template <typename U>
......
......@@ -45,6 +45,8 @@
# include <vaucanson/xml/builders.hh>
# include <vaucanson/xml/regexp.hh>
# include <vaucanson/algebra/implementation/series/series_rep.hh>
namespace vcsn
{
namespace xml
......@@ -300,12 +302,14 @@ namespace vcsn
monoid_t* monoid_;
semiring_t* semiring_;
algebra::series_rep<semiring_t, monoid_t> rep_;
// FIXME: maybe we should rename this attribute to aut_,
// as with all the other handlers.
T& param_;
Handler* monoidh_;
Handler* semiringh_;
UnsupHandler unsuph_;
};
/**
......
......@@ -127,7 +127,8 @@ namespace vcsn
Handler& root,
T& param)
: Handler(parser, root),
param_(param)
param_(param),
unsuph_(parser, *this)
{
}
......@@ -151,6 +152,31 @@ namespace vcsn
monoidh_ = builders::create_monoidh(*monoid_, attrs, parser_, *this);
parser_->setContentHandler(monoidh_);
}
else if (XMLString::equals(eq_.writingData, localname))
{
if (tools::has_attribute(attrs, eq_.openPar))
rep_.open_par = xmlstr(tools::get_attribute(attrs, eq_.openPar));
if (tools::has_attribute(attrs, eq_.closePar))
rep_.close_par = xmlstr(tools::get_attribute(attrs, eq_.closePar));
if (tools::has_attribute(attrs, eq_.plus))
rep_.plus = xmlstr(tools::get_attribute(attrs, eq_.plus));
if (tools::has_attribute(attrs, eq_.times))
rep_.times = xmlstr(tools::get_attribute(attrs, eq_.times));
if (tools::has_attribute(attrs, eq_.star))
rep_.star = xmlstr(tools::get_attribute(attrs, eq_.star));
if (tools::has_attribute(attrs, eq_.zero))
rep_.zero = xmlstr(tools::get_attribute(attrs, eq_.zero));
if (tools::has_attribute(attrs, eq_.openWeight))
rep_.open_weight = xmlstr(tools::get_attribute(attrs, eq_.openWeight));
if (tools::has_attribute(attrs, eq_.closeWeight))
rep_.close_weight = xmlstr(tools::get_attribute(attrs, eq_.closeWeight));
if (tools::has_attribute(attrs, eq_.plus))
{
rep_.spaces.clear();
rep_.spaces.push_back(xmlstr(tools::get_attribute(attrs, eq_.plus)));
}
parser_->setContentHandler(&unsuph_);
}
else
error::token(localname);
}
......@@ -162,7 +188,7 @@ namespace vcsn
const XMLCh* const)
{
using namespace xercesc;
typename T::series_set_t series(*semiring_, *monoid_);
typename T::series_set_t series(*semiring_, *monoid_, rep_);
param_.attach(series);
if (XMLString::equals(eq_.valueType, localname))
......
......@@ -81,6 +81,7 @@ namespace vcsn
DOMElement* valueType = tools::create_element(doc_, "valueType");
automaton->appendChild(valueType);
builders::create_type_writingData_node(aut_, doc_, valueType);
builders::create_semiring_node(aut_, doc_, valueType);
builders::create_monoid_node(aut_, doc_, valueType);
......
......@@ -84,6 +84,10 @@ namespace vcsn
XMLCh* writingData;
XMLCh* identitySymbol;
XMLCh* zeroSymbol;
XMLCh* concat;
XMLCh* openPar;
XMLCh* closePar;
XMLCh* plus;
......
......@@ -67,14 +67,17 @@ namespace vcsn
writingData = xercesc::XMLString::transcode("writingData");
/* attributes */
identitySymbol = xercesc::XMLString::transcode("identitySym");
zeroSymbol = xercesc::XMLString::transcode("zeroSym");
concat = xercesc::XMLString::transcode("concatSym");
openPar = xercesc::XMLString::transcode("openPar");
closePar = xercesc::XMLString::transcode("closePar");
plus = xercesc::XMLString::transcode("plus");
times = xercesc::XMLString::transcode("times");
plus = xercesc::XMLString::transcode("plusSym");
times = xercesc::XMLString::transcode("timesSym");
openWeight = xercesc::XMLString::transcode("openWeight");
closeWeight = xercesc::XMLString::transcode("closeWeight");
spaces = xercesc::XMLString::transcode("spaces");
spaces = xercesc::XMLString::transcode("spacesSym");
value = xercesc::XMLString::transcode("value");
id = xercesc::XMLString::transcode("id");
......@@ -124,6 +127,12 @@ namespace vcsn
xercesc::XMLString::release(&monElmt);
xercesc::XMLString::release(&weight);
xercesc::XMLString::release(&writingData);
xercesc::XMLString::release(&identitySymbol);
xercesc::XMLString::release(&zeroSymbol);
xercesc::XMLString::release(&concat);
xercesc::XMLString::release(&openPar);
xercesc::XMLString::release(&closePar);
xercesc::XMLString::release(&plus);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment