diff --git a/Import/VlppRegex.cpp b/Import/VlppRegex.cpp index 96a104bb..216635b6 100644 --- a/Import/VlppRegex.cpp +++ b/Import/VlppRegex.cpp @@ -20,6 +20,41 @@ namespace vl using namespace collections; using namespace regex_internal; +/*********************************************************************** +String Conversion +***********************************************************************/ + + template + struct U32; + + template<> + struct U32 + { + static constexpr U32String(*ToU32)(const WString&) = &wtou32; + static constexpr WString(*FromU32)(const U32String&) = &u32tow; + }; + + template<> + struct U32 + { + static constexpr U32String(*ToU32)(const U8String&) = &u8tou32; + static constexpr U8String(*FromU32)(const U32String&) = &u32tou8; + }; + + template<> + struct U32 + { + static constexpr U32String(*ToU32)(const U16String&) = &u16tou32; + static constexpr U16String(*FromU32)(const U32String&) = &u32tou16; + }; + + template<> + struct U32 + { + static U32String ToU32(const U32String& text) { return text; } + static U32String FromU32(const U32String& text) { return text; } + }; + /*********************************************************************** RegexMatch_ ***********************************************************************/ @@ -64,7 +99,7 @@ RegexMatch_ } template - const typename RegexString_& RegexMatch_::Result()const + const RegexString_& RegexMatch_::Result()const { return result; } @@ -267,60 +302,12 @@ RegexBase_ /*********************************************************************** Regex_ ***********************************************************************/ - - template<> - U32String Regex_::ToU32(const ObjectString& text) - { - return wtou32(text); - } - - template<> - ObjectString Regex_::FromU32(const U32String& text) - { - return u32tow(text); - } - - template<> - U32String Regex_::ToU32(const ObjectString& text) - { - return u8tou32(text); - } - - template<> - ObjectString Regex_::FromU32(const U32String& text) - { - return u32tou8(text); - } - - template<> - U32String Regex_::ToU32(const ObjectString& text) - { - return u16tou32(text); - } - - template<> - ObjectString Regex_::FromU32(const U32String& text) - { - return u32tou16(text); - } - - template<> - U32String Regex_::ToU32(const ObjectString& text) - { - return text; - } - - template<> - ObjectString Regex_::FromU32(const U32String& text) - { - return text; - } template Regex_::Regex_(const ObjectString& code, bool preferPure) { CharRange::List subsets; - RegexExpression::Ref regex = ParseRegexExpression(ToU32(code)); + RegexExpression::Ref regex = ParseRegexExpression(U32::ToU32(code)); Expression::Ref expression = regex->Merge(); expression->NormalizeCharSet(subsets); @@ -372,7 +359,7 @@ Regex_ for (auto&& name : rich->CaptureNames()) { - captureNames.Add(FromU32(name)); + captureNames.Add(U32::FromU32(name)); } } } @@ -965,7 +952,7 @@ RegexLexer_ CharRange::List subsets; for (auto&& code : tokens) { - RegexExpression::Ref regex = ParseRegexExpression(Regex_::ToU32(code)); + RegexExpression::Ref regex = ParseRegexExpression(U32::ToU32(code)); Expression::Ref expression = regex->Merge(); expression->CollectCharSet(subsets); expressions.Add(expression); @@ -1112,21 +1099,21 @@ Template Instantiation template class RegexLexerColorizer_; template class RegexLexerColorizer_; - template RegexTokens_ RegexLexerBase_::Parse (const ObjectString& code, RegexProc_ _proc, vint codeIndex)const; - template RegexLexerWalker_ RegexLexerBase_::Walk ()const; - template RegexLexerColorizer_ RegexLexerBase_::Colorize (RegexProc_ _proc)const; + template RegexTokens_ RegexLexerBase_::Parse (const ObjectString& code, RegexProc_ _proc, vint codeIndex)const; + template RegexLexerWalker_ RegexLexerBase_::Walk ()const; + template RegexLexerColorizer_ RegexLexerBase_::Colorize (RegexProc_ _proc)const; - template RegexTokens_ RegexLexerBase_::Parse (const ObjectString& code, RegexProc_ _proc, vint codeIndex)const; - template RegexLexerWalker_ RegexLexerBase_::Walk ()const; - template RegexLexerColorizer_ RegexLexerBase_::Colorize (RegexProc_ _proc)const; + template RegexTokens_ RegexLexerBase_::Parse (const ObjectString& code, RegexProc_ _proc, vint codeIndex)const; + template RegexLexerWalker_ RegexLexerBase_::Walk ()const; + template RegexLexerColorizer_ RegexLexerBase_::Colorize (RegexProc_ _proc)const; - template RegexTokens_ RegexLexerBase_::Parse (const ObjectString& code, RegexProc_ _proc, vint codeIndex)const; - template RegexLexerWalker_ RegexLexerBase_::Walk ()const; - template RegexLexerColorizer_ RegexLexerBase_::Colorize (RegexProc_ _proc)const; + template RegexTokens_ RegexLexerBase_::Parse (const ObjectString& code, RegexProc_ _proc, vint codeIndex)const; + template RegexLexerWalker_ RegexLexerBase_::Walk ()const; + template RegexLexerColorizer_ RegexLexerBase_::Colorize (RegexProc_ _proc)const; - template RegexTokens_ RegexLexerBase_::Parse (const ObjectString& code, RegexProc_ _proc, vint codeIndex)const; - template RegexLexerWalker_ RegexLexerBase_::Walk ()const; - template RegexLexerColorizer_ RegexLexerBase_::Colorize (RegexProc_ _proc)const; + template RegexTokens_ RegexLexerBase_::Parse (const ObjectString& code, RegexProc_ _proc, vint codeIndex)const; + template RegexLexerWalker_ RegexLexerBase_::Walk ()const; + template RegexLexerColorizer_ RegexLexerBase_::Colorize (RegexProc_ _proc)const; template class RegexLexer_; template class RegexLexer_; diff --git a/Import/VlppRegex.h b/Import/VlppRegex.h index 168dffb9..b6c7d84c 100644 --- a/Import/VlppRegex.h +++ b/Import/VlppRegex.h @@ -381,13 +381,9 @@ Regex template class Regex_ : public RegexBase_ { - template - friend class RegexLexer_; protected: collections::List> captureNames; - static U32String ToU32(const ObjectString& text); - static ObjectString FromU32(const U32String& text); public: NOT_COPYABLE(Regex_); @@ -1229,21 +1225,21 @@ Template Instantiation extern template class RegexLexerColorizer_; extern template class RegexLexerColorizer_; - extern template RegexTokens_ RegexLexerBase_::Parse (const ObjectString& code, RegexProc_ _proc, vint codeIndex)const; - extern template RegexLexerWalker_ RegexLexerBase_::Walk ()const; - extern template RegexLexerColorizer_ RegexLexerBase_::Colorize (RegexProc_ _proc)const; + extern template RegexTokens_ RegexLexerBase_::Parse (const ObjectString& code, RegexProc_ _proc, vint codeIndex)const; + extern template RegexLexerWalker_ RegexLexerBase_::Walk ()const; + extern template RegexLexerColorizer_ RegexLexerBase_::Colorize (RegexProc_ _proc)const; - extern template RegexTokens_ RegexLexerBase_::Parse (const ObjectString& code, RegexProc_ _proc, vint codeIndex)const; - extern template RegexLexerWalker_ RegexLexerBase_::Walk ()const; - extern template RegexLexerColorizer_ RegexLexerBase_::Colorize (RegexProc_ _proc)const; + extern template RegexTokens_ RegexLexerBase_::Parse (const ObjectString& code, RegexProc_ _proc, vint codeIndex)const; + extern template RegexLexerWalker_ RegexLexerBase_::Walk ()const; + extern template RegexLexerColorizer_ RegexLexerBase_::Colorize (RegexProc_ _proc)const; - extern template RegexTokens_ RegexLexerBase_::Parse (const ObjectString& code, RegexProc_ _proc, vint codeIndex)const; - extern template RegexLexerWalker_ RegexLexerBase_::Walk ()const; - extern template RegexLexerColorizer_ RegexLexerBase_::Colorize (RegexProc_ _proc)const; + extern template RegexTokens_ RegexLexerBase_::Parse (const ObjectString& code, RegexProc_ _proc, vint codeIndex)const; + extern template RegexLexerWalker_ RegexLexerBase_::Walk ()const; + extern template RegexLexerColorizer_ RegexLexerBase_::Colorize (RegexProc_ _proc)const; - extern template RegexTokens_ RegexLexerBase_::Parse (const ObjectString& code, RegexProc_ _proc, vint codeIndex)const; - extern template RegexLexerWalker_ RegexLexerBase_::Walk ()const; - extern template RegexLexerColorizer_ RegexLexerBase_::Colorize (RegexProc_ _proc)const; + extern template RegexTokens_ RegexLexerBase_::Parse (const ObjectString& code, RegexProc_ _proc, vint codeIndex)const; + extern template RegexLexerWalker_ RegexLexerBase_::Walk ()const; + extern template RegexLexerColorizer_ RegexLexerBase_::Colorize (RegexProc_ _proc)const; extern template class RegexLexer_; extern template class RegexLexer_;