/* * This file part of makedict - convertor from any dictionary format to any * http://sdcv.sourceforge.net * Copyright (C) 2005 Evgeniy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef GENERATOR_HPP #define GENERATOR_HPP #include #include #include #include #include #include "utils.hpp" class makedict_generator { public: makedict_generator(); virtual ~makedict_generator() {} int run(int argc, char *argv[]); protected: std::list keys; std::string data; std::map dict_info; enum state_type{ AR, ABR_DEF, FULL_NAME, DESCRIPTION, K, V, OPT }; std::stack state; void set_format(const std::string& val) { format=val; } void set_version(const std::string& val) { version=val; } virtual int generate(const std::string& basename, const std::string& workdir) = 0; bool handle_meta(); bool handle_input();//this function call handle_meta virtual void on_have_data() {} private: std::string format; std::string version; static Str2StrTable xml_spec_seq; static std::map tag_table; struct key_t { std::vector parts; std::vector opts; void clear() { parts.clear(); opts.clear(); } } key; std::list sample_data; enum {mmNONE, mmICON} meta_mode; static void XMLCALL xml_start(void *userData, const XML_Char *name, const XML_Char **atts); static void XMLCALL xml_end(void *userData, const XML_Char *name); static void XMLCALL xml_char_data(void *userData, const XML_Char *s, int len); static void XMLCALL on_meta_start(void *userData, const XML_Char *name, const XML_Char **atts); static void XMLCALL on_meta_end(void *userData, const XML_Char *name); static void XMLCALL on_meta_data(void *userData, const XML_Char *s, int len); void generate_keys(); void sample(std::vector::size_type n); }; #endif//!GENERATOR_HPP