mirror of
https://github.com/mii443/AzooKeyKanaKanjiConverter.git
synced 2025-12-03 02:58:27 +00:00
fix: expose if necessary
This commit is contained in:
@@ -18,7 +18,7 @@ package extension Sequence {
|
||||
}
|
||||
}
|
||||
|
||||
package extension Collection {
|
||||
public extension Collection {
|
||||
/// Returns a `Set` containing the elements of this sequence with transformed values.
|
||||
/// - Parameters:
|
||||
/// - transform: A closure that transforms each element of this sequence into a value that can be hashed.
|
||||
@@ -60,7 +60,7 @@ package extension Collection {
|
||||
}
|
||||
}
|
||||
|
||||
package extension MutableCollection {
|
||||
public extension MutableCollection {
|
||||
/// Calls the given closure with a pointer to the array's mutable contiguous storage.
|
||||
/// - Parameter
|
||||
/// - transform: A closure that takes a pointer to the array's mutable contiguous storage.
|
||||
@@ -71,7 +71,7 @@ package extension MutableCollection {
|
||||
}
|
||||
}
|
||||
|
||||
package extension Collection {
|
||||
public extension Collection {
|
||||
/// Returns a SubSequence containing the elements of this sequence up to the first element that does not satisfy the given predicate.
|
||||
/// - Parameters:
|
||||
/// - condition: A closure that takes an element of the sequence as its argument and returns a Boolean value indicating whether the element should be included.
|
||||
@@ -85,7 +85,7 @@ package extension Collection {
|
||||
}
|
||||
}
|
||||
|
||||
package extension Collection where Self.Element: Equatable {
|
||||
public extension Collection where Self.Element: Equatable {
|
||||
/// Returns a Bool value indicating whether the collection has the given prefix.
|
||||
/// - Parameters:
|
||||
/// - prefix: A collection to search for at the start of this collection.
|
||||
|
||||
@@ -6,26 +6,26 @@
|
||||
// Copyright © 2020 ensan. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
public import Foundation
|
||||
|
||||
package extension StringProtocol {
|
||||
extension StringProtocol {
|
||||
/// ローマ字と数字のみかどうか
|
||||
/// - note: 空文字列の場合`false`を返す。
|
||||
@usableFromInline
|
||||
var onlyRomanAlphabetOrNumber: Bool {
|
||||
@inlinable
|
||||
package var onlyRomanAlphabetOrNumber: Bool {
|
||||
!isEmpty && range(of: "[^a-zA-Z0-9]", options: .regularExpression) == nil
|
||||
}
|
||||
/// ローマ字のみかどうか
|
||||
/// - note: 空文字列の場合`false`を返す。
|
||||
@usableFromInline
|
||||
var onlyRomanAlphabet: Bool {
|
||||
@inlinable
|
||||
package var onlyRomanAlphabet: Bool {
|
||||
!isEmpty && range(of: "[^a-zA-Z]", options: .regularExpression) == nil
|
||||
}
|
||||
/// ローマ字を含むかどうか
|
||||
/// - note: 空文字列の場合`false`を返す。
|
||||
/// 以前は正規表現ベースで実装していたが、パフォーマンス上良くなかったので以下のような実装にしたところ40倍程度高速化した。
|
||||
@inlinable
|
||||
var containsRomanAlphabet: Bool {
|
||||
package var containsRomanAlphabet: Bool {
|
||||
for value in self.utf8 {
|
||||
if (UInt8(ascii: "a") <= value && value <= UInt8(ascii: "z")) || (UInt8(ascii: "A") <= value && value <= UInt8(ascii: "Z")) {
|
||||
return true
|
||||
@@ -35,21 +35,21 @@ package extension StringProtocol {
|
||||
}
|
||||
/// 英語として許容可能な文字のみで構成されているか。
|
||||
/// - note: 空文字列の場合`false`を返す。
|
||||
@usableFromInline
|
||||
var isEnglishSentence: Bool {
|
||||
@inlinable
|
||||
public var isEnglishSentence: Bool {
|
||||
!isEmpty && range(of: "[^0-9a-zA-Z\n !'_<>\\[\\]{}*@`\\^|~=\"#$%&\\+\\(\\),\\-\\./:;?’\\\\]", options: .regularExpression) == nil
|
||||
}
|
||||
|
||||
/// 仮名か
|
||||
@usableFromInline
|
||||
var isKana: Bool {
|
||||
package var isKana: Bool {
|
||||
!isEmpty && range(of: "[^ぁ-ゖァ-ヶ]", options: .regularExpression) == nil
|
||||
}
|
||||
|
||||
/// Returns a String value in which Hiraganas are all converted to Katakana.
|
||||
/// - Returns: A String value in which Hiraganas are all converted to Katakana.
|
||||
@usableFromInline
|
||||
func toKatakana() -> String {
|
||||
@inlinable
|
||||
public func toKatakana() -> String {
|
||||
// カタカナはutf16で常に2バイトなので、utf16単位で処理して良い
|
||||
let result = self.utf16.map { scalar -> UInt16 in
|
||||
if 0x3041 <= scalar && scalar <= 0x3096 {
|
||||
@@ -63,8 +63,8 @@ package extension StringProtocol {
|
||||
|
||||
/// Returns a String value in which Katakana are all converted to Hiragana.
|
||||
/// - Returns: A String value in which Katakana are all converted to Hiragana.
|
||||
@usableFromInline
|
||||
func toHiragana() -> String {
|
||||
@inlinable
|
||||
public func toHiragana() -> String {
|
||||
// ひらがなはutf16で常に2バイトなので、utf16単位で処理して良い
|
||||
let result = self.utf16.map { scalar -> UInt16 in
|
||||
if 0x30A1 <= scalar && scalar <= 0x30F6 {
|
||||
@@ -87,7 +87,7 @@ package extension StringProtocol {
|
||||
" -> \d
|
||||
*/
|
||||
// please use these letters in order to avoid user-inputting text crash
|
||||
func templateDataSpecificEscaped() -> String {
|
||||
package func templateDataSpecificEscaped() -> String {
|
||||
var result = self.replacingOccurrences(of: "\\", with: "\\b")
|
||||
result = result.replacingOccurrences(of: "\0", with: "\\0")
|
||||
result = result.replacingOccurrences(of: "\n", with: "\\n")
|
||||
@@ -98,7 +98,7 @@ package extension StringProtocol {
|
||||
return result
|
||||
}
|
||||
|
||||
func templateDataSpecificUnescaped() -> String {
|
||||
package func templateDataSpecificUnescaped() -> String {
|
||||
var result = self.replacingOccurrences(of: "\\d", with: "\"")
|
||||
result = result.replacingOccurrences(of: "\\s", with: " ")
|
||||
result = result.replacingOccurrences(of: "\\c", with: ",")
|
||||
|
||||
Reference in New Issue
Block a user