Just for testing purposes: This example reads an EDS file and prints the resulting dictionary.
#include "eds_reader.h"
#include "logger.h"
#include <tuple>
#include <algorithm>
int main(int argc, char** argv) {
PRINT("This example reads an EDS file and prints the resulting dictionary.");
std::unordered_map<kaco::Address, kaco::Entry> dictionary;
std::unordered_map<std::string, kaco::Address> name_to_address;
bool success = false;
std::string path;
if (argc>1 && argv[1]) {
path = std::string(argv[1]);
PRINT("Loading EDS file from "<<path);
} else {
path = SHARE_SOURCE_PATH "/example.eds";
PRINT("Loading default EDS file from "<<path);
if (!success) {
path = SHARE_INSTALLED_PATH "/example.eds";
PRINT("Another try: Loading default EDS file from "<<path);
}
}
if (!success) {
ERROR("Loading file not successful. You can specify the path to the EDS file as command line argument.");
return EXIT_FAILURE;
}
if (!success) {
ERROR("Importing entries failed.");
return EXIT_FAILURE;
}
PRINT("Here is the dictionary:");
using EntryRef = std::reference_wrapper<const kaco::Entry>;
std::vector<EntryRef> entries;
for (const auto& pair : dictionary) {
entries.push_back(std::ref(pair.second));
}
std::sort(entries.begin(), entries.end(),
[](const EntryRef& l, const EntryRef& r) { return l.get()<r.get(); });
for (const auto& entry : entries) {
entry.get().print();
}
return EXIT_SUCCESS;
}