-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxml_reader.cpp
More file actions
61 lines (54 loc) · 1.94 KB
/
Copy pathxml_reader.cpp
File metadata and controls
61 lines (54 loc) · 1.94 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "xml_reader.h"
// constructor
xml_reader::xml_reader(const std::string filename)
{
std::cout << "Created xml read class object @PSA" << std::endl;
xml_reader::get_fileName(filename);
}
// destructor
xml_reader::~xml_reader()
{
std::cout << "destroyed xml read class object @PSA" << std::endl;
}
// get file name
int xml_reader::get_fileName(const std::string filename)
{
// Here we implement get file name
// we assigne file name to a char variable
// this can then be used by other members for further parsing, processing of the file
if (filename.length() == 0)
{
std::cout << "Error: No file name and path provided!" << std::endl;
return 0;
}
else
{
std::cout << "Got the file name correctly" << std::endl;
}
// Load the XML file into the property tree. If reading fails
// (cannot open file, parse error), an exception is thrown.
boost::property_tree::xml_parser::read_xml(filename, my_ptree_obj);
return 1;
}
// set xml attributes
void xml_reader::set_xmlAttributes()
{
// here we set xml attributes to vars
std::cout << "WARNING: Not yet implemented " << std::endl;
}
// print out xml attributes
void xml_reader::print_xmlAttributes()
{
// here we print test attributes
int i = 0;
BOOST_FOREACH(ptree::value_type & child, xml_reader::my_ptree_obj.get_child("localinfo.player_info"))
{
std::cout << " " << std::endl;
std::cout << i << std::endl; i++;
std::cout << "Node name: " << child.first << std::endl;
std::cout << "Pass value: " << child.second.get<std::string>("<xmlattr>.pass") << std::endl;
std::cout << "isSave value: " << child.second.get<int>("<xmlattr>.isSave") << std::endl;
std::cout << "isLastLogin value: " << child.second.get<int>("<xmlattr>.isLastLogin") << std::endl;
std::cout << "account value: " << child.second.get<std::string>("<xmlattr>.account") << std::endl;
}
}