A small Boost property tree library syntax problem

Hi!

Working on a software that needs data from the XML available here:http://api.eve-central.com/api/quicklook?typeid=34&usesystem=30000142

Therefor I need to import that data, and I chose boost property tree to help me with that.

I've spent most of a day reading up on it and quite a few hours on this problem in particular. So would really appreciate some help.

So the problem I have is that I don't know how to create a nested load function that lets me load elements that are nested. In this case, all the data inside the order.

I simply want to know how I access each order(inside the XML document) once and put it's data into the set container. current code:

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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/foreach.hpp>
#include <string>
#include <set>
#include <exception>
#include <iostream>


class Order{
    protected:
        const string m_StationName,m_Expires, m_ReportedTime, m_OrderID;
        const int m_Region, m_Station, m_Security, m_Range, m_Price, m_VolRemain, m_MinVolume;

    public:
        //constructor
        Order(string orderID, string station, string expires,string reported, int region, int station,int security, int range, int price, int volremain, int minvolume){
            m_OrderID = orderID;
            m_StationName = station;
            m_Expires = expires;
            m_ReportedTime = reported;
            m_Region = region;
            m_Station = station;
            m_Security = security;
            m_Range = range;
            m_Price = price;
            m_VolRemain = volremain;
            m_MinVolume = minvolume;
        }

        const string getStationName(){return m_StationName;};
        const string getExpires(){return m_Expires;};
        const string getReportedTime(){return m_ReportedTime;};
        const int getRegion(){return m_Region;};
        const int getStation(){return m_Station;};
        const int getSecurity(){return m_Security;};
        const int getRange(){return m_Range;};
        const int getPrice(){return m_Price;};
        const int getVolRemain(){return m_VolRemain;};
        const int getMinVolume(){return m_MinVolume;};


};

class MarketItem{
    protected:
        const int m_ItemID, m_Hours, m_Minqty;
        const string m_ItemName;
        //unigue Order IDs
        std::set<Order> m_SellOrders, m_BuyOrders;
    public:
        //get the data from the XML parser and extract the data
        void load(int);

        const int getItemID(){return m_ItemID;};
        const int getHours(){return m_Hours;};
        const int getMinqty(){return m_ItemName;};
        string getItemName(){return m_ItemName;};

        //they don't need to change thereof const &
        const std::set<Order>& getSellOrders(){return const std::set<Order>& temp = m_SellOrders;};
        const std::set<Order>& getBuyOrders(){return const std::set<Order>& temp = m_BuyOrders;};

};

void marketItem::load(int itemID){
    using boost::property_tree::ptree
    ptree pt;

    read_xml( ,pt)
    //load all the values
    m_ItemID = pt.get<std::int>("quicklook.item");
    m_ItemName = pt.get<std::string>("quicklook.itemname");
    m_Hours = pt.get<std::int>("quicklook.hours");
    m_Minqty = pt.get<std::int>("quicklook.minqty");


//this is where the problem is:
    BOOST_FOREACH(ptree::value_type &v, pt.get_child("quicklook.sell_orders")){
    }
}


the five minute tutorial:http://www.boost.org/doc/libs/1_53_0/doc/html/boost_propertytree/tutorial.html

further documentation is available here: http://www.boost.org/doc/libs/1_53_0/doc/html/property_tree.html#boost_propertytree.intro

And I also need some help with getting to that internet document but I already posted a thread for that. Either create a file and read that or if the read_xml function can handle it, take it directly from the webpage.
Last edited on
Topic archived. No new replies allowed.