"Fossies" - the Fresh Open Source Software Archive

Member "cb2bib-2.0.1/src/c2b/txtmatcher.h" (12 Feb 2021, 2213 Bytes) of package /linux/privat/cb2bib-2.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "txtmatcher.h" see the Fossies "Dox" file reference documentation.

    1 /***************************************************************************
    2  *   Copyright (C) 2004-2021 by Pere Constans
    3  *   constans@molspaces.com
    4  *   cb2Bib version 2.0.1. Licensed under the GNU GPL version 3.
    5  *   See the LICENSE file that comes with this distribution.
    6  ***************************************************************************/
    7 #ifndef TXTMATCHER_H
    8 #define TXTMATCHER_H
    9 
   10 #if defined(__AVX2__)
   11 #define C2B_USE_TXTMATCHER_AVX2 1
   12 #elif defined(__SSE2__)
   13 #define C2B_USE_TXTMATCHER_SSE2 1
   14 #else
   15 #define C2B_USE_TXTMATCHER_SCALAR 1
   16 #endif
   17 
   18 #include <QString>
   19 
   20 
   21 class txtmatcher
   22 {
   23 
   24 public:
   25     txtmatcher();
   26     explicit txtmatcher(const QString& spattern, const Qt::CaseSensitivity cs = Qt::CaseSensitive,
   27                         const int chook = -1);
   28     inline ~txtmatcher() {}
   29 
   30 
   31     void setPattern(const QString& spattern, const Qt::CaseSensitivity cs = Qt::CaseSensitive, const int chook = -1);
   32     inline const QString& pattern() const
   33     {
   34         return _pattern;
   35     }
   36     inline int frequency() const
   37     {
   38         return _frequency;
   39     }
   40     inline int indexIn(const QString& text, const int from = 0) const
   41     {
   42         return indexIn(text.unicode(), text.size(), from);
   43     }
   44     int indexIn(const QChar* const text, const int length, const int from) const;
   45 
   46 
   47 private:
   48     int _find_case_insensitive(const ushort* const t, const int length, const int from) const;
   49     int _find_case_sensitive(const ushort* const t, const int length, const int from) const;
   50 #ifdef C2B_USE_TXTMATCHER_SSE2
   51     int _find_case_insensitive_sse2(const ushort* const t, const int length, const int from) const;
   52     int _find_case_sensitive_sse2(const ushort* const t, const int length, const int from) const;
   53 #endif
   54 #ifdef C2B_USE_TXTMATCHER_AVX2
   55     int _find_case_insensitive_avx2(const ushort* const t, const int length, const int from) const;
   56     int _find_case_sensitive_avx2(const ushort* const t, const int length, const int from) const;
   57 #endif
   58     void _set_lowest_frequency_character(const QString& spattern, const bool cs);
   59 
   60     QString _padded_pattern;
   61     QString _pattern;
   62 
   63     QString _lcp;
   64     QString _ucp;
   65 
   66     bool _case_sensitive;
   67     int _chook;
   68     int _frequency;
   69 };
   70 
   71 #endif