13 std::string filename(
"$(XMLBASEROOT)/xml/myIFile.xml");
21 lookFor(ifile,
"section1",
"section1-val1");
22 lookFor(ifile,
"section1",
"section1-val2");
23 lookFor(ifile,
"subsection",
"subsectionItem");
24 lookFor(ifile,
"section2",
"subsectionItem");
25 lookFor(ifile,
"section2",
"bad-int");
27 else std::cout <<
"Unable to read file " << ifile << std::endl;
31 std::string filename2(
"$(XMLBASEROOT)/xml/mySchemaIFile.xml");
33 std::cout << std::endl << std::endl;
34 std::cout <<
"And for my next trick: process an IFile using XML Schema.";
35 std::cout << std::endl;
37 "This file should be flagged bad; it doesn't follow schema content model."
38 << std::endl << std::endl;
47 lookFor(ifile2,
"section1",
"section1-val1");
48 lookFor(ifile2,
"section1",
"section1-val2");
49 lookFor(ifile2,
"subsection",
"subsectionItem");
50 lookFor(ifile2,
"section2",
"subsectionItem");
51 lookFor(ifile2,
"section2",
"bad-int");
53 else std::cout <<
"Unable to read file " << ifile2 << std::endl;
59 bool haveItem = ifile->
contains(section, item);
60 std::cout <<
"Item " << item <<
" in section " << section;
63 std::cout <<
" was found." << std::endl;
65 const char* charRep = ifile->
getString(section, item);
66 std::cout <<
"..as a string = " << charRep << std::endl;
69 int intRep = ifile->
getInt(section, item);
70 std::cout <<
"..as an int = " << intRep << std::endl;
73 std::cout <<
"**ERROR** int conversion failed "
74 << std::endl << std::endl;
78 double doubleRep = ifile->
getDouble(section, item);
79 std::cout <<
"..as a double = " << doubleRep << std::endl;
82 std::cout <<
" **ERROR** double conversion failed "
83 << std::endl << std::endl;
87 else std::cout <<
" was NOT found." << std::endl;
virtual int getInt(const char *section, const char *item)
virtual bool contains(const char *section, const char *item)
virtual const char * getString(const char *section, const char *item)
virtual double getDouble(const char *section, const char *item)
void lookFor(xmlBase::IFile *ifile, const char *section, const char *item)
Test program for IFile facility within xmlBase package.