34 using namespace pwiz::util;
36 using namespace pwiz::msdata;
55 virtual std::string identify(
const std::string& filename,
const std::string& head)
const
57 bool result = (filename ==
"1");
58 if (
os_) *
os_ <<
"Reader1::identify(): " << boolalpha << result << endl;
59 return std::string (result?filename:std::string(
""));
62 virtual void read(
const std::string& filename,
63 const std::string& head,
68 if (
os_) *
os_ <<
"Reader1::read()\n";
69 readerConfig.done =
true;
72 virtual void read(
const std::string& filename,
73 const std::string& head,
74 std::vector<MSDataPtr>& results,
78 read(filename, head, *results.back(), 0, config);
81 virtual const char *
getType()
const {
return "Reader1";}
98 virtual std::string identify(
const std::string& filename,
const std::string& head)
const
100 bool result = (filename ==
"2");
101 if (
os_) *
os_ <<
"Reader2::identify(): " << boolalpha << result << endl;
102 return std::string (result?filename:std::string(
""));
105 virtual void read(
const std::string& filename,
106 const std::string& head,
111 if (
os_) *
os_ <<
"Reader2::read()\n";
112 readerConfig.done =
true;
115 virtual void read(
const std::string& filename,
116 const std::string& head,
117 std::vector<MSDataPtr>& results,
121 read(filename, head, *results.back(), 0, config);
124 const char *
getType()
const {
return "Reader2";}
130 if (
os_) *
os_ <<
"testGet()\n";
140 if (
os_) *
os_ <<
"reader1 config: " << reader1->readerConfig.name << endl;
141 unit_assert(reader1->readerConfig.name ==
"default");
142 reader1->readerConfig.name =
"raw";
143 if (
os_) *
os_ <<
"reader1 config: " << reader1->readerConfig.name << endl;
165 if (
os_) *
os_ <<
"testAccept()\n";
171 if (
os_) *
os_ <<
"accept 1:\n";
173 if (
os_) *
os_ <<
"accept 2:\n";
175 if (
os_) *
os_ <<
"accept 3:\n";
184 if (
os_) *
os_ <<
"testRead()\n";
197 if (readers.
accept(
"1",
"head"))
198 readers.
read(
"1",
"head", msd);
201 readers.
get<
Reader1>()->readerConfig.done =
false;
203 if (readers.
accept(
"2",
"head"))
204 readers.
read(
"2",
"head", msd);
216 {ofstream fs(
"testSpectraDataFile.mzedML"); fs <<
"<?xml?><mzML>";}
218 bfs::remove(
"testSpectraDataFile.mzedML");
220 {ofstream fs(
"testSpectraDataFile.mzedXML"); fs <<
"<?xml?><mzXML>";}
222 bfs::remove(
"testSpectraDataFile.mzedXML");
229 config.
format = MSDataFile::Format_MZ5;
235 bfs::remove(
"testSpectraDataFile.Mz5");
237 {ofstream fs(
"testSpectraDataFile.mGF"); fs <<
"MGF";}
239 bfs::remove(
"testSpectraDataFile.mGF");
241 {ofstream fs(
"testSpectraDataFile.Ms2"); fs <<
"MS2";}
243 bfs::remove(
"testSpectraDataFile.Ms2");
245 {ofstream fs(
"testSpectraDataFile.wiFF"); fs <<
"WIFF";}
247 bfs::remove(
"testSpectraDataFile.wiFF");
249 {ofstream fs(
"_FUNC42.DAT"); fs <<
"Life, the Universe, and Everything";}
251 bfs::remove(
"_FUNC42.DAT");
264 int main(
int argc,
char* argv[])
270 if (argc==2 && !strcmp(argv[1],
"-v"))
os_ = &cout;