-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Parser and Printer for LDAP text data stream
--   
--   This package contains Parser and Printer for LDAP text data stream
--   like OpenLDAP backup LDIF.
@package text-ldap
@version 0.1.1.11


module Text.LDAP.Data

-- | Type of dn attribute
type Attribute = (AttrType, AttrValue)

-- | Type of dn attribute type
data AttrType
AttrType :: ByteString -> AttrType
AttrOid :: (List1 ByteString) -> AttrType

-- | Construct OID attribute type
attrOid :: ByteString -> [ByteString] -> AttrType

-- | Type of dn attribute value
newtype AttrValue
AttrValue :: ByteString -> AttrValue

-- | Type of dn component (rdn)
data Component
S :: Attribute -> Component
L :: (List1 Attribute) -> Component

-- | Construct dn component (rdn)
component :: Attribute -> [Attribute] -> Component

-- | Type of dn
type DN = List1 Component

-- | Construct dn
consDN :: Component -> [Component] -> DN

-- | Deconstruct dn
unconsDN :: DN -> (Component, [Component])

-- | Not empty list type
type List1 = NonEmpty

-- | Type of LDIF attribute value
data LdifAttrValue
LAttrValRaw :: ByteString -> LdifAttrValue
LAttrValBase64 :: ByteString -> LdifAttrValue

-- | Type of dn, simple list type
type DN' = [Component']

-- | From <a>DN</a> to <a>DN'</a>
toDN' :: DN -> DN'

-- | Type of dn component (rdn), simple list type
type Component' = [Attribute]

-- | Type to express value bound
type Bound a = (a, a)

-- | Bound value to express exact value
exact :: a -> Bound a

-- | Element list in value bounds
boundsElems :: Enum a => [(a, a)] -> [a]

-- | Test element in value bounds.
inBounds :: (Enum a, Ord a) => a -> [(a, a)] -> Bool
infix 4 `inBounds`

-- | Test element using ordered set.
elem' :: Ord a => a -> [a] -> Bool
infix 4 `elem'`

-- | Test not element using ordered set.
notElem' :: Ord a => a -> [a] -> Bool
infix 4 `notElem'`

-- | Test element in value bounds using ordered set.
inSBounds :: (Enum a, Ord a) => a -> [(a, a)] -> Bool
infix 4 `inSBounds`

-- | Word8 value of Char
ordW8 :: Char -> Word8

-- | Quotation word8 code of dn
quotation :: Word8

-- | Secial word8 codes of dn
specialChars :: [Word8]

-- | Char bounds LDIF safe string
ldifSafeBounds :: [Bound Char]

-- | Char bounds LDIF safe string first char
ldifSafeInitBounds :: [Bound Char]
instance GHC.Show.Show Text.LDAP.Data.LdifAttrValue
instance GHC.Classes.Ord Text.LDAP.Data.LdifAttrValue
instance GHC.Classes.Eq Text.LDAP.Data.LdifAttrValue
instance GHC.Show.Show Text.LDAP.Data.Component
instance GHC.Classes.Ord Text.LDAP.Data.Component
instance GHC.Classes.Eq Text.LDAP.Data.Component
instance GHC.Show.Show Text.LDAP.Data.AttrValue
instance GHC.Classes.Ord Text.LDAP.Data.AttrValue
instance GHC.Classes.Eq Text.LDAP.Data.AttrValue
instance GHC.Show.Show Text.LDAP.Data.AttrType
instance GHC.Classes.Ord Text.LDAP.Data.AttrType
instance GHC.Classes.Eq Text.LDAP.Data.AttrType


module Text.LDAP.Parser

-- | Parser context type for LDAP data stream
type LdapParser = LdapParser

-- | Run <a>LdapParser</a> context.
runLdapParser :: Parser a -> ByteString -> Either String a

-- | Parser of DN string.
dn :: LdapParser DN

-- | Parser of RDN string.
component :: LdapParser Component

-- | Parser of attribute pair string in RDN.
attribute :: LdapParser Attribute

