[sword-svn] r3618 - in trunk: include src/modules src/modules/filters tests
scribe at crosswire.org
scribe at crosswire.org
Sun Apr 14 15:30:33 MST 2019
Author: scribe
Date: 2019-04-14 15:30:32 -0700 (Sun, 14 Apr 2019)
New Revision: 3618
Modified:
trunk/include/utf8transliterator.h
trunk/src/modules/filters/scsuutf8.cpp
trunk/src/modules/filters/utf8nfc.cpp
trunk/src/modules/filters/utf8scsu.cpp
trunk/src/modules/filters/utf8transliterator.cpp
trunk/src/modules/swmodule.cpp
trunk/tests/Makefile.am
trunk/tests/httptest.cpp
trunk/tests/tlitmgrtest.cpp
trunk/tests/translittest.cpp
Log:
Updated to include icu namespace where necessary. Added httptest to build (Thanks for the update ghellings)
Modified: trunk/include/utf8transliterator.h
===================================================================
--- trunk/include/utf8transliterator.h 2019-04-10 18:53:45 UTC (rev 3617)
+++ trunk/include/utf8transliterator.h 2019-04-14 22:30:32 UTC (rev 3618)
@@ -50,11 +50,11 @@
class SWModule;
struct SWTransData {
- UnicodeString resource;
+ icu::UnicodeString resource;
UTransDirection dir;
};
-typedef std::map<const UnicodeString, SWTransData> SWTransMap;
-typedef std::pair<UnicodeString, SWTransData> SWTransPair;
+typedef std::map<const icu::UnicodeString, SWTransData> SWTransMap;
+typedef std::pair<icu::UnicodeString, SWTransData> SWTransPair;
/** This Filter uses ICU for transliteration
*/
@@ -81,7 +81,7 @@
bool checkTrans(const UnicodeString& ID, UErrorCode &status);
#endif
bool addTrans(const char* newTrans, SWBuf* transList);
- Transliterator *createTrans(const UnicodeString& ID, UTransDirection dir, UErrorCode &status);
+ icu::Transliterator *createTrans(const icu::UnicodeString& ID, UTransDirection dir, UErrorCode &status);
public:
UTF8Transliterator();
Modified: trunk/src/modules/filters/scsuutf8.cpp
===================================================================
--- trunk/src/modules/filters/scsuutf8.cpp 2019-04-10 18:53:45 UTC (rev 3617)
+++ trunk/src/modules/filters/scsuutf8.cpp 2019-04-14 22:30:32 UTC (rev 3618)
@@ -140,7 +140,7 @@
#ifdef _ICU_
// Try decoding with ICU if possible
err = U_ZERO_ERROR;
- UnicodeString utf16Text(text.getRawData(), text.length(), scsuConv, err);
+ icu::UnicodeString utf16Text(text.getRawData(), text.length(), scsuConv, err);
err = U_ZERO_ERROR;
int32_t len = utf16Text.extract(text.getRawData(), text.size(), utf8Conv, err);
if (len > (int32_t)text.size()+1) {
Modified: trunk/src/modules/filters/utf8nfc.cpp
===================================================================
--- trunk/src/modules/filters/utf8nfc.cpp 2019-04-10 18:53:45 UTC (rev 3617)
+++ trunk/src/modules/filters/utf8nfc.cpp 2019-04-14 22:30:32 UTC (rev 3618)
@@ -46,11 +46,11 @@
return -1;
err = U_ZERO_ERROR;
- UnicodeString source(text.getRawData(), text.length(), conv, err);
- UnicodeString target;
+ icu::UnicodeString source(text.getRawData(), text.length(), conv, err);
+ icu::UnicodeString target;
err = U_ZERO_ERROR;
- Normalizer::normalize(source, UNORM_NFC, 0, target, err);
+ icu::Normalizer::normalize(source, UNORM_NFC, 0, target, err);
err = U_ZERO_ERROR;
text.setSize(text.size()*2); // potentially, it can grow to 2x the original size
Modified: trunk/src/modules/filters/utf8scsu.cpp
===================================================================
--- trunk/src/modules/filters/utf8scsu.cpp 2019-04-10 18:53:45 UTC (rev 3617)
+++ trunk/src/modules/filters/utf8scsu.cpp 2019-04-14 22:30:32 UTC (rev 3618)
@@ -46,7 +46,7 @@
return -1;
err = U_ZERO_ERROR;
- UnicodeString utf16Text(text.getRawData(), text.length(), utf8Conv, err);
+ icu::UnicodeString utf16Text(text.getRawData(), text.length(), utf8Conv, err);
err = U_ZERO_ERROR;
int32_t len = utf16Text.extract(text.getRawData(), text.size(), scsuConv, err);
if (len > (int32_t)text.size()+1) {
Modified: trunk/src/modules/filters/utf8transliterator.cpp
===================================================================
--- trunk/src/modules/filters/utf8transliterator.cpp 2019-04-10 18:53:45 UTC (rev 3617)
+++ trunk/src/modules/filters/utf8transliterator.cpp 2019-04-14 22:30:32 UTC (rev 3618)
@@ -328,9 +328,9 @@
}
-Transliterator * UTF8Transliterator::createTrans(const UnicodeString& ID, UTransDirection dir, UErrorCode &status )
+icu::Transliterator * UTF8Transliterator::createTrans(const icu::UnicodeString& ID, UTransDirection dir, UErrorCode &status )
{
- Transliterator *trans = Transliterator::createInstance(ID,UTRANS_FORWARD,status);
+ icu::Transliterator *trans = icu::Transliterator::createInstance(ID,UTRANS_FORWARD,status);
if (U_FAILURE(status)) {
delete trans;
return NULL;
@@ -906,9 +906,9 @@
addTrans("NFC", &ID);
err = U_ZERO_ERROR;
- Transliterator * trans = createTrans(UnicodeString(ID), UTRANS_FORWARD, err);
+ icu::Transliterator * trans = createTrans(icu::UnicodeString(ID), UTRANS_FORWARD, err);
if (trans && !U_FAILURE(err)) {
- UnicodeString target = UnicodeString(source);
+ icu::UnicodeString target = icu::UnicodeString(source);
trans->transliterate(target);
text.setSize(text.size()*2);
len = ucnv_fromUChars(conv, text.getRawData(), text.size(), target.getBuffer(), target.length(), &err);
Modified: trunk/src/modules/swmodule.cpp
===================================================================
--- trunk/src/modules/swmodule.cpp 2019-04-10 18:53:45 UTC (rev 3617)
+++ trunk/src/modules/swmodule.cpp 2019-04-14 22:30:32 UTC (rev 3618)
@@ -422,7 +422,7 @@
std::regex preg;
#elif defined(USEICUREGEX)
- RegexMatcher *matcher = 0;
+ icu::RegexMatcher *matcher = 0;
#else
regex_t preg;
#endif
@@ -468,7 +468,7 @@
preg = std::regex((SWBuf(".*")+istr+".*").c_str(), std::regex_constants::extended | searchType | flags);
#elif defined(USEICUREGEX)
UErrorCode status = U_ZERO_ERROR;
- matcher = new RegexMatcher(istr, searchType | flags, status);
+ matcher = new icu::RegexMatcher(istr, searchType | flags, status);
if (U_FAILURE(status)) {
SWLog::getSystemLog()->logError("Error compiling Regex: %d", status);
return listKey;
@@ -662,7 +662,7 @@
#ifdef USECXX11REGEX
if (std::regex_match(std::string(textBuf.c_str()), preg)) {
#elif defined(USEICUREGEX)
- UnicodeString stringToTest = textBuf.c_str();
+ icu::UnicodeString stringToTest = textBuf.c_str();
matcher->reset(stringToTest);
if (matcher->find()) {
Modified: trunk/tests/Makefile.am
===================================================================
--- trunk/tests/Makefile.am 2019-04-10 18:53:45 UTC (rev 3617)
+++ trunk/tests/Makefile.am 2019-04-14 22:30:32 UTC (rev 3618)
@@ -12,7 +12,8 @@
compnone complzss localetest introtest indextest \
configtest keycast romantest testblocks filtertest \
rawldidxtest lextest swaptest swbuftest xmltest \
- webiftest striptest ldtest osistest bibliotest
+ webiftest striptest ldtest osistest bibliotest \
+ httptest
if HAVE_ICU
ICUPROG = icutest translittest tlitmgrtest
@@ -71,4 +72,5 @@
ldtest_SOURCES = ldtest.cpp
osistest_SOURCES = osistest.cpp
bibliotest_SOURCES = bibliotest.cpp
+httptest_SOURCES = httptest.cpp
Modified: trunk/tests/httptest.cpp
===================================================================
--- trunk/tests/httptest.cpp 2019-04-10 18:53:45 UTC (rev 3617)
+++ trunk/tests/httptest.cpp 2019-04-14 22:30:32 UTC (rev 3618)
@@ -1,5 +1,5 @@
-#include <sword/curlhttpt.h>
-#include <sword/filemgr.h>
+#include <curlhttpt.h>
+#include <filemgr.h>
#include <vector>
#include <iostream>
Modified: trunk/tests/tlitmgrtest.cpp
===================================================================
--- trunk/tests/tlitmgrtest.cpp 2019-04-10 18:53:45 UTC (rev 3617)
+++ trunk/tests/tlitmgrtest.cpp 2019-04-14 22:30:32 UTC (rev 3618)
@@ -247,6 +247,8 @@
#include "unicode/ustream.h"
#include <iostream>
+using icu::UnicodeString;
+
class SWCharString {
public:
inline SWCharString(const UnicodeString& str);
@@ -285,6 +287,8 @@
#include <map>
using namespace std;
+using icu::UnicodeString;
+using icu::Transliterator;
struct SWTransData {
UnicodeString resource;
@@ -300,8 +304,7 @@
Transliterator * instantiateTrans(const UnicodeString& ID, const UnicodeString& resource,
UTransDirection dir, UParseError &parseError, UErrorCode &status );
-Transliterator *SWTransFactory(const UnicodeString &ID,
- Transliterator::Token context)
+Transliterator *SWTransFactory(const UnicodeString &ID, Transliterator::Token context)
{
std::cout << "running factory for " << ID << std::endl;
SWTransMap::iterator swelement;
@@ -320,9 +323,7 @@
return NULL;
}
-void instantiateTransFactory(const UnicodeString& ID, const UnicodeString& resource,
- UTransDirection dir, UParseError &parseError, UErrorCode &status )
-{
+void instantiateTransFactory(const UnicodeString& ID, const UnicodeString& resource, UTransDirection dir, UParseError &parseError, UErrorCode &status) {
std::cout << "making factory for ID " << ID << std::endl;
Transliterator::Token context;
SWTransData swstuff;
@@ -335,9 +336,7 @@
Transliterator::registerFactory(ID, &SWTransFactory, context);
}
-void registerTrans(const UnicodeString& ID, const UnicodeString& resource,
- UTransDirection dir, UErrorCode &status )
-{
+void registerTrans(const UnicodeString& ID, const UnicodeString& resource, UTransDirection dir, UErrorCode &status) {
std::cout << "registering ID locally " << ID << std::endl;
SWTransData swstuff;
swstuff.resource = resource;
@@ -348,7 +347,7 @@
sw_tmap->insert(swpair);
}
-bool checkTrans(const UnicodeString& ID, UErrorCode &status )
+bool checkTrans(const UnicodeString& ID, UErrorCode &status)
{
Transliterator *trans = Transliterator::createInstance(ID, UTRANS_FORWARD, status);
if (!U_FAILURE(status))
@@ -375,7 +374,7 @@
//std::cout << "importing: " << ID << ", " << resource << std::endl;
SWCharString ch(swstuff.resource);
UResourceBundle *bundle = ures_openDirect(SW_RESDATA, ch, &status);
- const UnicodeString rules = ures_getUnicodeStringByKey(bundle, RB_RULE, &status);
+ const UnicodeString rules = icu::ures_getUnicodeStringByKey(bundle, RB_RULE, &status);
ures_close(bundle);
//parser.parse(rules, isReverse ? UTRANS_REVERSE : UTRANS_FORWARD,
// parseError, status);
@@ -412,9 +411,7 @@
}
}
-Transliterator * createTrans(const UnicodeString& preID, const UnicodeString& ID,
- const UnicodeString& postID, UTransDirection dir, UErrorCode &status )
-{
+Transliterator * createTrans(const UnicodeString& preID, const UnicodeString& ID, const UnicodeString& postID, UTransDirection dir, UErrorCode &status) {
// extract id to check from ID xxx;id;xxx
if (checkTrans(ID, status)) {
UnicodeString fullID = preID;
@@ -434,8 +431,7 @@
}
}
-Transliterator * instantiateTrans(const UnicodeString& ID, const UnicodeString& resource,
- UTransDirection dir, UParseError &parseError, UErrorCode &status )
+Transliterator * instantiateTrans(const UnicodeString& ID, const UnicodeString& resource, UTransDirection dir, UParseError &parseError, UErrorCode &status )
{
//TransliterationRuleData *ruleData;
//TransliteratorParser parser;
@@ -447,7 +443,7 @@
std::cout << "importing: " << ID << ", " << resource << std::endl;
SWCharString ch(resource);
UResourceBundle *bundle = ures_openDirect(SW_RESDATA, ch, &status);
- const UnicodeString rules = ures_getUnicodeStringByKey(bundle, RB_RULE, &status);
+ const UnicodeString rules = icu::ures_getUnicodeStringByKey(bundle, RB_RULE, &status);
ures_close(bundle);
//parser.parse(rules, isReverse ? UTRANS_REVERSE : UTRANS_FORWARD,
// parseError, status);
@@ -500,9 +496,9 @@
colBund = ures_getByIndex(transIDs, row, 0, &status);
if (U_SUCCESS(status) && ures_getSize(colBund) == 4) {
- UnicodeString id = ures_getUnicodeStringByIndex(colBund, 0, &status);
- UChar type = ures_getUnicodeStringByIndex(colBund, 1, &status).charAt(0);
- UnicodeString resString = ures_getUnicodeStringByIndex(colBund, 2, &status);
+ UnicodeString id = icu::ures_getUnicodeStringByIndex(colBund, 0, &status);
+ UChar type = icu::ures_getUnicodeStringByIndex(colBund, 1, &status).charAt(0);
+ UnicodeString resString = icu::ures_getUnicodeStringByIndex(colBund, 2, &status);
if (U_SUCCESS(status)) {
switch (type) {
@@ -513,7 +509,7 @@
{
//UBool visible = (type == 0x0066 /*f*/);
UTransDirection dir =
- (ures_getUnicodeStringByIndex(colBund, 3, &status).charAt(0) ==
+ (icu::ures_getUnicodeStringByIndex(colBund, 3, &status).charAt(0) ==
0x0046 /*F*/) ?
UTRANS_FORWARD : UTRANS_REVERSE;
//registry->put(id, resString, dir, visible);
@@ -567,9 +563,9 @@
colBund = ures_getByIndex(transIDs, row, 0, &status);
if (U_SUCCESS(status) && ures_getSize(colBund) == 4) {
- UnicodeString id = ures_getUnicodeStringByIndex(colBund, 0, &status);
- UChar type = ures_getUnicodeStringByIndex(colBund, 1, &status).charAt(0);
- UnicodeString resString = ures_getUnicodeStringByIndex(colBund, 2, &status);
+ UnicodeString id = icu::ures_getUnicodeStringByIndex(colBund, 0, &status);
+ UChar type = icu::ures_getUnicodeStringByIndex(colBund, 1, &status).charAt(0);
+ UnicodeString resString = icu::ures_getUnicodeStringByIndex(colBund, 2, &status);
std::cout << "ok so far" << std::endl;
if (U_SUCCESS(status)) {
@@ -581,7 +577,7 @@
{
//UBool visible = (type == 0x0066 /*f*/);
UTransDirection dir =
- (ures_getUnicodeStringByIndex(colBund, 3, &status).charAt(0) ==
+ (icu::ures_getUnicodeStringByIndex(colBund, 3, &status).charAt(0) ==
0x0046 /*F*/) ?
UTRANS_FORWARD : UTRANS_REVERSE;
//registry->put(id, resString, dir, visible);
@@ -636,9 +632,9 @@
colBund = ures_getByIndex(transIDs, row, 0, &status);
if (U_SUCCESS(status) && ures_getSize(colBund) == 4) {
- UnicodeString id = ures_getUnicodeStringByIndex(colBund, 0, &status);
- UChar type = ures_getUnicodeStringByIndex(colBund, 1, &status).charAt(0);
- UnicodeString resString = ures_getUnicodeStringByIndex(colBund, 2, &status);
+ UnicodeString id = icu::ures_getUnicodeStringByIndex(colBund, 0, &status);
+ UChar type = icu::ures_getUnicodeStringByIndex(colBund, 1, &status).charAt(0);
+ UnicodeString resString = icu::ures_getUnicodeStringByIndex(colBund, 2, &status);
std::cout << "ok so far" << std::endl;
if (U_SUCCESS(status)) {
@@ -650,7 +646,7 @@
{
//UBool visible = (type == 0x0066 /*f*/);
UTransDirection dir =
- (ures_getUnicodeStringByIndex(colBund, 3, &status).charAt(0) ==
+ (icu::ures_getUnicodeStringByIndex(colBund, 3, &status).charAt(0) ==
0x0046 /*F*/) ?
UTRANS_FORWARD : UTRANS_REVERSE;
//registry->put(id, resString, dir, visible);
Modified: trunk/tests/translittest.cpp
===================================================================
--- trunk/tests/translittest.cpp 2019-04-10 18:53:45 UTC (rev 3617)
+++ trunk/tests/translittest.cpp 2019-04-14 22:30:32 UTC (rev 3618)
@@ -36,7 +36,7 @@
using namespace std;
// Print the given string to stdout
-void uprintf(const UnicodeString &str) {
+void uprintf(const icu::UnicodeString &str) {
char *buf = 0;
int32_t len = str.length();
// int32_t bufLen = str.extract(0, len, buf); // Preflight
@@ -90,7 +90,7 @@
u_errorName(status) << std::endl;
return 0;
}
- std::cout << "available " << Transliterator::countAvailableIDs() << std::endl;
+ std::cout << "available " << icu::Transliterator::countAvailableIDs() << std::endl;
//udata_setAppData("/usr/local/lib/sword/swicu.dat" , pAppData, &status);
//if (U_FAILURE(status))
//{
@@ -99,20 +99,20 @@
//return 0;
//}
- int32_t i_ids = Transliterator::countAvailableIDs();
+ int32_t i_ids = icu::Transliterator::countAvailableIDs();
std::cout << "available " << i_ids << std::endl;
for (int i=0; i<i_ids;i++)
{
std::cout << "id " << i << ": ";
- uprintf(Transliterator::getAvailableID(i));
+ uprintf(icu::Transliterator::getAvailableID(i));
std::cout << std::endl;
}
//UTF8Transliterator utran = new UTF8Transliterator();
std::cout << "creating transliterator 2" << std::endl;
- Transliterator *btrans = Transliterator::createInstance("NFD;Latin-Greek;NFC",
+ icu::Transliterator *btrans = icu::Transliterator::createInstance("NFD;Latin-Greek;NFC",
UTRANS_FORWARD, status);
if (U_FAILURE(status))
{
@@ -121,7 +121,7 @@
return 0;
}
std::cout << "creating transliterator 1" << std::endl;
- Transliterator *trans = Transliterator::createInstance("NFD;Latin-Gothic;NFC",
+ icu::Transliterator *trans = icu::Transliterator::createInstance("NFD;Latin-Gothic;NFC",
UTRANS_FORWARD, status);
if (U_FAILURE(status))
{
More information about the sword-cvs
mailing list