Overview
Examples
Screenshots
Comparisons
Applications
Download
Manual
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Language
English











SourceForge.net Logo



Xmlize std

 

Xmlize with existing type, in this case std::vector<int>

 

 

Xmlize.cpp

 

#include <Core/Core.h>

#include <vector>

 

namespace Upp {

 

template<> void Xmlize(XmlIO& xml, std::vector<int>& data) {

    if(xml.IsStoring())

        for(int i = 0; i < (int)data.size(); i++)

            Xmlize(xml.Add("item"), data[i]);

    else {

        data.clear();

        for(int i = 0; i < xml->GetCount(); i++)

            if(xml->Node(i).IsTag("item")) {

                data.push_back(0);

                Xmlize(xml.At(i), data.back());

            }

    }

}

 

};

 

using namespace Upp;

using namespace std;

 

CONSOLE_APP_MAIN

{

    StdLogSetup(LOG_COUT|LOG_FILE);

    vector<int> x;

    x.push_back(1);

    x.push_back(2);

    x.push_back(3);

    String s = StoreAsXML(x, "std-test");

    DUMP(s);

    vector<int> y;

    LoadFromXML(y, s);

    for(int i = 0; i < (int)y.size(); i++)

        DUMP(y[i]);

}

 

 

 

 

This page is also in català, čeština, deutsch, español, euskara, français, română, русский, 中文(简体) and 中文(繁體). Do you want to contribute?