{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) module GI.Poppler.Functions ( -- * Methods -- ** dateParse #method:dateParse# dateParse , -- ** getBackend #method:getBackend# getBackend , -- ** getVersion #method:getVersion# getVersion , ) where import Data.GI.Base.ShortPrelude import qualified Data.GI.Base.ShortPrelude as SP import qualified Data.GI.Base.Overloading as O import qualified Prelude as P import qualified Data.GI.Base.Attributes as GI.Attributes import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr import qualified Data.GI.Base.GError as B.GError import qualified Data.GI.Base.GVariant as B.GVariant import qualified Data.GI.Base.GValue as B.GValue import qualified Data.GI.Base.GParamSpec as B.GParamSpec import qualified Data.GI.Base.CallStack as B.CallStack import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import qualified Foreign.Ptr as FP import {-# SOURCE #-} qualified GI.Poppler.Enums as Poppler.Enums -- function poppler_get_version -- Args : [] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "poppler_get_version" poppler_get_version :: IO CString {- | Returns the version of poppler in use. This result is not to be freed. -} getVersion :: (B.CallStack.HasCallStack, MonadIO m) => m T.Text {- ^ __Returns:__ the version of poppler. -} getVersion = liftIO $ do result <- poppler_get_version checkUnexpectedReturnNULL "getVersion" result result' <- cstringToText result return result' -- function poppler_get_backend -- Args : [] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "Poppler", name = "Backend"})) -- throws : False -- Skip return : False foreign import ccall "poppler_get_backend" poppler_get_backend :: IO CUInt {- | Returns the backend compiled into the poppler library. -} getBackend :: (B.CallStack.HasCallStack, MonadIO m) => m Poppler.Enums.Backend {- ^ __Returns:__ The backend used by poppler -} getBackend = liftIO $ do result <- poppler_get_backend let result' = (toEnum . fromIntegral) result return result' -- function poppler_date_parse -- Args : [Arg {argCName = "date", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "string to parse", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "timet", argType = TBasicType TLong, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an uninitialized #time_t", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "poppler_date_parse" poppler_date_parse :: CString -> -- date : TBasicType TUTF8 CLong -> -- timet : TBasicType TLong IO CInt {- | Parses a PDF format date string and converts it to a @/time_t/@. Returns @/FALSE/@ if the parsing fails or the input string is not a valid PDF format date string /Since: 0.12/ -} dateParse :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@date@/: string to parse -} -> CLong {- ^ /@timet@/: an uninitialized @/time_t/@ -} -> m Bool {- ^ __Returns:__ @/TRUE/@, if /@timet@/ was set -} dateParse date timet = liftIO $ do date' <- textToCString date result <- poppler_date_parse date' timet let result' = (/= 0) result freeMem date' return result'