-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Updated localization system from another project - Updated original records data
- Loading branch information
Showing
19 changed files
with
2,102 additions
and
893 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
.xmake/ | ||
build/ | ||
package/ | ||
install/ | ||
vsxmake2015/ | ||
vsxmake2017/ | ||
vsxmake2019/ | ||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// Created by Andrej Redeky. | ||
// Copyright © 2015-2023 Feldarian Softworks. All rights reserved. | ||
// SPDX-License-Identifier: EUPL-1.2 | ||
// | ||
|
||
#pragma once | ||
|
||
template <typename InstanceType> | ||
class Singleton | ||
{ | ||
public: | ||
static InstanceType& Get() | ||
{ | ||
static InstanceType instance; | ||
return instance; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// Created by Andrej Redeky. | ||
// Copyright © 2015-2023 Feldarian Softworks. All rights reserved. | ||
// SPDX-License-Identifier: EUPL-1.2 | ||
// | ||
|
||
#pragma once | ||
|
||
namespace UTF | ||
{ | ||
|
||
template <typename TypeInput, typename... TypesToCompareWith> | ||
concept IsAnyOfTypes = (std::same_as<TypeInput, TypesToCompareWith> || ...); | ||
|
||
template <typename UTFCharType> | ||
concept IsUTF8CharType = IsAnyOfTypes<UTFCharType, char, char8_t, int8_t, uint8_t>; | ||
|
||
static_assert(std::same_as<char16_t, UChar>, "ICU UChar typedef is not char16_t!"); | ||
|
||
#ifdef _WIN32 | ||
|
||
template <typename UTFCharType> | ||
concept IsUTF16CharType = IsAnyOfTypes<UTFCharType, wchar_t, char16_t, int16_t, uint16_t, UChar>; | ||
|
||
template <typename UTFCharType> | ||
concept IsUTF32CharType = IsAnyOfTypes<UTFCharType, char32_t, int32_t, uint32_t, UChar32>; | ||
|
||
#else // _WIN32 | ||
|
||
static_assert(std::same_as<wchar_t, UChar32>, "STD wchar_t had unexpected size!"); | ||
|
||
template <typename UTFCharType> | ||
concept IsUTF16CharType = IsAnyOfTypes<UTFCharType, char16_t, int16_t, uint16_t, UChar>; | ||
|
||
template <typename UTFCharType> | ||
concept IsUTF32CharType = IsAnyOfTypes<UTFCharType, wchar_t, char32_t, int32_t, uint32_t, UChar32>; | ||
|
||
#endif // _WIN32 | ||
|
||
template <typename UTFCharType> | ||
concept IsUTFNativeCharType = IsAnyOfTypes<UTFCharType, char, wchar_t>; | ||
|
||
template <typename UTFCharType> | ||
concept IsUTFCharType = IsUTF8CharType<UTFCharType> || IsUTF16CharType<UTFCharType> || IsUTF32CharType<UTFCharType> || IsUTFNativeCharType<UTFCharType>; | ||
|
||
static constexpr auto CodepointInvalid{ 0u }; | ||
static constexpr auto CodepointMax{ 0x10FFFFu }; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
// | ||
// Created by Andrej Redeky. | ||
// Copyright © 2015-2023 Feldarian Softworks. All rights reserved. | ||
// SPDX-License-Identifier: EUPL-1.2 | ||
// | ||
|
||
#pragma once | ||
|
||
namespace UTF | ||
{ | ||
|
||
class GlyphRangesBuilder : public Singleton<GlyphRangesBuilder> | ||
{ | ||
public: | ||
|
||
GlyphRangesBuilder() | ||
{ | ||
Initialize(); | ||
} | ||
|
||
void Clear() | ||
{ | ||
glyphsInUse.reset(); | ||
|
||
Initialize(); | ||
} | ||
|
||
bool NeedsBuild() const | ||
{ | ||
return newGlyphsAdded; | ||
} | ||
|
||
std::vector<std::pair<uint32_t, uint32_t>> Build() | ||
{ | ||
std::vector<std::pair<uint32_t, uint32_t>> glyphRanges; | ||
|
||
std::lock_guard lock(dataMutex); | ||
|
||
std::pair<uint32_t, uint32_t> glyphRange{CodepointInvalid, CodepointInvalid}; | ||
for (uint32_t glyph = 1; glyph <= CodepointMax; ++glyph) | ||
{ | ||
if (glyphsInUse.test(glyph)) | ||
{ | ||
if (glyphRange.first == CodepointInvalid) | ||
glyphRange.first = glyph; | ||
|
||
glyphRange.second = glyph; | ||
} | ||
else | ||
{ | ||
if (glyphRange.first != CodepointInvalid) | ||
{ | ||
glyphRanges.emplace_back(glyphRange); | ||
glyphRange = {CodepointInvalid, CodepointInvalid}; | ||
} | ||
} | ||
} | ||
|
||
if (glyphRange.first != CodepointInvalid) | ||
glyphRanges.emplace_back(glyphRange); | ||
|
||
newGlyphsAdded = false; | ||
return glyphRanges; | ||
} | ||
|
||
void AddRange(std::pair<uint32_t, uint32_t> glyphRange) | ||
{ | ||
for (auto glyph = glyphRange.first; glyph <= glyphRange.second; ++glyph) | ||
Add(glyph); | ||
} | ||
|
||
void Add(uint32_t glyph) | ||
{ | ||
if (glyph == CodepointInvalid || glyph > CodepointMax) | ||
return; | ||
|
||
std::lock_guard lock(dataMutex); | ||
newGlyphsAdded |= !glyphsInUse.test(glyph); | ||
glyphsInUse.set(glyph); | ||
} | ||
|
||
template <typename UTFCharType> | ||
requires IsUTFCharType<UTFCharType> | ||
void AddText(const std::basic_string_view<UTFCharType> utf) | ||
{ | ||
if constexpr (IsUTF8CharType<UTFCharType>) | ||
{ | ||
const auto *utfData = utf.data(); | ||
const auto utfSize = utf.size(); | ||
for (size_t utfOffset = 0; utfOffset < utfSize;) | ||
{ | ||
uint32_t glyph = CodepointInvalid; | ||
U8_NEXT(utfData, utfOffset, utfSize, glyph); | ||
|
||
Add(glyph); | ||
} | ||
} | ||
|
||
if constexpr (IsUTF16CharType<UTFCharType>) | ||
{ | ||
const auto *utfData = utf.data(); | ||
const auto utfSize = utf.size(); | ||
for (size_t utfOffset = 0; utfOffset < utfSize;) | ||
{ | ||
uint32_t glyph = CodepointInvalid; | ||
U16_NEXT(utfData, utfOffset, utfSize, glyph); | ||
|
||
Add(glyph); | ||
} | ||
} | ||
|
||
if constexpr (IsUTF32CharType<UTFCharType>) | ||
{ | ||
for (const auto glyph : utf) | ||
Add(static_cast<uint32_t>(glyph)); | ||
} | ||
} | ||
|
||
template <typename UTFCharType> | ||
requires IsUTFCharType<UTFCharType> | ||
void AddText(const std::basic_string<UTFCharType> &utf) | ||
{ | ||
AddText(std::basic_string_view<UTFCharType>(utf)); | ||
} | ||
|
||
template <typename UTFCharType, size_t UTFSize> | ||
requires IsUTFCharType<UTFCharType> | ||
void AddText(const UTFCharType (&utf)[UTFSize]) | ||
{ | ||
AddText(std::basic_string_view<UTFCharType>(utf, UTFSize - 1)); | ||
} | ||
|
||
template <typename UTFCharType> | ||
requires IsUTFCharType<UTFCharType> | ||
void AddText(const UTFCharType *utf, const size_t length) | ||
{ | ||
AddText(std::basic_string_view<UTFCharType>(utf, length)); | ||
} | ||
|
||
void AddText(const std::filesystem::path& path) | ||
{ | ||
AddText(path.native()); | ||
} | ||
|
||
template <typename UTFStorageType, typename UTFCharType, bool CaseSensitive> | ||
requires IsUTFCharType<UTFCharType> && IsAnyOfTypes<UTFStorageType, std::basic_string<UTFCharType>, std::basic_string_view<UTFCharType>> | ||
void AddText(const StringWrapper<UTFStorageType, UTFCharType, CaseSensitive>& utf) | ||
{ | ||
AddText(utf.native()); | ||
} | ||
|
||
private: | ||
void Initialize() | ||
{ | ||
// Basic Latin (ASCII) + Latin-1 Supplement | ||
AddRange({0x0020, 0x00FF}); | ||
|
||
// Invalid Unicode Character | ||
Add(0xFFFD); | ||
} | ||
|
||
std::bitset<CodepointMax + 1> glyphsInUse; | ||
bool newGlyphsAdded = false; | ||
|
||
mutable std::mutex dataMutex; | ||
}; | ||
|
||
} |
Oops, something went wrong.