Line data Source code
1 : // Snap Websites Servers -- Fuzzy String Comparisons
2 : // Copyright (c) 2011-2019 Made to Order Software Corp. All Rights Reserved
3 : //
4 : // This program is free software; you can redistribute it and/or modify
5 : // it under the terms of the GNU General Public License as published by
6 : // the Free Software Foundation; either version 2 of the License, or
7 : // (at your option) any later version.
8 : //
9 : // This program is distributed in the hope that it will be useful,
10 : // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 : // GNU General Public License for more details.
13 : //
14 : // You should have received a copy of the GNU General Public License
15 : // along with this program; if not, write to the Free Software
16 : // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 : #pragma once
18 :
19 : #include "snapwebsites/snap_exception.h"
20 :
21 : #include <string>
22 :
23 : namespace snap
24 : {
25 :
26 0 : class fuzzy_string_compare_exception : public snap_exception
27 : {
28 : public:
29 0 : explicit fuzzy_string_compare_exception(char const * whatmsg) : snap_exception("snap_child", whatmsg) {}
30 : explicit fuzzy_string_compare_exception(std::string const & whatmsg) : snap_exception("snap_child", whatmsg) {}
31 : explicit fuzzy_string_compare_exception(QString const & whatmsg) : snap_exception("snap_child", whatmsg) {}
32 : };
33 :
34 0 : class fuzzy_string_compare_exception_invalid_parameters : public fuzzy_string_compare_exception
35 : {
36 : public:
37 0 : explicit fuzzy_string_compare_exception_invalid_parameters(char const * whatmsg) : fuzzy_string_compare_exception(whatmsg) {}
38 : explicit fuzzy_string_compare_exception_invalid_parameters(std::string const & whatmsg) : fuzzy_string_compare_exception(whatmsg) {}
39 : explicit fuzzy_string_compare_exception_invalid_parameters(QString const & whatmsg) : fuzzy_string_compare_exception(whatmsg) {}
40 : };
41 :
42 : int levenshtein_distance(std::wstring const & s, std::wstring const & t);
43 : bool strstr_with_levenshtein_distance(std::wstring const & haystack, std::wstring const & needle, int const distance);
44 :
45 : } // namespace snap
46 : // vim: ts=4 sw=4 et
|