// --------------------------------------------------------------------------
+ /*
+ * xpath and multiplicity of processed nodes are included in the code
+ * for convenience:
+ *
+ * // xpath: <xpath> (?|*|+)
+ *
+ * if multiplicity is ommited, then the node has multiplicity 'one'.
+ */
+
+ // --------------------------------------------------------------------------
+
bool PatchFileReader::consumeNode(Reader & reader_r)
{
if (isBeingProcessed(tag_atoms) && consumeAtomsNode(reader_r))
_patch->description.setText(reader_r.nodeText().asString(), locale);
return true;
}
-
- // xpath: /patch/licence-to-confirm
+
+ // xpath: /patch/licence-to-confirm (*)
if (reader_r->name() == "license-to-confirm")
{
+ // TODO support several licenses in several languages?
Locale locale(reader_r->getAttribute("lang").asString());
_patch->licenseToConfirm.setText(reader_r.nodeText().asString(), locale);
return true;
return true;
}
- // xpath: /patch/reboot-needed
+ // xpath: /patch/reboot-needed (?)
if (reader_r->name() == "reboot-needed")
{
_patch->rebootNeeded = true;
return true;
}
- // xpath: /patch/package-manager
+ // xpath: /patch/package-manager (?)
if (reader_r->name() == "package-manager")
{
_patch->affectsPkgManager = true;
return true;
}
- // TODO xpath: /patch/update-script
+ // xpath: /patch/update-script (?)
+ if (reader_r->name() == "update-script")
+ {
+ _patch->updateScript = reader_r.nodeText().asString();
+ }
- // xpath: /patch/atoms
+ // xpath: /patch/atoms (+)
if (reader_r->name() == "atoms")
{
// remember that we are processing atoms from now on
// xpath: /patch/atoms/*
tag(tag_atoms);
- // no need to further process this node so not calling consumeAtomsNode();
+ // no need to further process this node so not calling
+ // consumeAtomsNode() here
return true;
}
}
if (reader_r->name() == "package")
{
data::Atom_Ptr atom_ptr = new data::Atom;
- copyAtomFromTmpObj(atom_ptr);
+ copyPackageAtomFromTmpObj(atom_ptr);
_patch->atoms.insert(atom_ptr);
DBG << "Atom " << atom_ptr->name << " " << atom_ptr->edition << " successfully read." << endl;
bool PatchFileReader::consumeMessageNode(Reader & reader_r)
{
- if (FileReaderBase::consumeDependency(reader_r, _tmpResObj->deps))
+ if (consumeDependency(reader_r, _tmpResObj->deps))
return true;
if (reader_r->nodeType() == XML_READER_TYPE_ELEMENT)
bool PatchFileReader::consumeScriptNode(Reader & reader_r)
{
+ if (consumeDependency(reader_r, _tmpResObj->deps))
+ return true;
+
if (reader_r->nodeType() == XML_READER_TYPE_ELEMENT)
{
+ data::Script_Ptr script = dynamic_pointer_cast<data::Script>(_tmpResObj);
+ if (!script)
+ {
+ WAR << "data::Script object expected, but not found" << endl;
+ return true;
+ }
+
// xpath: /patch/atoms/script/yum:name
if (reader_r->name() == "yum:name")
{
reader_r->getAttribute("epoch").asString());
return true;
}
+
+ // xpath: /patch/atoms/script/do
+ if (reader_r->name() == "do")
+ {
+ script->doScript = reader_r.nodeText().asString();
+ return true;
+ }
+
+ // xpath: /patch/atoms/script/undo
+ if (reader_r->name() == "undo")
+ {
+ script->undoScript = reader_r.nodeText().asString();
+ return true;
+ }
+
+ // TODO xpath: /patch/atoms/script/do-location
+ if (reader_r->name() == "do-location")
+ {
+ // xsd:anyURI
+// script->doScriptLocation.filepath = reader_r->getAttribute("xml:base").asString();
+ // xsd:anyURI
+// script->doScriptLocation.? = reader_r->getAttribute("href").asString();
+ return true;
+ }
+
+ // xpath: /patch/atoms/script/do-checksum
+ if (reader_r->name() == "do-checksum")
+ {
+ script->doScriptLocation.fileChecksum = CheckSum(
+ reader_r->getAttribute("type").asString(),
+ reader_r.nodeText().asString());
+ return true;
+ }
+
+ // TODO xpath: /patch/atoms/script/undo-location
+ if (reader_r->name() == "undo-location")
+ {
+ // xsd:anyURI
+// script->undoScriptLocation.filepath = reader_r->getAttribute("xml:base").asString();
+ // xsd:anyURI
+// script->undoScriptLocation.? = reader_r->getAttribute("href").asString();
+ return true;
+ }
+
+ // xpath: /patch/atoms/script/undo-checksum
+ if (reader_r->name() == "undo-checksum")
+ {
+ script->undoScriptLocation.fileChecksum = CheckSum(
+ reader_r->getAttribute("type").asString(),
+ reader_r.nodeText().asString());
+ return true;
+ }
}
else if (reader_r->nodeType() == XML_READER_TYPE_END_ELEMENT)
// --------------------------------------------------------------------------
- void PatchFileReader::copyAtomFromTmpObj(data::Atom_Ptr & atom_ptr) const
+ void PatchFileReader::copyPackageAtomFromTmpObj(data::Atom_Ptr & atom_ptr) const
{
atom_ptr->name = _tmpResObj->name;
atom_ptr->edition = _tmpResObj->edition;
/**
+ * Reader of patch.xml files conforming to RNC/RNG definition located
+ * in zypp/parser/yum/schema/patch.rn(c|g).
*
+ * \see zypp::data::Patch
+ * \see zypp::parser::xml::Reader
*/
class PatchFileReader : FileReaderBase
{
public:
/**
- * Callback definition.
+ * Consumer callback definition. Function which will process the read
+ * data must be of this type.
*/
typedef function<bool(const data::Patch_Ptr &)> ProcessPatch;
/**
- *
+ * CTOR. Creates also \ref xml::Reader and starts reading.
+ *
+ * \param patch_file patch.xml file to read.
+ * \param callback Function which will process read data.
*/
PatchFileReader(const Pathname & patch_file, ProcessPatch callback);
bool consumeNode(xml::Reader & reader_r);
/**
- * Process atoms node and all of its children.
+ * Process <tt>atoms</tt> node and all of its children.
*
+ * \param reader_r XML file reader reading the patch file.
* \return true if current node has been completely processed, false
* if additional processing is required outside of the method.
*/
bool consumeAtomsNode(xml::Reader & reader_r);
+ /**
+ * Process <tt>message</tt> node and all of its children.
+ *
+ * \param reader_r XML file reader reading the patch file.
+ * \return true if current node has been completely processed, false
+ * if additional processing is required outside of the method.
+ */
bool consumeMessageNode(xml::Reader & reader_r);
+ /**
+ * Process <tt>script</tt> node and all of its children.
+ *
+ * \param reader_r XML file reader reading the patch file.
+ * \return true if current node has been completely processed, false
+ * if additional processing is required outside of the method.
+ */
bool consumeScriptNode(xml::Reader & reader_r);
/**
*/
data::Patch_Ptr handoutPatch();
+ /**
+ * Creates a new \ref data::ResObject_Ptr, swap its contents with
+ * \ref _tmpResObj and inserts it into <tt>_patch.atoms</tt>. Used
+ * after an atom is read.
+ */
void saveAtomInPatch();
-
- void copyAtomFromTmpObj(data::Atom_Ptr & atom_ptr) const;
+
+ /**
+ *
+ */
+ void copyPackageAtomFromTmpObj(data::Atom_Ptr & atom_ptr) const;
private:
/**