From 8aacea411b5108f8225d5aca71250980871243d3 Mon Sep 17 00:00:00 2001 From: AlexPeshkoff Date: Thu, 11 Jan 2024 20:00:14 +0300 Subject: [PATCH] Cleanup: moved INTL objects, defined in common, from namespace Jrd to namespace Firebird --- src/burp/restore.epp | 17 +++++++++++++--- src/common/CharSet.cpp | 4 ++-- src/common/CharSet.h | 13 ++++-------- src/common/CsConvert.h | 10 +++++----- src/common/IntlUtil.cpp | 28 +++++++++++++------------- src/common/IntlUtil.h | 35 +++++++++++++++------------------ src/common/SimilarToRegex.cpp | 4 ++-- src/common/TextType.cpp | 2 +- src/common/TextType.h | 10 +++++----- src/common/TimeZoneUtil.cpp | 16 +++++++-------- src/common/TimeZoneUtil.h | 4 ++-- src/common/cvt.cpp | 16 +++++++-------- src/common/cvt.h | 8 ++++---- src/common/tests/CvtTestUtils.h | 6 +++--- src/common/unicode_util.cpp | 6 +++--- src/common/unicode_util.h | 10 +++++----- src/dsql/Parser.h | 8 ++++---- src/intl/cs_icu.cpp | 2 +- src/intl/cv_icu.cpp | 6 +++--- src/intl/lc_ascii.cpp | 4 ++-- src/intl/lc_narrow.cpp | 8 ++++---- src/jrd/Attachment.h | 5 ++++- src/jrd/Collation.cpp | 8 ++++---- src/jrd/Collation.h | 8 ++++---- src/jrd/cvt_proto.h | 8 ++++---- src/jrd/dfw.epp | 2 +- src/jrd/intl_builtin.cpp | 2 +- src/jrd/intl_classes.h | 12 +++++------ src/jrd/intl_proto.h | 4 ++-- src/jrd/jrd.h | 5 ++++- 30 files changed, 140 insertions(+), 131 deletions(-) diff --git a/src/burp/restore.epp b/src/burp/restore.epp index 29cc217e21..8c74d1c0cb 100644 --- a/src/burp/restore.epp +++ b/src/burp/restore.epp @@ -156,7 +156,7 @@ bool get_sql_roles(BurpGlobals* tdgbl); bool get_mapping(BurpGlobals* tdgbl); bool get_db_creator(BurpGlobals* tdgbl); bool get_security_class(BurpGlobals* tdgbl); -void get_source_blob(BurpGlobals* tdgbl, ISC_QUAD&, bool); +void get_source_blob(BurpGlobals* tdgbl, ISC_QUAD&, bool, void (*postProcess) (BlobBuffer& segment) = nullptr); USHORT get_text(BurpGlobals* tdgbl, TEXT*, ULONG); USHORT get_text2(BurpGlobals* tdgbl, TEXT* text, ULONG length); bool get_trigger(BurpGlobals* tdgbl); @@ -2721,6 +2721,11 @@ bool get_chk_constraint(BurpGlobals* tdgbl) return true; } +void clearAttributes(BlobBuffer& attr) +{ + +} + bool get_collation(BurpGlobals* tdgbl) { /************************************** @@ -8831,7 +8836,7 @@ bool get_security_class(BurpGlobals* tdgbl) return true; } -void get_source_blob(BurpGlobals* tdgbl, ISC_QUAD& blob_id, bool glb_trans) +void get_source_blob(BurpGlobals* tdgbl, ISC_QUAD& blob_id, bool glb_trans, void (*postProcess) (BlobBuffer& segment)) { /************************************** * @@ -8895,7 +8900,7 @@ void get_source_blob(BurpGlobals* tdgbl, ISC_QUAD& blob_id, bool glb_trans) // Allocate blob buffer if static buffer is too short BlobBuffer static_buffer; - UCHAR* const buffer = static_buffer.getBuffer(length); + UCHAR* buffer = static_buffer.getBuffer(length); while (length > 0) { @@ -8906,6 +8911,12 @@ void get_source_blob(BurpGlobals* tdgbl, ISC_QUAD& blob_id, bool glb_trans) --length; // -- or ++ ??? p is decremented, will have to test. const USHORT seg_len = p - buffer; + if (postProcess) + { + postProcess(static_buffer); + buffer = static_buffer.begin(); + } + if (!blob.putSegment(seg_len, buffer)) { BURP_error_redirect(&status_vector, 38); diff --git a/src/common/CharSet.cpp b/src/common/CharSet.cpp index 02119fef01..8bce947a2e 100644 --- a/src/common/CharSet.cpp +++ b/src/common/CharSet.cpp @@ -239,7 +239,7 @@ ULONG MultiByteCharSet::substring(const ULONG srcLen, const UCHAR* src, const UL //------------- -namespace Jrd { +namespace Firebird { CharSet* CharSet::createInstance(MemoryPool& pool, USHORT id, charset* cs) @@ -300,4 +300,4 @@ ULONG CharSet::removeTrailingSpaces(ULONG srcLen, const UCHAR* src) const } -} // namespace Jrd +} // namespace Firebird diff --git a/src/common/CharSet.h b/src/common/CharSet.h index 8c9f686faf..bae7745589 100644 --- a/src/common/CharSet.h +++ b/src/common/CharSet.h @@ -27,8 +27,8 @@ * */ -#ifndef JRD_CHARSET_H -#define JRD_CHARSET_H +#ifndef COMMON_CHARSET_H +#define COMMON_CHARSET_H #include "CsConvert.h" #include "IntlUtil.h" @@ -45,11 +45,6 @@ namespace Firebird { } } -} - - -namespace Jrd { - class CharSet { public: @@ -146,7 +141,7 @@ private: BYTE sqlMatchOneLength; }; -} // namespace Jrd +} // namespace Firebird -#endif // JRD_CHARSET_H +#endif // COMMON_CHARSET_H diff --git a/src/common/CsConvert.h b/src/common/CsConvert.h index e65d9674cd..707b63ab9e 100644 --- a/src/common/CsConvert.h +++ b/src/common/CsConvert.h @@ -27,15 +27,15 @@ * */ -#ifndef JRD_CSCONVERT_H -#define JRD_CSCONVERT_H +#ifndef COMMON_CSCONVERT_H +#define COMMON_CSCONVERT_H #include "iberror.h" #include "../common/classes/array.h" #include "../common/StatusArg.h" -namespace Jrd { +namespace Firebird { class CsConvert { @@ -286,7 +286,7 @@ private: }; -} // namespace Jrd +} // namespace Firebird -#endif // JRD_CSCONVERT_H +#endif // COMMON_CSCONVERT_H diff --git a/src/common/IntlUtil.cpp b/src/common/IntlUtil.cpp index f1207c22fd..c7019a65c5 100644 --- a/src/common/IntlUtil.cpp +++ b/src/common/IntlUtil.cpp @@ -35,7 +35,7 @@ #include -using Jrd::UnicodeUtil; +using Firebird::UnicodeUtil; namespace @@ -80,11 +80,11 @@ GlobalPtr IntlUtil::utf8CharSet; IntlUtil::Utf8CharSet::Utf8CharSet(MemoryPool& pool) { IntlUtil::initUtf8Charset(&obj); - charSet = Jrd::CharSet::createInstance(pool, CS_UTF8, &obj); + charSet = Firebird::CharSet::createInstance(pool, CS_UTF8, &obj); } -string IntlUtil::generateSpecificAttributes(Jrd::CharSet* cs, SpecificAttributesMap& map) +string IntlUtil::generateSpecificAttributes(Firebird::CharSet* cs, SpecificAttributesMap& map) { SpecificAttributesMap::Accessor accessor(&map); @@ -125,7 +125,7 @@ string IntlUtil::generateSpecificAttributes(Jrd::CharSet* cs, SpecificAttributes } -bool IntlUtil::parseSpecificAttributes(Jrd::CharSet* cs, ULONG len, const UCHAR* s, +bool IntlUtil::parseSpecificAttributes(Firebird::CharSet* cs, ULONG len, const UCHAR* s, SpecificAttributesMap* map) { // Note that the map isn't cleared. @@ -523,11 +523,11 @@ bool IntlUtil::initUnicodeCollation(texttype* tt, charset* cs, const ASCII* name IntlUtil::SpecificAttributesMap map; - Jrd::CharSet* charSet = NULL; + Firebird::CharSet* charSet = NULL; try { - charSet = Jrd::CharSet::createInstance(*getDefaultMemoryPool(), 0, cs); + charSet = Firebird::CharSet::createInstance(*getDefaultMemoryPool(), 0, cs); IntlUtil::parseSpecificAttributes(charSet, specificAttributes.getCount(), specificAttributes.begin(), &map); delete charSet; @@ -594,7 +594,7 @@ void IntlUtil::finiCharset(charset* cs) } -ULONG IntlUtil::toLower(Jrd::CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst, +ULONG IntlUtil::toLower(Firebird::CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst, const ULONG* exceptions) { const ULONG utf16_length = cs->getConvToUnicode().convertLength(srcLen); @@ -620,7 +620,7 @@ ULONG IntlUtil::toLower(Jrd::CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG } -ULONG IntlUtil::toUpper(Jrd::CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst, +ULONG IntlUtil::toUpper(Firebird::CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst, const ULONG* exceptions) { const ULONG utf16_length = cs->getConvToUnicode().convertLength(srcLen); @@ -646,7 +646,7 @@ ULONG IntlUtil::toUpper(Jrd::CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG } -bool IntlUtil::readOneChar(Jrd::CharSet* cs, const UCHAR** s, const UCHAR* end, ULONG* size) +bool IntlUtil::readOneChar(Firebird::CharSet* cs, const UCHAR** s, const UCHAR* end, ULONG* size) { (*s) += *size; @@ -668,7 +668,7 @@ bool IntlUtil::readOneChar(Jrd::CharSet* cs, const UCHAR** s, const UCHAR* end, bool IntlUtil::setupIcuAttributes(charset* cs, const string& specificAttributes, const string& configInfo, string& newSpecificAttributes) { - AutoPtr charSet(Jrd::CharSet::createInstance(*getDefaultMemoryPool(), 0, cs)); + AutoPtr charSet(Firebird::CharSet::createInstance(*getDefaultMemoryPool(), 0, cs)); IntlUtil::SpecificAttributesMap map; if (!IntlUtil::parseSpecificAttributes(charSet, specificAttributes.length(), @@ -704,7 +704,7 @@ bool IntlUtil::setupIcuAttributes(charset* cs, const string& specificAttributes, } -string IntlUtil::escapeAttribute(Jrd::CharSet* cs, const string& s) +string IntlUtil::escapeAttribute(Firebird::CharSet* cs, const string& s) { string ret; const UCHAR* p = (const UCHAR*)s.begin(); @@ -739,7 +739,7 @@ string IntlUtil::escapeAttribute(Jrd::CharSet* cs, const string& s) } -string IntlUtil::unescapeAttribute(Jrd::CharSet* cs, const string& s) +string IntlUtil::unescapeAttribute(Firebird::CharSet* cs, const string& s) { string ret; const UCHAR* p = (const UCHAR*)s.begin(); @@ -753,7 +753,7 @@ string IntlUtil::unescapeAttribute(Jrd::CharSet* cs, const string& s) } -bool IntlUtil::isAttributeEscape(Jrd::CharSet* cs, const UCHAR* s, ULONG size) +bool IntlUtil::isAttributeEscape(Firebird::CharSet* cs, const UCHAR* s, ULONG size) { UCHAR uc[sizeof(ULONG)]; const ULONG uSize = cs->getConvToUnicode().convert(size, s, sizeof(uc), uc); @@ -762,7 +762,7 @@ bool IntlUtil::isAttributeEscape(Jrd::CharSet* cs, const UCHAR* s, ULONG size) } -bool IntlUtil::readAttributeChar(Jrd::CharSet* cs, const UCHAR** s, const UCHAR* end, ULONG* size, bool returnEscape) +bool IntlUtil::readAttributeChar(Firebird::CharSet* cs, const UCHAR** s, const UCHAR* end, ULONG* size, bool returnEscape) { if (readOneChar(cs, s, end, size)) { diff --git a/src/common/IntlUtil.h b/src/common/IntlUtil.h index a8471dc13e..b906e70e27 100644 --- a/src/common/IntlUtil.h +++ b/src/common/IntlUtil.h @@ -24,8 +24,8 @@ * Contributor(s): ______________________________________. */ -#ifndef JRD_INTLUTIL_H -#define JRD_INTLUTIL_H +#ifndef COMMON_INTLUTIL_H +#define COMMON_INTLUTIL_H #include "../common/classes/array.h" #include "../common/classes/auto.h" @@ -34,12 +34,9 @@ #include "../common/classes/init.h" #include "../common/intlobj_new.h" -namespace Jrd +namespace Firebird { - class CharSet; -} - -namespace Firebird { +class CharSet; class IntlUtil { @@ -48,13 +45,13 @@ public: typedef GenericMap SpecificAttributesMap; public: - static Jrd::CharSet* getUtf8CharSet() + static CharSet* getUtf8CharSet() { return utf8CharSet->charSet; } - static string generateSpecificAttributes(Jrd::CharSet* cs, SpecificAttributesMap& map); - static bool parseSpecificAttributes(Jrd::CharSet* cs, ULONG len, const UCHAR* s, + static string generateSpecificAttributes(CharSet* cs, SpecificAttributesMap& map); + static bool parseSpecificAttributes(CharSet* cs, ULONG len, const UCHAR* s, SpecificAttributesMap* map); static string convertAsciiToUtf16(const string& ascii); @@ -85,23 +82,23 @@ public: static void finiCharset(charset* cs); - static ULONG toLower(Jrd::CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst, + static ULONG toLower(CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst, const ULONG* exceptions); - static ULONG toUpper(Jrd::CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst, + static ULONG toUpper(CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst, const ULONG* exceptions); - static bool readOneChar(Jrd::CharSet* cs, const UCHAR** s, const UCHAR* end, ULONG* size); + static bool readOneChar(CharSet* cs, const UCHAR** s, const UCHAR* end, ULONG* size); static bool setupIcuAttributes(charset* cs, const string& specificAttributes, const string& configInfo, string& newSpecificAttributes); private: - static string escapeAttribute(Jrd::CharSet* cs, const string& s); - static string unescapeAttribute(Jrd::CharSet* cs, const string& s); + static string escapeAttribute(CharSet* cs, const string& s); + static string unescapeAttribute(CharSet* cs, const string& s); - static bool isAttributeEscape(Jrd::CharSet* cs, const UCHAR* s, ULONG size); + static bool isAttributeEscape(CharSet* cs, const UCHAR* s, ULONG size); - static bool readAttributeChar(Jrd::CharSet* cs, const UCHAR** s, const UCHAR* end, ULONG* size, + static bool readAttributeChar(CharSet* cs, const UCHAR** s, const UCHAR* end, ULONG* size, bool returnEscape); private: @@ -112,7 +109,7 @@ private: public: charset obj; - AutoPtr charSet; + AutoPtr charSet; }; static GlobalPtr utf8CharSet; @@ -120,4 +117,4 @@ private: } // namespace Firebird -#endif // JRD_INTLUTIL_H +#endif // COMMON_INTLUTIL_H diff --git a/src/common/SimilarToRegex.cpp b/src/common/SimilarToRegex.cpp index ee8b2b9ae8..42d0709133 100644 --- a/src/common/SimilarToRegex.cpp +++ b/src/common/SimilarToRegex.cpp @@ -74,7 +74,7 @@ namespace { if (!(flags & COMP_FLAG_LATIN) && !(flags & COMP_FLAG_WELLFORMED)) { - if (!Jrd::UnicodeUtil::utf8WellFormed(patternLen, reinterpret_cast(patternStr), nullptr)) + if (!UnicodeUtil::utf8WellFormed(patternLen, reinterpret_cast(patternStr), nullptr)) status_exception::raise(Arg::Gds(isc_malformed_string)); } @@ -82,7 +82,7 @@ namespace { if (!(flags & COMP_FLAG_LATIN) && !(flags & COMP_FLAG_WELLFORMED)) { - if (!Jrd::UnicodeUtil::utf8WellFormed(escapeLen, reinterpret_cast(escapeStr), nullptr)) + if (!UnicodeUtil::utf8WellFormed(escapeLen, reinterpret_cast(escapeStr), nullptr)) status_exception::raise(Arg::Gds(isc_malformed_string)); } diff --git a/src/common/TextType.cpp b/src/common/TextType.cpp index c13420ad30..ae095b4a2e 100644 --- a/src/common/TextType.cpp +++ b/src/common/TextType.cpp @@ -98,7 +98,7 @@ #include "../common/classes/Aligner.h" -namespace Jrd { +namespace Firebird { TextType::TextType(TTYPE_ID _type, texttype *_tt, USHORT _attributes, CharSet* _cs) diff --git a/src/common/TextType.h b/src/common/TextType.h index 1309a3d067..858b9fb5c8 100644 --- a/src/common/TextType.h +++ b/src/common/TextType.h @@ -27,14 +27,14 @@ * */ -#ifndef JRD_TEXTTYPE_H -#define JRD_TEXTTYPE_H +#ifndef COMMON_TEXTTYPE_H +#define COMMON_TEXTTYPE_H #include "../common/classes/MetaString.h" struct texttype; -namespace Jrd { +namespace Firebird { class CharSet; @@ -148,7 +148,7 @@ private: ULONG canonicalChars[CHAR_COUNT]; }; -} // namespace Jrd +} // namespace Firebird -#endif // JRD_TEXTTYPE_H +#endif // COMMON_TEXTTYPE_H diff --git a/src/common/TimeZoneUtil.cpp b/src/common/TimeZoneUtil.cpp index a64d4cd8b0..cbcdc44cc0 100644 --- a/src/common/TimeZoneUtil.cpp +++ b/src/common/TimeZoneUtil.cpp @@ -54,7 +54,7 @@ namespace { if (const auto calendar = icuCachedCalendar.exchange(nullptr)) { - auto& icuLib = Jrd::UnicodeUtil::getConversionICU(); + auto& icuLib = UnicodeUtil::getConversionICU(); icuLib.ucalClose(calendar); } } @@ -80,7 +80,7 @@ namespace return unicodeName.begin(); } - IcuCalendarWrapper getCalendar(const Jrd::UnicodeUtil::ConversionICU& icuLib, UErrorCode* err = nullptr) const + IcuCalendarWrapper getCalendar(const UnicodeUtil::ConversionICU& icuLib, UErrorCode* err = nullptr) const { auto calendar = icuCachedCalendar.exchange(nullptr); UErrorCode internalErr = U_ZERO_ERROR; @@ -336,7 +336,7 @@ USHORT TimeZoneUtil::getSystemTimeZone() return cachedTimeZoneId; UErrorCode icuErrorCode = U_ZERO_ERROR; - Jrd::UnicodeUtil::ConversionICU& icuLib = Jrd::UnicodeUtil::getConversionICU(); + UnicodeUtil::ConversionICU& icuLib = UnicodeUtil::getConversionICU(); char buffer[TimeZoneUtil::MAX_SIZE]; const char* str = buffer; @@ -435,7 +435,7 @@ USHORT TimeZoneUtil::getSystemTimeZone() void TimeZoneUtil::getDatabaseVersion(Firebird::string& str) { - Jrd::UnicodeUtil::ConversionICU& icuLib = Jrd::UnicodeUtil::getConversionICU(); + UnicodeUtil::ConversionICU& icuLib = UnicodeUtil::getConversionICU(); UErrorCode icuErrorCode = U_ZERO_ERROR; const char* version = icuLib.ucalGetTZDataVersion(&icuErrorCode); @@ -615,7 +615,7 @@ void TimeZoneUtil::extractOffset(const ISC_TIMESTAMP_TZ& timeStampTz, SSHORT* of { UErrorCode icuErrorCode = U_ZERO_ERROR; - Jrd::UnicodeUtil::ConversionICU& icuLib = Jrd::UnicodeUtil::getConversionICU(); + UnicodeUtil::ConversionICU& icuLib = UnicodeUtil::getConversionICU(); auto icuCalendar = getDesc(timeStampTz.time_zone)->getCalendar(icuLib, &icuErrorCode); @@ -715,7 +715,7 @@ void TimeZoneUtil::localTimeStampToUtc(ISC_TIMESTAMP_TZ& timeStampTz) UErrorCode icuErrorCode = U_ZERO_ERROR; - Jrd::UnicodeUtil::ConversionICU& icuLib = Jrd::UnicodeUtil::getConversionICU(); + UnicodeUtil::ConversionICU& icuLib = UnicodeUtil::getConversionICU(); auto icuCalendar = getDesc(timeStampTz.time_zone)->getCalendar(icuLib, &icuErrorCode); @@ -775,7 +775,7 @@ bool TimeZoneUtil::decodeTimeStamp(const ISC_TIMESTAMP_TZ& timeStampTz, bool gmt if (gmtFallback && getenv("MISSING_ICU_EMULATION")) (Arg::Gds(isc_random) << "Emulating missing ICU").raise(); #endif - Jrd::UnicodeUtil::ConversionICU& icuLib = Jrd::UnicodeUtil::getConversionICU(); + UnicodeUtil::ConversionICU& icuLib = UnicodeUtil::getConversionICU(); auto icuCalendar = getDesc(timeStampTz.time_zone)->getCalendar(icuLib, &icuErrorCode); @@ -1059,7 +1059,7 @@ ISC_TIMESTAMP_TZ TimeZoneUtil::dateToTimeStampTz(const ISC_DATE& date, Callbacks TimeZoneRuleIterator::TimeZoneRuleIterator(USHORT aId, const ISC_TIMESTAMP_TZ& aFrom, const ISC_TIMESTAMP_TZ& aTo) : id(aId), - icuLib(Jrd::UnicodeUtil::getConversionICU()), + icuLib(UnicodeUtil::getConversionICU()), toTicks(TimeStamp::timeStampToTicks(aTo.utc_timestamp)), icuCalendar(getDesc(aId)->getCalendar(icuLib)) { diff --git a/src/common/TimeZoneUtil.h b/src/common/TimeZoneUtil.h index 1e8883b70a..17109edfbb 100644 --- a/src/common/TimeZoneUtil.h +++ b/src/common/TimeZoneUtil.h @@ -166,7 +166,7 @@ public: if (newCached) { - auto& icuLib = Jrd::UnicodeUtil::getConversionICU(); + auto& icuLib = UnicodeUtil::getConversionICU(); icuLib.ucalClose(newCached); } } @@ -212,7 +212,7 @@ public: private: const USHORT id; - Jrd::UnicodeUtil::ConversionICU& icuLib; + UnicodeUtil::ConversionICU& icuLib; SINT64 startTicks; SINT64 toTicks; IcuCalendarWrapper icuCalendar; diff --git a/src/common/cvt.cpp b/src/common/cvt.cpp index 708a5f209f..54404a255f 100644 --- a/src/common/cvt.cpp +++ b/src/common/cvt.cpp @@ -2932,7 +2932,7 @@ void CVT_move_common(const dsc* from, dsc* to, DecimalStatus decSt, Callbacks* c if (to->dsc_dtype == dtype_varying) ptr += sizeof(USHORT); - Jrd::CharSet* charSet = cb->getToCharset(to->getCharSet()); + CharSet* charSet = cb->getToCharset(to->getCharSet()); UCHAR maxBytesPerChar = charSet ? charSet->maxBytesPerChar() : 1; if (len / maxBytesPerChar < from->dsc_length) @@ -3009,7 +3009,7 @@ void CVT_move_common(const dsc* from, dsc* to, DecimalStatus decSt, Callbacks* c } // end scope const USHORT to_size = TEXT_LEN(to); - Jrd::CharSet* toCharset = cb->getToCharset(charset2); + CharSet* toCharset = cb->getToCharset(charset2); cb->validateData(toCharset, length, q); ULONG toLength = cb->validateLength(toCharset, charset2, length, q, to_size); @@ -4801,9 +4801,9 @@ namespace public: virtual bool transliterate(const dsc* from, dsc* to, CHARSET_ID&); virtual CHARSET_ID getChid(const dsc* d); - virtual Jrd::CharSet* getToCharset(CHARSET_ID charset2); - virtual void validateData(Jrd::CharSet* toCharset, SLONG length, const UCHAR* q); - virtual ULONG validateLength(Jrd::CharSet* charSet, CHARSET_ID charSetId, ULONG length, const UCHAR* start, + virtual CharSet* getToCharset(CHARSET_ID charset2); + virtual void validateData(CharSet* toCharset, SLONG length, const UCHAR* q); + virtual ULONG validateLength(CharSet* charSet, CHARSET_ID charSetId, ULONG length, const UCHAR* start, const USHORT size); virtual SLONG getLocalDate(); virtual ISC_TIMESTAMP getCurrentGmtTimeStamp(); @@ -4817,16 +4817,16 @@ namespace return false; } - Jrd::CharSet* CommonCallbacks::getToCharset(CHARSET_ID) + CharSet* CommonCallbacks::getToCharset(CHARSET_ID) { return NULL; } - void CommonCallbacks::validateData(Jrd::CharSet*, SLONG, const UCHAR*) + void CommonCallbacks::validateData(CharSet*, SLONG, const UCHAR*) { } - ULONG CommonCallbacks::validateLength(Jrd::CharSet* charSet, CHARSET_ID charSetId, ULONG length, const UCHAR* start, + ULONG CommonCallbacks::validateLength(CharSet* charSet, CHARSET_ID charSetId, ULONG length, const UCHAR* start, const USHORT size) { if (length > size) diff --git a/src/common/cvt.h b/src/common/cvt.h index dc920d992b..5c2d22910c 100644 --- a/src/common/cvt.h +++ b/src/common/cvt.h @@ -31,7 +31,7 @@ #include "../common/DecFloat.h" -namespace Jrd { +namespace Firebird { class CharSet; @@ -56,9 +56,9 @@ public: public: virtual bool transliterate(const dsc* from, dsc* to, CHARSET_ID&) = 0; virtual CHARSET_ID getChid(const dsc* d) = 0; - virtual Jrd::CharSet* getToCharset(CHARSET_ID charset2) = 0; - virtual void validateData(Jrd::CharSet* toCharset, SLONG length, const UCHAR* q) = 0; - virtual ULONG validateLength(Jrd::CharSet* charSet, CHARSET_ID charSetId, ULONG length, const UCHAR* start, + virtual CharSet* getToCharset(CHARSET_ID charset2) = 0; + virtual void validateData(CharSet* toCharset, SLONG length, const UCHAR* q) = 0; + virtual ULONG validateLength(CharSet* charSet, CHARSET_ID charSetId, ULONG length, const UCHAR* start, const USHORT size) = 0; virtual SLONG getLocalDate() = 0; virtual ISC_TIMESTAMP getCurrentGmtTimeStamp() = 0; diff --git a/src/common/tests/CvtTestUtils.h b/src/common/tests/CvtTestUtils.h index 3baa601a01..beafaf7055 100644 --- a/src/common/tests/CvtTestUtils.h +++ b/src/common/tests/CvtTestUtils.h @@ -93,9 +93,9 @@ public: public: bool transliterate(const dsc* from, dsc* to, CHARSET_ID&) override { return true; } CHARSET_ID getChid(const dsc* d) override { return 0; } - Jrd::CharSet* getToCharset(CHARSET_ID charset2) override { return nullptr; } - void validateData(Jrd::CharSet* toCharset, SLONG length, const UCHAR* q) override { } - ULONG validateLength(Jrd::CharSet* charSet, CHARSET_ID charSetId, ULONG length, const UCHAR* start, + Firebird::CharSet* getToCharset(CHARSET_ID charset2) override { return nullptr; } + void validateData(Firebird::CharSet* toCharset, SLONG length, const UCHAR* q) override { } + ULONG validateLength(Firebird::CharSet* charSet, CHARSET_ID charSetId, ULONG length, const UCHAR* start, const USHORT size) override { return 0; } SLONG getLocalDate() override { return 0; } ISC_TIMESTAMP getCurrentGmtTimeStamp() override { ISC_TIMESTAMP ts; return ts; } diff --git a/src/common/unicode_util.cpp b/src/common/unicode_util.cpp index 41931e6489..f20984e6ee 100644 --- a/src/common/unicode_util.cpp +++ b/src/common/unicode_util.cpp @@ -284,7 +284,7 @@ void BaseICU::initialize(ModuleLoader::Module* module) } -namespace Jrd { +namespace Firebird { // encapsulate ICU collations libraries struct UnicodeUtil::ICU : public BaseICU @@ -519,7 +519,7 @@ static void getVersions(const string& configInfo, ObjectsArray& versions charset cs; IntlUtil::initAsciiCharset(&cs); - AutoPtr ascii(Jrd::CharSet::createInstance(*getDefaultMemoryPool(), 0, &cs)); + AutoPtr ascii(Firebird::CharSet::createInstance(*getDefaultMemoryPool(), 0, &cs)); IntlUtil::SpecificAttributesMap config; IntlUtil::parseSpecificAttributes(ascii, configInfo.length(), @@ -2111,4 +2111,4 @@ void UnicodeUtil::Utf16Collation::normalize(ULONG* strLen, const USHORT** str, b } -} // namespace Jrd +} // namespace Firebird diff --git a/src/common/unicode_util.h b/src/common/unicode_util.h index 09de723045..460d981bc4 100644 --- a/src/common/unicode_util.h +++ b/src/common/unicode_util.h @@ -24,8 +24,8 @@ * Contributor(s): ______________________________________. */ -#ifndef JRD_UNICODE_UTIL_H -#define JRD_UNICODE_UTIL_H +#ifndef COMMON_UNICODE_UTIL_H +#define COMMON_UNICODE_UTIL_H #include "intlobj_new.h" #include "../common/IntlUtil.h" @@ -40,7 +40,7 @@ struct UCollator; struct USet; -namespace Jrd { +namespace Firebird { class UnicodeUtil { @@ -262,6 +262,6 @@ public: friend class Utf16Collation; }; -} // namespace Jrd +} // namespace Firebird -#endif // JRD_UNICODE_UTIL_H +#endif // COMMON_UNICODE_UTIL_H diff --git a/src/dsql/Parser.h b/src/dsql/Parser.h index 516982d7d0..51cb519562 100644 --- a/src/dsql/Parser.h +++ b/src/dsql/Parser.h @@ -39,6 +39,8 @@ #include "gen/parse.h" namespace Firebird { +class CharSet; + namespace Arg { class StatusVector; } // namespace @@ -46,8 +48,6 @@ namespace Arg { namespace Jrd { -class CharSet; - class Parser : public Firebird::PermanentStorage { private: @@ -371,9 +371,9 @@ private: USHORT db_dialect; const bool requireSemicolon; USHORT parser_version; - CharSet* charSet; + Firebird::CharSet* charSet; - CharSet* metadataCharSet; + Firebird::CharSet* metadataCharSet; Firebird::string transformedString; Firebird::GenericMap > strMarks; bool stmt_ambiguous; diff --git a/src/intl/cs_icu.cpp b/src/intl/cs_icu.cpp index 76f15a2e68..45436e863c 100644 --- a/src/intl/cs_icu.cpp +++ b/src/intl/cs_icu.cpp @@ -43,7 +43,7 @@ bool CSICU_charset_init(charset* cs, const ASCII* charSetName) { UErrorCode status = U_ZERO_ERROR; - Jrd::UnicodeUtil::ConversionICU& cIcu(Jrd::UnicodeUtil::getConversionICU()); + Firebird::UnicodeUtil::ConversionICU& cIcu(Firebird::UnicodeUtil::getConversionICU()); UConverter* conv = cIcu.ucnv_open(charSetName, &status); if (U_SUCCESS(status)) diff --git a/src/intl/cv_icu.cpp b/src/intl/cv_icu.cpp index b1ac01fce5..036620b312 100644 --- a/src/intl/cv_icu.cpp +++ b/src/intl/cv_icu.cpp @@ -34,7 +34,7 @@ static UConverter* create_converter(csconvert* cv, UErrorCode* status) { - Jrd::UnicodeUtil::ConversionICU& cIcu(Jrd::UnicodeUtil::getConversionICU()); + Firebird::UnicodeUtil::ConversionICU& cIcu(Firebird::UnicodeUtil::getConversionICU()); UConverter* conv = cIcu.ucnv_open(cv->csconvert_impl->cs->charset_name, status); const void* oldContext; @@ -90,7 +90,7 @@ static ULONG unicode_to_icu(csconvert* cv, Firebird::Aligner alignedSource(src, srcLen); const UChar* source = alignedSource; char* target = reinterpret_cast(dst); - Jrd::UnicodeUtil::ConversionICU& cIcu(Jrd::UnicodeUtil::getConversionICU()); + Firebird::UnicodeUtil::ConversionICU& cIcu(Firebird::UnicodeUtil::getConversionICU()); cIcu.ucnv_fromUnicode(conv, &target, target + dstLen, &source, source + srcLen / sizeof(UChar), NULL, TRUE, &status); @@ -146,7 +146,7 @@ static ULONG icu_to_unicode(csconvert* cv, const char* source = reinterpret_cast(src); Firebird::OutAligner alignedTarget(dst, dstLen); UChar* target = alignedTarget; - Jrd::UnicodeUtil::ConversionICU& cIcu(Jrd::UnicodeUtil::getConversionICU()); + Firebird::UnicodeUtil::ConversionICU& cIcu(Firebird::UnicodeUtil::getConversionICU()); cIcu.ucnv_toUnicode(conv, &target, target + dstLen / sizeof(UChar), &source, source + srcLen, NULL, TRUE, &status); diff --git a/src/intl/lc_ascii.cpp b/src/intl/lc_ascii.cpp index e70eadd900..182e3496a8 100644 --- a/src/intl/lc_ascii.cpp +++ b/src/intl/lc_ascii.cpp @@ -49,7 +49,7 @@ namespace { struct TextTypeImpl { - Jrd::CharSet* charSet; + Firebird::CharSet* charSet; charset cs; const ULONG* lower_exceptions; const ULONG* upper_exceptions; @@ -136,7 +136,7 @@ static inline bool FAMILY_ASCII(texttype* cache, memset(&impl->cs, 0, sizeof(impl->cs)); LD_lookup_charset(&impl->cs, cs_name, config_info); - impl->charSet = Jrd::CharSet::createInstance(*getDefaultMemoryPool(), 0, &impl->cs); + impl->charSet = Firebird::CharSet::createInstance(*getDefaultMemoryPool(), 0, &impl->cs); impl->lower_exceptions = lower_exceptions; impl->upper_exceptions = upper_exceptions; diff --git a/src/intl/lc_narrow.cpp b/src/intl/lc_narrow.cpp index f391f7fc5b..5a1bc0dbae 100644 --- a/src/intl/lc_narrow.cpp +++ b/src/intl/lc_narrow.cpp @@ -831,11 +831,11 @@ bool LC_NARROW_family2( impl->texttype_bytes_per_key = 0; IntlUtil::SpecificAttributesMap map; - Jrd::CharSet* charSet = NULL; + Firebird::CharSet* charSet = NULL; try { - charSet = Jrd::CharSet::createInstance(*getDefaultMemoryPool(), 0, cs); + charSet = Firebird::CharSet::createInstance(*getDefaultMemoryPool(), 0, cs); if (!IntlUtil::parseSpecificAttributes(charSet, specificAttributesLength, specificAttributes, &map)) { @@ -953,12 +953,12 @@ bool LC_NARROW_family3( bool multiLevel = false; IntlUtil::SpecificAttributesMap map; - Jrd::CharSet* charSet = NULL; + Firebird::CharSet* charSet = NULL; string newSpecificAttributes; try { - charSet = Jrd::CharSet::createInstance(*getDefaultMemoryPool(), 0, cs); + charSet = Firebird::CharSet::createInstance(*getDefaultMemoryPool(), 0, cs); if (!IntlUtil::parseSpecificAttributes(charSet, specificAttributesLength, specificAttributes, &map)) { diff --git a/src/jrd/Attachment.h b/src/jrd/Attachment.h index 1df3287a15..7771cf58ef 100644 --- a/src/jrd/Attachment.h +++ b/src/jrd/Attachment.h @@ -62,6 +62,10 @@ namespace Replication class TableMatcher; } +namespace Firebird { + class TextType; +} + class CharSetContainer; namespace Jrd @@ -84,7 +88,6 @@ namespace Jrd class ArrayField; struct sort_context; class vcl; - class TextType; class Parameter; class jrd_fld; class dsql_dbb; diff --git a/src/jrd/Collation.cpp b/src/jrd/Collation.cpp index 34b585f16f..a5bc9650f1 100644 --- a/src/jrd/Collation.cpp +++ b/src/jrd/Collation.cpp @@ -603,7 +603,7 @@ private: // // Matches is not a case-sensitive operation, thus it has no // 8-bit international impact. - static bool matches(MemoryPool& pool, Jrd::TextType* obj, const CharType* p1, + static bool matches(MemoryPool& pool, TextType* obj, const CharType* p1, SLONG l1_bytes, const CharType* p2, SLONG l2_bytes) { fb_assert(p1 != NULL); @@ -687,7 +687,7 @@ public: private: // Evaluate the "sleuth" search operator. - static bool aux(Jrd::TextType* obj, USHORT flags, + static bool aux(TextType* obj, USHORT flags, const CharType* search, const CharType* end_search, const CharType* match, const CharType* end_match) { @@ -817,7 +817,7 @@ private: // See if a character is a member of a class. // Japanese version operates on short-based buffer, // instead of SCHAR-based. - static bool className(Jrd::TextType* obj, // USHORT flags, + static bool className(TextType* obj, // USHORT flags, const CharType* char_class, const CharType* const end_class, CharType character) { fb_assert(char_class != NULL); @@ -867,7 +867,7 @@ private: // The silly loop setting *v++ to zero initializes the array up to the // highest character defined (also max_op). Believe it or not, that part // is not a bug. - static ULONG actualMerge(/*MemoryPool& pool,*/ Jrd::TextType* obj, + static ULONG actualMerge(/*MemoryPool& pool,*/ TextType* obj, const CharType* match, SLONG match_bytes, const CharType* control, SLONG control_bytes, CharType* combined) //, SLONG combined_bytes) diff --git a/src/jrd/Collation.h b/src/jrd/Collation.h index 1f19820f09..cd00977b1f 100644 --- a/src/jrd/Collation.h +++ b/src/jrd/Collation.h @@ -38,14 +38,14 @@ namespace Jrd { class Lock; class BaseSubstringSimilarMatcher; -class Collation : public TextType +class Collation : public Firebird::TextType { public: - static Collation* createInstance(MemoryPool& pool, TTYPE_ID id, texttype* tt, USHORT attributes, CharSet* cs); + static Collation* createInstance(MemoryPool& pool, TTYPE_ID id, texttype* tt, USHORT attributes, Firebird::CharSet* cs); protected: - Collation(TTYPE_ID id, texttype *a_tt, USHORT a_attributes, CharSet* a_cs) - : TextType(id, a_tt, a_attributes, a_cs), + Collation(TTYPE_ID id, texttype *a_tt, USHORT a_attributes, Firebird::CharSet* a_cs) + : Firebird::TextType(id, a_tt, a_attributes, a_cs), useCount(0), existenceLock(NULL), obsolete(false) diff --git a/src/jrd/cvt_proto.h b/src/jrd/cvt_proto.h index a8a5fb32ce..76eb08bde7 100644 --- a/src/jrd/cvt_proto.h +++ b/src/jrd/cvt_proto.h @@ -55,9 +55,9 @@ namespace Jrd public: virtual bool transliterate(const dsc* from, dsc* to, CHARSET_ID&); virtual CHARSET_ID getChid(const dsc* d); - virtual CharSet* getToCharset(CHARSET_ID charset2); - virtual void validateData(CharSet* toCharset, SLONG length, const UCHAR* q); - virtual ULONG validateLength(CharSet* charSet, CHARSET_ID charSetId, ULONG length, const UCHAR* start, + virtual Firebird::CharSet* getToCharset(CHARSET_ID charset2); + virtual void validateData(Firebird::CharSet* toCharset, SLONG length, const UCHAR* q); + virtual ULONG validateLength(Firebird::CharSet* charSet, CHARSET_ID charSetId, ULONG length, const UCHAR* start, const USHORT size); virtual SLONG getLocalDate(); virtual ISC_TIMESTAMP getCurrentGmtTimeStamp(); @@ -76,7 +76,7 @@ namespace Jrd { } - virtual ULONG validateLength(CharSet* charSet, CHARSET_ID charSetId, ULONG length, const UCHAR* start, + virtual ULONG validateLength(Firebird::CharSet* charSet, CHARSET_ID charSetId, ULONG length, const UCHAR* start, const USHORT size); private: diff --git a/src/jrd/dfw.epp b/src/jrd/dfw.epp index 02f645b9d1..5caa0d91e0 100644 --- a/src/jrd/dfw.epp +++ b/src/jrd/dfw.epp @@ -4044,7 +4044,7 @@ static string remove_icu_info_from_attributes(const string& charsetName, const s { DbgRebuildIntl::out("Remove_icu_info_from_attributes for charset '%s'\n", charsetName.c_str()); - AutoPtr charSet(Jrd::CharSet::createInstance(*getDefaultMemoryPool(), 0, cs)); + AutoPtr charSet(Firebird::CharSet::createInstance(*getDefaultMemoryPool(), 0, cs)); IntlUtil::SpecificAttributesMap map; if (IntlUtil::parseSpecificAttributes(charSet, specificAttributes.length(), (const UCHAR*) specificAttributes.begin(), &map)) diff --git a/src/jrd/intl_builtin.cpp b/src/jrd/intl_builtin.cpp index 4eefd9943f..2a447cc6a9 100644 --- a/src/jrd/intl_builtin.cpp +++ b/src/jrd/intl_builtin.cpp @@ -15,7 +15,7 @@ #include "../common/classes/Aligner.h" using Firebird::IntlUtil; -using Jrd::UnicodeUtil; +using Firebird::UnicodeUtil; static USHORT internal_keylength(texttype*, USHORT); diff --git a/src/jrd/intl_classes.h b/src/jrd/intl_classes.h index 714f40877e..e80c19dae0 100644 --- a/src/jrd/intl_classes.h +++ b/src/jrd/intl_classes.h @@ -42,7 +42,7 @@ namespace Jrd { class PatternMatcher { public: - PatternMatcher(MemoryPool& aPool, TextType* aTextType) + PatternMatcher(MemoryPool& aPool, Firebird::TextType* aTextType) : pool(aPool), textType(aTextType) { @@ -58,13 +58,13 @@ public: protected: MemoryPool& pool; - TextType* textType; + Firebird::TextType* textType; }; class BaseSubstringSimilarMatcher : public PatternMatcher { public: - BaseSubstringSimilarMatcher(MemoryPool& pool, TextType* ttype) + BaseSubstringSimilarMatcher(MemoryPool& pool, Firebird::TextType* ttype) : PatternMatcher(pool, ttype) { } @@ -75,7 +75,7 @@ public: class NullStrConverter { public: - NullStrConverter(MemoryPool& /*pool*/, const TextType* /*obj*/, const UCHAR* /*str*/, SLONG /*len*/) + NullStrConverter(MemoryPool& /*pool*/, const Firebird::TextType* /*obj*/, const UCHAR* /*str*/, SLONG /*len*/) { } }; @@ -84,7 +84,7 @@ template class UpcaseConverter : public PrevConverter { public: - UpcaseConverter(MemoryPool& pool, TextType* obj, const UCHAR*& str, SLONG& len) + UpcaseConverter(MemoryPool& pool, Firebird::TextType* obj, const UCHAR*& str, SLONG& len) : PrevConverter(pool, obj, str, len) { const auto charSet = obj->getCharSet(); @@ -102,7 +102,7 @@ template class CanonicalConverter : public PrevConverter { public: - CanonicalConverter(MemoryPool& pool, TextType* obj, const UCHAR*& str, SLONG& len) + CanonicalConverter(MemoryPool& pool, Firebird::TextType* obj, const UCHAR*& str, SLONG& len) : PrevConverter(pool, obj, str, len) { const SLONG out_len = len / obj->getCharSet()->minBytesPerChar() * obj->getCanonicalWidth(); diff --git a/src/jrd/intl_proto.h b/src/jrd/intl_proto.h index 4f46af9159..abde9c3933 100644 --- a/src/jrd/intl_proto.h +++ b/src/jrd/intl_proto.h @@ -41,13 +41,13 @@ CHARSET_ID INTL_charset(Jrd::thread_db*, USHORT); int INTL_compare(Jrd::thread_db*, const dsc*, const dsc*, ErrorFunction); ULONG INTL_convert_bytes(Jrd::thread_db*, CHARSET_ID, UCHAR*, const ULONG, CHARSET_ID, const BYTE*, const ULONG, ErrorFunction); -Jrd::CsConvert INTL_convert_lookup(Jrd::thread_db*, CHARSET_ID, CHARSET_ID); +Firebird::CsConvert INTL_convert_lookup(Jrd::thread_db*, CHARSET_ID, CHARSET_ID); void INTL_convert_string(dsc*, const dsc*, Firebird::Callbacks* cb); bool INTL_data(const dsc*); bool INTL_data_or_binary(const dsc*); bool INTL_defined_type(Jrd::thread_db*, USHORT); USHORT INTL_key_length(Jrd::thread_db*, USHORT, USHORT); -Jrd::CharSet* INTL_charset_lookup(Jrd::thread_db* tdbb, USHORT parm1); +Firebird::CharSet* INTL_charset_lookup(Jrd::thread_db* tdbb, USHORT parm1); Jrd::Collation* INTL_texttype_lookup(Jrd::thread_db* tdbb, USHORT parm1); void INTL_texttype_unload(Jrd::thread_db*, USHORT); bool INTL_texttype_validate(Jrd::thread_db*, const SubtypeInfo*); diff --git a/src/jrd/jrd.h b/src/jrd/jrd.h index 57dd988ff3..f5eb377619 100644 --- a/src/jrd/jrd.h +++ b/src/jrd/jrd.h @@ -99,6 +99,10 @@ namespace EDS { class Connection; } +namespace Firebird { + class TextType; +} + namespace Jrd { const unsigned MAX_CALLBACKS = 50; @@ -121,7 +125,6 @@ class IndexLock; class ArrayField; struct sort_context; class vcl; -class TextType; class Parameter; class jrd_fld; class dsql_dbb;