1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
30 #include <abidebug.hxx>
34 using namespace xmlsearch::util
;
35 using namespace xmlsearch::db
;
36 using namespace xmlsearch::qe
;
39 extern RandomAccessStream
* theFile();
42 void print_rtl_OUString( const OUString bla
)
44 OString bluber
= OUStringToOString( bla
,RTL_TEXTENCODING_UTF8
);
45 char* bluberChr
= new char[ 1+bluber
.getLength() ];
46 const char* jux
= bluber
.getStr();
48 for( int i
= 0; i
< bluber
.getLength(); ++i
)
49 bluberChr
[i
] = jux
[i
];
51 bluberChr
[ bluber
.getLength() ] = 0;
52 printf( "%s\n",bluberChr
);
61 int main( int argc
,char* argv
[] )
64 QueryResults
* queryResults
= 0;
68 OUString
installDir("//./e|/index/");
69 QueryProcessor
queryProcessor( installDir
);
71 std::vector
<OUString
> Query(2);
73 Query
[1] = "abbildung";
74 OUString Scope
= "headingheading";
77 QueryStatement
queryStatement( HitCount
,Query
,Scope
);
78 queryResults
= queryProcessor
.processQuery( queryStatement
);
80 OUString translations
[2];
81 translations
[0] = "#HLP#";
82 translations
[1] = "vnd.sun.star.help://";
84 PrefixTranslator
* translator
= PrefixTranslator::makePrefixTranslator( translations
,2 );
86 QueryHitIterator
* it
= queryResults
->makeQueryHitIterator();
88 while( j
< 10 && it
->next() )
90 printf( "Ergebnis %2d ",j
);
91 QueryHitData
* qhd
= it
->getHit( translator
);
92 printf( "Penalty = %10.4f ",qhd
->getPenalty() );
93 print_rtl_OUString( qhd
->getDocument() );
101 printf( "caught exception" );
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */