{-# 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 Foreign.C.Types
import GHC.Generics



-- | Locale for case mapping.
type Locale = CSize

pattern LocaleDefault              :: Locale
pattern LocaleDefault               = 0
{-# LINE 26 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern LocaleLithuanian           :: Locale
pattern LocaleLithuanian            = 1
{-# LINE 28 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern LocaleTurkishAndAzeriLatin :: Locale
pattern LocaleTurkishAndAzeriLatin  = 2
{-# LINE 30 "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 50 "Z/Data/Text/UTF8Rewind.hsc" #-}
normalizeModeToFlag NFKC = 1 + 4
{-# LINE 51 "Z/Data/Text/UTF8Rewind.hsc" #-}
normalizeModeToFlag NFD  = 2
{-# LINE 52 "Z/Data/Text/UTF8Rewind.hsc" #-}
normalizeModeToFlag NFKD = 2 + 4
{-# LINE 53 "Z/Data/Text/UTF8Rewind.hsc" #-}

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

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


-- | Unicode categories.
--
-- See 'Z.Data.Text.Base.isCategory', you can combine categories with bitwise or.
type Category = CSize

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

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

pattern CategoryNumberDecimal         :: Category
pattern CategoryNumberLetter          :: Category
pattern CategoryNumberOther           :: Category
pattern CategoryNumber                :: Category
pattern CategoryNumberDecimal          = 256
{-# LINE 94 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryNumberLetter           = 512
{-# LINE 95 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryNumberOther            = 1024
{-# LINE 96 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryNumber                 = 1792
{-# LINE 97 "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   = 2048
{-# LINE 107 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryPunctuationDash        = 4096
{-# LINE 108 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryPunctuationOpen        = 8192
{-# LINE 109 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryPunctuationClose       = 16384
{-# LINE 110 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryPunctuationInitial     = 32768
{-# LINE 111 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryPunctuationFinal       = 65536
{-# LINE 112 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryPunctuationOther       = 131072
{-# LINE 113 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryPunctuation            = 260096
{-# LINE 114 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategorySymbolMath            :: Category
pattern CategorySymbolCurrency        :: Category
pattern CategorySymbolModifier        :: Category
pattern CategorySymbolOther           :: Category
pattern CategorySymbol                :: Category
pattern CategorySymbolMath             = 262144
{-# LINE 120 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategorySymbolCurrency         = 524288
{-# LINE 121 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategorySymbolModifier         = 1048576
{-# LINE 122 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategorySymbolOther            = 2097152
{-# LINE 123 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategorySymbol                 = 3932160
{-# LINE 124 "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         = 4194304
{-# LINE 138 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategorySeparatorLine          = 8388608
{-# LINE 139 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategorySeparatorParagraph     = 16777216
{-# LINE 140 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategorySeparator              = 29360128
{-# LINE 141 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryControl                = 33554432
{-# LINE 142 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryFormat                 = 67108864
{-# LINE 143 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategorySurrogate              = 134217728
{-# LINE 144 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryPrivateUse             = 268435456
{-# LINE 145 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryUnassigned             = 536870912
{-# LINE 146 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryCompatibility          = 1073741824
{-# LINE 147 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIgnoreGraphemeCluster  = 2147483648
{-# LINE 148 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIscntrl                = 1107296256
{-# LINE 149 "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                = 1107296031
{-# LINE 162 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIsspace                = 1077936128
{-# LINE 163 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIsblank                = 1346371584
{-# LINE 164 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIsgraph                = 1077935903
{-# LINE 165 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIspunct                = 1077934080
{-# LINE 166 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIsalnum                = 1073743647
{-# LINE 167 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIsalpha                = 1073741855
{-# LINE 168 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIsupper                = 1073741825
{-# LINE 169 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIslower                = 1073741826
{-# LINE 170 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIsdigit                = 1073743616
{-# LINE 171 "Z/Data/Text/UTF8Rewind.hsc" #-}
pattern CategoryIsxdigit               = 1342179072
{-# LINE 172 "Z/Data/Text/UTF8Rewind.hsc" #-}