/* * This file part of makedict - convertor from any dictionary format to any * http://xdxf.sourceforge.net * Copyright (C) 2006 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. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include #include #include #include "generator.hpp" using std::string; using std::cin; using std::cout; using std::cerr; using std::endl; class xdxf_generator : public makedict_generator { public: xdxf_generator() { set_format("xdxf"); set_version("xdxf_generator, version 0.1"); } protected: int generate(const string& basename, const string& workdir); }; int xdxf_generator::generate(const string& basename, const string& workdir) { if (!handle_meta()) return EXIT_FAILURE; string dirname(workdir+G_DIR_SEPARATOR+basename); if (!make_directory(dirname)) return EXIT_FAILURE; std::map::const_iterator it=dict_info.find("icon"); if (it!=dict_info.end()) { string::size_type pos=it->second.rfind("."); string ext; if (pos!=string::npos) ext=it->second.substr(pos); copy_file(it->second, dirname+G_DIR_SEPARATOR+"dict"+ext); } string dictname=dirname+G_DIR_SEPARATOR+"dict.xdxf"; std::ofstream dict(dictname.c_str(), std::ios::out|std::ios::binary|std::ios::trunc); if (!dict) return EXIT_FAILURE; string line; while (getline(cin, line)) if (!(dict<