MCPcopy Create free account
hub / github.com/QuiteRSS/quiterss / regexpFunction

Function regexpFunction

3rdparty/sqlitex/sqliteextension.cpp:46–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46static void regexpFunction( sqlite3_context* context, int /*argc*/, sqlite3_value** argv )
47{
48 int len1 = sqlite3_value_bytes16( argv[ 0 ] );
49 const void* data1 = sqlite3_value_text16( argv[ 0 ] );
50 int len2 = sqlite3_value_bytes16( argv[ 1 ] );
51 const void* data2 = sqlite3_value_text16( argv[ 1 ] );
52
53 if ( !data1 || !data2 )
54 return;
55
56 // do not use fromRawData for pattern string because it may be cached internally by the regexp engine
57 QString string1 = QString::fromRawData( reinterpret_cast<const QChar*>( data1 ), len1 / sizeof( QChar ) );
58 QString string2 = QString::fromRawData( reinterpret_cast<const QChar*>( data2 ), len2 / sizeof( QChar ) );
59
60 QzRegExp pattern( string1, Qt::CaseInsensitive);
61 int pos = pattern.indexIn( string2 );
62
63 sqlite3_result_int( context, (pos > -1) ? 1 : 0 );
64}
65
66static void upperFunction(sqlite3_context* context, int /*argc*/, sqlite3_value** argv)
67{

Callers

nothing calls this directly

Calls 1

indexInMethod · 0.80

Tested by

no test coverage detected