LCOV - code coverage report
Current view: top level - libreoffice/helpcompiler/source - HelpIndexer_main.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 32 41 78.0 %
Date: 2012-12-27 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       4             :  *
       5             :  * The contents of this file are subject to the Mozilla Public License Version
       6             :  * 1.1 (the "License"); you may not use this file except in compliance with
       7             :  * the License or as specified alternatively below. You may obtain a copy of
       8             :  * the License at http://www.mozilla.org/MPL/
       9             :  *
      10             :  * Software distributed under the License is distributed on an "AS IS" basis,
      11             :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12             :  * for the specific language governing rights and limitations under the
      13             :  * License.
      14             :  *
      15             :  * Major Contributor(s):
      16             :  * Copyright (C) 2012 Gert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
      17             :  *  (initial developer)
      18             :  *
      19             :  * All Rights Reserved.
      20             :  *
      21             :  * For minor contributions see the git repository.
      22             :  *
      23             :  * Alternatively, the contents of this file may be used under the terms of
      24             :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      25             :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      26             :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      27             :  * instead of those above.
      28             :  */
      29             : 
      30             : #include <helpcompiler/HelpIndexer.hxx>
      31             : #include <osl/file.hxx>
      32             : #include <osl/process.h>
      33             : #include <osl/thread.h>
      34             : #include <string>
      35             : #include <iostream>
      36             : 
      37             : #include "LuceneHelper.hxx"
      38             : 
      39           9 : int main(int argc, char **argv) {
      40           9 :     const std::string pLang("-lang");
      41           9 :     const std::string pModule("-mod");
      42           9 :     const std::string pDir("-dir");
      43             : 
      44           9 :     std::string lang;
      45           9 :     std::string module;
      46           9 :     std::string dir;
      47             : 
      48           9 :     bool error = false;
      49          36 :     for (int i = 1; i < argc; ++i) {
      50          27 :         if (pLang.compare(argv[i]) == 0) {
      51           9 :             if (i + 1 < argc) {
      52           9 :                 lang = argv[++i];
      53             :             } else {
      54           0 :                 error = true;
      55             :             }
      56          18 :         } else if (pModule.compare(argv[i]) == 0) {
      57           9 :             if (i + 1 < argc) {
      58           9 :                 module = argv[++i];
      59             :             } else {
      60           0 :                 error = true;
      61             :             }
      62           9 :         } else if (pDir.compare(argv[i]) == 0) {
      63           9 :             if (i + 1 < argc) {
      64           9 :                 dir = argv[++i];
      65             :             } else {
      66           0 :                 error = true;
      67             :             }
      68             :         } else {
      69           0 :             error = true;
      70             :         }
      71             :     }
      72             : 
      73           9 :     if (error) {
      74           0 :         std::cerr << "Error parsing command-line arguments" << std::endl;
      75             :     }
      76             : 
      77           9 :     if (error || lang.empty() || module.empty() || dir.empty()) {
      78           0 :         std::cerr << "Usage: HelpIndexer -lang ISOLangCode -mod HelpModule -dir Dir" << std::endl;
      79           0 :         return 1;
      80             :     }
      81             : 
      82           9 :     rtl::OUString sDir;
      83             : 
      84             :     osl::File::getFileURLFromSystemPath(
      85          18 :         rtl::OUString(dir.c_str(), dir.size(), osl_getThreadTextEncoding()),
      86          18 :         sDir);
      87             : 
      88           9 :     rtl::OUString cwd;
      89           9 :     osl_getProcessWorkingDir(&cwd.pData);
      90             : 
      91           9 :     osl::File::getAbsoluteFileURL(cwd, sDir, sDir);
      92             : 
      93             :     HelpIndexer indexer(
      94          18 :         rtl::OUString(lang.c_str(), lang.size(), osl_getThreadTextEncoding()),
      95          18 :         rtl::OUString(module.c_str(), module.size(), osl_getThreadTextEncoding()),
      96          36 :         sDir, sDir);
      97             : 
      98           9 :     if (!indexer.indexDocuments()) {
      99           0 :         std::cerr << rtl::OUStringToOString(indexer.getErrorMessage(), osl_getThreadTextEncoding()).getStr()  << std::endl;
     100           0 :         return 2;
     101             :     }
     102           9 :     return 0;
     103          27 : }
     104             : 
     105             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10