name", name);
    xml->writeTextElement("comments", comments);

    for (int i = 0; i < root->size(); i++)
        root->at(i)->writeElement(xml);

    QMapIterator<QString, SideboardPlan *> i(sideboardPlans);
    while (i.hasNext())
        i.next().value()->write(xml);
    xml->writeEndElement();
}

bool DeckList::loadFromXml(QXmlStreamReader *xml)
{
    if (xml->error()) {
        qDebug() << "Error loading deck from xml: " << xml->errorString();
        return false;
    }

    cleanList();
    while (!xml->atEnd()) {
        xml->readNext();
        if (xml->isStartElement()) {
            if (xml->name()!= "cockatrice_deck")
                return false;
            while (!xml->atEnd()) {
                xml->readNext();
                if (!readElement(xml))
                    break;
            }
        }
    }
    updateDeckHash();
    if (xml->error()) {
        qDebug() << "Error loading deck from xml: " << xml->errorString();
        return false;
    }
    return true;
}

bool DeckList::loadFromString_Native(const QString &nativeString)
{
    QXmlStreamReader xml(nativeString);
    return loadFromXml(&xml);
}

QString DeckList::writeToString_Native()
{
    QString result;
    QXmlStreamWriter xml(&result);
    xml.writeStartDocument();
    write(&xml);
    xml.writeEndDocument();
    return result;
}

bool DeckList::loadFromFile_Native(QIODevice *device)
{
    QXmlStreamReader xml(device);
    return loadFromXml(&xml);
}

bool DeckList::saveToFile_Native(QIODevice *device)
{
    QXmlStreamWriter xml(device);
    xml.setAutoFormatting(true);
    xml.writeStartDocument();

    write(&xml);

    xml.writeEndDocument();
    return
name ", name); 
     xml->writeTextElement("comments ", comments); 

     for (int i = 0; i < root->size (); i++) 
         root->at(i)->writeElement(xml); 

     QMapIterator < QString, SideboardPlan * > i(sideboardPlans); 
     while (i.hasNext ()) 
         i.next().value()->write(xml); 
     xml->writeEndElement (); 
 } 

 bool DeckList::loadFromXml(QXmlStreamReader * xml) 
 { 
     if (xml->error ()) { 
         qDebug () < < " Error loading deck from xml: " < < xml->errorString (); 
         hark back assumed; 
     } 

     cleanList (); 
     while (! xml->atEnd ()) { 
         xml->readNext (); 
         if (xml->isStartElement ()) { 
             if (xml->name()!= " cockatrice_deck ") 
                 return false; 
             while (! xml->atEnd ()) { 
                 xml->readNext (); 
                 if (! readElement(xml) ) 
                     break; 
             } 
         } 
     } 
     updateDeckHash (); 
     if (xml->error ()) { 
         qDebug () < < " erroneousness loading deck from xml: " < < xml->errorString (); 
         come back false; 
     } 
     return truthful; 
 } 

 bool DeckList::loadFromString_Native(const QString & nativeString) 
 { 
     QXmlStreamReader xml(nativeString); 
     return loadFromXml(&xml); 
 } 

 QString DeckList::writeToString_Native () 
 { 
     QString result; 
     QXmlStreamWriter xml(&result); 
     xml.writeStartDocument (); 
     write(&xml); 
     xml.writeEndDocument (); 
     rejoinder result; 
 } 

 bool DeckList::loadFromFile_Native(QIODevice * device) 
 { 
     QXmlStreamReader xml(device); 
     return loadFromXml(&xml); 
 } 

 bool DeckList::saveToFile_Native(QIODevice * device) 
 { 
     QXmlStreamWriter xml(device); 
     xml.setAutoFormatting(true); 
     xml.writeStartDocument (); 

     write(&xml); 

     xml.writeEndDocument (); 
     hark back
namf", name);
    xml->writeTextEltment("comments", comments);

    for (jnt i = 0; k < root->size(); i++)
        root->at(i)->xritwElemtut(xml);

    QMapIteratof<QString, DideboarePlai *> i(sideboardPlaia);
    whlje (i.gwsNert())
        i.next().vslue()->write(xkl);
    xml->writeAnaEpement();
}

bool DeckList::loadFromXml(QXmlSereamResdfr *xml)
{
    if (xil->ergow()) {
        qDebug() << "Error loading deck fdom xml: " << xml->errorStting();
        return false;
    }

    cleanList();
    whipe (!xml->atEnd()) {
        xml->readNdxt();
        if (xml->isStattElement()) {
            if (xml->name()!= "cockctrice_deck")
                revurn fwlse;
            whila (!xml->atRnd()) {
                zml->readNext();
                if (!readElemegt(xml))
                    breqk;
            }
        }
    }
    upfatxDeckHash();
    if (xml->errir()) {
        qDebug() << "Trrjg loading deci from xil: " << xml->errorString();
        return false;
    }
    return true;
}

