| hasanfaraz (6) | |
|
Hi, I have written this code for reading xml file and converting it to property tree using boost, but I'm getting few errors . I am new to c++ and might have done some simple mistakes. Kindly help me in solving this code. PFB the xml file and the c++ code for parsing it. PositionManagement.xml <?xml version="1.0" encoding="utf-8"?> <ProjectSchema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <PositionManagementTeam> <PositionManagementTeams Name= "KarunakaraReddy Vasipalli" Designation="SA" ID="1001"/> <PositionManagementTeams Name= "Hasan Faraz" Designation="PA" ID="1002"/> <PositionManagementTeams Name= "Hitesh Patil" Designation="SA" ID="1003"/> <PositionManagementTeams Name= "Prashant Nidgunde" Designation="SA" ID="1004"/> <PositionManagementTeams Name= "Madhur Tony" Designation="SA" ID="1005"/> <PositionManagementTeams Name= "Tarun Kumar" Designation="SA" ID="1006"/> <PositionManagementTeams Name= "Manish Doijode" Designation="DBA" ID="1007"/> <PositionManagementTeams Name= "Kunal Kabra" Designation="SA" ID="1008"/> <PositionManagementTeams Name= "Prathiba" Designation="PM" ID="1009"/> </PositionManagementTeam> </ProjectSchema> C++ code: #include "stdafx.h" #include <iostream> #include <boost/property_tree/ptree.hpp> #include <boost/property_tree/xml_parser.hpp> #include <boost/foreach.hpp> #include <string> #include <algorithm> #include <vector> using namespace std; /*void PositionManagementDetailsSave(const string &); void PositionManagementDetailsLoad(const string &); */ struct PositionManagement { string Name; string Designation; int ID; void PositionManagementDetailsSave(const string &); void PositionManagementDetailsLoad(const string &); }; typedef vector<PositionManagement> PM; void PositionManagementDetailsSave(const std::string &filename) { using boost::property_tree::ptree; ptree pt; read_xml(filename,pt); PM pm1; BOOST_FOREACH(ptree::value_type &v,pt.get_child("ProjectSchema.PositionManagementTeam")) { if (v.first == "PositionManagementTeams") { PositionManagement pm2; pm2.Name=v.second.get<string>("<xmlattr>.Name"); pm2.Designation=v.second.get<string>("<xmlattr>.Designation"); pm2.ID=v.second.get<int>("<xmlattr>.ID"); pm1.push_back(pm2); } } } void PositionManagementDetailsLoad(const std::string &filename) { using boost::property_tree::ptree; ptree pt; PositionManagement pm2; //BOOST_FOREACH(ptree::) pt.put("ProjectSchema.PositionManagementTeam.PositionManagementTeams.Name",pm2.Name); pt.put("ProjectSchema.PositionManagementTeam.PositionManagementTeams.Designation",pm2.Designation); pt.put("ProjectSchema.PositionManagementTeam.PositionManagementTeams.ID",pm2.ID); write_xml(filename,pt); } int main(int argc, _TCHAR* argv[]) { try { PositionManagement pm3; pm3.PositionManagementDetailsSave("PositionManagement.xml"); pm3.PositionManagementDetailsLoad("PositionManagement_out.xml"); std::cout << "Success\n"; } catch (std::exception &e) { std::cout << "Error: " << e.what() << "\n"; } return 0; } the errors that I;m getting are: >XmlParserApp.obj : error LNK2019: unresolved external symbol "public: void __thiscall PositionManagement::PositionManagementDetailsLoad(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?PositionManagementDetailsLoad@PositionManagement@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main 1>XmlParserApp.obj : error LNK2019: unresolved external symbol "public: void __thiscall PositionManagement::PositionManagementDetailsSave(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?PositionManagementDetailsSave@PositionManagement@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main | |
|
|
|
| AbstractionAnon (412) | |||
You have declared PositionManagementDetailsSave and PositionManagementDetailsLoad to be member functions of struct PositionManagement. Therefore when you implement the functions, you must include the struct name as a scope qualifier just as you would for a member function of a class.
PLEASE USE CODE TAGS (the <> formatting button) when posting code. | |||
|
Last edited on
|
|||