/* * 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. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include #include #include #include #include "utils.hpp" #include "parser.hpp" using std::string; using std::vector; using std::cout; int makedict_parser::run(int argc, char *argv[]) { static const char *shortopts = "hi"; static const option lopts[] = { {"version", no_argument, NULL, 0 }, {"help", no_argument, NULL, 'h' }, {"input-format", no_argument, NULL, 'i'}, {"is-your-format", required_argument, NULL, 1}, {"parser-option", required_argument, NULL, 2}, { NULL, 0, NULL, 0 }, }; int option_index, optc; std::string help = _("Usage: program path/to/dictionary\n" "-h, --help display this help and exit\n" "--version output version information and exit\n" "-i, --input-format output supported input format and exit\n" "--is-your-format file test if file in format which accept this codec\n" "--parser-option \"option_name=option_value\"\n"); while ((optc = getopt_long(argc, argv, shortopts, &lopts[0], &option_index))!=-1) { switch (optc) { case 'h': cout< l=split(optarg, '='); if (l.size()!=2) { std::cerr<<_("Invalid usage of parser-option: didn't find '=' in option") <first<second=l[1]; } break; case '?': default: std::cerr<first<<"\t"<second<\n"; str_map::const_iterator p=dict_info.find("icon"); if (p!=dict_info.end()) cout<<""<second<<"\n"; cout<<"\n"; } inline void makedict_parser::info() { cout<< "\n" ""<\n" ""<\n"; } void makedict_parser::begin() { meta_info(); cout<< "\n" "\n" ; info(); } void makedict_parser::end() { cout<< "\n" <\n"; } void makedict_parser::abbrs_end() { cout<<"\n"; } void makedict_parser::abbr(vector& keys, const std::string& val) { cout<<""; for (vector::iterator p=keys.begin(); p!=keys.end(); ++p) cout<<""<"; cout<<""<"; cout<<"\n"; } void makedict_parser::article(vector& keys, const std::string& val) { cout<<""; for (vector::iterator p=keys.begin(); p!=keys.end(); ++p) cout<<""<\n"; cout<\n"; } int makedict_parser::parse(const std::string& url) { return EXIT_SUCCESS; } void makedict_parser::remove_not_valid(std::string &str) { std::string valid_data; char utf8buf[8]; for (const char *p=str.c_str(); *p; p=g_utf8_next_char(p)) { gunichar ch=g_utf8_get_char(p); if (not_valid_chars.find(ch)==not_valid_chars.end()) { gint len=g_unichar_to_utf8(ch, utf8buf); utf8buf[len]='\0'; valid_data+=utf8buf; }/* else std::cerr<<_("Not valid character was removed, its code: ")<