#include "plist/Boolean.h"
#include <fstream>
#include <iostream>
#include <plist/Dictionary.h>
#include <plist/plist++.h>
#include <sstream>
int main(int argc, char *argv[]) {
if (argc != 3) {
printf("Wrong input\n");
return 1;
}
const char *file_in = argv[1];
const char *file_out = argv[2];
std::ifstream iplist;
iplist.open(file_in);
if (!iplist) {
printf("File does not exists\n");
return 2;
}
std::cout << "File " << file_in << " is open\n";
std::string plist_xml;
{
std::stringstream buffer;
buffer << iplist.rdbuf();
plist_xml = buffer.str();
}
iplist.close();
PList::Structure *root_node1 = PList::Structure::FromXml(plist_xml);
if (!root_node1) {
std::cout << "PList XML parsing failed\n";
return 3;
}
std::cout << "PList XML parsing succeeded\n";
std::vector<char> plist_bin = root_node1->ToBin();
std::cout << "PList BIN writing succeeded\n";
PList::Structure *root_node2 = PList::Structure::FromBin(plist_bin);
if (!root_node2) {
std::cout << "PList BIN parsing failed\n";
return 5;
}
PList::Dictionary dict = PList::Dictionary();
dict.Set("ur mom", PList::Boolean(true));
std::cout << "PList BIN parsing succeeded\n";
std::string plist_xml2 = root_node2->ToXml();
if (plist_xml2.empty()) {
std::cout << "PList XML writing failed\n";
return 8;
}
std::cout << "PList XML writing succeeded\n";
{
std::ofstream oplist;
oplist.open(file_out);
oplist << plist_xml2;
}
std::cout << "Input size : " << plist_xml.size()
<< "\nOutput size : " << plist_xml2.size() << '\n';
return 0;
}