{-# LINE 1 "Z/Data/Text/UTF8Rewind.hsc" #-}
{-|
Module      : Z.Data.Text.UTF8Rewind
Description : Errno provided by libuv
Copyright   : (c) Winterland, 2017-2018
License     : BSD
Maintainer  : drkoster@qq.com
Stability   : experimental
Portability : non-portable

INTERNAL MODULE, provides utf8rewind constants

-}

module Z.Data.Text.UTF8Rewind where

import Data.Bits
import Foreign.C.Types
import GHC.Generics



-- | Locale for case mapping.
newtype Locale = Locale CSize deriving (Show, Eq, Ord, Generic)

pattern LocaleDefault              :: Locale
pattern LocaleDefault               = Locale (0)
{-# LINE 27 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern LocaleLithuanian           :: Locale
pattern LocaleLithuanian            = Locale (1)
{-# LINE 29 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern LocaleTurkishAndAzeriLatin :: Locale
pattern LocaleTurkishAndAzeriLatin  = Locale (2)
{-# LINE 31 "Z/Data/Text/UTF8Rewind.hsc" #-}

-- | Get environment locale
foreign import ccall unsafe "utf8envlocale" envLocale :: IO Locale

{-|
These are the Unicode Normalization Forms:

@
Form                         | Description
---------------------------- | ---------------------------------------------
Normalization Form D (NFD)   | Canonical decomposition
Normalization Form C (NFC)   | Canonical decomposition, followed by canonical composition
Normalization Form KD (NFKD) | Compatibility decomposition
Normalization Form KC (NFKC) | Compatibility decomposition, followed by canonical composition
@ 
-}
data NormalizeMode = NFC | NFKC | NFD | NFKD deriving (Show, Eq, Ord, Generic)

normalizeModeToFlag :: NormalizeMode -> CSize
normalizeModeToFlag NFC  = 1
{-# LINE 51 "Z/Data/Text/UTF8Rewind.hsc" #-}
normalizeModeToFlag NFKC = 1 + 4
{-# LINE 52 "Z/Data/Text/UTF8Rewind.hsc" #-}
normalizeModeToFlag NFD  = 2
{-# LINE 53 "Z/Data/Text/UTF8Rewind.hsc" #-}
normalizeModeToFlag NFKD = 2 + 4
{-# LINE 54 "Z/Data/Text/UTF8Rewind.hsc" #-}

data NormalizationResult = NormalizedYes | NormalizedMaybe | NormalizedNo deriving (Show, Eq, Ord, Generic)

toNormalizationResult :: Int -> NormalizationResult
toNormalizationResult 0 = NormalizedYes
{-# LINE 59 "Z/Data/Text/UTF8Rewind.hsc" #-}
toNormalizationResult 1 = NormalizedMaybe
{-# LINE 60 "Z/Data/Text/UTF8Rewind.hsc" #-}
toNormalizationResult 2 = NormalizedNo
{-# LINE 61 "Z/Data/Text/UTF8Rewind.hsc" #-}


-- | Unicode categories.
--
-- See 'Z.Data.Text.Base.isCategory', you can combine categories with bitwise or.
newtype Category = Category CSize deriving (Show, Eq, Ord, Generic)
                                    deriving newtype (Bits, FiniteBits)

pattern CategoryLetterUppercase       :: Category
pattern CategoryLetterLowercase       :: Category
pattern CategoryLetterTitlecase       :: Category
pattern CategoryLetterOther           :: Category
pattern CategoryLetter                :: Category
pattern CategoryCaseMapped            :: Category
pattern CategoryLetterUppercase        = Category (1)
{-# LINE 76 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryLetterLowercase        = Category (2)
{-# LINE 77 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryLetterTitlecase        = Category (4)
{-# LINE 78 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryLetterOther            = Category (16)
{-# LINE 79 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryLetter                 = Category (31)
{-# LINE 80 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryCaseMapped             = Category (7)
{-# LINE 81 "Z/Data/Text/UTF8Rewind.hsc" #-}

pattern CategoryMarkNonSpacing        :: Category
pattern CategoryMarkSpacing           :: Category
pattern CategoryMarkEnclosing         :: Category
pattern CategoryMark                  :: Category
pattern CategoryMarkNonSpacing         = Category (32)
{-# LINE 87 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryMarkSpacing            = Category (64)
{-# LINE 88 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryMarkEnclosing          = Category (128)
{-# LINE 89 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryMark                   = Category (224)
{-# LINE 90 "Z/Data/Text/UTF8Rewind.hsc" #-}

pattern CategoryNumberDecimal         :: Category
pattern CategoryNumberLetter          :: Category
pattern CategoryNumberOther           :: Category
pattern CategoryNumber                :: Category
pattern CategoryNumberDecimal          = Category (256)
{-# LINE 96 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryNumberLetter           = Category (512)
{-# LINE 97 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryNumberOther            = Category (1024)
{-# LINE 98 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryNumber                 = Category (1792)
{-# LINE 99 "Z/Data/Text/UTF8Rewind.hsc" #-}

pattern CategoryPunctuationConnector  :: Category
pattern CategoryPunctuationDash       :: Category
pattern CategoryPunctuationOpen       :: Category
pattern CategoryPunctuationClose      :: Category
pattern CategoryPunctuationInitial    :: Category
pattern CategoryPunctuationFinal      :: Category
pattern CategoryPunctuationOther      :: Category
pattern CategoryPunctuation           :: Category
pattern CategoryPunctuationConnector   = Category (2048)
{-# LINE 109 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryPunctuationDash        = Category (4096)
{-# LINE 110 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryPunctuationOpen        = Category (8192)
{-# LINE 111 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryPunctuationClose       = Category (16384)
{-# LINE 112 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryPunctuationInitial     = Category (32768)
{-# LINE 113 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryPunctuationFinal       = Category (65536)
{-# LINE 114 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryPunctuationOther       = Category (131072)
{-# LINE 115 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryPunctuation            = Category (260096)
{-# LINE 116 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategorySymbolMath            :: Category
pattern CategorySymbolCurrency        :: Category
pattern CategorySymbolModifier        :: Category
pattern CategorySymbolOther           :: Category
pattern CategorySymbol                :: Category
pattern CategorySymbolMath             = Category (262144)
{-# LINE 122 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategorySymbolCurrency         = Category (524288)
{-# LINE 123 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategorySymbolModifier         = Category (1048576)
{-# LINE 124 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategorySymbolOther            = Category (2097152)
{-# LINE 125 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategorySymbol                 = Category (3932160)
{-# LINE 126 "Z/Data/Text/UTF8Rewind.hsc" #-}

pattern CategorySeparatorSpace        :: Category
pattern CategorySeparatorLine         :: Category
pattern CategorySeparatorParagraph    :: Category
pattern CategorySeparator             :: Category
pattern CategoryControl               :: Category
pattern CategoryFormat                :: Category
pattern CategorySurrogate             :: Category
pattern CategoryPrivateUse            :: Category
pattern CategoryUnassigned            :: Category
pattern CategoryCompatibility         :: Category
pattern CategoryIgnoreGraphemeCluster :: Category
pattern CategoryIscntrl               :: Category
pattern CategorySeparatorSpace         = Category (4194304)
{-# LINE 140 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategorySeparatorLine          = Category (8388608)
{-# LINE 141 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategorySeparatorParagraph     = Category (16777216)
{-# LINE 142 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategorySeparator              = Category (29360128)
{-# LINE 143 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryControl                = Category (33554432)
{-# LINE 144 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryFormat                 = Category (67108864)
{-# LINE 145 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategorySurrogate              = Category (134217728)
{-# LINE 146 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryPrivateUse             = Category (268435456)
{-# LINE 147 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryUnassigned             = Category (536870912)
{-# LINE 148 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryCompatibility          = Category (1073741824)
{-# LINE 149 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIgnoreGraphemeCluster  = Category (2147483648)
{-# LINE 150 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIscntrl                = Category (1107296256)
{-# LINE 151 "Z/Data/Text/UTF8Rewind.hsc" #-}

pattern CategoryIsprint               :: Category
pattern CategoryIsspace               :: Category
pattern CategoryIsblank               :: Category
pattern CategoryIsgraph               :: Category
pattern CategoryIspunct               :: Category
pattern CategoryIsalnum               :: Category
pattern CategoryIsalpha               :: Category
pattern CategoryIsupper               :: Category
pattern CategoryIslower               :: Category
pattern CategoryIsdigit               :: Category
pattern CategoryIsxdigit              :: Category
pattern CategoryIsprint                = Category (1107296031)
{-# LINE 164 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIsspace                = Category (1077936128)
{-# LINE 165 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIsblank                = Category (1346371584)
{-# LINE 166 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIsgraph                = Category (1077935903)
{-# LINE 167 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIspunct                = Category (1077934080)
{-# LINE 168 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIsalnum                = Category (1073743647)
{-# LINE 169 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIsalpha                = Category (1073741855)
{-# LINE 170 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIsupper                = Category (1073741825)
{-# LINE 171 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIslower                = Category (1073741826)
{-# LINE 172 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIsdigit                = Category (1073743616)
{-# LINE 173 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIsxdigit               = Category (1342179072)
{-# LINE 174 "Z/Data/Text/UTF8Rewind.hsc" #-}