Compare commits
No commits in common. "master" and "2.7" have entirely different histories.
12
.gitmodules
vendored
12
.gitmodules
vendored
@ -1,21 +1,21 @@
|
|||||||
[submodule "lib/stdex"]
|
[submodule "lib/stdex"]
|
||||||
path = lib/stdex
|
path = lib/stdex
|
||||||
url = https://git.amebis.si/Amebis/stdex.git
|
url = https://github.com/Amebis/stdex.git
|
||||||
[submodule "lib/WinStd"]
|
[submodule "lib/WinStd"]
|
||||||
path = lib/WinStd
|
path = lib/WinStd
|
||||||
url = https://git.amebis.si/Amebis/WinStd.git
|
url = https://github.com/Amebis/WinStd.git
|
||||||
[submodule "lib/wxExtend"]
|
[submodule "lib/wxExtend"]
|
||||||
path = lib/wxExtend
|
path = lib/wxExtend
|
||||||
url = https://git.amebis.si/Amebis/wxExtend.git
|
url = https://github.com/Amebis/wxExtend.git
|
||||||
[submodule "MSI/MSIBuild"]
|
[submodule "MSI/MSIBuild"]
|
||||||
path = MSI/MSIBuild
|
path = MSI/MSIBuild
|
||||||
url = https://git.amebis.si/Amebis/MSIBuild.git
|
url = https://github.com/Amebis/MSIBuild.git
|
||||||
[submodule "MSI/MSICA"]
|
[submodule "MSI/MSICA"]
|
||||||
path = MSI/MSICA
|
path = MSI/MSICA
|
||||||
url = https://git.amebis.si/Amebis/MSICA.git
|
url = https://github.com/Amebis/MSICA.git
|
||||||
[submodule "Updater"]
|
[submodule "Updater"]
|
||||||
path = Updater
|
path = Updater
|
||||||
url = https://git.amebis.si/Amebis/Updater.git
|
url = https://github.com/Amebis/Updater.git
|
||||||
[submodule "lib/oatpp"]
|
[submodule "lib/oatpp"]
|
||||||
path = lib/oatpp
|
path = lib/oatpp
|
||||||
url = https://github.com/oatpp/oatpp.git
|
url = https://github.com/oatpp/oatpp.git
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit f989fdc827d8fa731977d1771097cf038a50e145
|
Subproject commit d2069d779960d7760ed75d36eb144f0cc3bab6ce
|
Binary file not shown.
2
Updater
2
Updater
@ -1 +1 @@
|
|||||||
Subproject commit a98ef46c5d38dec796dcb78f48240c17f743e3af
|
Subproject commit 46495773c213359200e4294ddcac828a4887e5a9
|
@ -150,8 +150,7 @@ void wxZRColaComposerPanel::SynchronizePanels()
|
|||||||
dst = std::move(dst2);
|
dst = std::move(dst2);
|
||||||
dst2.clear();
|
dst2.clear();
|
||||||
|
|
||||||
for (auto& m : map)
|
map.invert();
|
||||||
m.invert();
|
|
||||||
m_mapping.push_back(std::move(map));
|
m_mapping.push_back(std::move(map));
|
||||||
map.clear();
|
map.clear();
|
||||||
}
|
}
|
||||||
@ -162,8 +161,7 @@ void wxZRColaComposerPanel::SynchronizePanels()
|
|||||||
dst = std::move(dst2);
|
dst = std::move(dst2);
|
||||||
dst2.clear();
|
dst2.clear();
|
||||||
|
|
||||||
for (auto& m : map)
|
map.invert();
|
||||||
m.invert();
|
|
||||||
m_mapping.push_back(std::move(map));
|
m_mapping.push_back(std::move(map));
|
||||||
map.clear();
|
map.clear();
|
||||||
}
|
}
|
||||||
@ -205,16 +203,16 @@ void wxZRColaComposerPanel::OnSourcePaint(wxPaintEvent& event)
|
|||||||
m_selSource.second = to;
|
m_selSource.second = to;
|
||||||
|
|
||||||
m_sourceHex->SetSelection(
|
m_sourceHex->SetSelection(
|
||||||
m_selSourceHex.first = (long)stdex::src2dst<size_t>(m_mappingSourceHex, from),
|
m_selSourceHex.first = (long)m_mappingSourceHex.to_dst(from),
|
||||||
m_selSourceHex.second = (long)stdex::src2dst<size_t>(m_mappingSourceHex, to ));
|
m_selSourceHex.second = (long)m_mappingSourceHex.to_dst(to ));
|
||||||
|
|
||||||
m_destination->SetSelection(
|
m_destination->SetSelection(
|
||||||
m_selDestination.first = (long)MapToDestination(from),
|
m_selDestination.first = (long)MapToDestination(from),
|
||||||
m_selDestination.second = (long)MapToDestination(to ));
|
m_selDestination.second = (long)MapToDestination(to ));
|
||||||
|
|
||||||
m_destinationHex->SetSelection(
|
m_destinationHex->SetSelection(
|
||||||
m_selDestinationHex.first = (long)stdex::src2dst<size_t>(m_mappingDestinationHex, m_selDestination.first ),
|
m_selDestinationHex.first = (long)m_mappingDestinationHex.to_dst(m_selDestination.first ),
|
||||||
m_selDestinationHex.second = (long)stdex::src2dst<size_t>(m_mappingDestinationHex, m_selDestination.second));
|
m_selDestinationHex.second = (long)m_mappingDestinationHex.to_dst(m_selDestination.second));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,16 +230,16 @@ void wxZRColaComposerPanel::OnSourceHexPaint(wxPaintEvent& event)
|
|||||||
m_selSourceHex.second = to;
|
m_selSourceHex.second = to;
|
||||||
|
|
||||||
m_source->SetSelection(
|
m_source->SetSelection(
|
||||||
m_selSource.first = (long)stdex::dst2src<size_t>(m_mappingSourceHex, from),
|
m_selSource.first = (long)m_mappingSourceHex.to_src(from),
|
||||||
m_selSource.second = (long)stdex::dst2src<size_t>(m_mappingSourceHex, to ));
|
m_selSource.second = (long)m_mappingSourceHex.to_src(to ));
|
||||||
|
|
||||||
m_destination->SetSelection(
|
m_destination->SetSelection(
|
||||||
m_selDestination.first = (long)MapToDestination(m_selSource.first ),
|
m_selDestination.first = (long)MapToDestination(m_selSource.first ),
|
||||||
m_selDestination.second = (long)MapToDestination(m_selSource.second));
|
m_selDestination.second = (long)MapToDestination(m_selSource.second));
|
||||||
|
|
||||||
m_destinationHex->SetSelection(
|
m_destinationHex->SetSelection(
|
||||||
m_selDestinationHex.first = (long)stdex::src2dst<size_t>(m_mappingDestinationHex, m_selDestination.first ),
|
m_selDestinationHex.first = (long)m_mappingDestinationHex.to_dst(m_selDestination.first ),
|
||||||
m_selDestinationHex.second = (long)stdex::src2dst<size_t>(m_mappingDestinationHex, m_selDestination.second));
|
m_selDestinationHex.second = (long)m_mappingDestinationHex.to_dst(m_selDestination.second));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,16 +276,16 @@ void wxZRColaComposerPanel::OnDestinationPaint(wxPaintEvent& event)
|
|||||||
m_selDestination.second = to;
|
m_selDestination.second = to;
|
||||||
|
|
||||||
m_destinationHex->SetSelection(
|
m_destinationHex->SetSelection(
|
||||||
m_selDestinationHex.first = (long)stdex::src2dst<size_t>(m_mappingDestinationHex, from),
|
m_selDestinationHex.first = (long)m_mappingDestinationHex.to_dst(from),
|
||||||
m_selDestinationHex.second = (long)stdex::src2dst<size_t>(m_mappingDestinationHex, to ));
|
m_selDestinationHex.second = (long)m_mappingDestinationHex.to_dst(to ));
|
||||||
|
|
||||||
m_source->SetSelection(
|
m_source->SetSelection(
|
||||||
m_selSource.first = (long)MapToSource(from),
|
m_selSource.first = (long)MapToSource(from),
|
||||||
m_selSource.second = (long)MapToSource(to ));
|
m_selSource.second = (long)MapToSource(to ));
|
||||||
|
|
||||||
m_sourceHex->SetSelection(
|
m_sourceHex->SetSelection(
|
||||||
m_selSourceHex.first = (long)stdex::src2dst<size_t>(m_mappingSourceHex, m_selSource.first ),
|
m_selSourceHex.first = (long)m_mappingSourceHex.to_dst(m_selSource.first ),
|
||||||
m_selSourceHex.second = (long)stdex::src2dst<size_t>(m_mappingSourceHex, m_selSource.second));
|
m_selSourceHex.second = (long)m_mappingSourceHex.to_dst(m_selSource.second));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,16 +303,16 @@ void wxZRColaComposerPanel::OnDestinationHexPaint(wxPaintEvent& event)
|
|||||||
m_selDestinationHex.second = to;
|
m_selDestinationHex.second = to;
|
||||||
|
|
||||||
m_destination->SetSelection(
|
m_destination->SetSelection(
|
||||||
m_selDestination.first = (long)stdex::dst2src<size_t>(m_mappingDestinationHex, from),
|
m_selDestination.first = (long)m_mappingDestinationHex.to_src(from),
|
||||||
m_selDestination.second = (long)stdex::dst2src<size_t>(m_mappingDestinationHex, to ));
|
m_selDestination.second = (long)m_mappingDestinationHex.to_src(to ));
|
||||||
|
|
||||||
m_source->SetSelection(
|
m_source->SetSelection(
|
||||||
m_selSource.first = (long)MapToSource(m_selDestination.first ),
|
m_selSource.first = (long)MapToSource(m_selDestination.first ),
|
||||||
m_selSource.second = (long)MapToSource(m_selDestination.second));
|
m_selSource.second = (long)MapToSource(m_selDestination.second));
|
||||||
|
|
||||||
m_sourceHex->SetSelection(
|
m_sourceHex->SetSelection(
|
||||||
m_selSourceHex.first = (long)stdex::src2dst<size_t>(m_mappingSourceHex, m_selSource.first ),
|
m_selSourceHex.first = (long)m_mappingSourceHex.to_dst(m_selSource.first ),
|
||||||
m_selSourceHex.second = (long)stdex::src2dst<size_t>(m_mappingSourceHex, m_selSource.second));
|
m_selSourceHex.second = (long)m_mappingSourceHex.to_dst(m_selSource.second));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,8 +416,8 @@ void wxZRColaComposerPanel::SetHexValue(wxTextCtrl *wnd, std::pair<long, long> &
|
|||||||
|
|
||||||
wnd->SetValue(hex);
|
wnd->SetValue(hex);
|
||||||
wnd->SetSelection(
|
wnd->SetSelection(
|
||||||
range.first = (long)stdex::src2dst<size_t>(mapping, from),
|
range.first = (long)mapping.to_dst(from),
|
||||||
range.second = (long)stdex::src2dst<size_t>(mapping, to ));
|
range.second = (long)mapping.to_dst(to ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ protected:
|
|||||||
inline size_t wxZRColaComposerPanel::MapToDestination(_In_ size_t src) const
|
inline size_t wxZRColaComposerPanel::MapToDestination(_In_ size_t src) const
|
||||||
{
|
{
|
||||||
for (auto m = m_mapping.cbegin(), m_end = m_mapping.cend(); m != m_end; ++m)
|
for (auto m = m_mapping.cbegin(), m_end = m_mapping.cend(); m != m_end; ++m)
|
||||||
src = stdex::src2dst(*m, src);
|
src = m->to_dst(src);
|
||||||
|
|
||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ inline size_t wxZRColaComposerPanel::MapToDestination(_In_ size_t src) const
|
|||||||
inline size_t wxZRColaComposerPanel::MapToSource(_In_ size_t dst) const
|
inline size_t wxZRColaComposerPanel::MapToSource(_In_ size_t dst) const
|
||||||
{
|
{
|
||||||
for (auto m = m_mapping.crbegin(), m_end = m_mapping.crend(); m != m_end; ++m)
|
for (auto m = m_mapping.crbegin(), m_end = m_mapping.crend(); m != m_end; ++m)
|
||||||
dst = stdex::dst2src(*m, dst);
|
dst = m->to_src(dst);
|
||||||
|
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
/// Character description index key comparator
|
/// Character description index key comparator
|
||||||
///
|
///
|
||||||
struct character_desc_idx_less
|
struct character_desc_idx_less : public std::binary_function<std::wstring, std::wstring, bool>
|
||||||
{
|
{
|
||||||
inline bool operator()(const std::wstring& _Left, const std::wstring& _Right) const
|
inline bool operator()(const std::wstring& _Left, const std::wstring& _Right) const
|
||||||
{
|
{
|
||||||
|
@ -981,10 +981,10 @@ int _tmain(int argc, _TCHAR *argv[])
|
|||||||
<< "\"Content-Transfer-Encoding: 8bit\\n\"" << endl
|
<< "\"Content-Transfer-Encoding: 8bit\\n\"" << endl
|
||||||
<< "\"X-Generator: ZRColaCompile\\n\"" << endl;
|
<< "\"X-Generator: ZRColaCompile\\n\"" << endl;
|
||||||
|
|
||||||
charset_encoder<wchar_t, char> conv(stdex::wchar_t_charset, charset_id::utf8);
|
wstring_convert<codecvt_utf8<wchar_t>> conv;
|
||||||
for (auto p = pot.cbegin(); p != pot.cend(); ++p) {
|
for (auto p = pot.cbegin(); p != pot.cend(); ++p) {
|
||||||
// Convert UTF-16 to UTF-8 and escape.
|
// Convert UTF-16 to UTF-8 and escape.
|
||||||
string t(conv.convert(*p)), u;
|
string t(conv.to_bytes(*p)), u;
|
||||||
for (size_t i = 0, n = t.size(); i < n; i++) {
|
for (size_t i = 0, n = t.size(); i < n; i++) {
|
||||||
char c = t[i];
|
char c = t[i];
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdex/compat.hpp>
|
#include <stdex/sal.hpp>
|
||||||
#include <iconv.h>
|
#include <iconv.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
<DisableSpecificWarnings>4100;4505</DisableSpecificWarnings>
|
<DisableSpecificWarnings>4100;4505</DisableSpecificWarnings>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
<EnablePREfast>true</EnablePREfast>
|
<EnablePREfast>true</EnablePREfast>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// Product version as a single DWORD
|
// Product version as a single DWORD
|
||||||
// Note: Used for version comparison within C/C++ code.
|
// Note: Used for version comparison within C/C++ code.
|
||||||
//
|
//
|
||||||
#define PRODUCT_VERSION 0x02070100
|
#define PRODUCT_VERSION 0x02070000
|
||||||
|
|
||||||
//
|
//
|
||||||
// Product version by components
|
// Product version by components
|
||||||
@ -19,26 +19,26 @@
|
|||||||
//
|
//
|
||||||
#define PRODUCT_VERSION_MAJ 2
|
#define PRODUCT_VERSION_MAJ 2
|
||||||
#define PRODUCT_VERSION_MIN 7
|
#define PRODUCT_VERSION_MIN 7
|
||||||
#define PRODUCT_VERSION_REV 1
|
#define PRODUCT_VERSION_REV 0
|
||||||
#define PRODUCT_VERSION_BUILD 0
|
#define PRODUCT_VERSION_BUILD 0
|
||||||
|
|
||||||
//
|
//
|
||||||
// Human readable product version and build year for UI
|
// Human readable product version and build year for UI
|
||||||
//
|
//
|
||||||
#define PRODUCT_VERSION_STR "2.7.1"
|
#define PRODUCT_VERSION_STR "2.7"
|
||||||
#define PRODUCT_BUILD_YEAR_STR "2024"
|
#define PRODUCT_BUILD_YEAR_STR "2023"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Numerical version presentation for ProductVersion propery in
|
// Numerical version presentation for ProductVersion propery in
|
||||||
// MSI packages (syntax: N.N[.N[.N]])
|
// MSI packages (syntax: N.N[.N[.N]])
|
||||||
//
|
//
|
||||||
#define PRODUCT_VERSION_INST "2.7.1"
|
#define PRODUCT_VERSION_INST "2.7"
|
||||||
|
|
||||||
//
|
//
|
||||||
// The product code for ProductCode property in MSI packages
|
// The product code for ProductCode property in MSI packages
|
||||||
// Replace with new on every version change, regardless how minor it is.
|
// Replace with new on every version change, regardless how minor it is.
|
||||||
//
|
//
|
||||||
#define PRODUCT_VERSION_GUID "{9423BEC3-3159-4130-8C3E-48D5DE24D48A}"
|
#define PRODUCT_VERSION_GUID "{BD675AE4-7800-412A-9F89-1C213B722B16}"
|
||||||
|
|
||||||
//
|
//
|
||||||
// The product vendor and application name for configuration keeping.
|
// The product vendor and application name for configuration keeping.
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 6dead076a2e48e7f561c6e72e027c48ffcbb07be
|
Subproject commit 8e323efef9b1305cddc41137bd0483f0a390e2ec
|
@ -66,6 +66,7 @@
|
|||||||
<ClCompile Include="..\src\common.cpp" />
|
<ClCompile Include="..\src\common.cpp" />
|
||||||
<ClCompile Include="..\src\highlight.cpp" />
|
<ClCompile Include="..\src\highlight.cpp" />
|
||||||
<ClCompile Include="..\src\language.cpp" />
|
<ClCompile Include="..\src\language.cpp" />
|
||||||
|
<ClCompile Include="..\src\mapping.cpp" />
|
||||||
<ClCompile Include="..\src\pch.cpp">
|
<ClCompile Include="..\src\pch.cpp">
|
||||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -14,6 +14,9 @@
|
|||||||
<ClCompile Include="..\src\pch.cpp">
|
<ClCompile Include="..\src\pch.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\src\mapping.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\src\translate.cpp">
|
<ClCompile Include="..\src\translate.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
#include <stdex/compat.hpp>
|
#include <stdex/compat.hpp>
|
||||||
#include <stdex/mapping.hpp>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -715,15 +714,57 @@ namespace ZRCola {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Source-destination index transformation mapping
|
/// Source-destination index transformation mapping
|
||||||
///
|
///
|
||||||
using mapping = stdex::mapping<size_t>;
|
struct mapping {
|
||||||
|
public:
|
||||||
|
size_t src; ///< Character index in source string
|
||||||
|
size_t dst; ///< Character index in destination string
|
||||||
|
|
||||||
|
inline mapping() : src(0), dst(0) {};
|
||||||
|
inline mapping(_In_ size_t s, _In_ size_t d) : src(s), dst(d) {}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Reverses source and destination indexes
|
||||||
|
///
|
||||||
|
inline void invert() { size_t tmp = src; src = dst; dst = tmp; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// A vector for destination-source index transformation mapping
|
/// A vector for destination-source index transformation mapping
|
||||||
///
|
///
|
||||||
using mapping_vector = std::vector<mapping>;
|
class mapping_vector : public std::vector<mapping> {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Transforms character index of destination to source
|
||||||
|
///
|
||||||
|
/// \param[in] decmp Character index in destination string
|
||||||
|
///
|
||||||
|
/// \returns Character index in source string
|
||||||
|
///
|
||||||
|
size_t to_src(_In_ size_t dst) const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Transforms source index to destination index
|
||||||
|
///
|
||||||
|
/// \param[in] cmp Character index in source string
|
||||||
|
///
|
||||||
|
/// \returns Character index in destination string
|
||||||
|
///
|
||||||
|
size_t to_dst(_In_ size_t src) const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Reverses source and destination indexes
|
||||||
|
///
|
||||||
|
inline void invert()
|
||||||
|
{
|
||||||
|
for (iterator i = begin(), iEnd = end(); i != iEnd; ++i)
|
||||||
|
i->invert();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Binary compares two strings
|
/// Binary compares two strings
|
||||||
|
@ -12,6 +12,16 @@ namespace ZRCola {
|
|||||||
class translation_db;
|
class translation_db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Reads translation database from a stream
|
||||||
|
///
|
||||||
|
/// \param[in ] stream Input stream
|
||||||
|
/// \param[out] db Translation database
|
||||||
|
///
|
||||||
|
/// \returns The stream \p stream
|
||||||
|
///
|
||||||
|
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::translation_db &db);
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
68
lib/libZRCola/src/mapping.cpp
Normal file
68
lib/libZRCola/src/mapping.cpp
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
Copyright © 2015-2022 Amebis
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "pch.h"
|
||||||
|
|
||||||
|
|
||||||
|
size_t ZRCola::mapping_vector::to_src(_In_ size_t dst) const
|
||||||
|
{
|
||||||
|
if (empty()) {
|
||||||
|
// One-to-one mapping.
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_type l = 0, r = size();;) {
|
||||||
|
if (l < r) {
|
||||||
|
size_type m = (l + r) / 2;
|
||||||
|
const mapping &el = (*this)[m];
|
||||||
|
|
||||||
|
if ( dst < el.dst) r = m;
|
||||||
|
else if (el.dst < dst) l = m + 1;
|
||||||
|
else {
|
||||||
|
// An exact match found.
|
||||||
|
return el.src;
|
||||||
|
}
|
||||||
|
} else if (l) {
|
||||||
|
// We found a map interval.
|
||||||
|
const mapping &el = (*this)[l - 1];
|
||||||
|
return el.src + (dst - el.dst);
|
||||||
|
} else {
|
||||||
|
// The destination character index is left of the first transformation.
|
||||||
|
const mapping &el = (*this)[0];
|
||||||
|
return std::min<size_t>(dst, el.src);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
size_t ZRCola::mapping_vector::to_dst(_In_ size_t src) const
|
||||||
|
{
|
||||||
|
if (empty()) {
|
||||||
|
// One-to-one mapping.
|
||||||
|
return src;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_type l = 0, r = size();;) {
|
||||||
|
if (l < r) {
|
||||||
|
size_type m = (l + r) / 2;
|
||||||
|
const mapping &el = (*this)[m];
|
||||||
|
|
||||||
|
if ( src < el.src) r = m;
|
||||||
|
else if (el.src < src) l = m + 1;
|
||||||
|
else {
|
||||||
|
// An exact match found.
|
||||||
|
return el.dst;
|
||||||
|
}
|
||||||
|
} else if (l) {
|
||||||
|
// We found a map interval.
|
||||||
|
const mapping &el = (*this)[l - 1];
|
||||||
|
return el.dst + (src - el.src);
|
||||||
|
} else {
|
||||||
|
// The source character index is left of the first transformation.
|
||||||
|
const mapping &el = (*this)[0];
|
||||||
|
return std::min<size_t>(src, el.dst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1 +1 @@
|
|||||||
Subproject commit 14ca5e55c8a7c8265b090e1704463c7ab42ca2ee
|
Subproject commit 1e5b0c49179c75508498c91660ae12a7866edebf
|
@ -1 +1 @@
|
|||||||
Subproject commit c1616b032e9597b072de6fae634ef242a6a67b1d
|
Subproject commit fedeef0beaaf9206c38026a110f56645da964803
|
@ -1 +1 @@
|
|||||||
Subproject commit 79ec08365068ab6e03b06caef13de0ce6b06fcd5
|
Subproject commit e3a59d1118053ed48dc15b83d17125da87c434dd
|
Loading…
x
Reference in New Issue
Block a user