Added ifdef to exclude ICU/unicode code from Android build

This commit is contained in:
renaud gaudin 2013-04-04 10:48:33 +02:00
parent 2d88190f28
commit 8fcd9583c4
2 changed files with 36 additions and 5 deletions

View File

@ -19,18 +19,20 @@
#include "stringTools.h" #include "stringTools.h"
#ifndef __ANDROID__
/* Prepare integer for display */ /* Prepare integer for display */
std::string kiwix::beautifyInteger(const unsigned int number) { std::string kiwix::beautifyInteger(const unsigned int number) {
std::stringstream numberStream; std::stringstream numberStream;
numberStream << number; numberStream << number;
std::string numberString = numberStream.str(); std::string numberString = numberStream.str();
signed int offset = numberString.size() - 3; signed int offset = numberString.size() - 3;
while (offset > 0) { while (offset > 0) {
numberString.insert(offset, ","); numberString.insert(offset, ",");
offset -= 3; offset -= 3;
} }
return numberString; return numberString;
} }
@ -41,14 +43,14 @@ std::vector<std::string> kiwix::split(const std::string & str,
std::string::size_type lastPos = str.find_first_not_of(delims, 0); std::string::size_type lastPos = str.find_first_not_of(delims, 0);
std::string::size_type pos = str.find_first_of(delims, lastPos); std::string::size_type pos = str.find_first_of(delims, lastPos);
std::vector<std::string> tokens; std::vector<std::string> tokens;
while (std::string::npos != pos || std::string::npos != lastPos) while (std::string::npos != pos || std::string::npos != lastPos)
{ {
tokens.push_back(str.substr(lastPos, pos - lastPos)); tokens.push_back(str.substr(lastPos, pos - lastPos));
lastPos = str.find_first_not_of(delims, pos); lastPos = str.find_first_not_of(delims, pos);
pos = str.find_first_of(delims, lastPos); pos = str.find_first_of(delims, lastPos);
} }
return tokens; return tokens;
} }
@ -190,3 +192,26 @@ std::string kiwix::urlDecode(const std::string &SRC) {
return (ret); return (ret);
} }
#else
std::string kiwix::ucFirst (const std::string &word) {
if (word.empty())
return "";
std::string new_string = word;
new_string[0] = toupper(new_string[0]);
return new_string;
}
std::string kiwix::lcFirst (const std::string &word) {
if (word.empty())
return "";
std::string new_string = word;
new_string[0] = tolower(new_string[0]);
return new_string;
}
#endif

View File

@ -20,6 +20,7 @@
#ifndef KIWIX_STRINGTOOLS_H #ifndef KIWIX_STRINGTOOLS_H
#define KIWIX_STRINGTOOLS_H #define KIWIX_STRINGTOOLS_H
#ifndef __ANDROID__
#include <unicode/translit.h> #include <unicode/translit.h>
#include <unicode/normlzr.h> #include <unicode/normlzr.h>
#include <unicode/unistr.h> #include <unicode/unistr.h>
@ -28,6 +29,7 @@
#include <unicode/uniset.h> #include <unicode/uniset.h>
#include <unicode/ustring.h> #include <unicode/ustring.h>
#include <unicode/ucnv.h> #include <unicode/ucnv.h>
#endif
#include <iostream> #include <iostream>
#include <vector> #include <vector>
@ -36,6 +38,7 @@
#include <sstream> #include <sstream>
namespace kiwix { namespace kiwix {
#ifndef __ANDROID__
std::string removeAccents(const std::string &text); std::string removeAccents(const std::string &text);
std::string beautifyInteger(const unsigned int number); std::string beautifyInteger(const unsigned int number);
std::vector<std::string> split(const std::string&, const std::string&); std::vector<std::string> split(const std::string&, const std::string&);
@ -45,14 +48,17 @@ namespace kiwix {
void printStringInHexadecimal(const char *s); void printStringInHexadecimal(const char *s);
void printStringInHexadecimal(UnicodeString s); void printStringInHexadecimal(UnicodeString s);
#endif
std::string ucFirst(const std::string &word); std::string ucFirst(const std::string &word);
std::string lcFirst(const std::string &word); std::string lcFirst(const std::string &word);
#ifndef __ANDROID__
void stringReplacement(std::string& str, const std::string& oldStr, const std::string& newStr); void stringReplacement(std::string& str, const std::string& oldStr, const std::string& newStr);
std::string urlEncode(const std::string &c); std::string urlEncode(const std::string &c);
std::string urlDecode(const std::string &c); std::string urlDecode(const std::string &c);
#endif
} }
#endif #endif