Copyright | (c) 2010-2013 Vincent Hanquez <vincent@snarc.org> |
---|---|
License | BSD-style |
Stability | experimental |
Portability | unknown |
Safe Haskell | None |
Language | Haskell98 |
Data.ASN1.Parse
Contents
Description
A monadic parser combinator for a stream of ASN.1 items.
Synopsis
- data ParseASN1 a
- runParseASN1State :: ParseASN1 a -> [ASN1] -> Either String (a, [ASN1])
- runParseASN1 :: ParseASN1 a -> [ASN1] -> Either String a
- throwParseError :: String -> ParseASN1 a
- onNextContainer :: ASN1ConstructionType -> ParseASN1 a -> ParseASN1 a
- onNextContainerMaybe :: ASN1ConstructionType -> ParseASN1 a -> ParseASN1 (Maybe a)
- getNextContainer :: ASN1ConstructionType -> ParseASN1 [ASN1]
- getNextContainerMaybe :: ASN1ConstructionType -> ParseASN1 (Maybe [ASN1])
- getNext :: ParseASN1 ASN1
- getNextMaybe :: (ASN1 -> Maybe a) -> ParseASN1 (Maybe a)
- hasNext :: ParseASN1 Bool
- getObject :: ASN1Object a => ParseASN1 a
- getMany :: ParseASN1 a -> ParseASN1 [a]
Documentation
Type representing a parser combinator for a stream of ASN.1 items.
Run ParseASN1
runParseASN1State :: ParseASN1 a -> [ASN1] -> Either String (a, [ASN1]) Source #
Run the given parse monad over the given list of ASN.1 items. Returns the result and a list of the ASN.1 items remaining in the stream (if successful).
runParseASN1 :: ParseASN1 a -> [ASN1] -> Either String a Source #
Run the given parse monad over the given list of ASN.1 items and returns the result (if successful).
If ASN.1 items remain in the stream after doing so, returns an error.
Combinators
onNextContainer :: ASN1ConstructionType -> ParseASN1 a -> ParseASN1 a Source #
Run the parse monad over the elements of the next container of specified type. Throws an error if there is no next container of the specified type.
onNextContainerMaybe :: ASN1ConstructionType -> ParseASN1 a -> ParseASN1 (Maybe a) Source #
As for onNextContainer
, except that it does not throw an error if there
is no next container of the specified type.
getNextContainer :: ASN1ConstructionType -> ParseASN1 [ASN1] Source #
Get the next container of the specified type and return a list of all its ASN.1 elements. Throws a parse error if there is no next container of the specified type.
getNextContainerMaybe :: ASN1ConstructionType -> ParseASN1 (Maybe [ASN1]) Source #
As for getNextContainer
, except that it does not throw an error if there
is no next container of the specified type.
getNextMaybe :: (ASN1 -> Maybe a) -> ParseASN1 (Maybe a) Source #
Applies the given function to the next ASN.1 item in a stream of ASN.1 items, if there is one.
getObject :: ASN1Object a => ParseASN1 a Source #
Get the object from the next ASN.1 item in a stream of ASN.1 items. Throws a parse error if the object cannot be obtained from the item.