From 8fcd9583c41f4a47fb3f4a1a6d631791cd1eac0e Mon Sep 17 00:00:00 2001 From: renaud gaudin Date: Thu, 4 Apr 2013 10:48:33 +0200 Subject: [PATCH] Added ifdef to exclude ICU/unicode code from Android build --- src/common/stringTools.cpp | 33 +++++++++++++++++++++++++++++---- src/common/stringTools.h | 8 +++++++- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/common/stringTools.cpp b/src/common/stringTools.cpp index da0359edc..e5755392b 100644 --- a/src/common/stringTools.cpp +++ b/src/common/stringTools.cpp @@ -19,18 +19,20 @@ #include "stringTools.h" +#ifndef __ANDROID__ + /* Prepare integer for display */ std::string kiwix::beautifyInteger(const unsigned int number) { std::stringstream numberStream; numberStream << number; std::string numberString = numberStream.str(); - + signed int offset = numberString.size() - 3; while (offset > 0) { numberString.insert(offset, ","); offset -= 3; } - + return numberString; } @@ -41,14 +43,14 @@ std::vector kiwix::split(const std::string & str, std::string::size_type lastPos = str.find_first_not_of(delims, 0); std::string::size_type pos = str.find_first_of(delims, lastPos); std::vector tokens; - + while (std::string::npos != pos || std::string::npos != lastPos) { tokens.push_back(str.substr(lastPos, pos - lastPos)); lastPos = str.find_first_not_of(delims, pos); pos = str.find_first_of(delims, lastPos); } - + return tokens; } @@ -190,3 +192,26 @@ std::string kiwix::urlDecode(const std::string &SRC) { 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 \ No newline at end of file diff --git a/src/common/stringTools.h b/src/common/stringTools.h index 5790b63b3..532eaba74 100644 --- a/src/common/stringTools.h +++ b/src/common/stringTools.h @@ -20,6 +20,7 @@ #ifndef KIWIX_STRINGTOOLS_H #define KIWIX_STRINGTOOLS_H +#ifndef __ANDROID__ #include #include #include @@ -28,6 +29,7 @@ #include #include #include + #endif #include #include @@ -36,6 +38,7 @@ #include namespace kiwix { +#ifndef __ANDROID__ std::string removeAccents(const std::string &text); std::string beautifyInteger(const unsigned int number); std::vector split(const std::string&, const std::string&); @@ -45,14 +48,17 @@ namespace kiwix { void printStringInHexadecimal(const char *s); void printStringInHexadecimal(UnicodeString s); +#endif std::string ucFirst(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); std::string urlEncode(const std::string &c); std::string urlDecode(const std::string &c); +#endif } #endif