void finLigne()
{
unsigned char w=fgetc(XMLFile);
}
string lireMot(string motCible)
{
string mot,lettre,sortie;
mot="";
unsigned char i;
for( i=1; i<44; i++ )
{
lettre=fgetc(XMLFile);
mot=mot+lettre;
//s1.substr( 1, 3 );
if (mot.size()>=motCible.size())
{
if (mot.substr( mot.size()-motCible.size(), motCible.size() )==motCible)
{
goto finMot;
}
if (mot.substr( mot.size()-8, 8 )=="</decks>")
{
sortie="</decks>";
cout<<"fin de TOUT";
goto finMot;
}
}
}
finMot:
i=1;
//cout <<mot<<endl;
//cout <<i*1<<endl;
return(sortie);
}
string lireNoeud(string noeud)
{
string entree="<"+noeud+">";
string sortie="</"+noeud+">";
string mot,lettre;
string contenu;
mot="";
unsigned char i;
//lire entree
for( i=1; i<44; i++ )
{
lettre=fgetc(XMLFile);
mot=mot+lettre;
if (mot.size()>=entree.size())
{
if (mot.substr( mot.size()-entree.size(), entree.size() )==entree)
{goto finEntree;}
}
if (mot.size()>=8)
{
if (mot.substr( mot.size()-8, 8 )=="</decks>")
{
sortie="</decks>";
//cout<<"fin de TOUT";
goto finNoeud;
}
}
if (mot.size()>=10)
{
if (mot.substr( mot.size()-10, 10 )=="</oneDeck>")
{
sortie="</oneDeck>";
//cout<<"fin d un deck";
goto finNoeud;
}
}
}
finEntree:
mot="";
//trouver sortie
for( i=1; i<44; i++ )
{
lettre=fgetc(XMLFile);
mot=mot+lettre;
if (mot.size()>=sortie.size())
{
if (mot.substr( mot.size()-sortie.size(), sortie.size() )==sortie)
{goto finSortie;}
}
}
finSortie:
//deduire contenu
contenu=mot.substr( 0, mot.size()-sortie.size() );
cout <<" >"+contenu+"<"<<endl;
return(contenu);
finNoeud:
//fin d'un noeud
contenu=sortie;
//cout <<"FIN x"+contenu+"x"<<endl;
return(contenu);
}
void lireXML()
{
cout <<"start"<<endl;
unsigned char i,j;
string ligne,mot;
ligne="";
XMLFile = fopen("k2x/decks.txt","r");
for( j=1; j<44; j++ )
{
ligne = ligne+to_string(fgetc(XMLFile));
}
finLigne();
mot=lireMot("<decks>");
//bool finNoeud;
for (i=0;i<19;i++)
{
mot=lireMot("<oneDeck>");
if (mot=="</decks>"){cout <<"fin decks"<<endl;break;}
cout <<" folder:";
mot=lireNoeud("folder");
//if (mot=="</oneDeck>"){cout <<"fin deck"<<endl;break;}
if (mot=="</decks>"){cout <<"fin decks"<<endl;break;}
deckNames[i]=mot;
for (j=0;j<9;j++)
{
mot=lireNoeud("oneVideo");
if (mot=="</oneDeck>"){cout <<"fin deck"<<endl;break;}
if (mot=="</decks>"){cout <<"fin decks"<<endl;break;}
videoNames[i*10+j]=mot;
}
//j=lireMot("</oneDeck>");
if (mot=="</decks>"){cout <<"fin decks"<<endl;break;}
}
maxDeck=i;
fclose (XMLFile);
cout <<"stop"<<endl;
cout <<"decks: ";
cout<<(1*maxDeck)<<endl;/**/
}