LibreOffice Module xmlhelp (master) 1
searchdemo.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <rtl/string.hxx>
21#include <osl/file.hxx>
22#include <db/Block.hxx>
23#include <db/BtreeDictParameters.hxx>
24#include <db/BtreeDict.hxx>
25#include <util/RandomAccessStream.hxx>
26#include <db/DBEnv.hxx>
27#include <qe/QueryProcessor.hxx>
28
29#ifdef ABIDEBUG
30#include <abidebug.hxx>
31#endif
32
33
34using namespace xmlsearch::util;
35using namespace xmlsearch::db;
36using namespace xmlsearch::qe;
37
38
39extern RandomAccessStream* theFile();
40
41
42void print_rtl_OUString( const OUString bla )
43{
44 OString bluber = OUStringToOString( bla,RTL_TEXTENCODING_UTF8 );
45 char* bluberChr = new char[ 1+bluber.getLength() ];
46 const char* jux = bluber.getStr();
47
48 for( int i = 0; i < bluber.getLength(); ++i )
49 bluberChr[i] = jux[i];
50
51 bluberChr[ bluber.getLength() ] = 0;
52 printf( "%s\n",bluberChr );
53 delete[] bluberChr;
54}
55
56
57extern void bla();
58extern void blu();
59
60
61int main( int argc,char* argv[] )
62{
63
64 QueryResults* queryResults = 0;
65
66 try
67 {
68 OUString installDir("//./e|/index/");
69 QueryProcessor queryProcessor( installDir );
70
71 std::vector<OUString> Query(2);
72 Query[0] = "text*";
73 Query[1] = "abbildung";
74 OUString Scope = "headingheading";
75 int HitCount = 40;
76
77 QueryStatement queryStatement( HitCount,Query,Scope );
78 queryResults = queryProcessor.processQuery( queryStatement );
79
80 OUString translations[2];
81 translations[0] = "#HLP#";
82 translations[1] = "vnd.sun.star.help://";
83
84 PrefixTranslator* translator = PrefixTranslator::makePrefixTranslator( translations,2 );
85
86 QueryHitIterator* it = queryResults->makeQueryHitIterator();
87 sal_Int32 j = 0;
88 while( j < 10 && it->next() )
89 {
90 printf( "Ergebnis %2d ",j );
91 QueryHitData* qhd = it->getHit( translator );
92 printf( "Penalty = %10.4f ",qhd->getPenalty() );
93 print_rtl_OUString( qhd->getDocument() );
94 ++j;
95 }
96
97 delete it;
98 }
99 catch( ... )
100 {
101 printf( "caught exception" );
102 throw;
103 }
104 return 0;
105}
106
107/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Query
int i
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
int main(int argc, char *argv[])
Definition: searchdemo.cxx:61
void blu()
void bla()
RandomAccessStream * theFile()
void print_rtl_OUString(const OUString bla)
Definition: searchdemo.cxx:42