#ifndef HFST_OSPELL_ZHFSTOSPELLERXMLMETADATA_H_
#define HFST_OSPELL_ZHFSTOSPELLERXMLMETADATA_H_ 1
#include "hfstol-stdafx.h"
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <map>
using std::map;
#if HAVE_LIBXML
# include <libxml++/libxml++.h>
#elif HAVE_TINYXML2
# include <tinyxml2.h>
#endif
#include "ospell.h"
#include "hfst-ol.h"
namespace hfst_ospell
{
typedef std::map<std::string,std::string> LanguageVersions;
struct ZHfstOspellerInfoMetadata
{
std::string locale_;
LanguageVersions title_;
LanguageVersions description_;
std::string version_;
std::string vcsrev_;
std::string date_;
std::string producer_;
std::string email_;
std::string website_;
};
struct ZHfstOspellerAcceptorMetadata
{
std::string id_;
std::string descr_;
std::string type_;
std::string transtype_;
LanguageVersions title_;
LanguageVersions description_;
};
struct ZHfstOspellerErrModelMetadata
{
std::string id_;
std::string descr_;
LanguageVersions title_;
LanguageVersions description_;
std::vector<std::string> type_;
std::vector<std::string> model_;
};
class ZHfstOspellerXmlMetadata
{
public:
ZHfstOspellerXmlMetadata();
void read_xml(const std::string& filename);
void read_xml(const char* data, size_t data_length);
std::string debug_dump() const;
public:
ZHfstOspellerInfoMetadata info_;
std::map<std::string,ZHfstOspellerAcceptorMetadata> acceptor_;
std::vector<ZHfstOspellerErrModelMetadata> errmodel_;
#if HAVE_LIBXML
private:
void parse_xml(const xmlpp::Document* doc);
void verify_hfstspeller(xmlpp::Node* hfstspellerNode);
void parse_info(xmlpp::Node* infoNode);
void parse_locale(xmlpp::Node* localeNode);
void parse_title(xmlpp::Node* titleNode);
void parse_description(xmlpp::Node* descriptionNode);
void parse_version(xmlpp::Node* versionNode);
void parse_date(xmlpp::Node* dateNode);
void parse_producer(xmlpp::Node* producerNode);
void parse_contact(xmlpp::Node* contactNode);
void parse_acceptor(xmlpp::Node* acceptorNode);
void parse_title(xmlpp::Node* titleNode, const std::string& accName);
void parse_description(xmlpp::Node* descriptionNode,
const std::string& accName);
void parse_errmodel(xmlpp::Node* errmodelNode);
void parse_title(xmlpp::Node* titleNode, size_t errm_count);
void parse_description(xmlpp::Node* descriptionNode, size_t errm_count);
void parse_type(xmlpp::Node* typeNode, size_t errm_count);
void parse_model(xmlpp::Node* modelNode, size_t errm_count);
#elif HAVE_TINYXML2
private:
void parse_xml(const tinyxml2::XMLDocument& doc);
void verify_hfstspeller(const tinyxml2::XMLElement& hfstspellerNode);
void parse_info(const tinyxml2::XMLElement& infoNode);
void parse_locale(const tinyxml2::XMLElement& localeNode);
void parse_title(const tinyxml2::XMLElement& titleNode);
void parse_description(const tinyxml2::XMLElement& descriptionNode);
void parse_version(const tinyxml2::XMLElement& versionNode);
void parse_date(const tinyxml2::XMLElement& dateNode);
void parse_producer(const tinyxml2::XMLElement& producerNode);
void parse_contact(const tinyxml2::XMLElement& contactNode);
void parse_acceptor(const tinyxml2::XMLElement& acceptorNode);
void parse_title(const tinyxml2::XMLElement& titleNode, const std::string& accName);
void parse_description(const tinyxml2::XMLElement& descriptionNode,
const std::string& accName);
void parse_errmodel(const tinyxml2::XMLElement& errmodelNode);
void parse_title(const tinyxml2::XMLElement& titleNode, size_t errm_count);
void parse_description(const tinyxml2::XMLElement& descriptionNode, size_t errm_count);
void parse_type(const tinyxml2::XMLElement& typeNode, size_t errm_count);
void parse_model(const tinyxml2::XMLElement& modelNode, size_t errm_count);
#endif
};
}
#endif