-
Notifications
You must be signed in to change notification settings - Fork 3
/
print_version.cpp
36 lines (35 loc) · 910 Bytes
/
print_version.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <mpolib/mpo_xml.h>
#include <mpolib/mpo_fileio.h>
#include <mpolib/mpo_misc.h>
int main(int argc, char **argv)
{
mpo_io *io = mpo_open("DaphneManifest.xml", MPO_OPEN_READONLY);
if (io)
{
string strErrMsg;
bool bRes;
mpo_xml x;
mpo_buf buf;
buf.alloc(io->size);
mpo_read(buf.data(), buf.size(), NULL, io);
bRes = x.parse(buf.data(), buf.size(), strErrMsg);
if (bRes)
{
const xml_element *e = x.get_parsed_element();
const xml_element *pElVer = x.find_child(e, "version", false);
const xml_element *pChild = x.find_child(pElVer, "major", false);
cout << pChild->text << ".";
pChild = x.find_child(pElVer, "minor", false);
cout << pChild->text << ".";
pChild = x.find_child(pElVer, "build", false);
cout << pChild->text;
}
else
{
cerr << "ERROR IN PRINT_VERSION : XML parse failed!" << endl;
}
mpo_close(io);
}
return 0;
}