// our includes #include "XMLMirror.h" #include "XMLSpec.h" using namespace std; // attribute structure for XMLMirror structValidAttrs g_paMirrorAttrs[] = { {0x0000, true, false, "path", XATTRTYPE_STRING, {"*", NULL}}, {0x0001, false, false, "description", XATTRTYPE_STRING, {"*", NULL}}, {0x0002, false, false, "country", XATTRTYPE_STRING, {"*", NULL}}, {XATTR_END, false, false, "end", XATTRTYPE_NONE, {NULL}} }; bool XMLMirror::parseCreate(XMLAttrs* pAttrs, XMLSpec* pSpec, bool bPatch) { // validate the attributes if (!pAttrs->validate(g_paMirrorAttrs, (XMLBase*)pSpec)) return false; XMLMirror mirror(pAttrs->asString("path"), pAttrs->asString("description"), pAttrs->asString("country")); if (bPatch && pSpec->numPatches()) pSpec->lastPatch().addMirror(mirror); else if (!bPatch && pSpec->numSources()) pSpec->lastSource().addMirror(mirror); return true; } XMLMirror::XMLMirror(const char* szPath, const char* szDescription, const char* szCountry) : XMLBase() { if (szPath) m_sPath.assign(szPath); if (szDescription) m_sDescription.assign(szDescription); if (szCountry) m_sCountry.assign(szCountry); } XMLMirror::XMLMirror(const XMLMirror& rMirror) : XMLBase() { m_sPath.assign(rMirror.m_sPath); m_sDescription.assign(rMirror.m_sDescription); m_sCountry.assign(rMirror.m_sCountry); } XMLMirror::~XMLMirror() { } XMLMirror XMLMirror::operator=(XMLMirror mirror) { m_sPath.assign(mirror.m_sPath); m_sDescription.assign(mirror.m_sDescription); m_sCountry.assign(mirror.m_sCountry); } void XMLMirror::toSpecFile(ostream& rOut) { rOut << endl << "# mirror: " << getPath(); } void XMLMirror::toXMLFile(ostream& rOut) { rOut << endl << "\t\t"; }