void PlaySincro
::ValidateFile( QString xmlfile
) {
bool cvalid = true;
const char *dat;
std::cout << "### loading file wait... " << fi.fileName().toAscii().data() << " Size/" << BiteorMega(fi.size()).toAscii().data() << std::endl;
if( file.
open( QFile::ReadOnly |
QFile::Text ) ) { int cur = 0;
while( ! in.atEnd() ) {
re.append(line);
cur++;
switch(cur)
{
case 1:
dat ="-";
break;
case 2:
dat ="\\";
break;
case 3:
dat ="|";
break;
case 4:
dat ="/";
cur = 0;
break;
}
std::cout << "Read file " << fi.fileName().toAscii().data() << " [" << dat << "]\r";
fflush ( stdin );
}
}
Qxml doc; /* class Qxml : public QDomDocument */
int errorLine, errorColumn, position;
if (!doc.setContent(re,false, &errorStr, &errorLine, &errorColumn)) {
std::cout << "### Unable to read XML file! errorLine" << errorLine << " errorColumn" << errorColumn << std::endl;
return;
}
QString user
= doc.
GetAtt(query,
"user");
QString summs
= doc.
GetAtt(query,
"sumrow");
QString cools
= doc.
GetAtt(query,
"sumcool");
QString data
= doc.
GetAtt(root,
"build");
QString org
= doc.
GetAtt(root,
"org");
if (data.size() < 1 && user.size() < 1 && summs.size() < 1 && cools.size() < 1 && org.size() < 1) {
cvalid = false;
}
if (root.tagName() != "odbc_root" ) {
cvalid = false;
}
if (cvalid) {
std::cout << "###" << xmlfile.toAscii().data() << " valid Ok! From " << user.toAscii().data() << std::endl;
PlayFileDom(root,org);
doc.clear();
} else {
std::cout << "###" << xmlfile.toAscii().data() << " not valid!" << std::endl;
}
}
void PlaySincro::ValidateFile( QString xmlfile )
{
QFileInfo fi(xmlfile);
bool cvalid = true;
QString re;
QFile file( xmlfile );
const char *dat;
std::cout << "### loading file wait... " << fi.fileName().toAscii().data() << " Size/" << BiteorMega(fi.size()).toAscii().data() << std::endl;
if( file.open( QFile::ReadOnly | QFile::Text ) ) {
QTextStream in( &file );
int cur = 0;
while( ! in.atEnd() ) {
QString line = QString( in.readLine() );
re.append(line);
cur++;
switch(cur)
{
case 1:
dat ="-";
break;
case 2:
dat ="\\";
break;
case 3:
dat ="|";
break;
case 4:
dat ="/";
cur = 0;
break;
}
std::cout << "Read file " << fi.fileName().toAscii().data() << " [" << dat << "]\r";
fflush ( stdin );
}
}
Qxml doc; /* class Qxml : public QDomDocument */
QString errorStr;
int errorLine, errorColumn, position;
if (!doc.setContent(re,false, &errorStr, &errorLine, &errorColumn)) {
std::cout << "### Unable to read XML file! errorLine" << errorLine << " errorColumn" << errorColumn << std::endl;
return;
}
QDomElement root = doc.root();
QDomElement query = root.firstChildElement("query");
QString user = doc.GetAtt(query,"user");
QString summs = doc.GetAtt(query,"sumrow");
QString cools = doc.GetAtt(query,"sumcool");
QString data = doc.GetAtt(root,"build");
QString org = doc.GetAtt(root,"org");
if (data.size() < 1 && user.size() < 1 && summs.size() < 1 && cools.size() < 1 && org.size() < 1) {
cvalid = false;
}
if (root.tagName() != "odbc_root" ) {
cvalid = false;
}
if (cvalid) {
std::cout << "###" << xmlfile.toAscii().data() << " valid Ok! From " << user.toAscii().data() << std::endl;
PlayFileDom(root,org);
doc.clear();
} else {
std::cout << "###" << xmlfile.toAscii().data() << " not valid!" << std::endl;
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks