π κ°μ
**Rune Caster**λ STLμμ μκ°μ λ°μ Modern C++ ν
μ€νΈ μ²λ¦¬ νλ μμν¬μ
λλ€. μ§κ΄μ μ΄κ³ κ³ μ±λ₯μ λ€κ΅μ΄ ν
μ€νΈ μ²λ¦¬ λ° μΈμ΄ κ° λ³ν κΈ°λ₯μ μ 곡ν©λλ€.
π μ£Όμ νΉμ§
- π€ Rune μμ€ν
: μ λμ½λ λ¬Έμμ λ¬Έμμ΄μ λ€λ£¨λ STL μ€νμΌ μ»¨ν
μ΄λ
- β‘ Zero-cost Abstractions: λ°νμ μ€λ²ν€λ μλ κ³ μ±λ₯ μ²λ¦¬
- π λ€κ΅μ΄ μ§μ: νκ΅μ΄, μμ΄, μΌλ³Έμ΄ λ± 34κ° μΈμ΄ Unicode ν
μ€νΈ μ²λ¦¬
- π― STL νΈν: μ΅μν 컨ν
μ΄λ-μκ³ λ¦¬μ¦-μ΄ν°λ μ΄ν° ν¨ν΄
- π§ C++20: Modern C++ κΈ°λ₯μ μ κ·Ή νμ©ν νμ
μμ ν API
π ν΅μ¬ μ»΄ν¬λνΈ
1. Rune ν΄λμ€
κ°λ³ Unicode λ¬Έμλ₯Ό νννλ κΈ°λ³Έ λ¨μμ
λλ€.
auto korean = U'κ°'_rune;
auto english = Rune::from_utf8("A");
auto japanese = Rune(U'γ');
static_assert(korean.is_hangul());
static_assert(english.is_ascii());
static_assert(japanese.is_hiragana());
2. RuneString ν΄λμ€
Unicode λ¬Έμμ΄μ λ€λ£¨λ STL νΈν 컨ν
μ΄λμ
λλ€.
auto text = RuneString::from_utf8("μλ
νμΈμ Hello γγγ«γ‘γ―");
auto korean_part = text.substr(0, 5);
auto has_greeting = text.contains(U'μ'_rune);
for (const auto& rune : text) {
std::cout << "μΈμ΄: " << static_cast<int>(rune.language()) << std::endl;
}
3. Spell μμ€ν
ν
μ€νΈ λ³ν μκ³ λ¦¬μ¦μ μ 곡ν©λλ€.
auto normalized = text
| spell::normalize_whitespace()
| spell::lowercase()
| spell::unicode_nfc();
auto complex_spell = spell::compose(
spell::normalize_whitespace(true, true),
spell::lowercase()
);
Simple and unified spell system for text transformation.
4. Caster νμ΄νλΌμΈ
ν¨μν μ€νμΌμ ν
μ€νΈ μ²λ¦¬ νμ΄νλΌμΈμ μ 곡ν©λλ€.
.result();
auto result2 = input_text
auto unicode_nfc()
Apply Unicode NFC normalization.
auto normalize_whitespace(bool collapse_multiple=true, bool trim_edges=true)
Normalize whitespace (collapse multiple spaces, optionally trim)
auto lowercase()
Convert text to lowercase.
constexpr auto make_caster(T &&data) noexcept -> caster< std::decay_t< T > >
Factory function to create a caster (C++20 template argument deduction)
π οΈ λΉ λ₯Έ μμ
1. κΈ°λ³Έ μ€μ
2. κ°λ¨ν μμ
int main() {
auto cleaned = text
.result();
std::cout << "μλ³Έ: " << text.to_utf8() << std::endl;
std::cout << "μ μ : " << cleaned.to_utf8() << std::endl;
std::cout << "μ£Όμ μΈμ΄: " << static_cast<int>(text.primary_language()) << std::endl;
return 0;
}
static RuneString from_utf8(std::string_view utf8_text)
Create a RuneString from UTF-8 text.
auto trim()
Trim leading and trailing whitespace.
π― κ³ κΈ κΈ°λ₯
constexpr μ§μ
μ»΄νμΌ νμμ λ¬Έμ μμ±μ νμΈν μ μμ΅λλ€.
constexpr auto korean_char = U'κ°'_rune;
static_assert(korean_char.is_hangul());
@ Korean
νκ΅μ΄ (ko-KR) - Korean
C++20 Concepts
νμ
μμ μ±μ 보μ₯ν©λλ€.
template<spell_for<RuneString> Spell>
}
A sequence container for Rune objects (API Design Document: RuneString)
Unified spell object for text transformation.
Ranges μ§μ
STL rangesμ μλ²½νκ² νΈνλ©λλ€.
auto vowels = text
| std::views::filter([](
const Rune& r) {
return r.
is_vowel(); })
| std::ranges::to<std::vector>();
Represents a single textual unit with Unicode and linguistic properties.
constexpr bool is_vowel() const noexcept
Check if this rune represents a vowel.
π μμΈ λ¬Έμ
κ° ν΄λμ€μ ν¨μμ μμΈν μ¬μ©λ²μ λ€μ μΉμ
μ μ°Έμ‘°νμΈμ:
π§ λΉλ μꡬμ¬ν
- C++ νμ€: C++20 μ΄μ
- μ»΄νμΌλ¬: GCC 10+, Clang 10+, MSVC 19.29+
- CMake: 3.20 μ΄μ
π λΌμ΄μ μ€
MIT License
**Rune Caster**λ‘ νλμ μ΄κ³ μμ ν λ€κ΅μ΄ ν
μ€νΈ μ²λ¦¬λ₯Ό μμν΄λ³΄μΈμ! π