Compare commits
68 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bbad80235 | ||
|
|
ffe11b17b5 | ||
|
|
0daae5af37 | ||
|
|
2f1f6a6c83 | ||
|
|
f8393e3d77 | ||
|
|
40c4d65669 | ||
|
|
7d866b183b | ||
|
|
b13f77ce95 | ||
|
|
cb324389e4 | ||
|
|
2de62b1636 | ||
|
|
afb137edee | ||
|
|
d4fdd62916 | ||
|
|
ac63e5a957 | ||
|
|
b8aa592b19 | ||
|
|
325b9334b5 | ||
|
|
f547fbc601 | ||
|
|
0e2678f09e | ||
|
|
e78bbc9c3b | ||
|
|
f523d12fa1 | ||
|
|
c6f844775f | ||
|
|
450c18198a | ||
|
|
ad57071515 | ||
|
|
f6d0323485 | ||
|
|
004958f464 | ||
|
|
09117d68a6 | ||
|
|
04eea84f8a | ||
|
|
685ffedb53 | ||
|
|
f74e9930c1 | ||
|
|
a05e62f1d3 | ||
|
|
3aba608001 | ||
|
|
fa59e71fe3 | ||
|
|
839c6fc1e6 | ||
|
|
ff509ed6b5 | ||
|
|
ca3239f0ff | ||
|
|
eb0911d3c0 | ||
|
|
a7c7a3f40c | ||
|
|
a6f0357ad8 | ||
|
|
35eb472e6b | ||
|
|
ba4ff3cd42 | ||
|
|
9709cc2845 | ||
|
|
f35e49dc8b | ||
|
|
9a307978b5 | ||
|
|
bd01e250b2 | ||
|
|
8bb1049cf0 | ||
|
|
52391d9a08 | ||
|
|
823390d28b | ||
|
|
eedab7da56 | ||
|
|
63fda12c99 | ||
|
|
5cc005583c | ||
|
|
6b856314d0 | ||
|
|
b581b7a8b1 | ||
|
|
0bfa44e6bb | ||
|
|
5c05dc6eb6 | ||
|
|
7a2845fef3 | ||
|
|
5b71b776a7 | ||
|
|
2bd3b4c3b9 | ||
|
|
b90ce09c5e | ||
|
|
04a1b95372 | ||
|
|
3c65720188 | ||
|
|
335fdbf949 | ||
|
|
5637381ca6 | ||
|
|
082773fdc9 | ||
|
|
3c9ace0bbe | ||
|
|
7ea4072724 | ||
|
|
3e9f7d6478 | ||
|
|
46a3a13311 | ||
|
|
47d3884af3 | ||
|
|
1f498ab916 |
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -16,3 +16,9 @@
|
||||
[submodule "Updater"]
|
||||
path = Updater
|
||||
url = https://github.com/Amebis/Updater.git
|
||||
[submodule "lib/oatpp"]
|
||||
path = lib/oatpp
|
||||
url = https://github.com/oatpp/oatpp.git
|
||||
[submodule "lib/oatpp-swagger"]
|
||||
path = lib/oatpp-swagger
|
||||
url = https://github.com/oatpp/oatpp-swagger.git
|
||||
|
||||
Submodule MSI/MSIBuild updated: 05edc2b598...b8364dea81
Submodule MSI/MSICA updated: f98cfef1e7...d2069d7799
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# Copyright © 1991-2021 Amebis
|
||||
# Copyright © 1991-2022 Amebis
|
||||
|
||||
!INCLUDE "..\..\include\MSIBuildCfg.mak"
|
||||
!INCLUDE "..\MSIBuild\Makefile"
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,5 +1,6 @@
|
||||
#
|
||||
# Translators:
|
||||
# Simon Rozman <simon@rozman.si>, 2018
|
||||
# Simon Rozman <simon@rozman.si>, 2022
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
@@ -8,7 +9,7 @@ msgstr ""
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-09-19 08:59+0200\n"
|
||||
"PO-Revision-Date: 2018-09-19 07:19+0000\n"
|
||||
"Last-Translator: Simon Rozman <simon@rozman.si>, 2018\n"
|
||||
"Last-Translator: Simon Rozman <simon@rozman.si>, 2022\n"
|
||||
"Language-Team: German (Germany) (https://www.transifex.com/amebis/teams/91592/de_DE/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
@@ -3468,8 +3469,8 @@ msgstr ""
|
||||
#: en_US.Win32.Release.Control-2.idtx:5 en_US.Win32.Release.Control-2.idtx:12
|
||||
#: en_US.x64.Debug.Control-2.idtx:5 en_US.x64.Debug.Control-2.idtx:12
|
||||
#: en_US.x64.Release.Control-2.idtx:5 en_US.x64.Release.Control-2.idtx:12
|
||||
msgid "binUIHeader.bmp"
|
||||
msgstr "binUIHeader.bmp"
|
||||
msgid "UIHeader.bmp"
|
||||
msgstr "UIHeader.bmp"
|
||||
|
||||
#: en_US.Win32.Debug.Control-2.idtx:6 en_US.Win32.Release.Control-2.idtx:6
|
||||
#: en_US.x64.Debug.Control-2.idtx:6 en_US.x64.Release.Control-2.idtx:6
|
||||
@@ -3522,8 +3523,8 @@ msgstr ""
|
||||
|
||||
#: en_US.Win32.Debug.Control-2.idtx:14 en_US.Win32.Release.Control-2.idtx:14
|
||||
#: en_US.x64.Debug.Control-2.idtx:14 en_US.x64.Release.Control-2.idtx:14
|
||||
msgid "binfontsubst.bmp"
|
||||
msgstr "binfontsubst.bmp"
|
||||
msgid "fontsubst.bmp"
|
||||
msgstr "fontsubst.bmp"
|
||||
|
||||
#: en_US.Win32.Debug.Control-2.idtx:15 en_US.Win32.Release.Control-2.idtx:15
|
||||
#: en_US.x64.Debug.Control-2.idtx:15 en_US.x64.Release.Control-2.idtx:15
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#
|
||||
# Translators:
|
||||
# Simon Rozman <simon@rozman.si>, 2018
|
||||
# Simon Rozman <simon@rozman.si>, 2022
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
@@ -8,7 +9,7 @@ msgstr ""
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-09-19 08:59+0200\n"
|
||||
"PO-Revision-Date: 2018-09-19 07:19+0000\n"
|
||||
"Last-Translator: Simon Rozman <simon@rozman.si>, 2018\n"
|
||||
"Last-Translator: Simon Rozman <simon@rozman.si>, 2022\n"
|
||||
"Language-Team: Russian (Russia) (https://www.transifex.com/amebis/teams/91592/ru_RU/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
@@ -3468,8 +3469,8 @@ msgstr ""
|
||||
#: en_US.Win32.Release.Control-2.idtx:5 en_US.Win32.Release.Control-2.idtx:12
|
||||
#: en_US.x64.Debug.Control-2.idtx:5 en_US.x64.Debug.Control-2.idtx:12
|
||||
#: en_US.x64.Release.Control-2.idtx:5 en_US.x64.Release.Control-2.idtx:12
|
||||
msgid "binUIHeader.bmp"
|
||||
msgstr "binUIHeader.bmp"
|
||||
msgid "UIHeader.bmp"
|
||||
msgstr "UIHeader.bmp"
|
||||
|
||||
#: en_US.Win32.Debug.Control-2.idtx:6 en_US.Win32.Release.Control-2.idtx:6
|
||||
#: en_US.x64.Debug.Control-2.idtx:6 en_US.x64.Release.Control-2.idtx:6
|
||||
@@ -3542,8 +3543,8 @@ msgstr "[DlgTitleFont]Шрифт «00 ZRCola» в «ZRCola»"
|
||||
|
||||
#: en_US.Win32.Debug.Control-2.idtx:14 en_US.Win32.Release.Control-2.idtx:14
|
||||
#: en_US.x64.Debug.Control-2.idtx:14 en_US.x64.Release.Control-2.idtx:14
|
||||
msgid "binfontsubst.bmp"
|
||||
msgstr "binfontsubst.bmp"
|
||||
msgid "fontsubst.bmp"
|
||||
msgstr "fontsubst.bmp"
|
||||
|
||||
#: en_US.Win32.Debug.Control-2.idtx:15 en_US.Win32.Release.Control-2.idtx:15
|
||||
#: en_US.x64.Debug.Control-2.idtx:15 en_US.x64.Release.Control-2.idtx:15
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#
|
||||
# Translators:
|
||||
# Simon Rozman <simon@rozman.si>, 2018
|
||||
# Simon Rozman <simon@rozman.si>, 2022
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
@@ -8,7 +9,7 @@ msgstr ""
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-09-19 08:59+0200\n"
|
||||
"PO-Revision-Date: 2018-09-19 07:19+0000\n"
|
||||
"Last-Translator: Simon Rozman <simon@rozman.si>, 2018\n"
|
||||
"Last-Translator: Simon Rozman <simon@rozman.si>, 2022\n"
|
||||
"Language-Team: Slovenian (Slovenia) (https://www.transifex.com/amebis/teams/91592/sl_SI/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
@@ -3468,8 +3469,8 @@ msgstr ""
|
||||
#: en_US.Win32.Release.Control-2.idtx:5 en_US.Win32.Release.Control-2.idtx:12
|
||||
#: en_US.x64.Debug.Control-2.idtx:5 en_US.x64.Debug.Control-2.idtx:12
|
||||
#: en_US.x64.Release.Control-2.idtx:5 en_US.x64.Release.Control-2.idtx:12
|
||||
msgid "binUIHeader.bmp"
|
||||
msgstr "binUIHeader.bmp"
|
||||
msgid "UIHeader.bmp"
|
||||
msgstr "UIHeader.bmp"
|
||||
|
||||
#: en_US.Win32.Debug.Control-2.idtx:6 en_US.Win32.Release.Control-2.idtx:6
|
||||
#: en_US.x64.Debug.Control-2.idtx:6 en_US.x64.Release.Control-2.idtx:6
|
||||
@@ -3503,9 +3504,9 @@ msgstr ""
|
||||
"Roman;}Times New Roman CE;}}{\\colortbl "
|
||||
";\\red0\\green0\\blue255;}{\\*\\generator Msftedit "
|
||||
"5.41.21.2510;}\\viewkind4\\uc1\\pard\\sa200\\sl276\\slmult1\\i\\f0\\fs22 "
|
||||
"Besedilo je bilo pripravljeno z vna\\'9aalnim sistemom ZRCola (http://zrcola"
|
||||
".zrc-sazu.si), ki ga je na Znanstvenoraziskovalnem centru SAZU v Ljubljani "
|
||||
"(http://www.zrc-sazu.si) razvil Peter Weiss.\\i0\\f1\\par}"
|
||||
"Besedilo je bilo pripravljeno z vna\\'9aalnim sistemom ZRCola "
|
||||
"(http://zrcola.zrc-sazu.si), ki ga je na Znanstvenoraziskovalnem centru SAZU"
|
||||
" v Ljubljani (http://www.zrc-sazu.si) razvil Peter Weiss.\\i0\\f1\\par}"
|
||||
|
||||
#: en_US.Win32.Debug.Control-2.idtx:9 en_US.Win32.Release.Control-2.idtx:9
|
||||
#: en_US.x64.Debug.Control-2.idtx:9 en_US.x64.Release.Control-2.idtx:9
|
||||
@@ -3535,8 +3536,8 @@ msgstr "[DlgTitleFont]\"00 ZRCola\" v pisavo \"ZRCola\""
|
||||
|
||||
#: en_US.Win32.Debug.Control-2.idtx:14 en_US.Win32.Release.Control-2.idtx:14
|
||||
#: en_US.x64.Debug.Control-2.idtx:14 en_US.x64.Release.Control-2.idtx:14
|
||||
msgid "binfontsubst.bmp"
|
||||
msgstr "binfontsubst.bmp"
|
||||
msgid "fontsubst.bmp"
|
||||
msgstr "fontsubst.bmp"
|
||||
|
||||
#: en_US.Win32.Debug.Control-2.idtx:15 en_US.Win32.Release.Control-2.idtx:15
|
||||
#: en_US.x64.Debug.Control-2.idtx:15 en_US.x64.Release.Control-2.idtx:15
|
||||
|
||||
BIN
MakefileLang.mak
BIN
MakefileLang.mak
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
MakefilePlat.mak
BIN
MakefilePlat.mak
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
# ZRCola
|
||||
# ZRCola
|
||||
|
||||
A Microsoft Windows application for composing texts using a wide range of Slavic (and general) letters from or beyond Unicode.
|
||||
|
||||
@@ -56,6 +56,10 @@ Use Microsoft NMAKE to build the project. The resulting files can be found in ou
|
||||
|
||||
The `/ls` flag can be appended to the commands above to reduce NMAKE's verbosity. You can combine multiple targets (e.g. nmake Unregister Clean). Please, see NMAKE reference for further reading.
|
||||
|
||||
## Building and installing ZRCola webservice
|
||||
|
||||
ZRCola is also available as a Linux web-service. See [ZRColaWS/README.md](ZRColaWS/README.md) for instructions.
|
||||
|
||||
## Translating ZRCola
|
||||
Instructions how to translate ZRCola to your language can be found [here](LOCALIZATION.md).
|
||||
|
||||
|
||||
2
Updater
2
Updater
Submodule Updater updated: 0ba186c984...46495773c2
30
ZRCola.sln
30
ZRCola.sln
@@ -18,12 +18,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libZRCola", "lib\libZRCola\
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libZRColaUI", "lib\libZRColaUI\build\libZRColaUI.vcxproj", "{C0A84BD2-3870-4CD6-B281-0AB322E3C579}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stdex", "lib\stdex\build\stdex.vcxproj", "{518777CC-0A59-4415-A12A-82751ED75343}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Updater", "Updater\Updater\build\Updater.vcxproj", "{990D8CF9-4457-4DC0-AA18-4968EF434741}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinStd", "lib\WinStd\build\WinStd.vcxproj", "{47399D91-7EB9-41DE-B521-514BA5DB0C43}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|ARM64 = Debug|ARM64
|
||||
@@ -82,18 +78,6 @@ Global
|
||||
{C0A84BD2-3870-4CD6-B281-0AB322E3C579}.Release|Win32.Build.0 = Release|Win32
|
||||
{C0A84BD2-3870-4CD6-B281-0AB322E3C579}.Release|x64.ActiveCfg = Release|x64
|
||||
{C0A84BD2-3870-4CD6-B281-0AB322E3C579}.Release|x64.Build.0 = Release|x64
|
||||
{518777CC-0A59-4415-A12A-82751ED75343}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{518777CC-0A59-4415-A12A-82751ED75343}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{518777CC-0A59-4415-A12A-82751ED75343}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{518777CC-0A59-4415-A12A-82751ED75343}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{518777CC-0A59-4415-A12A-82751ED75343}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{518777CC-0A59-4415-A12A-82751ED75343}.Debug|x64.Build.0 = Debug|x64
|
||||
{518777CC-0A59-4415-A12A-82751ED75343}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{518777CC-0A59-4415-A12A-82751ED75343}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{518777CC-0A59-4415-A12A-82751ED75343}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{518777CC-0A59-4415-A12A-82751ED75343}.Release|Win32.Build.0 = Release|Win32
|
||||
{518777CC-0A59-4415-A12A-82751ED75343}.Release|x64.ActiveCfg = Release|x64
|
||||
{518777CC-0A59-4415-A12A-82751ED75343}.Release|x64.Build.0 = Release|x64
|
||||
{990D8CF9-4457-4DC0-AA18-4968EF434741}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{990D8CF9-4457-4DC0-AA18-4968EF434741}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{990D8CF9-4457-4DC0-AA18-4968EF434741}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
@@ -106,18 +90,6 @@ Global
|
||||
{990D8CF9-4457-4DC0-AA18-4968EF434741}.Release|Win32.Build.0 = Release|Win32
|
||||
{990D8CF9-4457-4DC0-AA18-4968EF434741}.Release|x64.ActiveCfg = Release|x64
|
||||
{990D8CF9-4457-4DC0-AA18-4968EF434741}.Release|x64.Build.0 = Release|x64
|
||||
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Debug|x64.Build.0 = Debug|x64
|
||||
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Release|Win32.Build.0 = Release|Win32
|
||||
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Release|x64.ActiveCfg = Release|x64
|
||||
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -126,9 +98,7 @@ Global
|
||||
{D3E29951-D9F5-486D-A167-20AE8E90B1FA} = {6D85AD6A-69D6-40EB-BF0C-7495479DDCE5}
|
||||
{3C61929E-7289-4101-8D0A-DA22D6E1AEA8} = {6D85AD6A-69D6-40EB-BF0C-7495479DDCE5}
|
||||
{C0A84BD2-3870-4CD6-B281-0AB322E3C579} = {6D85AD6A-69D6-40EB-BF0C-7495479DDCE5}
|
||||
{518777CC-0A59-4415-A12A-82751ED75343} = {6D85AD6A-69D6-40EB-BF0C-7495479DDCE5}
|
||||
{990D8CF9-4457-4DC0-AA18-4968EF434741} = {6D85AD6A-69D6-40EB-BF0C-7495479DDCE5}
|
||||
{47399D91-7EB9-41DE-B521-514BA5DB0C43} = {6D85AD6A-69D6-40EB-BF0C-7495479DDCE5}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {EECB5329-0607-4D77-8BC0-48BD8C08BEF9}
|
||||
|
||||
Binary file not shown.
BIN
ZRCola/ZRCola.rc
BIN
ZRCola/ZRCola.rc
Binary file not shown.
@@ -108,9 +108,6 @@
|
||||
<ProjectReference Include="..\lib\libZRCola\build\libZRCola.vcxproj">
|
||||
<Project>{3c61929e-7289-4101-8d0a-da22d6e1aea8}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\lib\WinStd\build\WinStd.vcxproj">
|
||||
<Project>{47399d91-7eb9-41de-b521-514ba5db0c43}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\lib\wxExtend\build\wxExtendLib.vcxproj">
|
||||
<Project>{D3E29951-D9F5-486D-A167-20AE8E90B1FA}</Project>
|
||||
</ProjectReference>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -46,7 +46,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <stdex/idrec.h>
|
||||
#include <zrcola/idrec.h>
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include <Msi.h>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
///
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
@@ -82,7 +82,7 @@ bool ZRColaApp::OnInit()
|
||||
ZRCola::recordid_t id;
|
||||
if (!stdex::idrec::read_id(dat, id, size)) break;
|
||||
|
||||
if (id == ZRCola::translation_rec::id) {
|
||||
if (id == ZRCola::translation_rec::id()) {
|
||||
dat >> ZRCola::translation_rec(m_t_db);
|
||||
if (dat.good()) {
|
||||
has_translation_data = true;
|
||||
@@ -90,61 +90,61 @@ bool ZRColaApp::OnInit()
|
||||
wxFAIL_MSG(wxT("Error reading translation data from ZRCola.zrcdb."));
|
||||
m_t_db.clear();
|
||||
}
|
||||
} else if (id == ZRCola::transet_rec::id) {
|
||||
} else if (id == ZRCola::transet_rec::id()) {
|
||||
dat >> ZRCola::transet_rec(m_ts_db);
|
||||
if (!dat.good()) {
|
||||
wxFAIL_MSG(wxT("Error reading translation set data from ZRCola.zrcdb."));
|
||||
m_ts_db.clear();
|
||||
}
|
||||
} else if (id == ZRCola::transeq_rec::id) {
|
||||
} else if (id == ZRCola::transeq_rec::id()) {
|
||||
dat >> ZRCola::transeq_rec(m_tsq_db);
|
||||
if (!dat.good()) {
|
||||
wxFAIL_MSG(wxT("Error reading translation sequence data from ZRCola.zrcdb."));
|
||||
m_tsq_db.clear();
|
||||
}
|
||||
} else if (id == ZRCola::langchar_rec::id) {
|
||||
} else if (id == ZRCola::langchar_rec::id()) {
|
||||
dat >> ZRCola::langchar_rec(m_lc_db);
|
||||
if (!dat.good()) {
|
||||
wxFAIL_MSG(wxT("Error reading language character data from ZRCola.zrcdb."));
|
||||
m_lc_db.clear();
|
||||
}
|
||||
} else if (id == ZRCola::language_rec::id) {
|
||||
} else if (id == ZRCola::language_rec::id()) {
|
||||
dat >> ZRCola::language_rec(m_lang_db);
|
||||
if (!dat.good()) {
|
||||
wxFAIL_MSG(wxT("Error reading language character data from ZRCola.zrcdb."));
|
||||
m_lang_db.clear();
|
||||
}
|
||||
} else if (id == ZRCola::keyseq_rec::id) {
|
||||
} else if (id == ZRCola::keyseq_rec::id()) {
|
||||
dat >> ZRCola::keyseq_rec(m_ks_db);
|
||||
if (!dat.good()) {
|
||||
wxFAIL_MSG(wxT("Error reading key sequences data from ZRCola.zrcdb."));
|
||||
m_ks_db.clear();
|
||||
}
|
||||
} else if (id == ZRCola::character_rec::id) {
|
||||
} else if (id == ZRCola::character_rec::id()) {
|
||||
dat >> ZRCola::character_rec(m_chr_db);
|
||||
if (!dat.good()) {
|
||||
wxFAIL_MSG(wxT("Error reading character data from ZRCola.zrcdb."));
|
||||
m_chr_db.clear();
|
||||
}
|
||||
} else if (id == ZRCola::chrcat_rec::id) {
|
||||
} else if (id == ZRCola::chrcat_rec::id()) {
|
||||
dat >> ZRCola::chrcat_rec(m_cc_db);
|
||||
if (!dat.good()) {
|
||||
wxFAIL_MSG(wxT("Error reading character category data from ZRCola.zrcdb."));
|
||||
m_cc_db.clear();
|
||||
}
|
||||
} else if (id == ZRCola::chrtag_rec::id) {
|
||||
} else if (id == ZRCola::chrtag_rec::id()) {
|
||||
dat >> ZRCola::chrtag_rec(m_ct_db);
|
||||
if (!dat.good()) {
|
||||
wxFAIL_MSG(wxT("Error reading character tag data from ZRCola.zrcdb."));
|
||||
m_ct_db.clear();
|
||||
}
|
||||
} else if (id == ZRCola::tagname_rec::id) {
|
||||
} else if (id == ZRCola::tagname_rec::id()) {
|
||||
dat >> ZRCola::tagname_rec(m_tn_db);
|
||||
if (!dat.good()) {
|
||||
wxFAIL_MSG(wxT("Error reading tag name data from ZRCola.zrcdb."));
|
||||
m_tn_db.clear();
|
||||
}
|
||||
} else if (id == ZRCola::highlight_rec::id) {
|
||||
} else if (id == ZRCola::highlight_rec::id()) {
|
||||
dat >> ZRCola::highlight_rec(m_h_db);
|
||||
if (!dat.good()) {
|
||||
wxFAIL_MSG(wxT("Error reading highlight data from ZRCola.zrcdb."));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
///
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
|
||||
protected:
|
||||
#ifdef __WXMSW__
|
||||
winstd::win_handle<NULL> m_running; ///< Global Win32 event to determine if another instance of ZRCola is already running
|
||||
winstd::event m_running; ///< Global Win32 event to determine if another instance of ZRCola is already running
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
@@ -148,11 +148,11 @@ void wxZRColaCharacterCatalogPanel::Update()
|
||||
wxArrayShort(reinterpret_cast<const short*>(cg.chrshow()), reinterpret_cast<const short*>(cg.chrshow_end())));
|
||||
} else {
|
||||
// Select frequently used characters only.
|
||||
const wchar_t *src = cg.chrlst();
|
||||
const unsigned __int16 *shown = cg.chrshow();
|
||||
const auto *src = cg.chrlst();
|
||||
const uint16_t *shown = cg.chrshow();
|
||||
wxArrayString chars;
|
||||
for (size_t i = 0, i_end = cg.chrlst_len(), j = 0; i < i_end; j++) {
|
||||
for (unsigned __int16 k = 0, mask = shown[j]; k < 16 && i < i_end; k++, mask >>= 1) {
|
||||
for (uint16_t k = 0, mask = shown[j]; k < 16 && i < i_end; k++, mask >>= 1) {
|
||||
size_t len = wcsnlen(src + i, i_end - i);
|
||||
if (mask & 1)
|
||||
chars.Add(wxString(src + i, len));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
///
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
@@ -110,7 +110,7 @@ wxString wxZRColaCharGrid::GetToolTipText(int idx)
|
||||
const auto &chr = m_chars[idx];
|
||||
|
||||
// See if this character has a key sequence registered.
|
||||
std::unique_ptr<ZRCola::keyseq_db::keyseq> ks((ZRCola::keyseq_db::keyseq*)new char[sizeof(ZRCola::keyseq_db::keyseq) + sizeof(wchar_t)*chr.length()]);
|
||||
std::unique_ptr<ZRCola::keyseq_db::keyseq> ks((ZRCola::keyseq_db::keyseq*)new char[sizeof(ZRCola::keyseq_db::keyseq) + sizeof(ZRCola::char_t)*chr.length()]);
|
||||
ks->ZRCola::keyseq_db::keyseq::keyseq(NULL, 0, chr.data(), chr.length());
|
||||
ZRCola::keyseq_db::indexKey::size_type start;
|
||||
if (app->m_ks_db.idxChr.find(*ks, start)) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
///
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
///
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
@@ -13,7 +13,7 @@
|
||||
wxIMPLEMENT_DYNAMIC_CLASS(wxZRColaUTF16CharValidator, wxValidator);
|
||||
|
||||
|
||||
wxZRColaUTF16CharValidator::wxZRColaUTF16CharValidator(wchar_t *val) :
|
||||
wxZRColaUTF16CharValidator::wxZRColaUTF16CharValidator(ZRCola::char_t *val) :
|
||||
m_val(val),
|
||||
wxValidator()
|
||||
{
|
||||
@@ -58,11 +58,11 @@ bool wxZRColaUTF16CharValidator::TransferFromWindow()
|
||||
}
|
||||
|
||||
|
||||
bool wxZRColaUTF16CharValidator::Parse(const wxString &val_in, size_t i_start, size_t i_end, wxTextCtrl *ctrl, wxWindow *parent, wchar_t *val_out)
|
||||
bool wxZRColaUTF16CharValidator::Parse(const wxString &val_in, size_t i_start, size_t i_end, wxTextCtrl *ctrl, wxWindow *parent, ZRCola::char_t *val_out)
|
||||
{
|
||||
const wxStringCharType *buf = val_in;
|
||||
|
||||
wchar_t chr = 0;
|
||||
ZRCola::char_t chr = 0;
|
||||
for (size_t i = i_start;;) {
|
||||
if (i >= i_end) {
|
||||
// End of Unicode found.
|
||||
@@ -156,7 +156,7 @@ bool wxZRColaUnicodeDumpValidator::Parse(const wxString &val_in, size_t i_start,
|
||||
wxString str;
|
||||
for (size_t i = i_start;;) {
|
||||
const wxStringCharType *buf_next;
|
||||
wchar_t chr;
|
||||
ZRCola::char_t chr;
|
||||
if ((buf_next = wmemchr(buf + i, L'+', i_end - i)) != NULL) {
|
||||
// Unicode dump separator found.
|
||||
if (!wxZRColaUTF16CharValidator::Parse(val_in, i, buf_next - buf, ctrl, parent, &chr))
|
||||
@@ -242,7 +242,7 @@ void wxZRColaCharSelect::OnIdle(wxIdleEvent& event)
|
||||
|
||||
m_gridPreview->SetCellValue(0, 0, m_char);
|
||||
|
||||
std::unique_ptr<ZRCola::character_db::character> ch((ZRCola::character_db::character*)new char[sizeof(ZRCola::character_db::character) + sizeof(wchar_t)*m_char.length()]);
|
||||
std::unique_ptr<ZRCola::character_db::character> ch((ZRCola::character_db::character*)new char[sizeof(ZRCola::character_db::character) + sizeof(ZRCola::char_t)*m_char.length()]);
|
||||
ch->ZRCola::character_db::character::character(m_char.data(), m_char.length());
|
||||
ZRCola::character_db::indexChr::size_type ch_start;
|
||||
if (app->m_chr_db.idxChr.find(*ch, ch_start)) {
|
||||
@@ -251,7 +251,7 @@ void wxZRColaCharSelect::OnIdle(wxIdleEvent& event)
|
||||
m_description->SetValue(wxString(chr.desc(), chr.desc_len()));
|
||||
{
|
||||
// See if this character has a key sequence registered.
|
||||
std::unique_ptr<ZRCola::keyseq_db::keyseq> ks((ZRCola::keyseq_db::keyseq*)new char[sizeof(ZRCola::keyseq_db::keyseq) + sizeof(wchar_t)*m_char.length()]);
|
||||
std::unique_ptr<ZRCola::keyseq_db::keyseq> ks((ZRCola::keyseq_db::keyseq*)new char[sizeof(ZRCola::keyseq_db::keyseq) + sizeof(ZRCola::char_t)*m_char.length()]);
|
||||
ks->ZRCola::keyseq_db::keyseq::keyseq(NULL, 0, m_char.data(), m_char.length());
|
||||
ZRCola::keyseq_db::indexKey::size_type ks_start;
|
||||
if (app->m_ks_db.idxChr.find(*ks, ks_start)) {
|
||||
@@ -284,7 +284,7 @@ void wxZRColaCharSelect::OnIdle(wxIdleEvent& event)
|
||||
|
||||
// Find character tags.
|
||||
std::list<std::wstring> tag_names;
|
||||
std::unique_ptr<ZRCola::chrtag_db::chrtag> ct((ZRCola::chrtag_db::chrtag*)new char[sizeof(ZRCola::chrtag_db::chrtag) + sizeof(wchar_t)*m_char.length()]);
|
||||
std::unique_ptr<ZRCola::chrtag_db::chrtag> ct((ZRCola::chrtag_db::chrtag*)new char[sizeof(ZRCola::chrtag_db::chrtag) + sizeof(ZRCola::char_t)*m_char.length()]);
|
||||
ct->ZRCola::chrtag_db::chrtag::chrtag(m_char.data(), m_char.length());
|
||||
ZRCola::chrtag_db::indexChr::size_type ct_start, ct_end;
|
||||
if (app->m_ct_db.idxChr.find(*ct, ct_start, ct_end)) {
|
||||
@@ -301,7 +301,7 @@ void wxZRColaCharSelect::OnIdle(wxIdleEvent& event)
|
||||
// Add name to the list.
|
||||
tag_names.push_back(std::wstring(tn.name(), tn.name_end()));
|
||||
break;
|
||||
} else if (ZRCola::tagname_db::tagname::CompareName(m_locale, name->data(), (unsigned __int16)name->length(), tn.name(), tn.name_len()) == 0)
|
||||
} else if (ZRCola::tagname_db::tagname::CompareName(m_locale, name->data(), (uint16_t)name->length(), tn.name(), tn.name_len()) == 0)
|
||||
// Name is already on the list.
|
||||
break;
|
||||
}
|
||||
@@ -718,7 +718,7 @@ wxThread::ExitCode wxZRColaCharSelect::SearchThread::Entry()
|
||||
|
||||
{
|
||||
// Search by tags: Get tags with given names. Then, get characters of found tags.
|
||||
std::map<ZRCola::tagid_t, unsigned __int16> hits_tag;
|
||||
std::map<ZRCola::tagid_t, uint16_t> hits_tag;
|
||||
if (!app->m_tn_db.Search(m_search.c_str(), m_parent->m_locale, hits_tag, TestDestroyS, this)) return (wxThread::ExitCode)1;
|
||||
if (!app->m_ct_db.Search(hits_tag, app->m_chr_db, m_cats, hits, TestDestroyS, this)) return (wxThread::ExitCode)1;
|
||||
}
|
||||
@@ -766,14 +766,14 @@ wxThread::ExitCode wxZRColaCharSelect::SearchThread::Entry()
|
||||
|
||||
int __cdecl wxZRColaCharSelect::SearchThread::CompareHits(const void *a, const void *b)
|
||||
{
|
||||
const std::pair<ZRCola::charrank_t, wchar_t> *_a = (const std::pair<ZRCola::charrank_t, wchar_t>*)a;
|
||||
const std::pair<ZRCola::charrank_t, wchar_t> *_b = (const std::pair<ZRCola::charrank_t, wchar_t>*)b;
|
||||
const std::pair<ZRCola::charrank_t, ZRCola::char_t> *_a = (const std::pair<ZRCola::charrank_t, ZRCola::char_t>*)a;
|
||||
const std::pair<ZRCola::charrank_t, ZRCola::char_t> *_b = (const std::pair<ZRCola::charrank_t, ZRCola::char_t>*)b;
|
||||
|
||||
if (_a->first > _b->first) return -1;
|
||||
else if (_a->first < _b->first) return 1;
|
||||
if (_a->first > _b->first) return -1;
|
||||
if (_a->first < _b->first) return 1;
|
||||
|
||||
if (_a->second < _b->second) return -1;
|
||||
else if (_a->second > _b->second) return 1;
|
||||
if (_a->second < _b->second) return -1;
|
||||
if (_a->second > _b->second) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -843,7 +843,7 @@ bool wxPersistentZRColaCharSelect::Restore()
|
||||
for (wxStringTokenizer tok(str, wxT("|")); tok.HasMoreTokens(); ) {
|
||||
wxString chr;
|
||||
for (wxStringTokenizer tok_chr(tok.GetNextToken(), wxT("+")); tok_chr.HasMoreTokens(); )
|
||||
chr += (wchar_t)_tcstoul(tok_chr.GetNextToken().c_str(), NULL, 16);
|
||||
chr += (ZRCola::char_t)_tcstoul(tok_chr.GetNextToken().c_str(), NULL, 16);
|
||||
val.Add(chr);
|
||||
}
|
||||
wnd->m_gridRecent->SetCharacters(val);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
///
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
///
|
||||
/// Construct the validator with a value to store data
|
||||
///
|
||||
wxZRColaUTF16CharValidator(wchar_t *val = NULL);
|
||||
wxZRColaUTF16CharValidator(ZRCola::char_t *val = NULL);
|
||||
|
||||
///
|
||||
/// Copies this validator
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
@@ -49,7 +49,7 @@ void wxZRColaComposerPanel::RestoreFromStateFile()
|
||||
wxFFile file(fileName, wxT("rb"));
|
||||
if (file.IsOpened()) {
|
||||
// Load source text.
|
||||
unsigned __int64 n;
|
||||
uint64_t n;
|
||||
file.Read(&n, sizeof(n));
|
||||
if (!file.Error()) {
|
||||
wxString source;
|
||||
@@ -98,9 +98,11 @@ void wxZRColaComposerPanel::SynchronizePanels()
|
||||
// ZRCola decompose first, then re-compose.
|
||||
app->m_t_db.TranslateInv(app->m_mainWnd->m_composition_id, dst.data(), dst.size(), dst2, &map);
|
||||
m_mapping.push_back(std::move(map));
|
||||
map.clear();
|
||||
|
||||
app->m_t_db.Translate(app->m_mainWnd->m_composition_id, dst2.data(), dst2.size(), dst, &map);
|
||||
m_mapping.push_back(std::move(map));
|
||||
map.clear();
|
||||
}
|
||||
|
||||
// Other translations
|
||||
@@ -109,7 +111,9 @@ void wxZRColaComposerPanel::SynchronizePanels()
|
||||
for (auto s = sets_begin; s != sets_end; ++s) {
|
||||
app->m_t_db.Translate(*s, dst.data(), dst.size(), dst2, &map);
|
||||
m_mapping.push_back(std::move(map));
|
||||
map.clear();
|
||||
dst = std::move(dst2);
|
||||
dst2.clear();
|
||||
}
|
||||
|
||||
m_source->GetSelection(&m_selSource.first, &m_selSource.second);
|
||||
@@ -144,18 +148,22 @@ void wxZRColaComposerPanel::SynchronizePanels()
|
||||
for (auto s = sets_end; (s--) != sets_begin;) {
|
||||
app->m_t_db.TranslateInv(*s, dst.data(), dst.size(), dst2, &map);
|
||||
dst = std::move(dst2);
|
||||
dst2.clear();
|
||||
|
||||
map.invert();
|
||||
m_mapping.push_back(std::move(map));
|
||||
map.clear();
|
||||
}
|
||||
|
||||
if (app->m_mainWnd->m_composition) {
|
||||
// ZRCola decompose.
|
||||
app->m_t_db.TranslateInv(app->m_mainWnd->m_composition_id, dst.data(), dst.size(), &app->m_lc_db, app->m_mainWnd->m_settings->m_lang, dst2, &map);
|
||||
dst = std::move(dst2);
|
||||
dst2.clear();
|
||||
|
||||
map.invert();
|
||||
m_mapping.push_back(std::move(map));
|
||||
map.clear();
|
||||
}
|
||||
|
||||
m_destination->GetSelection(&m_selDestination.first, &m_selDestination.second);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
///
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
///
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
///
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
///
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
///
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
///
|
||||
|
||||
Binary file not shown.
@@ -66,9 +66,6 @@
|
||||
<ProjectReference Include="..\lib\libZRCola\build\libZRCola.vcxproj">
|
||||
<Project>{3c61929e-7289-4101-8d0a-da22d6e1aea8}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\lib\WinStd\build\WinStd.vcxproj">
|
||||
<Project>{47399d91-7eb9-41de-b521-514ba5db0c43}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\lib\wxExtend\build\wxExtendLib.vcxproj">
|
||||
<Project>{D3E29951-D9F5-486D-A167-20AE8E90B1FA}</Project>
|
||||
</ProjectReference>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
@@ -42,7 +42,7 @@ void ZRCola::DBSource::character_bank::build_related()
|
||||
|
||||
|
||||
ZRCola::DBSource::character_bank::build_related_worker::build_related_worker(_In_ const character_bank *cb, _In_ iterator from, _In_ iterator to) :
|
||||
win_handle<INVALID_HANDLE_VALUE>((HANDLE)_beginthreadex(NULL, 0, process, this, CREATE_SUSPENDED, NULL)),
|
||||
winstd::thread((HANDLE)_beginthreadex(NULL, 0, process, this, CREATE_SUSPENDED, NULL)),
|
||||
m_heap(HeapCreate(0, 0, 0)),
|
||||
m_cb(cb),
|
||||
m_from(from),
|
||||
@@ -186,7 +186,7 @@ void ZRCola::DBSource::character_desc_idx::add_keywords(const set<wstring> &term
|
||||
}
|
||||
|
||||
|
||||
void ZRCola::DBSource::character_desc_idx::save(ZRCola::textindex<wchar_t, wchar_t, unsigned __int32> &idx) const
|
||||
void ZRCola::DBSource::character_desc_idx::save(ZRCola::textindex<wchar_t, wchar_t, uint32_t> &idx) const
|
||||
{
|
||||
idx .clear();
|
||||
idx.keys .clear();
|
||||
@@ -205,7 +205,7 @@ void ZRCola::DBSource::character_desc_idx::save(ZRCola::textindex<wchar_t, wchar
|
||||
|
||||
// Convert the index.
|
||||
for (const_iterator i = cbegin(), i_end = cend(); i != i_end; ++i) {
|
||||
ZRCola::mappair_t<unsigned __int32> p = { idx.keys.size(), idx.values.size() };
|
||||
ZRCola::mappair_t<uint32_t> p = { idx.keys.size(), idx.values.size() };
|
||||
idx.push_back(p);
|
||||
idx.keys.insert(idx.keys.end(), i->first.cbegin(), i->first.cend());
|
||||
idx.values.insert(idx.values.end(), i->second.cbegin(), i->second.cend());
|
||||
@@ -670,7 +670,7 @@ bool ZRCola::DBSource::GetTagNames(const winstd::com_obj<ADOField>& f, LCID lcid
|
||||
// Add name to the list.
|
||||
names.push_back(std::move(name));
|
||||
break;
|
||||
} else if (ZRCola::tagname_db::tagname::CompareName(lcid, n->data(), (unsigned __int16)n->length(), name.data(), (unsigned __int16)name.length()) == CSTR_EQUAL) {
|
||||
} else if (ZRCola::tagname_db::tagname::CompareName(lcid, n->data(), (uint16_t)n->length(), name.data(), (uint16_t)name.length()) == CSTR_EQUAL) {
|
||||
// Name is already on the list.
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -222,11 +222,11 @@ namespace ZRCola {
|
||||
///
|
||||
class chrgrp {
|
||||
public:
|
||||
short grp; ///< Character group ID
|
||||
short rank; ///< Rank
|
||||
std::wstring name; ///< Name
|
||||
std::vector<wchar_t> chars; ///< Characters (zero-delimited)
|
||||
std::vector<unsigned __int16> show; ///< Bit vector if particular character from \c chars is displayed initially
|
||||
short grp; ///< Character group ID
|
||||
short rank; ///< Rank
|
||||
std::wstring name; ///< Name
|
||||
std::vector<wchar_t> chars; ///< Characters (zero-delimited)
|
||||
std::vector<uint16_t> show; ///< Bit vector if particular character from \c chars is displayed initially
|
||||
|
||||
inline chrgrp() : grp(0), rank(0) {}
|
||||
};
|
||||
@@ -275,7 +275,7 @@ namespace ZRCola {
|
||||
void build_related();
|
||||
|
||||
protected:
|
||||
class build_related_worker : public winstd::win_handle<INVALID_HANDLE_VALUE>
|
||||
class build_related_worker : public winstd::thread
|
||||
{
|
||||
public:
|
||||
build_related_worker(_In_ const character_bank *cb, _In_ iterator from, _In_ iterator to);
|
||||
@@ -312,15 +312,8 @@ namespace ZRCola {
|
||||
{
|
||||
inline bool operator()(const std::wstring& _Left, const std::wstring& _Right) const
|
||||
{
|
||||
size_t
|
||||
_Left_len = _Left .size(),
|
||||
_Right_len = _Right.size();
|
||||
|
||||
int r = _wcsncoll(_Left.c_str(), _Right.c_str(), std::min<size_t>(_Left_len, _Right_len));
|
||||
if (r != 0 ) return r < 0;
|
||||
else if (_Left_len < _Right_len) return true;
|
||||
|
||||
return false;
|
||||
auto &coll = std::use_facet<std::collate<wchar_t>>(std::locale());
|
||||
return coll.compare(&*_Left.cbegin(), &*_Left.cend(), &*_Right.cbegin(), &*_Right.cend()) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -340,7 +333,7 @@ namespace ZRCola {
|
||||
add_keywords(terms, chr, sub);
|
||||
}
|
||||
|
||||
void save(ZRCola::textindex<wchar_t, wchar_t, unsigned __int32> &idx) const;
|
||||
void save(ZRCola::textindex<wchar_t, wchar_t, uint32_t> &idx) const;
|
||||
|
||||
protected:
|
||||
inline void add_keyword(const std::wstring &term, const std::wstring &chr)
|
||||
@@ -920,16 +913,16 @@ namespace ZRCola {
|
||||
|
||||
inline ZRCola::translation_db& operator<<(_Inout_ ZRCola::translation_db &db, _In_ const ZRCola::DBSource::translation &rec)
|
||||
{
|
||||
unsigned __int32 idx = db.data.size();
|
||||
db.data.push_back((unsigned __int16)rec.set);
|
||||
db.data.push_back((unsigned __int16)rec.dst.rank);
|
||||
db.data.push_back((unsigned __int16)rec.src.rank);
|
||||
uint32_t idx = db.data.size();
|
||||
db.data.push_back((uint16_t)rec.set);
|
||||
db.data.push_back((uint16_t)rec.dst.rank);
|
||||
db.data.push_back((uint16_t)rec.src.rank);
|
||||
std::wstring::size_type n = rec.dst.str.length();
|
||||
wxASSERT_MSG(n <= 0xffff, wxT("destination overflow"));
|
||||
db.data.push_back((unsigned __int16)n);
|
||||
db.data.push_back((uint16_t)n);
|
||||
n += rec.src.str.length();
|
||||
wxASSERT_MSG(n <= 0xffff, wxT("source overflow"));
|
||||
db.data.push_back((unsigned __int16)n);
|
||||
db.data.push_back((uint16_t)n);
|
||||
db.data.insert(db.data.end(), rec.dst.str.cbegin(), rec.dst.str.cend());
|
||||
db.data.insert(db.data.end(), rec.src.str.cbegin(), rec.src.str.cend());
|
||||
db.idxSrc.push_back(idx);
|
||||
@@ -941,14 +934,14 @@ inline ZRCola::translation_db& operator<<(_Inout_ ZRCola::translation_db &db, _I
|
||||
|
||||
inline ZRCola::transet_db& operator<<(_Inout_ ZRCola::transet_db &db, _In_ const ZRCola::DBSource::transet &rec)
|
||||
{
|
||||
unsigned __int32 idx = db.data.size();
|
||||
db.data.push_back((unsigned __int16)rec.set);
|
||||
uint32_t idx = db.data.size();
|
||||
db.data.push_back((uint16_t)rec.set);
|
||||
std::wstring::size_type n = rec.src.length();
|
||||
wxASSERT_MSG(n <= 0xffff, wxT("translation set source name overflow"));
|
||||
db.data.push_back((unsigned __int16)n);
|
||||
db.data.push_back((uint16_t)n);
|
||||
n += rec.dst.length();
|
||||
wxASSERT_MSG(n <= 0xffff, wxT("translation set destination name overflow"));
|
||||
db.data.push_back((unsigned __int16)n);
|
||||
db.data.push_back((uint16_t)n);
|
||||
db.data.insert(db.data.end(), rec.src.cbegin(), rec.src.cend());
|
||||
db.data.insert(db.data.end(), rec.dst.cbegin(), rec.dst.cend());
|
||||
db.idxTranSet.push_back(idx);
|
||||
@@ -959,18 +952,18 @@ inline ZRCola::transet_db& operator<<(_Inout_ ZRCola::transet_db &db, _In_ const
|
||||
|
||||
inline ZRCola::transeq_db& operator<<(_Inout_ ZRCola::transeq_db &db, _In_ const ZRCola::DBSource::transeq &rec)
|
||||
{
|
||||
unsigned __int32 idx = db.data.size();
|
||||
db.data.push_back((unsigned __int16)rec.seq);
|
||||
db.data.push_back((unsigned __int16)rec.rank);
|
||||
uint32_t idx = db.data.size();
|
||||
db.data.push_back((uint16_t)rec.seq);
|
||||
db.data.push_back((uint16_t)rec.rank);
|
||||
std::wstring::size_type n = rec.name.length();
|
||||
wxASSERT_MSG(n <= 0xffff, wxT("translation sequence name overflow"));
|
||||
db.data.push_back((unsigned __int16)n);
|
||||
db.data.push_back((uint16_t)n);
|
||||
n += rec.sets.size();
|
||||
wxASSERT_MSG(n <= 0xffff, wxT("translation sequence sets overflow"));
|
||||
db.data.push_back((unsigned __int16)n);
|
||||
db.data.push_back((uint16_t)n);
|
||||
db.data.insert(db.data.end(), rec.name.cbegin(), rec.name.cend());
|
||||
for (auto s = rec.sets.cbegin(), s_end = rec.sets.cend(); s != s_end; ++s)
|
||||
db.data.push_back((unsigned __int16)*s);
|
||||
db.data.push_back((uint16_t)*s);
|
||||
db.idxTranSeq.push_back(idx);
|
||||
db.idxRank .push_back(idx);
|
||||
|
||||
@@ -980,13 +973,13 @@ inline ZRCola::transeq_db& operator<<(_Inout_ ZRCola::transeq_db &db, _In_ const
|
||||
|
||||
inline ZRCola::keyseq_db& operator<<(_Inout_ ZRCola::keyseq_db &db, _In_ const ZRCola::DBSource::keyseq &rec)
|
||||
{
|
||||
unsigned __int32 idx = db.data.size();
|
||||
uint32_t idx = db.data.size();
|
||||
std::wstring::size_type n = rec.chr.length();
|
||||
wxASSERT_MSG(n <= 0xffff, wxT("character overflow"));
|
||||
db.data.push_back((unsigned __int16)n);
|
||||
db.data.push_back((uint16_t)n);
|
||||
n += rec.seq.size() * sizeof(ZRCola::keyseq_db::keyseq::key_t) / sizeof(wchar_t);
|
||||
wxASSERT_MSG(n <= 0xffff, wxT("key sequence overflow"));
|
||||
db.data.push_back((unsigned __int16)n);
|
||||
db.data.push_back((uint16_t)n);
|
||||
db.data.insert(db.data.end(), rec.chr.cbegin(), rec.chr.cend());
|
||||
for (auto kc = rec.seq.cbegin(), kc_end = rec.seq.cend(); kc != kc_end; ++kc) {
|
||||
db.data.push_back(kc->key);
|
||||
@@ -1004,11 +997,11 @@ inline ZRCola::keyseq_db& operator<<(_Inout_ ZRCola::keyseq_db &db, _In_ const Z
|
||||
|
||||
inline ZRCola::language_db& operator<<(_Inout_ ZRCola::language_db &db, _In_ const ZRCola::DBSource::language &rec)
|
||||
{
|
||||
unsigned __int32 idx = db.data.size();
|
||||
db.data.insert(db.data.end(), reinterpret_cast<const unsigned __int16*>(&rec.lang), reinterpret_cast<const unsigned __int16*>(&rec.lang + 1));
|
||||
uint32_t idx = db.data.size();
|
||||
db.data.insert(db.data.end(), reinterpret_cast<const uint16_t*>(&rec.lang), reinterpret_cast<const uint16_t*>(&rec.lang + 1));
|
||||
std::wstring::size_type n = rec.name.length();
|
||||
wxASSERT_MSG(n <= 0xffff, wxT("language name overflow"));
|
||||
db.data.push_back((unsigned __int16)n);
|
||||
db.data.push_back((uint16_t)n);
|
||||
db.data.insert(db.data.end(), rec.name.cbegin(), rec.name.cend());
|
||||
db.idxLang.push_back(idx);
|
||||
|
||||
@@ -1018,11 +1011,11 @@ inline ZRCola::language_db& operator<<(_Inout_ ZRCola::language_db &db, _In_ con
|
||||
|
||||
inline ZRCola::langchar_db& operator<<(_Inout_ ZRCola::langchar_db &db, _In_ const ZRCola::DBSource::langchar &rec)
|
||||
{
|
||||
unsigned __int32 idx = db.data.size();
|
||||
db.data.insert(db.data.end(), reinterpret_cast<const unsigned __int16*>(&rec.lang), reinterpret_cast<const unsigned __int16*>(&rec.lang + 1));
|
||||
uint32_t idx = db.data.size();
|
||||
db.data.insert(db.data.end(), reinterpret_cast<const uint16_t*>(&rec.lang), reinterpret_cast<const uint16_t*>(&rec.lang + 1));
|
||||
std::wstring::size_type n = rec.chr.length();
|
||||
wxASSERT_MSG(n <= 0xffff, wxT("character overflow"));
|
||||
db.data.push_back((unsigned __int16)n);
|
||||
db.data.push_back((uint16_t)n);
|
||||
db.data.insert(db.data.end(), rec.chr.cbegin(), rec.chr.cend());
|
||||
db.idxChr .push_back(idx);
|
||||
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
|
||||
@@ -1035,15 +1028,15 @@ inline ZRCola::langchar_db& operator<<(_Inout_ ZRCola::langchar_db &db, _In_ con
|
||||
|
||||
inline ZRCola::chrgrp_db& operator<<(_Inout_ ZRCola::chrgrp_db &db, _In_ const ZRCola::DBSource::chrgrp &rec)
|
||||
{
|
||||
unsigned __int32 idx = db.data.size();
|
||||
db.data.push_back((unsigned __int16)rec.grp);
|
||||
db.data.push_back((unsigned __int16)rec.rank);
|
||||
uint32_t idx = db.data.size();
|
||||
db.data.push_back((uint16_t)rec.grp);
|
||||
db.data.push_back((uint16_t)rec.rank);
|
||||
std::wstring::size_type n = rec.name.length();
|
||||
wxASSERT_MSG(n <= 0xffff, wxT("character group name overflow"));
|
||||
db.data.push_back((unsigned __int16)n);
|
||||
db.data.push_back((uint16_t)n);
|
||||
n += rec.chars.size();
|
||||
wxASSERT_MSG(n <= 0xffff, wxT("character group characters overflow"));
|
||||
db.data.push_back((unsigned __int16)n);
|
||||
db.data.push_back((uint16_t)n);
|
||||
db.data.insert(db.data.end(), rec.name .cbegin(), rec.name .cend());
|
||||
db.data.insert(db.data.end(), rec.chars.cbegin(), rec.chars.cend());
|
||||
db.data.insert(db.data.end(), rec.show .cbegin(), rec.show .cend());
|
||||
@@ -1055,17 +1048,17 @@ inline ZRCola::chrgrp_db& operator<<(_Inout_ ZRCola::chrgrp_db &db, _In_ const Z
|
||||
|
||||
inline ZRCola::character_db& operator<<(_Inout_ ZRCola::character_db &db, _In_ const ZRCola::DBSource::character &rec)
|
||||
{
|
||||
unsigned __int32 idx = db.data.size();
|
||||
db.data.insert(db.data.end(), reinterpret_cast<const unsigned __int16*>(&rec.second.cat), reinterpret_cast<const unsigned __int16*>(&rec.second.cat + 1));
|
||||
uint32_t idx = db.data.size();
|
||||
db.data.insert(db.data.end(), reinterpret_cast<const uint16_t*>(&rec.second.cat), reinterpret_cast<const uint16_t*>(&rec.second.cat + 1));
|
||||
std::wstring::size_type n = rec.first.length();
|
||||
wxASSERT_MSG(n <= 0xffff, wxT("character overflow"));
|
||||
db.data.push_back((unsigned __int16)n);
|
||||
db.data.push_back((uint16_t)n);
|
||||
n += rec.second.desc.length();
|
||||
wxASSERT_MSG(n <= 0xffff, wxT("character description overflow"));
|
||||
db.data.push_back((unsigned __int16)n);
|
||||
db.data.push_back((uint16_t)n);
|
||||
n += rec.second.rel.size();
|
||||
wxASSERT_MSG(n <= 0xffff, wxT("related characters overflow"));
|
||||
db.data.push_back((unsigned __int16)n);
|
||||
db.data.push_back((uint16_t)n);
|
||||
db.data.insert(db.data.end(), rec.first .cbegin(), rec.first .cend());
|
||||
db.data.insert(db.data.end(), rec.second.desc.cbegin(), rec.second.desc.cend());
|
||||
db.data.insert(db.data.end(), rec.second.rel .cbegin(), rec.second.rel .cend());
|
||||
@@ -1077,12 +1070,12 @@ inline ZRCola::character_db& operator<<(_Inout_ ZRCola::character_db &db, _In_ c
|
||||
|
||||
inline ZRCola::chrcat_db& operator<<(_Inout_ ZRCola::chrcat_db &db, _In_ const ZRCola::DBSource::chrcat &rec)
|
||||
{
|
||||
unsigned __int32 idx = db.data.size();
|
||||
db.data.insert(db.data.end(), reinterpret_cast<const unsigned __int16*>(&rec.cat), reinterpret_cast<const unsigned __int16*>(&rec.cat + 1));
|
||||
db.data.push_back((unsigned __int16)rec.rank);
|
||||
uint32_t idx = db.data.size();
|
||||
db.data.insert(db.data.end(), reinterpret_cast<const uint16_t*>(&rec.cat), reinterpret_cast<const uint16_t*>(&rec.cat + 1));
|
||||
db.data.push_back((uint16_t)rec.rank);
|
||||
std::wstring::size_type n = rec.name.length();
|
||||
wxASSERT_MSG(n <= 0xffff, wxT("character category name overflow"));
|
||||
db.data.push_back((unsigned __int16)n);
|
||||
db.data.push_back((uint16_t)n);
|
||||
db.data.insert(db.data.end(), rec.name.cbegin(), rec.name.cend());
|
||||
db.idxChrCat.push_back(idx);
|
||||
db.idxRank .push_back(idx);
|
||||
@@ -1093,11 +1086,11 @@ inline ZRCola::chrcat_db& operator<<(_Inout_ ZRCola::chrcat_db &db, _In_ const Z
|
||||
|
||||
inline ZRCola::chrtag_db& operator<<(_Inout_ ZRCola::chrtag_db &db, _In_ const ZRCola::DBSource::chrtag &rec)
|
||||
{
|
||||
unsigned __int32 idx = db.data.size();
|
||||
db.data.push_back((unsigned __int16)rec.tag);
|
||||
uint32_t idx = db.data.size();
|
||||
db.data.push_back((uint16_t)rec.tag);
|
||||
std::wstring::size_type n = rec.chr.length();
|
||||
wxASSERT_MSG(n <= 0xffff, wxT("character overflow"));
|
||||
db.data.push_back((unsigned __int16)n);
|
||||
db.data.push_back((uint16_t)n);
|
||||
db.data.insert(db.data.end(), rec.chr.cbegin(), rec.chr.cend());
|
||||
db.idxChr.push_back(idx);
|
||||
db.idxTag.push_back(idx);
|
||||
@@ -1110,13 +1103,13 @@ inline ZRCola::tagname_db& operator<<(_Inout_ ZRCola::tagname_db &db, _In_ const
|
||||
{
|
||||
for (auto ln = rec.names.cbegin(), ln_end = rec.names.cend(); ln != ln_end; ++ln) {
|
||||
for (auto nm = ln->second.cbegin(), nm_end = ln->second.cend(); nm != nm_end; ++nm) {
|
||||
unsigned __int32 idx = db.data.size();
|
||||
db.data.push_back((unsigned __int16)rec.tag);
|
||||
uint32_t idx = db.data.size();
|
||||
db.data.push_back((uint16_t)rec.tag);
|
||||
db.data.push_back(LOWORD(ln->first));
|
||||
db.data.push_back(HIWORD(ln->first));
|
||||
std::wstring::size_type n = nm->length();
|
||||
wxASSERT_MSG(n <= 0xffff, wxT("tag name overflow"));
|
||||
db.data.push_back((unsigned __int16)n);
|
||||
db.data.push_back((uint16_t)n);
|
||||
db.data.insert(db.data.end(), nm->cbegin(), nm->cend());
|
||||
db.idxName.push_back(idx);
|
||||
db.idxTag .push_back(idx);
|
||||
@@ -1129,11 +1122,11 @@ inline ZRCola::tagname_db& operator<<(_Inout_ ZRCola::tagname_db &db, _In_ const
|
||||
|
||||
inline ZRCola::highlight_db& operator<<(_Inout_ ZRCola::highlight_db &db, _In_ const ZRCola::DBSource::highlight &rec)
|
||||
{
|
||||
unsigned __int32 idx = db.data.size();
|
||||
db.data.push_back((unsigned __int16)rec.set);
|
||||
uint32_t idx = db.data.size();
|
||||
db.data.push_back((uint16_t)rec.set);
|
||||
std::wstring::size_type n = rec.chr.length();
|
||||
wxASSERT_MSG(n <= 0xffff, wxT("character overflow"));
|
||||
db.data.push_back((unsigned __int16)n);
|
||||
db.data.push_back((uint16_t)n);
|
||||
db.data.insert(db.data.end(), rec.chr.cbegin(), rec.chr.cend());
|
||||
db.idxChr.push_back(idx);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: ZRColaCompile\n"
|
||||
"POT-Creation-Date: 2018-09-19 09:00+0200\n"
|
||||
"POT-Creation-Date: 2022-02-17 13:30+0100\n"
|
||||
"PO-Revision-Date: 2016-04-13 18:11+0200\n"
|
||||
"Last-Translator: Simon Rozman <simon.rozman@amebis.si>\n"
|
||||
"Language-Team: Amebis, d. o. o., Kamnik <info@amebis.si>\n"
|
||||
@@ -10,25 +10,25 @@ msgstr ""
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 2.1.1\n"
|
||||
"X-Generator: Poedit 2.4.2\n"
|
||||
"X-Poedit-Basepath: ..\n"
|
||||
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
"X-Poedit-KeywordsList: _\n"
|
||||
"X-Poedit-SearchPath-0: .\n"
|
||||
|
||||
#: main.cpp:251
|
||||
#: main.cpp:239
|
||||
msgid "Show this help message"
|
||||
msgstr ""
|
||||
|
||||
#: main.cpp:252
|
||||
msgid "<input file>"
|
||||
#: main.cpp:240
|
||||
msgid "<Input file>"
|
||||
msgstr ""
|
||||
|
||||
#: main.cpp:253
|
||||
msgid "<output file>"
|
||||
#: main.cpp:241
|
||||
msgid "<Output file>"
|
||||
msgstr ""
|
||||
|
||||
#: main.cpp:254
|
||||
msgid "<output POT catalog>"
|
||||
#: main.cpp:242
|
||||
msgid "Output POT catalog"
|
||||
msgstr ""
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2018-2021 Amebis
|
||||
Copyright © 2018-2022 Amebis
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2018-2021 Amebis
|
||||
Copyright © 2018-2022 Amebis
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <wx/intl.h>
|
||||
#pragma warning(pop)
|
||||
|
||||
#include <stdex/idrec.h>
|
||||
#include <zrcola/idrec.h>
|
||||
|
||||
#include <WinStd/Common.h>
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -16,14 +16,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZRColaCompile", "ZRColaComp
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxExtend", "lib\wxExtend\build\wxExtendLib.vcxproj", "{D3E29951-D9F5-486D-A167-20AE8E90B1FA}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stdex", "lib\stdex\build\stdex.vcxproj", "{518777CC-0A59-4415-A12A-82751ED75343}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libZRColaUI", "lib\libZRColaUI\build\libZRColaUI.vcxproj", "{C0A84BD2-3870-4CD6-B281-0AB322E3C579}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZRColaInstall", "ZRColaInstall\ZRColaInstall.vcxproj", "{5BD95B95-38B0-4C7D-9471-F99CA1203DF4}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinStd", "lib\WinStd\build\WinStd.vcxproj", "{47399D91-7EB9-41DE-B521-514BA5DB0C43}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
@@ -42,10 +38,6 @@ Global
|
||||
{D3E29951-D9F5-486D-A167-20AE8E90B1FA}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D3E29951-D9F5-486D-A167-20AE8E90B1FA}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D3E29951-D9F5-486D-A167-20AE8E90B1FA}.Release|Win32.Build.0 = Release|Win32
|
||||
{518777CC-0A59-4415-A12A-82751ED75343}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{518777CC-0A59-4415-A12A-82751ED75343}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{518777CC-0A59-4415-A12A-82751ED75343}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{518777CC-0A59-4415-A12A-82751ED75343}.Release|Win32.Build.0 = Release|Win32
|
||||
{C0A84BD2-3870-4CD6-B281-0AB322E3C579}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{C0A84BD2-3870-4CD6-B281-0AB322E3C579}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{C0A84BD2-3870-4CD6-B281-0AB322E3C579}.Release|Win32.ActiveCfg = Release|Win32
|
||||
@@ -54,10 +46,6 @@ Global
|
||||
{5BD95B95-38B0-4C7D-9471-F99CA1203DF4}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{5BD95B95-38B0-4C7D-9471-F99CA1203DF4}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{5BD95B95-38B0-4C7D-9471-F99CA1203DF4}.Release|Win32.Build.0 = Release|Win32
|
||||
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -65,9 +53,7 @@ Global
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{3C61929E-7289-4101-8D0A-DA22D6E1AEA8} = {A7D28E0C-BB96-444D-AAB0-F22A6483FE5F}
|
||||
{D3E29951-D9F5-486D-A167-20AE8E90B1FA} = {A7D28E0C-BB96-444D-AAB0-F22A6483FE5F}
|
||||
{518777CC-0A59-4415-A12A-82751ED75343} = {A7D28E0C-BB96-444D-AAB0-F22A6483FE5F}
|
||||
{C0A84BD2-3870-4CD6-B281-0AB322E3C579} = {A7D28E0C-BB96-444D-AAB0-F22A6483FE5F}
|
||||
{47399D91-7EB9-41DE-B521-514BA5DB0C43} = {A7D28E0C-BB96-444D-AAB0-F22A6483FE5F}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {22B0355E-423C-4ACC-81F8-DAD72A8BEC0E}
|
||||
|
||||
3
ZRColaWS/.gitignore
vendored
Normal file
3
ZRColaWS/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/*.d
|
||||
/*.o
|
||||
/zrcolaws
|
||||
91
ZRColaWS/Makefile
Normal file
91
ZRColaWS/Makefile
Normal file
@@ -0,0 +1,91 @@
|
||||
CPPFLAGS := $(CPPFLAGS) -I../lib/libZRCola/include -I../lib/stdex/include -I../lib/oatpp-swagger/src -I../lib/oatpp/src
|
||||
LDFLAGS := $(LDFLAGS) -L../lib/libZRCola/lib -L../lib/oatpp-swagger/build/src -L../lib/oatpp/build/src
|
||||
LDLIBS := $(LDLIBS) -lZRCola -loatpp-swagger -loatpp -lstdc++
|
||||
SRCS := zrcolaws.cpp
|
||||
|
||||
include ../include/props.mak
|
||||
|
||||
.PHONY: all
|
||||
all: zrcolaws
|
||||
|
||||
zrcolaws: \
|
||||
../lib/oatpp/build/src/liboatpp.a \
|
||||
../lib/oatpp-swagger/build/src/liboatpp-swagger.a \
|
||||
../lib/libZRCola/lib/libZRCola.a \
|
||||
$(OBJS)
|
||||
$(CC) $(LDFLAGS) $(OBJS) -o $@ $(LDLIBS)
|
||||
|
||||
../lib/oatpp/build/src/liboatpp.a: ../lib/oatpp/build/Makefile
|
||||
$(MAKE) $(MFLAGS) -C ../lib/oatpp/build
|
||||
|
||||
../lib/oatpp/build/Makefile: ../lib/oatpp/CMakeLists.txt
|
||||
cmake -D OATPP_INSTALL=OFF -D OATPP_BUILD_TESTS=OFF -D OATPP_LINK_TEST_LIBRARY=OFF -S ../lib/oatpp -B ../lib/oatpp/build
|
||||
|
||||
../lib/oatpp-swagger/build/src/liboatpp-swagger.a: ../lib/oatpp-swagger/build/Makefile
|
||||
$(MAKE) $(MFLAGS) -C ../lib/oatpp-swagger/build
|
||||
|
||||
../lib/oatpp-swagger/build/Makefile: ../lib/oatpp-swagger/CMakeLists.txt
|
||||
cmake -D OATPP_INSTALL=OFF -D OATPP_BUILD_TESTS=OFF -D OATPP_MODULES_LOCATION=CUSTOM -D OATPP_DIR_SRC=${CURDIR}/../lib/oatpp/src -D OATPP_DIR_LIB=${CURDIR}/../lib/oatpp/build/src -S ../lib/oatpp-swagger -B ../lib/oatpp-swagger/build
|
||||
|
||||
../lib/libZRCola/lib/libZRCola.a:
|
||||
$(MAKE) $(MFLAGS) -C ../lib/libZRCola/build
|
||||
|
||||
.PHONY: install
|
||||
install: zrcolaws ../output/data/ZRCola.zrcdb
|
||||
install -d $(PREFIX)/bin/
|
||||
install -m 755 zrcolaws $(PREFIX)/bin/
|
||||
install -d $(PREFIX)/share/zrcola/
|
||||
install -m 644 ../output/data/ZRCola.zrcdb $(PREFIX)/share/zrcola/
|
||||
install -d $(PREFIX)/share/zrcola/res/
|
||||
install -m 644 ../lib/oatpp-swagger/res/favicon-16x16.png $(PREFIX)/share/zrcola/res/
|
||||
install -m 644 ../lib/oatpp-swagger/res/favicon-32x32.png $(PREFIX)/share/zrcola/res/
|
||||
install -m 644 ../lib/oatpp-swagger/res/index.html $(PREFIX)/share/zrcola/res/
|
||||
install -m 644 ../lib/oatpp-swagger/res/oauth2-redirect.html $(PREFIX)/share/zrcola/res/
|
||||
install -m 644 ../lib/oatpp-swagger/res/swagger-ui-bundle.js $(PREFIX)/share/zrcola/res/
|
||||
install -m 644 ../lib/oatpp-swagger/res/swagger-ui-bundle.js.map $(PREFIX)/share/zrcola/res/
|
||||
install -m 644 ../lib/oatpp-swagger/res/swagger-ui-es-bundle-core.js $(PREFIX)/share/zrcola/res/
|
||||
install -m 644 ../lib/oatpp-swagger/res/swagger-ui-es-bundle-core.js.map $(PREFIX)/share/zrcola/res/
|
||||
install -m 644 ../lib/oatpp-swagger/res/swagger-ui-es-bundle.js $(PREFIX)/share/zrcola/res/
|
||||
install -m 644 ../lib/oatpp-swagger/res/swagger-ui-es-bundle.js.map $(PREFIX)/share/zrcola/res/
|
||||
install -m 644 ../lib/oatpp-swagger/res/swagger-ui-standalone-preset.js $(PREFIX)/share/zrcola/res/
|
||||
install -m 644 ../lib/oatpp-swagger/res/swagger-ui-standalone-preset.js.map $(PREFIX)/share/zrcola/res/
|
||||
install -m 644 ../lib/oatpp-swagger/res/swagger-ui.css $(PREFIX)/share/zrcola/res/
|
||||
install -m 644 ../lib/oatpp-swagger/res/swagger-ui.css.map $(PREFIX)/share/zrcola/res/
|
||||
install -m 644 ../lib/oatpp-swagger/res/swagger-ui.js $(PREFIX)/share/zrcola/res/
|
||||
install -m 644 ../lib/oatpp-swagger/res/swagger-ui.js.map $(PREFIX)/share/zrcola/res/
|
||||
install -d $(PREFIX)/etc/sysconfig/
|
||||
{ echo '#!/bin/sh'; \
|
||||
echo ''; \
|
||||
echo '# Interface to listen on. Default: localhost'; \
|
||||
echo '#HOST=0.0.0.0'; \
|
||||
echo ''; \
|
||||
echo '# Port to listen on. Default: 54591'; \
|
||||
echo '#PORT=54591'; \
|
||||
echo ''; \
|
||||
echo '# Additional zrcolaws command line options'; \
|
||||
echo '#OPTIONS=-4'; \
|
||||
} > $(PREFIX)/etc/sysconfig/zrcolaws
|
||||
install -d $(PREFIX)/lib/systemd/system/
|
||||
{ echo '[Unit]'; \
|
||||
echo 'Description=ZRCola Web Service'; \
|
||||
echo 'After=network.target'; \
|
||||
echo ''; \
|
||||
echo '[Service]'; \
|
||||
echo 'Environment="HOST=localhost" "PORT=54591"'; \
|
||||
echo 'EnvironmentFile=-$(PREFIX)/etc/sysconfig/zrcolaws'; \
|
||||
echo 'DynamicUser=yes'; \
|
||||
echo 'ExecStart=/usr/local/bin/zrcolaws --host $$HOST --port $$PORT $$OPTIONS'; \
|
||||
echo 'Type=exec'; \
|
||||
echo 'Restart=always'; \
|
||||
echo ''; \
|
||||
echo '[Install]'; \
|
||||
echo 'WantedBy=multi-user.target'; \
|
||||
echo 'RequiredBy=network.target'; \
|
||||
} > $(PREFIX)/lib/systemd/system/zrcolaws.service
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm -r *.{d,o} zrcolaws
|
||||
|
||||
include ../include/targets.mak
|
||||
-include $(DEPS)
|
||||
23
ZRColaWS/README.md
Normal file
23
ZRColaWS/README.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# ZRCola Web Service
|
||||
|
||||
## Building and Installation
|
||||
|
||||
1. Install prerequisites: `sudo dnf install git cmake gcc gcc-c++ make libatomic`
|
||||
|
||||
2. Clone this Git repository: `git clone --recursive https://github.com/Amebis/ZRCola.git`
|
||||
|
||||
3. Build ZRColaWS: `make -C ZRCola/ZRColaWS`
|
||||
|
||||
4. Install ZRColaWS: `sudo make -C ZRCola/ZRColaWS install`
|
||||
|
||||
5. Configure ZRColaWS by editing _/usr/local/etc/sysconfig/zrcolaws_
|
||||
|
||||
6. Start ZRColaWS: `sudo systemctl start zrcolaws.service`
|
||||
|
||||
7. Configure ZRColaWS for auto-start: `sudo systemctl enable zrcolaws.service`
|
||||
|
||||
8. Remember to open webservice port in firewall, should the service require external access.
|
||||
|
||||
## Usage
|
||||
|
||||
Web service API documentation is available at _http://host:port/swagger/ui_.
|
||||
73
ZRColaWS/appcomponent.hpp
Normal file
73
ZRColaWS/appcomponent.hpp
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2022 Amebis
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../include/version.h"
|
||||
#include "controller.hpp"
|
||||
#include <oatpp-swagger/Model.hpp>
|
||||
#include <oatpp-swagger/Resources.hpp>
|
||||
#include <oatpp/core/base/CommandLineArguments.hpp>
|
||||
#include <oatpp/core/macro/component.hpp>
|
||||
#include <oatpp/network/Server.hpp>
|
||||
#include <oatpp/network/tcp/server/ConnectionProvider.hpp>
|
||||
#include <oatpp/parser/json/mapping/ObjectMapper.hpp>
|
||||
#include <oatpp/web/server/HttpConnectionHandler.hpp>
|
||||
|
||||
class AppComponent
|
||||
{
|
||||
protected:
|
||||
oatpp::network::Address m_address;
|
||||
|
||||
public:
|
||||
AppComponent(const oatpp::network::Address& address) : m_address(address) {}
|
||||
|
||||
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ServerConnectionProvider>, serverConnectionProvider)([this] {
|
||||
return oatpp::network::tcp::server::ConnectionProvider::createShared({m_address.host, m_address.port, m_address.family});
|
||||
}());
|
||||
|
||||
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::web::server::HttpRouter>, httpRouter)([] {
|
||||
return oatpp::web::server::HttpRouter::createShared();
|
||||
}());
|
||||
|
||||
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ConnectionHandler>, serverConnectionHandler)([] {
|
||||
OATPP_COMPONENT(std::shared_ptr<oatpp::web::server::HttpRouter>, router);
|
||||
return oatpp::web::server::HttpConnectionHandler::createShared(router);
|
||||
}());
|
||||
|
||||
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::data::mapping::ObjectMapper>, apiObjectMapper)([] {
|
||||
auto serializerConfig = oatpp::parser::json::mapping::Serializer::Config::createShared();
|
||||
serializerConfig->escapeFlags &= ~oatpp::parser::json::Utils::FLAG_ESCAPE_UTF8CHAR;
|
||||
return oatpp::parser::json::mapping::ObjectMapper::createShared(
|
||||
serializerConfig,
|
||||
oatpp::parser::json::mapping::Deserializer::Config::createShared());
|
||||
}());
|
||||
|
||||
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::Server>, server)([] {
|
||||
OATPP_COMPONENT(std::shared_ptr<oatpp::network::ServerConnectionProvider>, connectionProvider);
|
||||
OATPP_COMPONENT(std::shared_ptr<oatpp::network::ConnectionHandler>, connectionHandler);
|
||||
return oatpp::network::Server::createShared(connectionProvider, connectionHandler);
|
||||
}());
|
||||
|
||||
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::swagger::DocumentInfo>, swaggerDocumentInfo)([] {
|
||||
oatpp::swagger::DocumentInfo::Builder builder;
|
||||
builder
|
||||
.setTitle("ZRCola Web Service")
|
||||
.setDescription(
|
||||
"ZRCola is an input system designed mainly, although not exclusively, for linguistic use. "
|
||||
"It allows the user to combine basic letters with any diacritic marks and insert the resulting complex characters into the texts with ease.")
|
||||
.setVersion(PRODUCT_VERSION_STR)
|
||||
.setContactName("ZRCola")
|
||||
.setContactUrl("https://zrcola.zrc-sazu.si/en/")
|
||||
|
||||
.setLicenseName("GNU General Public License, Version 3")
|
||||
.setLicenseUrl("https://www.gnu.org/licenses/gpl-3.0.en.html");
|
||||
return builder.build();
|
||||
}());
|
||||
|
||||
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::swagger::Resources>, swaggerResources)([] {
|
||||
return oatpp::swagger::Resources::loadResources(PREFIX "/share/zrcola/res");
|
||||
}());
|
||||
};
|
||||
243
ZRColaWS/controller.hpp
Normal file
243
ZRColaWS/controller.hpp
Normal file
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2022 Amebis
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../include/version.h"
|
||||
#include "dto.hpp"
|
||||
#include "iconverter.hpp"
|
||||
#include "zrcolaws.hpp"
|
||||
#include <zrcola/translate.h>
|
||||
#include <oatpp/core/macro/codegen.hpp>
|
||||
#include <oatpp/core/macro/component.hpp>
|
||||
#include <oatpp/web/server/api/ApiController.hpp>
|
||||
|
||||
#include OATPP_CODEGEN_BEGIN(ApiController)
|
||||
|
||||
class Controller : public oatpp::web::server::api::ApiController
|
||||
{
|
||||
public:
|
||||
Controller(const std::shared_ptr<oatpp::data::mapping::ObjectMapper>& defaultObjectMapper, const oatpp::String &routerPrefix = nullptr) :
|
||||
oatpp::web::server::api::ApiController(defaultObjectMapper, routerPrefix)
|
||||
{}
|
||||
|
||||
ADD_CORS(getAbout)
|
||||
ENDPOINT_INFO(getAbout) {
|
||||
info->summary = "Returns service information";
|
||||
info->addResponse<Object<dto::About>>(Status::CODE_200, "application/json");
|
||||
}
|
||||
ENDPOINT("GET", "/about", getAbout)
|
||||
{
|
||||
auto dto = dto::About::createShared();
|
||||
dto->vendor = PRODUCT_CFG_VENDOR;
|
||||
dto->application = PRODUCT_CFG_APPLICATION;
|
||||
dto->version = PRODUCT_VERSION_STR;
|
||||
return createDtoResponse(Status::CODE_200, dto);
|
||||
}
|
||||
|
||||
ADD_CORS(getTranset)
|
||||
ENDPOINT_INFO(getTranset) {
|
||||
info->summary = "Lists supported translation sets";
|
||||
info->description = "Each translation set describes a set of replacements that are performed to translate text from one script or encoding to another. ";
|
||||
info->addResponse<oatpp::Vector<oatpp::Object<dto::TranSet>>>(Status::CODE_200, "application/json");
|
||||
}
|
||||
ENDPOINT("GET", "/transet", getTranset)
|
||||
{
|
||||
try {
|
||||
utf16toutf8 c;
|
||||
auto result = oatpp::Vector<oatpp::Object<dto::TranSet>>::createShared();
|
||||
auto dto = dto::TranSet::createShared();
|
||||
dto->set = ZRCOLA_TRANSETID_DEFAULT;
|
||||
dto->src = "ZRCola Decomposed";
|
||||
dto->dst = "ZRCola Composed";
|
||||
result->push_back(dto);
|
||||
for (size_t i = 0, n = ts_db.idxTranSet.size(); i < n; i++) {
|
||||
const auto &ts = ts_db.idxTranSet[i];
|
||||
dto = dto::TranSet::createShared();
|
||||
dto->set = ts.set;
|
||||
dto->src = c.convert(ts.src(), ts.src_len());
|
||||
dto->dst = c.convert(ts.dst(), ts.dst_len());
|
||||
result->push_back(dto);
|
||||
}
|
||||
dto = dto::TranSet::createShared();
|
||||
dto->set = ZRCOLA_TRANSETID_UNICODE;
|
||||
dto->src = "ZRCola Decomposed";
|
||||
dto->dst = "Unicode";
|
||||
result->push_back(dto);
|
||||
return createDtoResponse(Status::CODE_200, result);
|
||||
} catch (std::exception &ex) {
|
||||
OATPP_LOGE(__FUNCTION__, "%s: %s", typeid(ex).name(), ex.what());
|
||||
return ResponseFactory::createResponse(Status::CODE_500, ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
ADD_CORS(getLanguage)
|
||||
ENDPOINT_INFO(getLanguage) {
|
||||
info->summary = "Lists supported languages";
|
||||
info->description = "Each language describes a set of special characters that are specific to that language (e.g. č, š, ž in Slovenian, or ä, ö, ü in German).";
|
||||
info->addResponse<oatpp::Vector<oatpp::Object<dto::Language>>>(Status::CODE_200, "application/json");
|
||||
}
|
||||
ENDPOINT("GET", "/language", getLanguage)
|
||||
{
|
||||
try {
|
||||
utf16toutf8 c;
|
||||
auto result = oatpp::Vector<oatpp::Object<dto::Language>>::createShared();
|
||||
for (size_t i = 0, n = lang_db.idxLang.size(); i < n; i++) {
|
||||
const auto &lang = lang_db.idxLang[i];
|
||||
auto dto = dto::Language::createShared();
|
||||
dto->lang = std::string(&lang.lang.data[0], strnlen(lang.lang.data, std::size(lang.lang.data)));
|
||||
dto->name = c.convert(lang.name(), lang.name_len());
|
||||
result->push_back(dto);
|
||||
}
|
||||
return createDtoResponse(Status::CODE_200, result);
|
||||
} catch (std::exception &ex) {
|
||||
OATPP_LOGE(__FUNCTION__, "%s: %s", typeid(ex).name(), ex.what());
|
||||
return ResponseFactory::createResponse(Status::CODE_500, ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
ADD_CORS(postTranslate)
|
||||
ENDPOINT_INFO(postTranslate) {
|
||||
info->summary = "Translate text";
|
||||
info->description =
|
||||
"Performs any number of supported translations (see /transet) on a given input text in a sequence. "
|
||||
"Together with the output text, it also returns character index mapping between input and output texts.";
|
||||
auto transet = oatpp::Vector<UInt16>::createShared();
|
||||
transet->push_back(ZRCOLA_TRANSETID_DEFAULT);
|
||||
auto dto = dto::TranslateIn::createShared();
|
||||
dto->transet = transet;
|
||||
dto->text = "To je test.";
|
||||
info->addConsumes<Object<dto::TranslateIn>>("application/json")
|
||||
.addExample("Perform ZRCola composition", dto);
|
||||
info->addResponse<Object<dto::TranslateOut>>(Status::CODE_200, "application/json");
|
||||
}
|
||||
ENDPOINT("POST", "/translate", postTranslate, BODY_DTO(Object<dto::TranslateIn>, input))
|
||||
{
|
||||
try {
|
||||
utf8toutf16 cIn;
|
||||
std::u16string dst, dst2;
|
||||
if (input->text)
|
||||
dst = cIn.convert(*input->text);
|
||||
size_t src_len = dst.size();
|
||||
std::vector<ZRCola::mapping_vector> mapping;
|
||||
if (input->transet) {
|
||||
ZRCola::mapping_vector map;
|
||||
const auto ts_end = input->transet->cend();
|
||||
for (auto ts = input->transet->cbegin(); ts != ts_end; ++ts) {
|
||||
switch (*ts) {
|
||||
case ZRCOLA_TRANSETID_DEFAULT:
|
||||
case ZRCOLA_TRANSETID_UNICODE:
|
||||
// Decompose first, then re-compose.
|
||||
t_db.TranslateInv(*ts, dst.data(), dst.size(), dst2, &map);
|
||||
mapping.push_back(std::move(map));
|
||||
map.clear();
|
||||
t_db.Translate(*ts, dst2.data(), dst2.size(), dst, &map);
|
||||
mapping.push_back(std::move(map));
|
||||
map.clear();
|
||||
break;
|
||||
|
||||
default:
|
||||
t_db.Translate(*ts, dst.data(), dst.size(), dst2, &map);
|
||||
mapping.push_back(std::move(map));
|
||||
map.clear();
|
||||
dst = std::move(dst2);
|
||||
dst2.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
utf16toutf8 cOut;
|
||||
auto dto = dto::TranslateOut::createShared();
|
||||
dto->text = cOut.convert(dst);
|
||||
auto map = oatpp::Vector<oatpp::UInt32>::createShared();
|
||||
auto m_end = mapping.cend();
|
||||
for (size_t i = 0; i < src_len; ++i) {
|
||||
auto j = i;
|
||||
for (auto m = mapping.cbegin(); m != m_end; ++m)
|
||||
j = m->to_dst(j);
|
||||
map->push_back(j);
|
||||
}
|
||||
dto->map = map;
|
||||
return createDtoResponse(Status::CODE_200, dto);
|
||||
} catch (std::exception &ex) {
|
||||
OATPP_LOGE(__FUNCTION__, "%s: %s", typeid(ex).name(), ex.what());
|
||||
return ResponseFactory::createResponse(Status::CODE_500, ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
ADD_CORS(postTranslateInv)
|
||||
ENDPOINT_INFO(postTranslateInv) {
|
||||
info->summary = "Inverse translate text";
|
||||
info->description =
|
||||
"Performs any number of supported translations (see /transet) on a given input text in a sequence in reverse. "
|
||||
"Together with the output text, it also returns character index mapping between input and output texts.";
|
||||
auto transet = oatpp::Vector<UInt16>::createShared();
|
||||
transet->push_back(ZRCOLA_TRANSETID_DEFAULT);
|
||||
auto dto = dto::TranslateIn::createShared();
|
||||
dto->transet = transet;
|
||||
dto->text = "T ťᵉⓢṭ.";
|
||||
dto->lang = "slv";
|
||||
info->addConsumes<Object<dto::TranslateIn>>("application/json")
|
||||
.addExample("Perform ZRCola decomposition", dto);
|
||||
info->addResponse<Object<dto::TranslateOut>>(Status::CODE_200, "application/json");
|
||||
}
|
||||
ENDPOINT("POST", "/translateInv", postTranslateInv, BODY_DTO(Object<dto::TranslateIn>, input))
|
||||
{
|
||||
try {
|
||||
utf8toutf16 cIn;
|
||||
std::u16string dst, dst2;
|
||||
ZRCola::langid_t lang;
|
||||
if (input->text)
|
||||
dst = cIn.convert(*input->text);
|
||||
lang = input->lang->c_str();
|
||||
size_t src_len = dst.size();
|
||||
std::vector<ZRCola::mapping_vector> mapping;
|
||||
if (input->transet) {
|
||||
ZRCola::mapping_vector map;
|
||||
const auto ts_begin = input->transet->cbegin();
|
||||
for (auto ts = input->transet->cend(); (ts--) != ts_begin; ) {
|
||||
switch (*ts) {
|
||||
case ZRCOLA_TRANSETID_DEFAULT:
|
||||
case ZRCOLA_TRANSETID_UNICODE:
|
||||
t_db.TranslateInv(*ts, dst.data(), dst.size(), &lc_db, lang, dst2, &map);
|
||||
dst = std::move(dst2);
|
||||
dst2.clear();
|
||||
map.invert();
|
||||
mapping.push_back(std::move(map));
|
||||
map.clear();
|
||||
break;
|
||||
|
||||
default:
|
||||
t_db.TranslateInv(*ts, dst.data(), dst.size(), dst2, &map);
|
||||
dst = std::move(dst2);
|
||||
dst2.clear();
|
||||
map.invert();
|
||||
mapping.push_back(std::move(map));
|
||||
map.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
utf16toutf8 cOut;
|
||||
auto dto = dto::TranslateOut::createShared();
|
||||
dto->text = cOut.convert(dst);
|
||||
auto map = oatpp::Vector<oatpp::UInt32>::createShared();
|
||||
auto m_end = mapping.crend();
|
||||
for (size_t i = 0; i < src_len; ++i) {
|
||||
auto j = i;
|
||||
for (auto m = mapping.crbegin(); m != m_end; ++m)
|
||||
j = m->to_src(j);
|
||||
map->push_back(j);
|
||||
}
|
||||
dto->map = map;
|
||||
return createDtoResponse(Status::CODE_200, dto);
|
||||
} catch (std::exception &ex) {
|
||||
OATPP_LOGE(__FUNCTION__, "%s: %s", typeid(ex).name(), ex.what());
|
||||
return ResponseFactory::createResponse(Status::CODE_500, ex.what());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#include OATPP_CODEGEN_END(ApiController)
|
||||
90
ZRColaWS/dto.hpp
Normal file
90
ZRColaWS/dto.hpp
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2022 Amebis
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <oatpp/core/data/mapping/type/Object.hpp>
|
||||
#include <oatpp/core/macro/codegen.hpp>
|
||||
#include <oatpp/core/Types.hpp>
|
||||
|
||||
#include OATPP_CODEGEN_BEGIN(DTO)
|
||||
|
||||
namespace dto {
|
||||
|
||||
class About : public oatpp::DTO
|
||||
{
|
||||
DTO_INIT(About, DTO)
|
||||
|
||||
DTO_FIELD_INFO(vendor) { info->description = "Application vendor"; }
|
||||
DTO_FIELD(String, vendor);
|
||||
|
||||
DTO_FIELD_INFO(application) { info->description = "Application name"; }
|
||||
DTO_FIELD(String, application);
|
||||
|
||||
DTO_FIELD_INFO(version) { info->description = "Application version"; }
|
||||
DTO_FIELD(String, version);
|
||||
};
|
||||
|
||||
class TranSet : public oatpp::DTO
|
||||
{
|
||||
DTO_INIT(TranSet, DTO)
|
||||
|
||||
DTO_FIELD_INFO(set) { info->description = "Translation set ID"; }
|
||||
DTO_FIELD(UInt16, set);
|
||||
|
||||
DTO_FIELD_INFO(src) { info->description = "Input transcript name in English"; }
|
||||
DTO_FIELD(String, src);
|
||||
|
||||
DTO_FIELD_INFO(dst) { info->description = "Output transcript name in English"; }
|
||||
DTO_FIELD(String, dst);
|
||||
};
|
||||
|
||||
class Language : public oatpp::DTO
|
||||
{
|
||||
DTO_INIT(Language, DTO)
|
||||
|
||||
DTO_FIELD_INFO(lang) { info->description = "Language ID"; }
|
||||
DTO_FIELD(String, lang);
|
||||
|
||||
DTO_FIELD_INFO(name) { info->description = "Language name in English"; }
|
||||
DTO_FIELD(String, name);
|
||||
};
|
||||
|
||||
class TranslateIn : public oatpp::DTO
|
||||
{
|
||||
DTO_INIT(TranslateIn, DTO)
|
||||
|
||||
DTO_FIELD_INFO(transet) {
|
||||
info->description = "Array of one or multiple translation set IDs to perform translation on the text. When inverse translating, the translation sets are read in reverse order listed in this array. Use /transet to get IDs of all supported translation sets.";
|
||||
info->required = true;
|
||||
}
|
||||
DTO_FIELD(Vector<UInt16>, transet);
|
||||
|
||||
DTO_FIELD_INFO(text) {
|
||||
info->description = "Text to be translated";
|
||||
info->required = true;
|
||||
}
|
||||
DTO_FIELD(String, text);
|
||||
|
||||
DTO_FIELD_INFO(lang) {
|
||||
info->description = "Language ID of the text to be translated. This is used on inverse translating to skip decomposing language-specific common characters (e.g. č, š, ž in Slovenian, or ä, ö, ü in German). Use /language to get IDs of all supported languages.";
|
||||
}
|
||||
DTO_FIELD(String, lang) = "slv";
|
||||
};
|
||||
|
||||
class TranslateOut : public oatpp::DTO
|
||||
{
|
||||
DTO_INIT(TranslateOut, DTO)
|
||||
|
||||
DTO_FIELD_INFO(text) { info->description = "Translated text"; }
|
||||
DTO_FIELD(String, text);
|
||||
|
||||
DTO_FIELD_INFO(map) { info->description = "Character index mapping between input and translated text. The map[i] value represents the index of the beginning of a character (in translated text) that translated from the character (in the input text) beginning at index i. All input indexes are measured in characters after input string is translated to UTF-16, and all output indexes are measured in characters before output string is translated from UTF-16."; }
|
||||
DTO_FIELD(Vector<UInt32>, map);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#include OATPP_CODEGEN_END(DTO)
|
||||
75
ZRColaWS/iconverter.hpp
Normal file
75
ZRColaWS/iconverter.hpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2022 Amebis
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdex/sal.hpp>
|
||||
#include <iconv.h>
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
inline static std::runtime_error errno_error(_In_z_ const char *file, _In_ int line, _In_z_ const char *func)
|
||||
{
|
||||
int _errno = errno;
|
||||
return std::runtime_error(
|
||||
std::string(file) + ":" + std::to_string(line) +
|
||||
std::string(func) + " error " + std::to_string(_errno) + ": " +
|
||||
std::strerror(_errno));
|
||||
}
|
||||
|
||||
template <typename T_from, typename T_to>
|
||||
class iconverter
|
||||
{
|
||||
public:
|
||||
iconverter(_In_z_ const char* from, _In_z_ const char* to)
|
||||
{
|
||||
m_handle = iconv_open(to, from);
|
||||
if (m_handle == (iconv_t)-1)
|
||||
throw errno_error(__FILE__, __LINE__, __FUNCTION__);
|
||||
}
|
||||
|
||||
~iconverter()
|
||||
{
|
||||
iconv_close(m_handle);
|
||||
}
|
||||
|
||||
std::basic_string<T_to> convert(_In_z_count_(count) const T_from* input, _In_ size_t count) const
|
||||
{
|
||||
T_to buf[0x100];
|
||||
std::basic_string<T_to> result;
|
||||
size_t inSize = sizeof(T_from) * count;
|
||||
do {
|
||||
T_to* output = &buf[0];
|
||||
size_t outSize = sizeof(buf);
|
||||
errno = 0;
|
||||
iconv(m_handle, (char**)&input, &inSize, (char**)&output, &outSize);
|
||||
if (errno)
|
||||
throw errno_error(__FILE__, __LINE__, __FUNCTION__);
|
||||
result.insert(result.end(), buf, (T_to*)((char*)buf + sizeof(buf) - outSize));
|
||||
} while (inSize);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::basic_string<T_to> convert(_In_ const std::basic_string<T_from>& input)
|
||||
{
|
||||
return convert(input.c_str(), input.length());
|
||||
}
|
||||
|
||||
protected:
|
||||
iconv_t m_handle;
|
||||
};
|
||||
|
||||
class utf16toutf8 : public iconverter<char16_t, char>
|
||||
{
|
||||
public:
|
||||
utf16toutf8() : iconverter("UTF-16LE", "UTF-8") {}
|
||||
};
|
||||
|
||||
class utf8toutf16 : public iconverter<char, char16_t>
|
||||
{
|
||||
public:
|
||||
utf8toutf16() : iconverter("UTF-8", "UTF-16LE") {}
|
||||
};
|
||||
27
ZRColaWS/stdlogger.hpp
Normal file
27
ZRColaWS/stdlogger.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2022 Amebis
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <oatpp/core/base/Environment.hpp>
|
||||
#include <iostream>
|
||||
#include <mutex>
|
||||
|
||||
class StdLogger : public oatpp::base::Logger
|
||||
{
|
||||
private:
|
||||
std::mutex m_lock;
|
||||
|
||||
public:
|
||||
StdLogger() {}
|
||||
|
||||
void log(v_uint32 priority, const std::string& tag, const std::string& message) override
|
||||
{
|
||||
if (!isLogPriorityEnabled(priority))
|
||||
return;
|
||||
std::lock_guard<std::mutex> guard(m_lock);
|
||||
(priority < oatpp::base::Logger::PRIORITY_W ? std::cout : std::cerr) << tag << ": " << message << std::endl;
|
||||
}
|
||||
};
|
||||
176
ZRColaWS/zrcolaws.cpp
Normal file
176
ZRColaWS/zrcolaws.cpp
Normal file
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2022 Amebis
|
||||
*/
|
||||
|
||||
#include "appcomponent.hpp"
|
||||
#include "controller.hpp"
|
||||
#include "stdlogger.hpp"
|
||||
#include "zrcolaws.hpp"
|
||||
#include <oatpp-swagger/Controller.hpp>
|
||||
#include <oatpp/core/base/CommandLineArguments.hpp>
|
||||
#include <oatpp/network/Server.hpp>
|
||||
#include <signal.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace ZRCola;
|
||||
|
||||
translation_db t_db;
|
||||
transet_db ts_db;
|
||||
// transeq_db tsq_db;
|
||||
langchar_db lc_db;
|
||||
language_db lang_db;
|
||||
// character_db chr_db;
|
||||
// chrcat_db cc_db;
|
||||
// chrtag_db ct_db;
|
||||
// tagname_db tn_db;
|
||||
// highlight_db h_db;
|
||||
|
||||
static void load_database()
|
||||
{
|
||||
fstream dat(PREFIX "/share/zrcola/ZRCola.zrcdb", ios_base::in | ios_base::binary);
|
||||
if (!dat.good())
|
||||
throw runtime_error(PREFIX "/share/zrcola/ZRCola.zrcdb not found or cannot be opened.");
|
||||
|
||||
if (!stdex::idrec::find<recordid_t, recordsize_t, ZRCOLA_RECORD_ALIGN>(dat, ZRCOLA_DB_ID, sizeof(recordid_t)))
|
||||
throw runtime_error(PREFIX "/share/zrcola/ZRCola.zrcdb is not a valid ZRCola database.");
|
||||
|
||||
recordsize_t size;
|
||||
dat.read((char*)&size, sizeof(recordsize_t));
|
||||
if (dat.good()) {
|
||||
bool has_translation_data = false;
|
||||
|
||||
for (;;) {
|
||||
recordid_t id;
|
||||
if (!stdex::idrec::read_id(dat, id, size)) break;
|
||||
|
||||
if (id == translation_rec::id()) {
|
||||
dat >> translation_rec(t_db);
|
||||
if (dat.good()) {
|
||||
has_translation_data = true;
|
||||
} else {
|
||||
OATPP_LOGE(__FUNCTION__, "Error reading translation data from " PREFIX "/share/zrcola/ZRCola.zrcdb.");
|
||||
t_db.clear();
|
||||
}
|
||||
} else if (id == transet_rec::id()) {
|
||||
dat >> transet_rec(ts_db);
|
||||
if (!dat.good()) {
|
||||
OATPP_LOGE(__FUNCTION__, "Error reading translation set data from " PREFIX "/share/zrcola/ZRCola.zrcdb.");
|
||||
ts_db.clear();
|
||||
}
|
||||
// } else if (id == transeq_rec::id()) {
|
||||
// dat >> transeq_rec(tsq_db);
|
||||
// if (!dat.good()) {
|
||||
// OATPP_LOGE(__FUNCTION__, "Error reading translation sequence data from " PREFIX "/share/zrcola/ZRCola.zrcdb.");
|
||||
// tsq_db.clear();
|
||||
// }
|
||||
} else if (id == langchar_rec::id()) {
|
||||
dat >> langchar_rec(lc_db);
|
||||
if (!dat.good()) {
|
||||
OATPP_LOGE(__FUNCTION__, "Error reading language character data from " PREFIX "/share/zrcola/ZRCola.zrcdb.");
|
||||
lc_db.clear();
|
||||
}
|
||||
} else if (id == language_rec::id()) {
|
||||
dat >> language_rec(lang_db);
|
||||
if (!dat.good()) {
|
||||
OATPP_LOGE(__FUNCTION__, "Error reading language character data from " PREFIX "/share/zrcola/ZRCola.zrcdb.");
|
||||
lang_db.clear();
|
||||
}
|
||||
// } else if (id == character_rec::id()) {
|
||||
// dat >> character_rec(chr_db);
|
||||
// if (!dat.good()) {
|
||||
// OATPP_LOGE(__FUNCTION__, "Error reading character data from " PREFIX "/share/zrcola/ZRCola.zrcdb.");
|
||||
// chr_db.clear();
|
||||
// }
|
||||
// } else if (id == chrcat_rec::id()) {
|
||||
// dat >> chrcat_rec(cc_db);
|
||||
// if (!dat.good()) {
|
||||
// OATPP_LOGE(__FUNCTION__, "Error reading character category data from " PREFIX "/share/zrcola/ZRCola.zrcdb.");
|
||||
// cc_db.clear();
|
||||
// }
|
||||
// } else if (id == chrtag_rec::id()) {
|
||||
// dat >> chrtag_rec(ct_db);
|
||||
// if (!dat.good()) {
|
||||
// OATPP_LOGE(__FUNCTION__, "Error reading character tag data from " PREFIX "/share/zrcola/ZRCola.zrcdb.");
|
||||
// ct_db.clear();
|
||||
// }
|
||||
// } else if (id == tagname_rec::id()) {
|
||||
// dat >> tagname_rec(tn_db);
|
||||
// if (!dat.good()) {
|
||||
// OATPP_LOGE(__FUNCTION__, "Error reading tag name data from " PREFIX "/share/zrcola/ZRCola.zrcdb.");
|
||||
// tn_db.clear();
|
||||
// }
|
||||
// } else if (id == highlight_rec::id()) {
|
||||
// dat >> highlight_rec(h_db);
|
||||
// if (!dat.good()) {
|
||||
// OATPP_LOGE(__FUNCTION__, "Error reading highlight data from " PREFIX "/share/zrcola/ZRCola.zrcdb.");
|
||||
// h_db.clear();
|
||||
// }
|
||||
} else
|
||||
stdex::idrec::ignore<recordsize_t, ZRCOLA_RECORD_ALIGN>(dat);
|
||||
}
|
||||
|
||||
if (!has_translation_data)
|
||||
throw runtime_error(PREFIX "/share/zrcola/ZRCola.zrcdb has no translation data.");
|
||||
}
|
||||
}
|
||||
|
||||
static void sig_handler(int s)
|
||||
{
|
||||
OATPP_LOGD(__FUNCTION__, "Caught signal %d", s);
|
||||
OATPP_COMPONENT(std::shared_ptr<oatpp::network::Server>, server);
|
||||
server->stop();
|
||||
}
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
auto logger = std::make_shared<StdLogger>();
|
||||
oatpp::base::Environment::init(logger);
|
||||
try {
|
||||
{
|
||||
oatpp::base::CommandLineArguments cmdArgs(argc, argv);
|
||||
if (cmdArgs.hasArgument("-?") || cmdArgs.hasArgument("--help")) {
|
||||
cerr << "ZRColaWS " << PRODUCT_VERSION_STR << " Copyright © 2022 Amebis" << endl;
|
||||
cerr << endl;
|
||||
cerr << argv[0] << " [--host <interface name>] [--port <port number>] [-4|-6]" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
load_database();
|
||||
|
||||
struct sigaction sigIntHandler;
|
||||
sigIntHandler.sa_handler = sig_handler;
|
||||
sigemptyset(&sigIntHandler.sa_mask);
|
||||
sigIntHandler.sa_flags = 0;
|
||||
sigaction(SIGINT, &sigIntHandler, NULL);
|
||||
|
||||
oatpp::String host = cmdArgs.getNamedArgumentValue("--host", "localhost");
|
||||
v_uint16 port = oatpp::utils::conversion::strToInt32(cmdArgs.getNamedArgumentValue("--port", "54591"));
|
||||
oatpp::network::Address::Family family = oatpp::network::Address::UNSPEC;
|
||||
if (cmdArgs.hasArgument("-4"))
|
||||
family = oatpp::network::Address::IP_4;
|
||||
else if (cmdArgs.hasArgument("-6"))
|
||||
family = oatpp::network::Address::IP_6;
|
||||
AppComponent components({host, port, family});
|
||||
OATPP_COMPONENT(std::shared_ptr<oatpp::web::server::HttpRouter>, router);
|
||||
OATPP_COMPONENT(std::shared_ptr<oatpp::data::mapping::ObjectMapper>, objectMapper);
|
||||
auto controller = std::make_shared<Controller>(objectMapper);
|
||||
router->addController(controller);
|
||||
auto swaggerController = oatpp::swagger::Controller::createShared(controller->getEndpoints());
|
||||
router->addController(swaggerController);
|
||||
OATPP_COMPONENT(std::shared_ptr<oatpp::network::ServerConnectionProvider>, connectionProvider);
|
||||
OATPP_LOGI(__FUNCTION__, "Server " PRODUCT_VERSION_STR " starting on %s:%s",
|
||||
connectionProvider->getProperty("host").getData(), connectionProvider->getProperty("port").getData());
|
||||
OATPP_COMPONENT(std::shared_ptr<oatpp::network::Server>, server);
|
||||
server->run();
|
||||
OATPP_LOGI(__FUNCTION__, "Server stopped");
|
||||
}
|
||||
oatpp::base::Environment::destroy();
|
||||
} catch (exception &ex) {
|
||||
OATPP_LOGE(__FUNCTION__, "%s: %s", typeid(ex).name(), ex.what());
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
24
ZRColaWS/zrcolaws.hpp
Normal file
24
ZRColaWS/zrcolaws.hpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2022 Amebis
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../include/version.h"
|
||||
#include <zrcola/idrec.h>
|
||||
|
||||
#ifndef PREFIX
|
||||
#define PREFIX "/usr/local"
|
||||
#endif
|
||||
|
||||
extern ZRCola::translation_db t_db;
|
||||
extern ZRCola::transet_db ts_db;
|
||||
// extern ZRCola::transeq_db tsq_db;
|
||||
extern ZRCola::langchar_db lc_db;
|
||||
extern ZRCola::language_db lang_db;
|
||||
// extern ZRCola::character_db chr_db;
|
||||
// extern ZRCola::chrcat_db cc_db;
|
||||
// extern ZRCola::chrtag_db ct_db;
|
||||
// extern ZRCola::tagname_db tn_db;
|
||||
// extern ZRCola::highlight_db h_db;
|
||||
@@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2017-2021 Amebis
|
||||
Copyright © 2017-2022 Amebis
|
||||
-->
|
||||
<package>
|
||||
<job id="CanoPerm">
|
||||
<runtime>
|
||||
<description>Generates character index permutations - Amebis, Copyright © 2017-2021</description>
|
||||
<description>Generates character index permutations - Amebis, Copyright © 2017-2022</description>
|
||||
<unnamed name="<Pattern>" required="true" helpstring="Cannonical form (X=unmoveable character; 0-9=moveable character, characters of the same number must preserve global order of appearance; maximum 10 characters)"/>
|
||||
<example>
|
||||
Example:
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2016-2021 Amebis
|
||||
Copyright © 2016-2022 Amebis
|
||||
-->
|
||||
<package>
|
||||
<job id="InstFont">
|
||||
<runtime>
|
||||
<description>Installs font - Amebis, Copyright © 2016-2021</description>
|
||||
<description>Installs font - Amebis, Copyright © 2016-2022</description>
|
||||
<unnamed name="<Shortcut.lnk>" required="true" helpstring="Shortcut file to create"/>
|
||||
<example>
|
||||
Example:
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 1991-2021 Amebis
|
||||
Copyright © 1991-2022 Amebis
|
||||
-->
|
||||
<package>
|
||||
<job id="MkLnk">
|
||||
<runtime>
|
||||
<description>Creates shortcut to a program - Amebis, Copyright © 1991-2021</description>
|
||||
<description>Creates shortcut to a program - Amebis, Copyright © 1991-2022</description>
|
||||
<unnamed name="<Shortcut.lnk>" required="true" helpstring="Shortcut file to create"/>
|
||||
<unnamed name="<Target>" required="true" helpstring="Target file the shortcut invokes"/>
|
||||
<named name="A" type="string" required="false" helpstring="Command line arguments"/>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2016-2021 Amebis
|
||||
Copyright © 2016-2022 Amebis
|
||||
-->
|
||||
<package>
|
||||
<job id="CharImport">
|
||||
|
||||
1
include/.gitignore
vendored
1
include/.gitignore
vendored
@@ -1,2 +1 @@
|
||||
/UpdaterKeypair.txt
|
||||
/UpdaterKeyPrivate.bin
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2016-2021 Amebis
|
||||
Copyright © 2016-2022 Amebis
|
||||
-->
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2016-2021 Amebis
|
||||
Copyright © 2016-2022 Amebis
|
||||
-->
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
|
||||
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2016-2021 Amebis
|
||||
Copyright © 2016-2022 Amebis
|
||||
-->
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#include "version.h"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2016-2021 Amebis
|
||||
Copyright © 2016-2022 Amebis
|
||||
-->
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2016-2021 Amebis
|
||||
Copyright © 2016-2022 Amebis
|
||||
-->
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
|
||||
17
include/props.mak
Normal file
17
include/props.mak
Normal file
@@ -0,0 +1,17 @@
|
||||
ifeq ($(PREFIX),)
|
||||
PREFIX := /usr/local
|
||||
endif
|
||||
CPPFLAGS := $(CPPFLAGS) -MMD -MP -DPREFIX='"$(PREFIX)"'
|
||||
ifeq ($(CFG),Debug)
|
||||
CPPFLAGS := $(CPPFLAGS) -D_DEBUG
|
||||
CFLAGS := $(CFLAGS) -Og -g
|
||||
CXXFLAGS := $(CXXFLAGS) -Og -g
|
||||
else
|
||||
CPPFLAGS := $(CPPFLAGS) -DNDEBUG
|
||||
CFLAGS := $(CFLAGS) -O3 -fdata-sections -ffunction-sections
|
||||
CXXFLAGS := $(CXXFLAGS) -O3 -fdata-sections -ffunction-sections
|
||||
LDFLAGS := $(LDFLAGS) -Wl,--gc-sections
|
||||
endif
|
||||
|
||||
OBJS := $(SRCS:%=%.o)
|
||||
DEPS := $(OBJS:.o=.d)
|
||||
5
include/targets.mak
Normal file
5
include/targets.mak
Normal file
@@ -0,0 +1,5 @@
|
||||
%.h.gch: %.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -x c++-header -o $@ -c $<
|
||||
|
||||
%.cpp.o: %.cpp
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ -c $<
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -9,7 +9,7 @@
|
||||
// Product version as a single DWORD
|
||||
// Note: Used for version comparison within C/C++ code.
|
||||
//
|
||||
#define PRODUCT_VERSION 0x02050500
|
||||
#define PRODUCT_VERSION 0x02070000
|
||||
|
||||
//
|
||||
// Product version by components
|
||||
@@ -18,27 +18,27 @@
|
||||
// separately.
|
||||
//
|
||||
#define PRODUCT_VERSION_MAJ 2
|
||||
#define PRODUCT_VERSION_MIN 5
|
||||
#define PRODUCT_VERSION_REV 5
|
||||
#define PRODUCT_VERSION_MIN 7
|
||||
#define PRODUCT_VERSION_REV 0
|
||||
#define PRODUCT_VERSION_BUILD 0
|
||||
|
||||
//
|
||||
// Human readable product version and build year for UI
|
||||
//
|
||||
#define PRODUCT_VERSION_STR "2.5.5"
|
||||
#define PRODUCT_BUILD_YEAR_STR "2021"
|
||||
#define PRODUCT_VERSION_STR "2.7"
|
||||
#define PRODUCT_BUILD_YEAR_STR "2023"
|
||||
|
||||
//
|
||||
// Numerical version presentation for ProductVersion propery in
|
||||
// MSI packages (syntax: N.N[.N[.N]])
|
||||
//
|
||||
#define PRODUCT_VERSION_INST "2.5.5"
|
||||
#define PRODUCT_VERSION_INST "2.7"
|
||||
|
||||
//
|
||||
// The product code for ProductCode property in MSI packages
|
||||
// Replace with new on every version change, regardless how minor it is.
|
||||
//
|
||||
#define PRODUCT_VERSION_GUID "{109805EF-6EB5-4F43-A05A-82B3862E16B5}"
|
||||
#define PRODUCT_VERSION_GUID "{BD675AE4-7800-412A-9F89-1C213B722B16}"
|
||||
|
||||
//
|
||||
// The product vendor and application name for configuration keeping.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2016-2021 Amebis
|
||||
Copyright © 2016-2022 Amebis
|
||||
-->
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 1991-2021 Amebis
|
||||
Copyright © 1991-2022 Amebis
|
||||
-->
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(POCompileBeforeTargets)' == '' and '$(POCompileAfterTargets)' == '' and '$(ConfigurationType)' != 'Makefile'">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 1991-2021 Amebis
|
||||
Copyright © 1991-2022 Amebis
|
||||
-->
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 1991-2021 Amebis
|
||||
Copyright © 1991-2022 Amebis
|
||||
-->
|
||||
<ProjectSchemaDefinitions xmlns="clr-namespace:Microsoft.Build.Framework.XamlTypes;assembly=Microsoft.Build.Framework" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:transformCallback="Microsoft.Cpp.Dev10.ConvertPropertyCallback">
|
||||
<Rule Name="POCompile" PageTemplate="tool" DisplayName="PO Compiler" SwitchPrefix="--" Order="200">
|
||||
|
||||
Submodule lib/WinStd updated: 27f3946c4f...8e323efef9
33
lib/libZRCola/build/Makefile
Normal file
33
lib/libZRCola/build/Makefile
Normal file
@@ -0,0 +1,33 @@
|
||||
CPPFLAGS := $(CPPFLAGS) -I../../stdex/include
|
||||
SRCS := \
|
||||
../src/character.cpp \
|
||||
../src/common.cpp \
|
||||
../src/highlight.cpp \
|
||||
../src/language.cpp \
|
||||
../src/mapping.cpp \
|
||||
../src/pch.cpp \
|
||||
../src/tag.cpp \
|
||||
../src/translate.cpp
|
||||
|
||||
include ../../../include/props.mak
|
||||
|
||||
.PHONY: all
|
||||
all: ../lib/libZRCola.a
|
||||
|
||||
../lib/libZRCola.a: ../src/pch.h.gch $(OBJS)
|
||||
$(AR) $(ARFLAGS) $@ $(OBJS)
|
||||
|
||||
.PHONY: test
|
||||
test: ../test/test
|
||||
../test/test
|
||||
|
||||
../test/test: ../lib/libZRCola.a
|
||||
$(CXX) $(CPPFLAGS) -I../../stdex/include -I../include $(CXXFLAGS) -L../lib -o $@ ../test/test.cpp -lstdc++ -lZRCola
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm -r ../src/*.{d,gch,o} ../lib/libZRCola.a ../test/*.d ../test/test
|
||||
|
||||
include ../../../include/targets.mak
|
||||
-include $(DEPS)
|
||||
-include ../test/test.d
|
||||
@@ -1,21 +1,21 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <stdex/idrec.h>
|
||||
#include <assert.h>
|
||||
#include <algorithm>
|
||||
#include <istream>
|
||||
#include <locale>
|
||||
#include <map>
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4200)
|
||||
@@ -29,11 +29,16 @@ namespace ZRCola {
|
||||
///
|
||||
typedef double charrank_t;
|
||||
|
||||
inline bool ispua(_In_ wchar_t c)
|
||||
inline bool ispua(_In_ char_t c)
|
||||
{
|
||||
return L'\ue000' <= c && c <= L'\uf8ff';
|
||||
return u'\ue000' <= c && c <= u'\uf8ff';
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
size_t wcslen(_In_z_ const char_t* str);
|
||||
size_t wcsnlen(_In_z_count_(count) const char_t* str, _In_ size_t count);
|
||||
#endif
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(2)
|
||||
///
|
||||
@@ -177,13 +182,13 @@ namespace ZRCola {
|
||||
///
|
||||
struct character {
|
||||
public:
|
||||
chrcatid_t cat; ///> Character category ID
|
||||
chrcatid_t cat; ///> Character category ID
|
||||
|
||||
protected:
|
||||
unsigned __int16 chr_to; ///< Character end in \c data
|
||||
unsigned __int16 desc_to; ///< Character description end in \c data
|
||||
unsigned __int16 rel_to; ///< Related characters end in \c data
|
||||
wchar_t data[]; ///< Character, character description
|
||||
uint16_t chr_to; ///< Character end in \c data
|
||||
uint16_t desc_to; ///< Character description end in \c data
|
||||
uint16_t rel_to; ///< Related characters end in \c data
|
||||
char_t data[]; ///< Character, character description
|
||||
|
||||
private:
|
||||
inline character(_In_ const character &other);
|
||||
@@ -202,47 +207,47 @@ namespace ZRCola {
|
||||
/// \param[in] rel_len Number of UTF-16 characters in \p rel (including zero delimiters)
|
||||
///
|
||||
inline character(
|
||||
_In_opt_z_count_(chr_len) const wchar_t *chr = NULL,
|
||||
_In_opt_z_count_(chr_len) const char_t *chr = NULL,
|
||||
_In_opt_ size_t chr_len = 0,
|
||||
_In_opt_ chrcatid_t cat = chrcatid_t::blank,
|
||||
_In_opt_z_count_(desc_len) const wchar_t *desc = NULL,
|
||||
_In_opt_z_count_(desc_len) const char_t *desc = NULL,
|
||||
_In_opt_ size_t desc_len = 0,
|
||||
_In_opt_z_count_(rel_len) const wchar_t *rel = NULL,
|
||||
_In_opt_z_count_(rel_len) const char_t *rel = NULL,
|
||||
_In_opt_ size_t rel_len = 0)
|
||||
{
|
||||
this->cat = cat;
|
||||
this->chr_to = static_cast<unsigned __int16>(chr_len);
|
||||
if (chr && chr_len) memcpy(this->data, chr, sizeof(wchar_t)*chr_len);
|
||||
this->desc_to = static_cast<unsigned __int16>(this->chr_to + desc_len);
|
||||
if (desc && desc_len) memcpy(this->data + this->chr_to, desc, sizeof(wchar_t)*desc_len);
|
||||
this->rel_to = static_cast<unsigned __int16>(this->desc_to + rel_len);
|
||||
if (rel && rel_len) memcpy(this->data + this->desc_to, rel, sizeof(wchar_t)*rel_len);
|
||||
this->chr_to = static_cast<uint16_t>(chr_len);
|
||||
if (chr && chr_len) memcpy(this->data, chr, sizeof(char_t)*chr_len);
|
||||
this->desc_to = static_cast<uint16_t>(this->chr_to + desc_len);
|
||||
if (desc && desc_len) memcpy(this->data + this->chr_to, desc, sizeof(char_t)*desc_len);
|
||||
this->rel_to = static_cast<uint16_t>(this->desc_to + rel_len);
|
||||
if (rel && rel_len) memcpy(this->data + this->desc_to, rel, sizeof(char_t)*rel_len);
|
||||
}
|
||||
|
||||
inline const wchar_t* chr () const { return data; };
|
||||
inline wchar_t* chr () { return data; };
|
||||
inline const wchar_t* chr_end() const { return data + chr_to; };
|
||||
inline wchar_t* chr_end() { return data + chr_to; };
|
||||
inline unsigned __int16 chr_len() const { return chr_to; };
|
||||
inline const char_t* chr () const { return data; };
|
||||
inline char_t* chr () { return data; };
|
||||
inline const char_t* chr_end() const { return data + chr_to; };
|
||||
inline char_t* chr_end() { return data + chr_to; };
|
||||
inline uint16_t chr_len() const { return chr_to; };
|
||||
|
||||
inline const wchar_t* desc () const { return data + chr_to; };
|
||||
inline wchar_t* desc () { return data + chr_to; };
|
||||
inline const wchar_t* desc_end() const { return data + desc_to; };
|
||||
inline wchar_t* desc_end() { return data + desc_to; };
|
||||
inline unsigned __int16 desc_len() const { return desc_to - chr_to; };
|
||||
inline const char_t* desc () const { return data + chr_to; };
|
||||
inline char_t* desc () { return data + chr_to; };
|
||||
inline const char_t* desc_end() const { return data + desc_to; };
|
||||
inline char_t* desc_end() { return data + desc_to; };
|
||||
inline uint16_t desc_len() const { return desc_to - chr_to; };
|
||||
|
||||
inline const wchar_t* rel () const { return data + desc_to; };
|
||||
inline wchar_t* rel () { return data + desc_to; };
|
||||
inline const wchar_t* rel_end() const { return data + rel_to; };
|
||||
inline wchar_t* rel_end() { return data + rel_to; };
|
||||
inline unsigned __int16 rel_len() const { return rel_to - desc_to; };
|
||||
inline const char_t* rel () const { return data + desc_to; };
|
||||
inline char_t* rel () { return data + desc_to; };
|
||||
inline const char_t* rel_end() const { return data + rel_to; };
|
||||
inline char_t* rel_end() { return data + rel_to; };
|
||||
inline uint16_t rel_len() const { return rel_to - desc_to; };
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
///
|
||||
/// Character index
|
||||
///
|
||||
class indexChr : public index<unsigned __int16, unsigned __int32, character>
|
||||
class indexChr : public index<uint16_t, uint32_t, character>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@@ -250,7 +255,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \param[in] h Reference to vector holding the data
|
||||
///
|
||||
indexChr(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, character>(h) {}
|
||||
indexChr(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, character>(h) {}
|
||||
|
||||
///
|
||||
/// Compares two characters by ID (for searching)
|
||||
@@ -272,9 +277,9 @@ namespace ZRCola {
|
||||
}
|
||||
} idxChr; ///< Character index
|
||||
|
||||
textindex<wchar_t, wchar_t, unsigned __int32> idxDsc; ///< Description index
|
||||
textindex<wchar_t, wchar_t, unsigned __int32> idxDscSub; ///< Description index (sub-terms)
|
||||
std::vector<unsigned __int16> data; ///< Character data
|
||||
textindex<char_t, char_t, uint32_t> idxDsc; ///< Description index
|
||||
textindex<char_t, char_t, uint32_t> idxDscSub; ///< Description index (sub-terms)
|
||||
std::vector<uint16_t> data; ///< Character data
|
||||
|
||||
public:
|
||||
///
|
||||
@@ -303,7 +308,7 @@ namespace ZRCola {
|
||||
/// \param[in ] fn_abort Pointer to function to periodically test for search cancellation
|
||||
/// \param[in ] cookie Cookie for \p fn_abort call
|
||||
///
|
||||
bool Search(_In_z_ const wchar_t *str, _In_ const std::set<chrcatid_t> &cats, _Inout_ std::map<std::wstring, charrank_t> &hits, _Inout_ std::map<std::wstring, charrank_t> &hits_sub, _In_opt_ bool (__cdecl *fn_abort)(void *cookie) = NULL, _In_opt_ void *cookie = NULL) const;
|
||||
bool Search(_In_z_ const char_t *str, _In_ const std::set<chrcatid_t> &cats, _Inout_ std::map<string_t, charrank_t> &hits, _Inout_ std::map<string_t, charrank_t> &hits_sub, _In_opt_ bool (__cdecl *fn_abort)(void *cookie) = NULL, _In_opt_ void *cookie = NULL) const;
|
||||
|
||||
///
|
||||
/// Get character category
|
||||
@@ -315,20 +320,99 @@ namespace ZRCola {
|
||||
/// - Character category if character found
|
||||
/// - `ZRCola::chrcatid_t::blank` otherwise
|
||||
///
|
||||
inline chrcatid_t GetCharCat(_In_z_count_(len) const wchar_t *chr, _In_ const size_t len) const
|
||||
inline chrcatid_t GetCharCat(_In_z_count_(len) const char_t *chr, _In_ const size_t len) const
|
||||
{
|
||||
assert(len <= 0xffff);
|
||||
std::unique_ptr<character> c((character*)new char[sizeof(character) + sizeof(wchar_t)*len]);
|
||||
c->character::character(chr, len);
|
||||
std::unique_ptr<character> c((character*)new char[sizeof(character) + sizeof(char_t)*len]);
|
||||
new (c.get()) character(chr, len);
|
||||
indexChr::size_type start;
|
||||
return idxChr.find(*c, start) ? idxChr[start].cat : chrcatid_t::blank;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Writes character database to a stream
|
||||
///
|
||||
/// \param[in] stream Output stream
|
||||
/// \param[in] db Character database
|
||||
///
|
||||
/// \returns The stream \p stream
|
||||
///
|
||||
friend std::ostream& operator <<(_In_ std::ostream& stream, _In_ const character_db &db)
|
||||
{
|
||||
// Write character index.
|
||||
if (stream.fail()) return stream;
|
||||
stream << db.idxChr;
|
||||
|
||||
// Write description index.
|
||||
if (!stream.good()) return stream;
|
||||
stream << db.idxDsc;
|
||||
|
||||
// Write sub-term description index.
|
||||
if (!stream.good()) return stream;
|
||||
stream << db.idxDscSub;
|
||||
|
||||
// Write data count.
|
||||
auto data_count = db.data.size();
|
||||
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
|
||||
// 4G check
|
||||
if (data_count > 0xffffffff) {
|
||||
stream.setstate(std::ios_base::failbit);
|
||||
return stream;
|
||||
}
|
||||
#endif
|
||||
if (stream.fail()) return stream;
|
||||
uint32_t count = (uint32_t)data_count;
|
||||
stream.write((const char*)&count, sizeof(count));
|
||||
|
||||
// Write data.
|
||||
if (stream.fail()) return stream;
|
||||
stream.write((const char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Reads character database from a stream
|
||||
///
|
||||
/// \param[in ] stream Input stream
|
||||
/// \param[out] db Character database
|
||||
///
|
||||
/// \returns The stream \p stream
|
||||
///
|
||||
friend std::istream& operator >>(_In_ std::istream& stream, _Out_ character_db& db)
|
||||
{
|
||||
// Read character index.
|
||||
stream >> db.idxChr;
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read description index.
|
||||
stream >> db.idxDsc;
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read sub-term description index.
|
||||
stream >> db.idxDscSub;
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read data count.
|
||||
uint32_t count;
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read data.
|
||||
db.data.resize(count);
|
||||
stream.read((char*)db.data.data(), sizeof(uint16_t) * static_cast<std::streamsize>(count));
|
||||
}
|
||||
else
|
||||
db.data.clear();
|
||||
|
||||
return stream;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
typedef stdex::idrec::record<character_db, recordid_t, recordsize_t, ZRCOLA_RECORD_ALIGN> character_rec;
|
||||
|
||||
|
||||
///
|
||||
/// Character category database
|
||||
///
|
||||
@@ -341,12 +425,12 @@ namespace ZRCola {
|
||||
///
|
||||
struct chrcat {
|
||||
public:
|
||||
chrcatid_t cat; ///< Character category ID
|
||||
unsigned __int16 rank; ///< Character category rank
|
||||
chrcatid_t cat; ///< Character category ID
|
||||
uint16_t rank; ///< Character category rank
|
||||
|
||||
protected:
|
||||
unsigned __int16 name_to; ///< Character category name end in \c data
|
||||
wchar_t data[]; ///< Character category name
|
||||
uint16_t name_to; ///< Character category name end in \c data
|
||||
char_t data[]; ///< Character category name
|
||||
|
||||
private:
|
||||
inline chrcat(_In_ const chrcat &other);
|
||||
@@ -362,29 +446,29 @@ namespace ZRCola {
|
||||
/// \param[in] name_len Number of UTF-16 characters in \p name
|
||||
///
|
||||
inline chrcat(
|
||||
_In_opt_ chrcatid_t cat = chrcatid_t::blank,
|
||||
_In_opt_ unsigned __int16 rank = 0,
|
||||
_In_opt_z_count_(name_len) const wchar_t *name = NULL,
|
||||
_In_opt_ size_t name_len = 0)
|
||||
_In_opt_ chrcatid_t cat = chrcatid_t::blank,
|
||||
_In_opt_ uint16_t rank = 0,
|
||||
_In_opt_z_count_(name_len) const char_t *name = NULL,
|
||||
_In_opt_ size_t name_len = 0)
|
||||
{
|
||||
this->cat = cat;
|
||||
this->rank = rank;
|
||||
this->name_to = static_cast<unsigned __int16>(name_len);
|
||||
if (name && name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
|
||||
this->name_to = static_cast<uint16_t>(name_len);
|
||||
if (name && name_len) memcpy(this->data, name, sizeof(char_t)*name_len);
|
||||
}
|
||||
|
||||
inline const wchar_t* name () const { return data; };
|
||||
inline wchar_t* name () { return data; };
|
||||
inline const wchar_t* name_end() const { return data + name_to; };
|
||||
inline wchar_t* name_end() { return data + name_to; };
|
||||
inline unsigned __int16 name_len() const { return name_to; };
|
||||
inline const char_t* name () const { return data; };
|
||||
inline char_t* name () { return data; };
|
||||
inline const char_t* name_end() const { return data + name_to; };
|
||||
inline char_t* name_end() { return data + name_to; };
|
||||
inline uint16_t name_len() const { return name_to; };
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
///
|
||||
/// Character category index
|
||||
///
|
||||
class indexChrCat : public index<unsigned __int16, unsigned __int32, chrcat>
|
||||
class indexChrCat : public index<uint16_t, uint32_t, chrcat>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@@ -392,7 +476,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \param[in] h Reference to vector holding the data
|
||||
///
|
||||
indexChrCat(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, chrcat>(h) {}
|
||||
indexChrCat(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, chrcat>(h) {}
|
||||
|
||||
///
|
||||
/// Compares two character categories by ID (for searching)
|
||||
@@ -407,8 +491,8 @@ namespace ZRCola {
|
||||
///
|
||||
virtual int compare(_In_ const chrcat &a, _In_ const chrcat &b) const
|
||||
{
|
||||
if (a.cat < b.cat) return -1;
|
||||
else if (a.cat > b.cat) return 1;
|
||||
if (a.cat < b.cat) return -1;
|
||||
if (a.cat > b.cat) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -417,7 +501,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// Rank index
|
||||
///
|
||||
class indexRank : public index<unsigned __int16, unsigned __int32, chrcat>
|
||||
class indexRank : public index<uint16_t, uint32_t, chrcat>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@@ -425,7 +509,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \param[in] h Reference to vector holding the data
|
||||
///
|
||||
indexRank(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, chrcat>(h) {}
|
||||
indexRank(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, chrcat>(h) {}
|
||||
|
||||
///
|
||||
/// Compares two character categories by ID (for searching)
|
||||
@@ -440,8 +524,8 @@ namespace ZRCola {
|
||||
///
|
||||
virtual int compare(_In_ const chrcat &a, _In_ const chrcat &b) const
|
||||
{
|
||||
if (a.rank < b.rank) return -1;
|
||||
else if (a.rank > b.rank) return +1;
|
||||
if (a.rank < b.rank) return -1;
|
||||
if (a.rank > b.rank) return +1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -462,19 +546,12 @@ namespace ZRCola {
|
||||
if (a.rank < b.rank) return -1;
|
||||
else if (a.rank > b.rank) return +1;
|
||||
|
||||
unsigned __int16
|
||||
a_name_len = a.name_len(),
|
||||
b_name_len = b.name_len();
|
||||
int r = _wcsncoll(a.name(), b.name(), std::min<unsigned __int16>(a_name_len, b_name_len));
|
||||
if (r != 0) return r;
|
||||
if (a_name_len < b_name_len) return -1;
|
||||
else if (a_name_len > b_name_len) return +1;
|
||||
|
||||
return 0;
|
||||
auto &coll = std::use_facet<std::collate<char_t>>(std::locale());
|
||||
return coll.compare(a.name(), a.name_end(), b.name(), b.name_end());
|
||||
}
|
||||
} idxRank; ///< Rank index
|
||||
|
||||
std::vector<unsigned __int16> data; ///< Character category data
|
||||
std::vector<uint16_t> data; ///< Character category data
|
||||
|
||||
public:
|
||||
///
|
||||
@@ -491,168 +568,81 @@ namespace ZRCola {
|
||||
idxRank .clear();
|
||||
data .clear();
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Writes character category database to a stream
|
||||
///
|
||||
/// \param[in] stream Output stream
|
||||
/// \param[in] db Character category database
|
||||
///
|
||||
/// \returns The stream \p stream
|
||||
///
|
||||
friend std::ostream& operator <<(_In_ std::ostream& stream, _In_ const chrcat_db& db)
|
||||
{
|
||||
// Write character category index.
|
||||
if (stream.fail()) return stream;
|
||||
stream << db.idxChrCat;
|
||||
|
||||
// Write rank index.
|
||||
if (stream.fail()) return stream;
|
||||
stream << db.idxRank;
|
||||
|
||||
// Write data count.
|
||||
auto data_count = db.data.size();
|
||||
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
|
||||
// 4G check
|
||||
if (data_count > 0xffffffff) {
|
||||
stream.setstate(std::ios_base::failbit);
|
||||
return stream;
|
||||
}
|
||||
#endif
|
||||
if (stream.fail()) return stream;
|
||||
uint32_t count = (uint32_t)data_count;
|
||||
stream.write((const char*)&count, sizeof(count));
|
||||
|
||||
// Write data.
|
||||
if (stream.fail()) return stream;
|
||||
stream.write((const char*)db.data.data(), sizeof(uint16_t) * static_cast<std::streamsize>(count));
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Reads character category database from a stream
|
||||
///
|
||||
/// \param[in ] stream Input stream
|
||||
/// \param[out] db Character category database
|
||||
///
|
||||
/// \returns The stream \p stream
|
||||
///
|
||||
friend std::istream& operator >>(_In_ std::istream& stream, _Out_ chrcat_db& db)
|
||||
{
|
||||
// Read character category index.
|
||||
stream >> db.idxChrCat;
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read rank index.
|
||||
stream >> db.idxRank;
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read data count.
|
||||
uint32_t count;
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read data.
|
||||
db.data.resize(count);
|
||||
stream.read((char*)db.data.data(), sizeof(uint16_t) * static_cast<std::streamsize>(count));
|
||||
}
|
||||
else
|
||||
db.data.clear();
|
||||
|
||||
return stream;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
typedef stdex::idrec::record<chrcat_db, recordid_t, recordsize_t, ZRCOLA_RECORD_ALIGN> chrcat_rec;
|
||||
};
|
||||
|
||||
|
||||
const ZRCola::recordid_t ZRCola::character_rec::id = *(ZRCola::recordid_t*)"CHR";
|
||||
const ZRCola::recordid_t ZRCola::chrcat_rec ::id = *(ZRCola::recordid_t*)"CCT";
|
||||
|
||||
|
||||
///
|
||||
/// Reads character database from a stream
|
||||
///
|
||||
/// \param[in ] stream Input stream
|
||||
/// \param[out] db Character database
|
||||
///
|
||||
/// \returns The stream \p stream
|
||||
///
|
||||
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::character_db &db)
|
||||
{
|
||||
// Read character index.
|
||||
stream >> db.idxChr;
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read description index.
|
||||
stream >> db.idxDsc;
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read sub-term description index.
|
||||
stream >> db.idxDscSub;
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read data count.
|
||||
unsigned __int32 count;
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read data.
|
||||
db.data.resize(count);
|
||||
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
|
||||
} else
|
||||
db.data.clear();
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Writes character database to a stream
|
||||
///
|
||||
/// \param[in] stream Output stream
|
||||
/// \param[in] db Character database
|
||||
///
|
||||
/// \returns The stream \p stream
|
||||
///
|
||||
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::character_db &db)
|
||||
{
|
||||
// Write character index.
|
||||
if (stream.fail()) return stream;
|
||||
stream << db.idxChr;
|
||||
|
||||
// Write description index.
|
||||
if (!stream.good()) return stream;
|
||||
stream << db.idxDsc;
|
||||
|
||||
// Write sub-term description index.
|
||||
if (!stream.good()) return stream;
|
||||
stream << db.idxDscSub;
|
||||
|
||||
// Write data count.
|
||||
auto data_count = db.data.size();
|
||||
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
|
||||
// 4G check
|
||||
if (data_count > 0xffffffff) {
|
||||
stream.setstate(std::ios_base::failbit);
|
||||
return stream;
|
||||
}
|
||||
#endif
|
||||
if (stream.fail()) return stream;
|
||||
unsigned __int32 count = (unsigned __int32)data_count;
|
||||
stream.write((const char*)&count, sizeof(count));
|
||||
|
||||
// Write data.
|
||||
if (stream.fail()) return stream;
|
||||
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Writes character category database to a stream
|
||||
///
|
||||
/// \param[in] stream Output stream
|
||||
/// \param[in] db Character category database
|
||||
///
|
||||
/// \returns The stream \p stream
|
||||
///
|
||||
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::chrcat_db &db)
|
||||
{
|
||||
// Write character category index.
|
||||
if (stream.fail()) return stream;
|
||||
stream << db.idxChrCat;
|
||||
|
||||
// Write rank index.
|
||||
if (stream.fail()) return stream;
|
||||
stream << db.idxRank;
|
||||
|
||||
// Write data count.
|
||||
auto data_count = db.data.size();
|
||||
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
|
||||
// 4G check
|
||||
if (data_count > 0xffffffff) {
|
||||
stream.setstate(std::ios_base::failbit);
|
||||
return stream;
|
||||
}
|
||||
#endif
|
||||
if (stream.fail()) return stream;
|
||||
unsigned __int32 count = (unsigned __int32)data_count;
|
||||
stream.write((const char*)&count, sizeof(count));
|
||||
|
||||
// Write data.
|
||||
if (stream.fail()) return stream;
|
||||
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Reads character category database from a stream
|
||||
///
|
||||
/// \param[in ] stream Input stream
|
||||
/// \param[out] db Character category database
|
||||
///
|
||||
/// \returns The stream \p stream
|
||||
///
|
||||
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::chrcat_db &db)
|
||||
{
|
||||
// Read character category index.
|
||||
stream >> db.idxChrCat;
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read rank index.
|
||||
stream >> db.idxRank;
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read data count.
|
||||
unsigned __int32 count;
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read data.
|
||||
db.data.resize(count);
|
||||
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
|
||||
} else
|
||||
db.data.clear();
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
#pragma warning(pop)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2015-2021 Amebis
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -9,8 +9,13 @@
|
||||
#define _WINSOCKAPI_ // Prevent inclusion of winsock.h in windows.h.
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
#include <sal.h>
|
||||
#include <stdex/compat.hpp>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <istream>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
@@ -29,12 +34,39 @@
|
||||
///
|
||||
/// Database IDs
|
||||
///
|
||||
#define ZRCOLA_DB_ID (*(ZRCola::recordid_t*)"ZRC")
|
||||
#define ZRCOLA_DB_ID 0x43525a // "ZRC"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#ifdef __i386__
|
||||
#define __cdecl __attribute__((__cdecl__))
|
||||
#else
|
||||
#define __cdecl
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace ZRCola {
|
||||
typedef unsigned __int32 recordid_t;
|
||||
typedef unsigned __int32 recordsize_t;
|
||||
typedef uint32_t recordid_t;
|
||||
typedef uint32_t recordsize_t;
|
||||
|
||||
|
||||
///
|
||||
/// ZRCola database character type
|
||||
///
|
||||
#ifdef _WIN32
|
||||
typedef wchar_t char_t;
|
||||
#else
|
||||
typedef char16_t char_t;
|
||||
#endif
|
||||
|
||||
|
||||
///
|
||||
/// ZRCola database string type
|
||||
///
|
||||
#ifdef _WIN32
|
||||
typedef std::wstring string_t;
|
||||
#else
|
||||
typedef std::u16string string_t;
|
||||
#endif
|
||||
|
||||
|
||||
#pragma pack(push)
|
||||
@@ -60,7 +92,7 @@ namespace ZRCola {
|
||||
struct langid_t {
|
||||
char data[4];
|
||||
|
||||
inline langid_t& operator=(const langid_t &src)
|
||||
inline langid_t& operator=(_In_ const langid_t &src)
|
||||
{
|
||||
data[0] = src.data[0];
|
||||
data[1] = src.data[1];
|
||||
@@ -69,7 +101,7 @@ namespace ZRCola {
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline langid_t& operator=(const char *src)
|
||||
inline langid_t& operator=(_In_z_ const char *src)
|
||||
{
|
||||
data[3] = (
|
||||
data[2] = (
|
||||
@@ -210,9 +242,14 @@ namespace ZRCola {
|
||||
///
|
||||
/// Memory index
|
||||
///
|
||||
template <class T_data, class T_idx = unsigned __int32, class T_el = T_data>
|
||||
template <class T_data, class T_idx = uint32_t, class T_el = T_data>
|
||||
class index : public std::vector<T_idx>
|
||||
{
|
||||
typedef std::vector<T_idx> base_t;
|
||||
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
|
||||
protected:
|
||||
std::vector<T_data> &host; ///< Reference to host data
|
||||
|
||||
@@ -234,7 +271,7 @@ namespace ZRCola {
|
||||
///
|
||||
inline const T_el& at(size_type pos) const
|
||||
{
|
||||
return *reinterpret_cast<const T_el*>(&host[std::vector<T_idx>::at(pos)]);
|
||||
return *reinterpret_cast<const T_el*>(&host[base_t::at(pos)]);
|
||||
}
|
||||
|
||||
|
||||
@@ -247,7 +284,7 @@ namespace ZRCola {
|
||||
///
|
||||
inline T_el& at(size_type pos)
|
||||
{
|
||||
return *reinterpret_cast<T_el*>(&host[std::vector<T_idx>::at(pos)]);
|
||||
return *reinterpret_cast<T_el*>(&host[base_t::at(pos)]);
|
||||
}
|
||||
|
||||
|
||||
@@ -260,7 +297,7 @@ namespace ZRCola {
|
||||
///
|
||||
inline const T_el& operator[](size_type pos) const
|
||||
{
|
||||
return *reinterpret_cast<const T_el*>(&host[std::vector<T_idx>::operator[](pos)]);
|
||||
return *reinterpret_cast<const T_el*>(&host[base_t::operator[](pos)]);
|
||||
}
|
||||
|
||||
|
||||
@@ -273,7 +310,7 @@ namespace ZRCola {
|
||||
///
|
||||
inline T_el& operator[](size_type pos)
|
||||
{
|
||||
return *reinterpret_cast<T_el*>(&host[std::vector<T_idx>::operator[](pos)]);
|
||||
return *reinterpret_cast<T_el*>(&host[base_t::operator[](pos)]);
|
||||
}
|
||||
|
||||
|
||||
@@ -282,7 +319,7 @@ namespace ZRCola {
|
||||
///
|
||||
inline void sort()
|
||||
{
|
||||
qsort_s(data(), size(), sizeof(T_idx), compare_s, this);
|
||||
qsort_s(base_t::data(), base_t::size(), sizeof(T_idx), compare_s, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -333,21 +370,21 @@ namespace ZRCola {
|
||||
bool find(_In_ const T_el &el, _Out_ size_type &start, _Out_ size_type &end) const
|
||||
{
|
||||
// Start with the full search area.
|
||||
for (start = 0, end = size(); start < end; ) {
|
||||
size_type m = (start + end) / 2;
|
||||
for (start = 0, end = base_t::size(); start < end; ) {
|
||||
auto m = (start + end) / 2;
|
||||
int r = compare(el, at(m));
|
||||
if (r < 0) end = m;
|
||||
else if (r > 0) start = m + 1;
|
||||
else {
|
||||
// Narrow the search area on the left to start at the first element in the run.
|
||||
for (size_type end2 = m; start < end2;) {
|
||||
size_type m2 = (start + end2) / 2;
|
||||
for (auto end2 = m; start < end2;) {
|
||||
auto m2 = (start + end2) / 2;
|
||||
if (compare(el, at(m2)) <= 0) end2 = m2; else start = m2 + 1;
|
||||
}
|
||||
|
||||
// Narrow the search area on the right to end at the first element not in the run.
|
||||
for (size_type start2 = m + 1; start2 < end;) {
|
||||
size_type m2 = (start2 + end) / 2;
|
||||
for (auto start2 = m + 1; start2 < end;) {
|
||||
auto m2 = (start2 + end) / 2;
|
||||
if (0 <= compare(el, at(m2))) start2 = m2 + 1; else end = m2;
|
||||
}
|
||||
|
||||
@@ -372,14 +409,14 @@ namespace ZRCola {
|
||||
{
|
||||
// Start with the full search area.
|
||||
size_t end;
|
||||
for (start = 0, end = size(); start < end; ) {
|
||||
size_type m = (start + end) / 2;
|
||||
for (start = 0, end = base_t::size(); start < end; ) {
|
||||
auto m = (start + end) / 2;
|
||||
int r = compare(el, at(m));
|
||||
if (r < 0) end = m;
|
||||
else if (r > 0) start = m + 1;
|
||||
else {
|
||||
// Narrow the search area on the left to start at the first element in the run.
|
||||
for (size_type end2 = m; start < end2;) {
|
||||
for (auto end2 = m; start < end2;) {
|
||||
m = (start + end2) / 2;
|
||||
if (compare(el, at(m)) <= 0) end2 = m; else start = m + 1;
|
||||
}
|
||||
@@ -391,6 +428,68 @@ namespace ZRCola {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Writes index to a stream
|
||||
///
|
||||
/// \param[in] stream Output stream
|
||||
/// \param[in] idx Index
|
||||
///
|
||||
/// \returns The stream \p stream
|
||||
///
|
||||
friend std::ostream& operator <<(_In_ std::ostream& stream, _In_ const index& idx)
|
||||
{
|
||||
// Write index count.
|
||||
auto idx_count = idx.size();
|
||||
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
|
||||
// 4G check
|
||||
if (idx_count > 0xffffffff) {
|
||||
stream.setstate(std::ios_base::failbit);
|
||||
return stream;
|
||||
}
|
||||
#endif
|
||||
if (stream.fail()) return stream;
|
||||
uint32_t count = (uint32_t)idx_count;
|
||||
stream.write((const char*)&count, sizeof(count));
|
||||
|
||||
// Write index data.
|
||||
if (stream.fail()) return stream;
|
||||
stream.write((const char*)idx.data(), sizeof(T_idx) * static_cast<std::streamsize>(count));
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Reads index from a stream
|
||||
///
|
||||
/// \param[in] stream Input stream
|
||||
/// \param[out] idx Index
|
||||
///
|
||||
/// \returns The stream \p stream
|
||||
///
|
||||
friend std::istream& operator >>(_In_ std::istream& stream, _Out_ index& idx)
|
||||
{
|
||||
uint32_t count;
|
||||
|
||||
// Read index count.
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) {
|
||||
idx.clear();
|
||||
return stream;
|
||||
}
|
||||
|
||||
if (count) {
|
||||
// Read index data.
|
||||
idx.resize(count);
|
||||
stream.read((char*)idx.data(), sizeof(T_idx) * static_cast<std::streamsize>(count));
|
||||
}
|
||||
else
|
||||
idx.clear();
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
private:
|
||||
static int __cdecl compare_s(void *p, const void *a, const void *b)
|
||||
{
|
||||
@@ -406,11 +505,13 @@ namespace ZRCola {
|
||||
///
|
||||
/// Memory text index
|
||||
///
|
||||
template <class T_key, class T_val, class T_idx = unsigned __int32>
|
||||
template <class T_key, class T_val, class T_idx = uint32_t>
|
||||
class textindex : public std::vector< mappair_t<T_idx> >
|
||||
{
|
||||
public:
|
||||
typedef std::vector< mappair_t<T_idx> > base_t;
|
||||
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
std::vector<T_key> keys; ///< Key data
|
||||
std::vector<T_val> values; ///< Index values
|
||||
|
||||
@@ -446,15 +547,15 @@ namespace ZRCola {
|
||||
///
|
||||
_Success_(return) bool find(_In_count_(key_len) const T_key *key, _In_ size_t key_len, _Out_ const T_val **val, _Out_ size_t *val_len) const
|
||||
{
|
||||
for (size_type start = 0, end = size(); start < end; ) {
|
||||
size_type m = (start + end) / 2;
|
||||
for (size_type start = 0, end = base_t::size(); start < end; ) {
|
||||
auto m = (start + end) / 2;
|
||||
int r = compare(key, key_len, m);
|
||||
if (r < 0) end = m;
|
||||
else if (r > 0) start = m + 1;
|
||||
else {
|
||||
// Get values at position m.
|
||||
start = base_t::at(m ).idx_val;
|
||||
*val_len = (m < size() ? base_t::at(m + 1).idx_val : values.size()) - start;
|
||||
start = base_t::at(m ).idx_val;
|
||||
*val_len = (m < base_t::size() ? base_t::at(m + 1).idx_val : values.size()) - start;
|
||||
*val = &values.at(start);
|
||||
return true;
|
||||
}
|
||||
@@ -463,15 +564,145 @@ namespace ZRCola {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Writes text index to a stream
|
||||
///
|
||||
/// \param[in] stream Output stream
|
||||
/// \param[in] idx Text index
|
||||
///
|
||||
/// \returns The stream \p stream
|
||||
///
|
||||
friend std::ostream& operator <<(_In_ std::ostream& stream, _In_ const textindex& idx)
|
||||
{
|
||||
uint32_t count;
|
||||
|
||||
// Write index count.
|
||||
auto idx_count = idx.size();
|
||||
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
|
||||
// 4G check
|
||||
if (idx_count > 0xffffffff) {
|
||||
stream.setstate(std::ios_base::failbit);
|
||||
return stream;
|
||||
}
|
||||
#endif
|
||||
if (stream.fail()) return stream;
|
||||
count = (uint32_t)idx_count;
|
||||
stream.write((const char*)&count, sizeof(count));
|
||||
|
||||
// Write index data.
|
||||
if (stream.fail()) return stream;
|
||||
auto idx_data = idx.data();
|
||||
stream.write((const char*)idx_data, sizeof(*idx_data) * static_cast<std::streamsize>(count));
|
||||
|
||||
// Write key count.
|
||||
auto key_count = idx.keys.size();
|
||||
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
|
||||
// 4G check
|
||||
if (idx_count > 0xffffffff) {
|
||||
stream.setstate(std::ios_base::failbit);
|
||||
return stream;
|
||||
}
|
||||
#endif
|
||||
if (stream.fail()) return stream;
|
||||
count = (uint32_t)key_count;
|
||||
stream.write((const char*)&count, sizeof(count));
|
||||
|
||||
// Write key data.
|
||||
if (stream.fail()) return stream;
|
||||
auto idx_keys_data = idx.keys.data();
|
||||
stream.write((const char*)idx_keys_data, sizeof(*idx_keys_data) * static_cast<std::streamsize>(count));
|
||||
|
||||
// Write value count.
|
||||
auto value_count = idx.values.size();
|
||||
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
|
||||
// 4G check
|
||||
if (idx_count > 0xffffffff) {
|
||||
stream.setstate(std::ios_base::failbit);
|
||||
return stream;
|
||||
}
|
||||
#endif
|
||||
if (stream.fail()) return stream;
|
||||
count = (uint32_t)value_count;
|
||||
stream.write((const char*)&count, sizeof(count));
|
||||
|
||||
// Write value data.
|
||||
if (stream.fail()) return stream;
|
||||
auto idx_values_data = idx.values.data();
|
||||
stream.write((const char*)idx_values_data, sizeof(*idx_values_data) * static_cast<std::streamsize>(count));
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Reads text index from a stream
|
||||
///
|
||||
/// \param[in] stream Input stream
|
||||
/// \param[out] idx Text index
|
||||
///
|
||||
/// \returns The stream \p stream
|
||||
///
|
||||
friend std::istream& operator >>(_In_ std::istream& stream, _Out_ textindex& idx)
|
||||
{
|
||||
uint32_t count;
|
||||
|
||||
// Read text index count.
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) {
|
||||
idx.clear();
|
||||
return stream;
|
||||
}
|
||||
|
||||
if (count) {
|
||||
// Read text index.
|
||||
idx.resize(count);
|
||||
auto p = idx.data();
|
||||
stream.read((char*)p, sizeof(*p) * static_cast<std::streamsize>(count));
|
||||
if (!stream.good()) return stream;
|
||||
}
|
||||
else
|
||||
idx.clear();
|
||||
|
||||
// Read keys count.
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read keys.
|
||||
idx.keys.resize(count);
|
||||
auto p = idx.keys.data();
|
||||
stream.read((char*)p, sizeof(*p) * static_cast<std::streamsize>(count));
|
||||
if (!stream.good()) return stream;
|
||||
}
|
||||
else
|
||||
idx.keys.clear();
|
||||
|
||||
// Read value count.
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read values.
|
||||
idx.values.resize(count);
|
||||
auto p = idx.values.data();
|
||||
stream.read((char*)p, sizeof(*p) * static_cast<std::streamsize>(count));
|
||||
}
|
||||
else
|
||||
idx.values.clear();
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
protected:
|
||||
inline int compare(_In_count_(key_len) const T_key *key, _In_ size_t key_len, size_type pos) const
|
||||
{
|
||||
// Get key at position pos.
|
||||
size_type pos_next = pos + 1;
|
||||
auto pos_next = pos + 1;
|
||||
size_t
|
||||
start = base_t::at(pos ).idx_key,
|
||||
key2_len = (pos_next < size() ? base_t::at(pos_next).idx_key : keys.size()) - start;
|
||||
std::vector<T_key>::const_pointer key2 = &keys.at(start);
|
||||
start = base_t::at(pos ).idx_key,
|
||||
key2_len = (pos_next < base_t::size() ? base_t::at(pos_next).idx_key : keys.size()) - start;
|
||||
auto key2 = &keys.at(start);
|
||||
|
||||
// Compare keys.
|
||||
int r = memcmp(key, key2, sizeof(T_key)*std::min<size_t>(key_len, key2_len));
|
||||
@@ -487,7 +718,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// Source-destination index transformation mapping
|
||||
///
|
||||
class __declspec(novtable) mapping {
|
||||
struct mapping {
|
||||
public:
|
||||
size_t src; ///< Character index in source string
|
||||
size_t dst; ///< Character index in destination string
|
||||
@@ -552,16 +783,7 @@ namespace ZRCola {
|
||||
/// The function does not treat \\0 characters as terminators for performance reasons.
|
||||
/// Therefore \p count_a and \p count_b must represent exact string lengths.
|
||||
///
|
||||
inline int CompareString(_In_ const wchar_t *str_a, _In_ size_t count_a, _In_ const wchar_t *str_b, _In_ size_t count_b)
|
||||
{
|
||||
for (size_t i = 0; ; i++) {
|
||||
if (i >= count_a && i >= count_b) return 0;
|
||||
else if (i >= count_a && i < count_b) return -1;
|
||||
else if (i < count_a && i >= count_b) return +1;
|
||||
else if (str_a[i] < str_b[i]) return -1;
|
||||
else if (str_a[i] > str_b[i]) return +1;
|
||||
}
|
||||
}
|
||||
int CompareString(_In_ const char_t* str_a, _In_ size_t count_a, _In_ const char_t* str_b, _In_ size_t count_b);
|
||||
|
||||
///
|
||||
/// Generates and returns Unicode representation of the string using hexadecimal codes.
|
||||
@@ -570,21 +792,7 @@ namespace ZRCola {
|
||||
/// \param[in] count Number of characters in string \p str
|
||||
/// \param[in] sep Separator
|
||||
///
|
||||
inline std::string GetUnicodeDumpA(_In_ const wchar_t *str, _In_ size_t count, _In_z_ const char *sep = "+")
|
||||
{
|
||||
std::string out;
|
||||
size_t dump_len_max = strlen(sep) + 4 + 1;
|
||||
char *dump;
|
||||
std::unique_ptr<char> dump_obj(dump = new char[dump_len_max]);
|
||||
if (count && str[0]) {
|
||||
size_t i = 0;
|
||||
out.insert(out.end(), dump, dump + _snprintf(dump, dump_len_max, "%04X", str[i++]));
|
||||
while (i < count && str[i])
|
||||
out.insert(out.end(), dump, dump + _snprintf(dump, dump_len_max, "%s%04X", sep, str[i++]));
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
std::string GetUnicodeDumpA(_In_z_count_(count) const char_t* str, _In_ size_t count, _In_z_ const char* sep = "+");
|
||||
|
||||
///
|
||||
/// Generates and returns Unicode representation of the string using hexadecimal codes.
|
||||
@@ -593,21 +801,7 @@ namespace ZRCola {
|
||||
/// \param[in] count Number of characters in string \p str
|
||||
/// \param[in] sep Separator
|
||||
///
|
||||
inline std::wstring GetUnicodeDumpW(_In_ const wchar_t *str, _In_ size_t count, _In_z_ const wchar_t *sep = L"+")
|
||||
{
|
||||
std::wstring out;
|
||||
size_t dump_len_max = wcslen(sep) + 4 + 1;
|
||||
wchar_t *dump;
|
||||
std::unique_ptr<wchar_t> dump_obj(dump = new wchar_t[dump_len_max]);
|
||||
if (count && str[0]) {
|
||||
size_t i = 0;
|
||||
out.insert(out.end(), dump, dump + _snwprintf(dump, dump_len_max, L"%04X", str[i++]));
|
||||
while (i < count && str[i])
|
||||
out.insert(out.end(), dump, dump + _snwprintf(dump, dump_len_max, L"%s%04X", sep, str[i++]));
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
std::wstring GetUnicodeDumpW(_In_z_count_(count) const char_t* str, _In_ size_t count, _In_z_ const wchar_t* sep = L"+");
|
||||
|
||||
#ifdef _UNICODE
|
||||
#define GetUnicodeDump GetUnicodeDumpW
|
||||
@@ -616,190 +810,4 @@ namespace ZRCola {
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// Writes index to a stream
|
||||
///
|
||||
/// \param[in] stream Output stream
|
||||
/// \param[in] idx Index
|
||||
///
|
||||
/// \returns The stream \p stream
|
||||
///
|
||||
template <class T_data, class T_idx, class T_el>
|
||||
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::index<T_data, T_idx, T_el> &idx)
|
||||
{
|
||||
// Write index count.
|
||||
auto idx_count = idx.size();
|
||||
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
|
||||
// 4G check
|
||||
if (idx_count > 0xffffffff) {
|
||||
stream.setstate(std::ios_base::failbit);
|
||||
return stream;
|
||||
}
|
||||
#endif
|
||||
if (stream.fail()) return stream;
|
||||
unsigned __int32 count = (unsigned __int32)idx_count;
|
||||
stream.write((const char*)&count, sizeof(count));
|
||||
|
||||
// Write index data.
|
||||
if (stream.fail()) return stream;
|
||||
stream.write((const char*)idx.data(), sizeof(T_idx)*static_cast<std::streamsize>(count));
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Reads index from a stream
|
||||
///
|
||||
/// \param[in] stream Input stream
|
||||
/// \param[out] idx Index
|
||||
///
|
||||
/// \returns The stream \p stream
|
||||
///
|
||||
template <class T_data, class T_idx, class T_el>
|
||||
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::index<T_data, T_idx, T_el> &idx)
|
||||
{
|
||||
unsigned __int32 count;
|
||||
|
||||
// Read index count.
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) {
|
||||
idx.clear();
|
||||
return stream;
|
||||
}
|
||||
|
||||
if (count) {
|
||||
// Read index data.
|
||||
idx.resize(count);
|
||||
stream.read((char*)idx.data(), sizeof(T_idx)*static_cast<std::streamsize>(count));
|
||||
} else
|
||||
idx.clear();
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Writes text index to a stream
|
||||
///
|
||||
/// \param[in] stream Output stream
|
||||
/// \param[in] idx Text index
|
||||
///
|
||||
/// \returns The stream \p stream
|
||||
///
|
||||
template <class T_key, class T_val, class T_idx>
|
||||
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::textindex<T_key, T_val, T_idx> &idx)
|
||||
{
|
||||
unsigned __int32 count;
|
||||
|
||||
// Write index count.
|
||||
auto idx_count = idx.size();
|
||||
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
|
||||
// 4G check
|
||||
if (idx_count > 0xffffffff) {
|
||||
stream.setstate(std::ios_base::failbit);
|
||||
return stream;
|
||||
}
|
||||
#endif
|
||||
if (stream.fail()) return stream;
|
||||
count = (unsigned __int32)idx_count;
|
||||
stream.write((const char*)&count, sizeof(count));
|
||||
|
||||
// Write index data.
|
||||
if (stream.fail()) return stream;
|
||||
stream.write((const char*)idx.data(), sizeof(ZRCola::textindex<T_key, T_val, T_idx>::value_type)*static_cast<std::streamsize>(count));
|
||||
|
||||
// Write key count.
|
||||
auto key_count = idx.keys.size();
|
||||
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
|
||||
// 4G check
|
||||
if (idx_count > 0xffffffff) {
|
||||
stream.setstate(std::ios_base::failbit);
|
||||
return stream;
|
||||
}
|
||||
#endif
|
||||
if (stream.fail()) return stream;
|
||||
count = (unsigned __int32)key_count;
|
||||
stream.write((const char*)&count, sizeof(count));
|
||||
|
||||
// Write key data.
|
||||
if (stream.fail()) return stream;
|
||||
stream.write((const char*)idx.keys.data(), sizeof(std::vector<T_key>::value_type)*static_cast<std::streamsize>(count));
|
||||
|
||||
// Write value count.
|
||||
auto value_count = idx.values.size();
|
||||
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
|
||||
// 4G check
|
||||
if (idx_count > 0xffffffff) {
|
||||
stream.setstate(std::ios_base::failbit);
|
||||
return stream;
|
||||
}
|
||||
#endif
|
||||
if (stream.fail()) return stream;
|
||||
count = (unsigned __int32)value_count;
|
||||
stream.write((const char*)&count, sizeof(count));
|
||||
|
||||
// Write value data.
|
||||
if (stream.fail()) return stream;
|
||||
stream.write((const char*)idx.values.data(), sizeof(std::vector<T_val>::value_type)*static_cast<std::streamsize>(count));
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Reads text index from a stream
|
||||
///
|
||||
/// \param[in] stream Input stream
|
||||
/// \param[out] idx Text index
|
||||
///
|
||||
/// \returns The stream \p stream
|
||||
///
|
||||
template <class T_key, class T_val, class T_idx>
|
||||
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::textindex<T_key, T_val, T_idx> &idx)
|
||||
{
|
||||
unsigned __int32 count;
|
||||
|
||||
// Read text index count.
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) {
|
||||
idx.clear();
|
||||
return stream;
|
||||
}
|
||||
|
||||
if (count) {
|
||||
// Read text index.
|
||||
idx.resize(count);
|
||||
stream.read((char*)idx.data(), sizeof(ZRCola::textindex<T_key, T_val, T_idx>::value_type)*static_cast<std::streamsize>(count));
|
||||
if (!stream.good()) return stream;
|
||||
} else
|
||||
idx.clear();
|
||||
|
||||
// Read keys count.
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read keys.
|
||||
idx.keys.resize(count);
|
||||
stream.read((char*)idx.keys.data(), sizeof(std::vector<T_key>::value_type)*static_cast<std::streamsize>(count));
|
||||
if (!stream.good()) return stream;
|
||||
} else
|
||||
idx.keys.clear();
|
||||
|
||||
// Read value count.
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read values.
|
||||
idx.values.resize(count);
|
||||
stream.read((char*)idx.values.data(), sizeof(std::vector<T_val>::value_type)*static_cast<std::streamsize>(count));
|
||||
} else
|
||||
idx.values.clear();
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
#pragma warning(pop)
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Copyright © 2021 Amebis
|
||||
Copyright © 2021-2022 Amebis
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <stdex/idrec.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
#pragma warning(push)
|
||||
@@ -29,7 +27,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// Highlight set ID
|
||||
///
|
||||
typedef unsigned __int16 hlghtsetid_t;
|
||||
typedef uint16_t hlghtsetid_t;
|
||||
|
||||
///
|
||||
/// Highlight database
|
||||
@@ -43,11 +41,11 @@ namespace ZRCola {
|
||||
///
|
||||
struct highlight {
|
||||
public:
|
||||
hlghtsetid_t set; ///< Highlight set ID
|
||||
hlghtsetid_t set; ///< Highlight set ID
|
||||
|
||||
protected:
|
||||
unsigned __int16 chr_to; ///< Character end in \c data
|
||||
wchar_t data[]; ///< Character
|
||||
uint16_t chr_to; ///< Character end in \c data
|
||||
char_t data[]; ///< Character
|
||||
|
||||
private:
|
||||
inline highlight(_In_ const highlight &other);
|
||||
@@ -63,21 +61,21 @@ namespace ZRCola {
|
||||
///
|
||||
inline highlight(
|
||||
_In_opt_ hlghtsetid_t set = 0,
|
||||
_In_opt_z_count_(chr_len) const wchar_t *chr = NULL,
|
||||
_In_opt_z_count_(chr_len) const char_t *chr = NULL,
|
||||
_In_opt_ size_t chr_len = 0)
|
||||
{
|
||||
this->set = set;
|
||||
this->chr_to = static_cast<unsigned __int16>(chr_len);
|
||||
if (chr && chr_len) memcpy(this->data, chr, sizeof(wchar_t)*chr_len);
|
||||
this->chr_to = static_cast<uint16_t>(chr_len);
|
||||
if (chr && chr_len) memcpy(this->data, chr, sizeof(char_t)*chr_len);
|
||||
}
|
||||
|
||||
inline const wchar_t* chr () const { return data; };
|
||||
inline wchar_t* chr () { return data; };
|
||||
inline const wchar_t* chr_end() const { return data + chr_to; };
|
||||
inline wchar_t* chr_end() { return data + chr_to; };
|
||||
inline unsigned __int16 chr_len() const { return chr_to; };
|
||||
inline const char_t* chr () const { return data; };
|
||||
inline char_t* chr () { return data; };
|
||||
inline const char_t* chr_end() const { return data + chr_to; };
|
||||
inline char_t* chr_end() { return data + chr_to; };
|
||||
inline uint16_t chr_len() const { return chr_to; };
|
||||
|
||||
inline wchar_t chr_at(_In_ size_t i) const
|
||||
inline char_t chr_at(_In_ size_t i) const
|
||||
{
|
||||
return i < chr_to ? data[i] : 0;
|
||||
}
|
||||
@@ -87,7 +85,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// Highlight index
|
||||
///
|
||||
class indexChr : public index<unsigned __int16, unsigned __int32, highlight>
|
||||
class indexChr : public index<uint16_t, uint32_t, highlight>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@@ -95,7 +93,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \param[in] h Reference to vector holding the data
|
||||
///
|
||||
indexChr(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, highlight>(h) {}
|
||||
indexChr(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, highlight>(h) {}
|
||||
|
||||
///
|
||||
/// Compares two highlights by string (for searching)
|
||||
@@ -113,8 +111,8 @@ namespace ZRCola {
|
||||
int r = ZRCola::CompareString(a.chr(), a.chr_len(), b.chr(), b.chr_len());
|
||||
if (r != 0) return r;
|
||||
|
||||
if (a.set < b.set) return -1;
|
||||
else if (a.set > b.set) return +1;
|
||||
if (a.set < b.set) return -1;
|
||||
if (a.set > b.set) return +1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -138,7 +136,7 @@ namespace ZRCola {
|
||||
} idxChr; ///< Highlight index
|
||||
|
||||
|
||||
std::vector<unsigned __int16> data; ///< Highlight data
|
||||
std::vector<uint16_t> data; ///< Highlight data
|
||||
|
||||
public:
|
||||
///
|
||||
@@ -162,79 +160,73 @@ namespace ZRCola {
|
||||
/// \param[in] inputMax Length of the input string in characters. Can be (size_t)-1 if \p input is zero terminated.
|
||||
/// \param[in] callback Function to be called on highlight switch
|
||||
///
|
||||
void Highlight(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _In_ std::function<void (hlghtsetid_t set, size_t start, size_t end)> callback) const;
|
||||
void Highlight(_In_z_count_(inputMax) const char_t* input, _In_ size_t inputMax, _In_ std::function<void (hlghtsetid_t set, size_t start, size_t end)> callback) const;
|
||||
|
||||
///
|
||||
/// Writes highlight database to a stream
|
||||
///
|
||||
/// \param[in] stream Output stream
|
||||
/// \param[in] db Highlight database
|
||||
///
|
||||
/// \returns The stream \p stream
|
||||
///
|
||||
friend std::ostream& operator <<(_In_ std::ostream& stream, _In_ const highlight_db& db)
|
||||
{
|
||||
// Write highlight index.
|
||||
if (stream.fail()) return stream;
|
||||
stream << db.idxChr;
|
||||
|
||||
// Write data count.
|
||||
auto data_count = db.data.size();
|
||||
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
|
||||
// 4G check
|
||||
if (data_count > 0xffffffff) {
|
||||
stream.setstate(std::ios_base::failbit);
|
||||
return stream;
|
||||
}
|
||||
#endif
|
||||
if (stream.fail()) return stream;
|
||||
uint32_t count = (uint32_t)data_count;
|
||||
stream.write((const char*)&count, sizeof(count));
|
||||
|
||||
// Write data.
|
||||
if (stream.fail()) return stream;
|
||||
stream.write((const char*)db.data.data(), sizeof(uint16_t) * static_cast<std::streamsize>(count));
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Reads highlight database from a stream
|
||||
///
|
||||
/// \param[in ] stream Input stream
|
||||
/// \param[out] db Highlight database
|
||||
///
|
||||
/// \returns The stream \p stream
|
||||
///
|
||||
friend std::istream& operator >>(_In_ std::istream& stream, _Out_ highlight_db& db)
|
||||
{
|
||||
// Read highlight index.
|
||||
stream >> db.idxChr;
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read data count.
|
||||
uint32_t count;
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read data.
|
||||
db.data.resize(count);
|
||||
stream.read((char*)db.data.data(), sizeof(uint16_t) * static_cast<std::streamsize>(count));
|
||||
}
|
||||
else
|
||||
db.data.clear();
|
||||
|
||||
return stream;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
typedef stdex::idrec::record<highlight_db, recordid_t, recordsize_t, ZRCOLA_RECORD_ALIGN> highlight_rec;
|
||||
};
|
||||
|
||||
|
||||
const ZRCola::recordid_t ZRCola::highlight_rec::id = *(ZRCola::recordid_t*)"HGH";
|
||||
|
||||
|
||||
///
|
||||
/// Writes highlight database to a stream
|
||||
///
|
||||
/// \param[in] stream Output stream
|
||||
/// \param[in] db Highlight database
|
||||
///
|
||||
/// \returns The stream \p stream
|
||||
///
|
||||
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::highlight_db &db)
|
||||
{
|
||||
// Write highlight index.
|
||||
if (stream.fail()) return stream;
|
||||
stream << db.idxChr;
|
||||
|
||||
// Write data count.
|
||||
auto data_count = db.data.size();
|
||||
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
|
||||
// 4G check
|
||||
if (data_count > 0xffffffff) {
|
||||
stream.setstate(std::ios_base::failbit);
|
||||
return stream;
|
||||
}
|
||||
#endif
|
||||
if (stream.fail()) return stream;
|
||||
unsigned __int32 count = (unsigned __int32)data_count;
|
||||
stream.write((const char*)&count, sizeof(count));
|
||||
|
||||
// Write data.
|
||||
if (stream.fail()) return stream;
|
||||
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Reads highlight database from a stream
|
||||
///
|
||||
/// \param[in ] stream Input stream
|
||||
/// \param[out] db Highlight database
|
||||
///
|
||||
/// \returns The stream \p stream
|
||||
///
|
||||
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::highlight_db &db)
|
||||
{
|
||||
// Read highlight index.
|
||||
stream >> db.idxChr;
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read data count.
|
||||
unsigned __int32 count;
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read data.
|
||||
db.data.resize(count);
|
||||
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
|
||||
} else
|
||||
db.data.clear();
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
#pragma warning(pop)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user