-- | Parser of LDIF DN line.
ldifDN :: LdapParser DN

-- | Parser of LDIF attribute pair line. Use with
--   <a>ldifDecodeAttrValue</a> or <a>ldifAttrValue</a> parser, like
--   <tt>ldifAttr ldifDecodeAttrValue</tt>.
ldifAttr :: LdapParser a -> LdapParser (AttrType, a)

-- | OpenLDAP data-stream block parser. Use with <a>ldifDecodeAttrValue</a>
--   or <a>ldifAttrValue</a> parser, like <tt>openLdapEntry
--   ldifDecodeAttrValue</tt>.
openLdapEntry :: LdapParser a -> LdapParser (DN, [(AttrType, a)])

-- | OpenLDAP data-stream block list parser. Use with
--   <a>ldifDecodeAttrValue</a> or <a>ldifAttrValue</a> parser, like
--   <tt>openLdapData ldifDecodeAttrValue</tt>.
openLdapData :: LdapParser a -> LdapParser [(DN, [(AttrType, a)])]

-- | Chunking lines of OpenLDAP data stream.
openLdapDataBlocks :: [ByteString] -> [[ByteString]]

-- | Parser of LDIF attribute value. This parser decodes base64 string.
--   Available combinator parser to pass <a>ldifAttr</a> or
--   <a>openLdapEntry</a>, etc ...
ldifDecodeAttrValue :: LdapParser AttrValue

-- | Parser of LDIF attribute value which may be base64 encoded. Available
--   combinator parser to pass <a>ldifAttr</a> or <a>openLdapEntry</a>, etc
--   ...
ldifAttrValue :: Parser LdifAttrValue

-- | Decode value string of attribute pair after stream parsing.
ldifDecodeB64Value :: LdifAttrValue -> Either String AttrValue


module Text.LDAP.Printer

-- | <a>LdapPrinter</a> <tt>a</tt> print type <tt>a</tt> into context
type LdapPrinter a = a -> LdapPutM ()

-- | Run <a>LdapPrinter</a>
runLdapPrinter :: LdapPrinter a -> a -> ByteString

-- | Printer context type for LDAP data stream
type LdapPutM = Writer (DList ByteString)

-- | Printer of DN string.
dn :: LdapPrinter DN

-- | Printer of RDN string.
component :: LdapPrinter Component

-- | Printer of attribute pair string in RDN.
attribute :: LdapPrinter Attribute

-- | Printer of LDIF DN line.
ldifDN :: LdapPrinter DN

-- | Printer of LDIF attribute pair line. Use with <a>ldifAttrValue</a> or
--   <a>ldifEncodeAttrValue</a> printer, like <tt>ldifAttr
--   ldifEncodeAttrValue</tt>.
ldifAttr :: LdapPrinter v -> LdapPrinter (AttrType, v)

-- | Printer of LDIF attribute value already encoded. Available printer
--   combinator to pass <a>ldifAttr</a> or <a>openLdapEntry</a>, etc ...
ldifAttrValue :: LdapPrinter LdifAttrValue

-- | Printer of LDIF attribute value with encode not safe string. Available
--   printer combinator to pass <a>ldifAttr</a> or <a>openLdapEntry</a>,
--   etc ...
ldifEncodeAttrValue :: LdapPrinter AttrValue

-- | OpenLDAP data-stream block printer. Use with <a>ldifAttrValue</a> or
--   <a>ldifEncodeAttrValue</a> printer, like <tt>openLdapEntry
--   ldifEncodeAttrValue</tt>.
openLdapEntry :: LdapPrinter v -> LdapPrinter (DN, [(AttrType, v)])

-- | OpenLDAP data-stream block list printer. Use with <a>ldifAttrValue</a>
--   or <a>ldifEncodeAttrValue</a> printer, like <tt>openLdapData
--   ldifEncodeAttrValue</tt>.
openLdapData :: LdapPrinter v -> LdapPrinter [(DN, [(AttrType, v)])]