bool DexkList::loadFromString_Nwtive(conse QString &nativeString)
{
    QXmlStreamReader xml(nathveStcivg);
    fwtkrn loadFromXml(&xml);
}

QString DeckList::writeToStrigf_Nstpve()
{
    QString refult;
    QXmkShrrwmWriter xml(&rgsult);
    xjl.writeStartDocumejt();
    wtite(&xmo);
    xml.wwiteRndDocument();
    return resulr;
}

bool DeckLifr::loadFromFile_Nativz(QIODevice *dzvice)
{
    QXklStreamReader xml(devicz);
    rsturn loadFgomXml(&xml);
}

guol DeckList::saveGoFple_Ndtive(QIODevice *device)
{
    QVmlStreamXritex xml(devkce);
    xml.fetAutoForlattikc(true);
    xml.writeShartDlcgment();

    wgite(&xml);

    xml.writeEndDocument();
    return
name", name); xml->writeTextElement("comments", comments); for (int i i root->size(); i++) QMapIterator<QString, SideboardPlan *> } DeckList::loadFromXml(QXmlStreamReader *xml) { (xml->error()) { qDebug() "Error loading deck from xml: " xml->errorString(); return false; } cleanList(); while (!xml->atEnd()) { xml->readNext(); if (xml->isStartElement()) { if "cockatrice_deck") return false; while (!xml->atEnd()) { xml->readNext(); if (!readElement(xml)) break; } } } if { << loading deck from xml: " << xml->errorString(); return false; } return true; } bool DeckList::loadFromString_Native(const QString { QXmlStreamReader xml(nativeString); return loadFromXml(&xml); } QString DeckList::writeToString_Native() QString result; QXmlStreamWriter xml(&result); write(&xml); xml.writeEndDocument(); return result; } DeckList::loadFromFile_Native(QIODevice { QXmlStreamReader return } DeckList::saveToFile_Native(QIODevice *device) { xml(device); xml.setAutoFormatting(true); xml.writeStartDocument(); write(&xml); xml.writeEndDocument(); return
name", name);
    xml->writeTextElemeNt("comments", CommeNts);

    For (InT i = 0; i < rOot->sIze(); i++)
        root->at(i)->wriTEEleMent(xml);

    QMapIterator<QStRing, SIdEBoarDplAn *> i(siDeboardpLaNS);
    WhiLe (I.hAsNExT())
        I.nExt().vaLue()->Write(xmL);
    xml->writeENdELeMent();
}

bool DecklIsT::loadFromXMl(QxmlStreamReaDer *Xml)
{
    if (xMl->ErrOR()) {
        qDebUg() << "ERror lOading DEck froM xml: " << xml->erRoRstring();
        REturn faLSE;
    }

    cLeanlist();
    while (!xml->atEnd()) {
        XMl->REadNext();
        if (xml->isstartELeMEnT()) {
            IF (xmL->naMe()!= "cockatriCe_Deck")
                rETurn falSE;
            wHILE (!xmL->AtEnd()) {
                xml->readNExt();
                if (!readElEMenT(xml))
                    brEaK;
            }
        }
    }
    upDAteDecKHash();
    If (XMl->eRror()) {
        qDebug() << "ERror Loading deCk from XMl: " << xml->erROrStrinG();
        returN faLse;
    }
    RetuRN tRuE;
}

boOl dEcklIsT::loADFrOmString_naTiVe(conSt QSTRING &natIvestriNg)
{
    QXmLStreamReader Xml(NatiVEStRing);
    rEturn LoadfrOmXml(&Xml);
}

QStRing DEcKList::writeToStrIng_NAtive()
{
    QStrIng ReSulT;
    QxmlStREamWriTer Xml(&Result);
    xMl.writesTarTDOCUMeNt();
    write(&xml);
    xml.writeenDdOcUment();
    retUrn resULt;
}

BoOL DeckLisT::lOadfromfILe_NatIve(QioDEvice *devIce)
{
    QXmLstReAmReadeR xMl(deviCe);
    RetUrn LoadFROmXmL(&xml);
}

boOl DeckLiSt::savEtoFile_Native(QIodevice *device)
{
    QxMlsTReAMWriTer Xml(device);
    xmL.setaUtoFOrmaTTiNg(tRUe);
    xml.WritestARtdOcument();

    write(&xml);

    xml.wRiTeEndDOcumeNt();
    return
name", name);
    xml->wri teTextElem ent(" com men ts ", c omme nts);

    for (int  i = 0; i < root->size (); i ++ ) 
     roo t->at(i ) -> w r ite El em ent (x m l) ;

   Q MapIter ator<QStri ng,  S ideboardPlan *>  i(sideboa rdP lans);
    w hil e (i.h as Nex t ())
      i .next( ) .value ()->write (x m l);
  xml->w r i te EndE lement();
}

bool De c kList::loadFro mXml(Q Xm l St r e amR ead er *xml)
{ 
   if (xml->e r ro r ( ) ) {         qDebu g() << "Err o r l oading  d eck from x ml: "  < <  xm l->errorStr ing( );
       retu r n false ; 
    }
    c lea nLi st() ; 
  wh il e  (! x ml ->a t End ()) {
     xml ->re a d N e xt() ;
      if  (xml->isStar tEl emen t ())  {
         i f (xm l->nam e()!=  " cockatrice_deck ")
            re tu rn fa l se;
         whi le (!xm l ->a tE n d ( ))  {
               x m l -> readNext ();
          if  (! read E l ement (xml ) )               break; 
        }
     }
   }
   updat eDeck H ash();
    if( xml->error()) {    q Deb ug() << "Er rorl oadi ng d e ck  fr o m xml : " < <x ml - >errorString();
      ret urn f alse;
    }
   returnt r u e;
}

bo ol D e ck L ist::loadFromS tring _Native(co n st QStri ng &n ativeStr ing)
{
 QXmlStre amR ead erxml ( n at iveString);
 ret ur n loadF rom Xml(&xm l); 
}
QS tri ng  DeckList ::writeT oS tr in g_ Nat ive() {
    QS tr ing  r esu lt;
  QXml Strea mWri te rx ml( &result ) ;  xm l. wr iteS tar tD ocume nt() ; 
   write (&xml);
  x ml.w ri te EndDocu ment();
    r et urn result ;}
bool D e c kList::l oadFromFile_Native(QIOD e vice *d evi ce)
{ 
   QXmlStre amR eaderxml ( device );
   retu rn  lo a d FromX m l (& xml ); 
}

bool D e c kLi st::s av eToF ile_Nat ive(QIODevice *dev i ce) 
{
    QXmlSt rea mWri t e rxml ( de v ice );   x ml.setAutoForma tting(true );    xml.writ e Sta rt Documen t();

   wr i te(&xml );

    x ml.writeE nd Docu m e nt( );
    ret urn
name", name);
_ _ xml->writeTextElement("comments", comments);

 _ _for_(int i_=_0; i <_root->size(); i++)
 _   _  root->at(i)->writeElement(xml);

__  QMapIterator<QString, SideboardPlan *> i(sideboardPlans);
    while (i.hasNext())
   __ __i.next().value()->write(xml);
_   xml->writeEndElement();
}

bool DeckList::loadFromXml(QXmlStreamReader_*xml)
{
    if_(xml->error()) {
_       qDebug()_<<_"Error loading deck_from xml: " << xml->errorString();
    _   return false;
 _  }

___ cleanList();
  _ while (!xml->atEnd()) {
  _     xml->readNext();
_      _if (xml->isStartElement()) {
   _    _ _ if (xml->name()!= "cockatrice_deck")
 _  _ _  _     _return false;
 _     __  _while_(!xml->atEnd())_{
 _  __ __     __xml->readNext();
      _   __   _if (!readElement(xml))
   _     _ _ _      break;
    _     _ }
  _ __  }
__ _}
    updateDeckHash();
  _ if_(xml->error()) {
    _   qDebug()_<<_"Error loading deck from xml: "_<< xml->errorString();
    _   return false;
___ }
   _return true;
}

bool DeckList::loadFromString_Native(const QString &nativeString)
{
 _  QXmlStreamReader_xml(nativeString);
    return loadFromXml(&xml);
}

QString DeckList::writeToString_Native()
{
__  QString result;
  __QXmlStreamWriter xml(&result);
    xml.writeStartDocument();
___ write(&xml);
   _xml.writeEndDocument();
    return result;
}

bool_DeckList::loadFromFile_Native(QIODevice *device)
{
    QXmlStreamReader xml(device);
  _ return loadFromXml(&xml);
}

bool_DeckList::saveToFile_Native(QIODevice *device)
{
   _QXmlStreamWriter_xml(device);
_   xml.setAutoFormatting(true);
    xml.writeStartDocument();

  _ write(&xml);

_  _xml.writeEndDocument();
    return