Maintainer | Bas van Dijk <v.dijk.bas@gmail.com> |
---|
Lifts functions and types from Foreign.C.String
to regional pointers.
- type RegionalCString r = RegionalPtr CChar r
- type RegionalCStringLen r = (RegionalPtr CChar r, Int)
- peekCString :: (ParentOf pr cr, MonadIO cr) => RegionalCString pr -> cr String
- peekCStringLen :: (ParentOf pr cr, MonadIO cr) => RegionalCStringLen pr -> cr String
- newCString :: MonadCatchIO pr => String -> RegionT s pr (RegionalCString (RegionT s pr))
- newCStringLen :: MonadCatchIO pr => String -> RegionT s pr (RegionalCStringLen (RegionT s pr))
- withCString :: MonadCatchIO pr => String -> (forall s. RegionalCString (RegionT s pr) -> RegionT s pr α) -> pr α
- withCStringLen :: MonadCatchIO pr => String -> (forall s. RegionalCStringLen (RegionT s pr) -> RegionT s pr α) -> pr α
- charIsRepresentable :: MonadIO m => Char -> m Bool
- castCharToCChar :: Char -> CChar
- castCCharToChar :: CChar -> Char
- peekCAString :: (ParentOf pr cr, MonadIO cr) => RegionalCString pr -> cr String
- peekCAStringLen :: (ParentOf pr cr, MonadIO cr) => RegionalCStringLen pr -> cr String
- newCAString :: MonadCatchIO pr => String -> RegionT s pr (RegionalCString (RegionT s pr))
- newCAStringLen :: MonadCatchIO pr => String -> RegionT s pr (RegionalCStringLen (RegionT s pr))
- withCAString :: MonadCatchIO pr => String -> (forall s. RegionalCString (RegionT s pr) -> RegionT s pr α) -> pr α
- withCAStringLen :: MonadCatchIO pr => String -> (forall s. RegionalCStringLen (RegionT s pr) -> RegionT s pr α) -> pr α
- type RegionalCWString r = RegionalPtr CWchar r
- type RegionalCWStringLen r = (RegionalPtr CWchar r, Int)
- peekCWString :: (ParentOf pr cr, MonadIO cr) => RegionalCWString pr -> cr String
- peekCWStringLen :: (ParentOf pr cr, MonadIO cr) => RegionalCWStringLen pr -> cr String
- newCWString :: MonadCatchIO pr => String -> RegionT s pr (RegionalCWString (RegionT s pr))
- newCWStringLen :: MonadCatchIO pr => String -> RegionT s pr (RegionalCWStringLen (RegionT s pr))
- withCWString :: MonadCatchIO pr => String -> (forall s. RegionalCWString (RegionT s pr) -> RegionT s pr α) -> pr α
- withCWStringLen :: MonadCatchIO pr => String -> (forall s. RegionalCWStringLen (RegionT s pr) -> RegionT s pr α) -> pr α
Regional C Strings
type RegionalCString r = RegionalPtr CChar rSource
Handy type synonym for a regional pointer to an array of C characters terminated by a NUL.
This should provide a safer replacement for Foreign.C.String.
.
CString
type RegionalCStringLen r = (RegionalPtr CChar r, Int)Source
Handy type synonym for a regional pointer to an array of C characters which is paired with the length of the array instead of terminated by a NUL. (Thus allowing NUL characters in the middle of the string)
This should provide a safer replacement for Foreign.C.String.
.
CStringLen
Using a locale-dependent encoding
peekCString :: (ParentOf pr cr, MonadIO cr) => RegionalCString pr -> cr StringSource
Marshal a NUL terminated C string into a Haskell string.
Wraps: Foreign.C.String.
peekCString
peekCStringLen :: (ParentOf pr cr, MonadIO cr) => RegionalCStringLen pr -> cr StringSource
Marshal a C string with explicit length into a Haskell string.
Wraps: Foreign.C.String.
.
peekCStringLen
newCString :: MonadCatchIO pr => String -> RegionT s pr (RegionalCString (RegionT s pr))Source
Marshal a Haskell string into a NUL terminated C string.
The Haskell string may not contain any NUL characters
Wraps: Foreign.C.String.
.
newCString
newCStringLen :: MonadCatchIO pr => String -> RegionT s pr (RegionalCStringLen (RegionT s pr))Source
Marshal a Haskell string into a C string (ie, character array) with explicit length information.
Wraps: Foreign.C.String.
.
newCStringLen
withCString :: MonadCatchIO pr => String -> (forall s. RegionalCString (RegionT s pr) -> RegionT s pr α) -> pr αSource
Marshal a Haskell string into a NUL terminated C string using temporary storage.
- the Haskell string may not contain any NUL characters
- the memory is freed when the subcomputation terminates (either normally or via an exception).
Wraps: Foreign.C.String.
.
withCString
withCStringLen :: MonadCatchIO pr => String -> (forall s. RegionalCStringLen (RegionT s pr) -> RegionT s pr α) -> pr αSource
Marshal a Haskell string into a C string (ie, character array) in temporary storage, with explicit length information.
- the memory is freed when the subcomputation terminates (either normally or via an exception).
Wraps: Foreign.C.String.
.
withCStringLen
charIsRepresentable :: MonadIO m => Char -> m BoolSource
Generalizes Foreign.C.String.
to any
charIsRepresentable
MonadIO
.
Using 8-bit characters
castCharToCChar :: Char -> CChar
Convert a Haskell character to a C character. This function is only safe on the first 256 characters.
castCCharToChar :: CChar -> Char
Convert a C byte, representing a Latin-1 character, to the corresponding Haskell character.
peekCAString :: (ParentOf pr cr, MonadIO cr) => RegionalCString pr -> cr StringSource
Marshal a NUL terminated C string into a Haskell string.
Wraps: Foreign.C.String.
.
peekCAString
peekCAStringLen :: (ParentOf pr cr, MonadIO cr) => RegionalCStringLen pr -> cr StringSource
Marshal a C string with explicit length into a Haskell string.
Wraps: Foreign.C.String.
.
peekCAStringLen
newCAString :: MonadCatchIO pr => String -> RegionT s pr (RegionalCString (RegionT s pr))Source
Marshal a Haskell string into a NUL terminated C string.
The Haskell string may not contain any NUL characters
Wraps: Foreign.C.String.
.
newCAString
newCAStringLen :: MonadCatchIO pr => String -> RegionT s pr (RegionalCStringLen (RegionT s pr))Source
Marshal a Haskell string into a C string (ie, character array) with explicit length information.
Wraps: Foreign.C.String.
.
newCAStringLen
withCAString :: MonadCatchIO pr => String -> (forall s. RegionalCString (RegionT s pr) -> RegionT s pr α) -> pr αSource
Marshal a Haskell string into a NUL terminated C string using temporary storage.
- the Haskell string may not contain any NUL characters
- the memory is freed when the subcomputation terminates (either normally or via an exception).
Wraps: Foreign.C.String.
.
withCAString
withCAStringLen :: MonadCatchIO pr => String -> (forall s. RegionalCStringLen (RegionT s pr) -> RegionT s pr α) -> pr αSource
Marshal a Haskell string into a C string (ie, character array) in temporary storage, with explicit length information.
- the memory is freed when the subcomputation terminates (either normally or via an exception).
Wraps: Foreign.C.String.
.
withCAStringLen
C wide strings
type RegionalCWString r = RegionalPtr CWchar rSource
Handy type synonym for a regional pointer to an array of C wide characters terminated by a NUL.
This should provide a safer replacement for Foreign.C.String.
.
CWString
type RegionalCWStringLen r = (RegionalPtr CWchar r, Int)Source
Handy type synonym for a regional pointer to an array of C wide characters which is paired with the length of the array instead of terminated by a NUL. (Thus allowing NUL characters in the middle of the string)
This should provide a safer replacement for Foreign.C.String.
.
CWStringLen
peekCWString :: (ParentOf pr cr, MonadIO cr) => RegionalCWString pr -> cr StringSource
Marshal a NUL terminated C wide string into a Haskell string.
Wraps: Foreign.C.String.
.
peekCWString
peekCWStringLen :: (ParentOf pr cr, MonadIO cr) => RegionalCWStringLen pr -> cr StringSource
Marshal a C wide string with explicit length into a Haskell string.
Wraps: Foreign.C.String.
.
peekCWStringLen
newCWString :: MonadCatchIO pr => String -> RegionT s pr (RegionalCWString (RegionT s pr))Source
Marshal a Haskell string into a NUL terminated C wide string.
The Haskell string may not contain any NUL characters.
Wraps: Foreign.C.String.
.
newCWString
newCWStringLen :: MonadCatchIO pr => String -> RegionT s pr (RegionalCWStringLen (RegionT s pr))Source
Marshal a Haskell string into a C wide string (ie, wide character array) with explicit length information.
Wraps: Foreign.C.String.
.
newCWStringLen
withCWString :: MonadCatchIO pr => String -> (forall s. RegionalCWString (RegionT s pr) -> RegionT s pr α) -> pr αSource
Marshal a Haskell string into a NUL terminated C wide string using temporary storage.
- the Haskell string may not contain any NUL characters
- the memory is freed when the subcomputation terminates (either normally or via an exception).
Wraps: Foreign.C.String.
.
withCWString
withCWStringLen :: MonadCatchIO pr => String -> (forall s. RegionalCWStringLen (RegionT s pr) -> RegionT s pr α) -> pr αSource
Marshal a Haskell string into a NUL terminated C wide string using temporary storage.
- the Haskell string may not contain any NUL characters.
- the memory is freed when the subcomputation terminates (either normally or via an exception).
Wraps: Foreign.C.String.
.
withCWStringLen