1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /***************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
33 #include <libexttextcat/textcat.h>
34 #include <altstrfunc.hxx>
41 language_str
= DEFAULT_LANGUAGE
;
42 country_str
= DEFAULT_COUNTRY
;
43 encoding_str
= DEFAULT_ENCODING
;
47 * this use a char * string to build the guess object
48 * a string like those is made as : [language-country-encoding]...
52 Guess::Guess(const char * guess_str
)
60 //if the guess is not like "UNKNOWN" or "SHORT", go into the brackets
61 // if(strncmp((const char*)(guess_str + 1), _TEXTCAT_RESULT_UNKOWN, strlen(_TEXTCAT_RESULT_UNKOWN)) != 0
63 // strncmp((const char*)(guess_str + 1), _TEXTCAT_RESULT_SHORT, strlen(_TEXTCAT_RESULT_SHORT)) != 0)
65 if(strcmp((const char*)(guess_str
+ 1), _TEXTCAT_RESULT_UNKOWN
) != 0
67 strcmp((const char*)(guess_str
+ 1), _TEXTCAT_RESULT_SHORT
) != 0)
70 int current_pointer
= 0;
72 //this is to go to the first char of the guess string ( the '[' of "[en-US-utf8]" )
73 while(!isSeparator(guess_str
[current_pointer
])){
78 //this is to pick up the language ( the "en" from "[en-US-utf8]" )
79 while(!isSeparator(guess_str
[current_pointer
])){
80 lang
+=guess_str
[current_pointer
];
85 //this is to pick up the country ( the "US" from "[en-US-utf8]" )
86 while(!isSeparator(guess_str
[current_pointer
])){
87 country
+=guess_str
[current_pointer
];
92 //this is to pick up the encoding ( the "utf8" from "[en-US-utf8]" )
93 while(!isSeparator(guess_str
[current_pointer
])){
94 enc
+=guess_str
[current_pointer
];
98 if(lang
!=""){//if not we use the default value
103 if(enc
!=""){//if not we use the default value
113 string
Guess::GetLanguage()
118 string
Guess::GetCountry()
123 string
Guess::GetEncoding()
128 bool Guess::operator==(string lang
)
131 toString
+= GetLanguage();
133 toString
+= GetCountry();
135 toString
+= GetEncoding();
136 return start(toString
, lang
);
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */