LCOV - code coverage report
Current view: top level - libreoffice/lingucomponent/source/languageguessing - guess.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 51 0.0 %
Date: 2012-12-27 Functions: 0 9 0.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             :  * 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             : 
      21             : #include <iostream>
      22             : #include <string.h>
      23             : 
      24             : #ifdef SYSTEM_LIBEXTTEXTCAT
      25             : #include <libexttextcat/textcat.h>
      26             : #else
      27             : #include <textcat.h>
      28             : #endif
      29             : #include <altstrfunc.hxx>
      30             : #include <guess.hxx>
      31             : 
      32             : using namespace std;
      33             : 
      34           0 : Guess::Guess()
      35             : {
      36           0 :     language_str = DEFAULT_LANGUAGE;
      37           0 :     country_str = DEFAULT_COUNTRY;
      38           0 :     encoding_str = DEFAULT_ENCODING;
      39           0 : }
      40             : 
      41             : /*
      42             : * this use a char * string to build the guess object
      43             : * a string like those is made as : [language-country-encoding]...
      44             : *
      45             : */
      46             : 
      47           0 : Guess::Guess(const char * guess_str)
      48             : {
      49           0 :     Guess();
      50             : 
      51           0 :     string lang;
      52           0 :     string country;
      53           0 :     string enc;
      54             : 
      55             :     //if the guess is not like "UNKNOWN" or "SHORT", go into the brackets
      56             : //     if(strncmp((const char*)(guess_str + 1), _TEXTCAT_RESULT_UNKOWN, strlen(_TEXTCAT_RESULT_UNKOWN)) != 0
      57             : //        &&
      58             : //        strncmp((const char*)(guess_str + 1), _TEXTCAT_RESULT_SHORT, strlen(_TEXTCAT_RESULT_SHORT)) != 0)
      59             : //     {
      60           0 :         if(strcmp((const char*)(guess_str + 1), _TEXTCAT_RESULT_UNKOWN) != 0
      61             :            &&
      62           0 :            strcmp((const char*)(guess_str + 1), _TEXTCAT_RESULT_SHORT) != 0)
      63             :         {
      64             : 
      65           0 :         int current_pointer = 0;
      66             : 
      67             :         //this is to go to the first char of the guess string ( the '[' of "[en-US-utf8]" )
      68           0 :         while(!isSeparator(guess_str[current_pointer])){
      69           0 :             current_pointer++;
      70             :         }
      71           0 :         current_pointer++;
      72             : 
      73             :         //this is to pick up the language ( the "en" from "[en-US-utf8]" )
      74           0 :         while(!isSeparator(guess_str[current_pointer])){
      75           0 :             lang+=guess_str[current_pointer];
      76           0 :             current_pointer++;
      77             :         }
      78           0 :         current_pointer++;
      79             : 
      80             :         //this is to pick up the country ( the "US" from "[en-US-utf8]" )
      81           0 :         while(!isSeparator(guess_str[current_pointer])){
      82           0 :             country+=guess_str[current_pointer];
      83           0 :             current_pointer++;
      84             :         }
      85           0 :         current_pointer++;
      86             : 
      87             :         //this is to pick up the encoding ( the "utf8" from "[en-US-utf8]" )
      88           0 :         while(!isSeparator(guess_str[current_pointer])){
      89           0 :             enc+=guess_str[current_pointer];
      90           0 :             current_pointer++;
      91             :         }
      92             : 
      93           0 :         if(lang!=""){//if not we use the default value
      94           0 :             language_str=lang;
      95             :         }
      96           0 :         country_str=country;
      97             : 
      98           0 :         if(enc!=""){//if not we use the default value
      99           0 :             encoding_str=enc;
     100             :         }
     101           0 :     }
     102           0 : }
     103             : 
     104           0 : Guess::~Guess()
     105             : {
     106           0 : }
     107             : 
     108           0 : string Guess::GetLanguage()
     109             : {
     110           0 :     return language_str;
     111             : }
     112             : 
     113           0 : string Guess::GetCountry()
     114             : {
     115           0 :     return country_str;
     116             : }
     117             : 
     118           0 : string Guess::GetEncoding()
     119             : {
     120           0 :     return encoding_str;
     121             : }
     122             : 
     123           0 : bool Guess::operator==(string lang)
     124             : {
     125           0 :     string toString;
     126           0 :     toString += GetLanguage();
     127           0 :     toString += "-";
     128           0 :     toString += GetCountry();
     129           0 :     toString += "-";
     130           0 :     toString += GetEncoding();
     131           0 :     return start(toString, lang);
     132           0 : }
     133             : 
     134             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10