-- GENERATED by C->Haskell Compiler, version 0.13.13 (gtk2hs branch) "Bin IO", 27 May 2012 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "./Graphics/UI/Gtk/WebKit/DOM/Storage.chs" #-}
module Graphics.UI.Gtk.WebKit.DOM.Storage(
key,
getItem,
setItem,
removeItem,
clear,
getLength,
Storage,
castToStorage,
gTypeStorage,
StorageClass,
toStorage,
) where
import Prelude hiding (drop, error, print)
import Data.Typeable (Typeable)
import Foreign.Marshal (maybePeek, maybeWith)
import System.Glib.FFI (maybeNull, withForeignPtr, nullForeignPtr, Ptr, nullPtr, castPtr, Word, Int64, Word64, CChar(..), CInt(..), CUInt(..), CLong(..), CULong(..), CLLong(..), CULLong(..), CShort(..), CUShort(..), CFloat(..), CDouble(..), toBool, fromBool)
import System.Glib.UTFString (GlibString(..), readUTFString)
import Control.Applicative ((<$>))
import Control.Monad (void)
import Control.Monad.IO.Class (MonadIO(..))
import System.Glib.GError
import Graphics.UI.Gtk.WebKit.DOM.EventTargetClosures
import Graphics.UI.Gtk.WebKit.DOM.EventM
import Graphics.UI.Gtk.WebKit.Types
{-# LINE 29 "./Graphics/UI/Gtk/WebKit/DOM/Storage.chs" #-}
import Graphics.UI.Gtk.WebKit.DOM.Enums


key ::
    (MonadIO m, StorageClass self, GlibString string) =>
      self -> Word -> m (Maybe string)
key self index
  = liftIO
      ((propagateGError $
          \ errorPtr_ ->
            (\(Storage arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->webkit_dom_storage_key argPtr1 arg2 arg3) (toStorage self)
              (fromIntegral index)
              errorPtr_)
         >>=
         maybePeek readUTFString)
 
getItem ::
        (MonadIO m, StorageClass self, GlibString string) =>
          self -> string -> m (Maybe string)
getItem self key
  = liftIO
      ((propagateGError $
          \ errorPtr_ ->
            withUTFString key $
              \ keyPtr ->
                (\(Storage arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->webkit_dom_storage_get_item argPtr1 arg2 arg3) (toStorage self) keyPtr
              errorPtr_)
         >>=
         maybePeek readUTFString)
 
setItem ::
        (MonadIO m, StorageClass self, GlibString string) =>
          self -> string -> string -> m ()
setItem self key data'
  = liftIO
      (propagateGError $
         \ errorPtr_ ->
           withUTFString data' $
             \ dataPtr ->
               withUTFString key $
                 \ keyPtr ->
                   (\(Storage arg1) arg2 arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->webkit_dom_storage_set_item argPtr1 arg2 arg3 arg4) (toStorage self) keyPtr
                 dataPtr
             errorPtr_)

removeItem ::
           (MonadIO m, StorageClass self, GlibString string) =>
             self -> string -> m ()
removeItem self key
  = liftIO
      (propagateGError $
         \ errorPtr_ ->
           withUTFString key $
             \ keyPtr ->
               (\(Storage arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->webkit_dom_storage_remove_item argPtr1 arg2 arg3) (toStorage self) keyPtr
             errorPtr_)
 
clear :: (MonadIO m, StorageClass self) => self -> m ()
clear self
  = liftIO
      (propagateGError $
         \ errorPtr_ ->
           (\(Storage arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->webkit_dom_storage_clear argPtr1 arg2) (toStorage self) errorPtr_)
 
getLength :: (MonadIO m, StorageClass self) => self -> m Word
getLength self
  = liftIO
      (fromIntegral <$>
         (propagateGError $
            \ errorPtr_ ->
              (\(Storage arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->webkit_dom_storage_get_length argPtr1 arg2) (toStorage self)
                errorPtr_))

foreign import ccall safe "dist/build/Graphics/UI/Gtk/WebKit/DOM/Storage.h webkit_dom_storage_key"
  webkit_dom_storage_key :: ((Ptr Storage) -> (CULong -> ((Ptr (Ptr ())) -> (IO (Ptr CChar)))))

foreign import ccall safe "dist/build/Graphics/UI/Gtk/WebKit/DOM/Storage.h webkit_dom_storage_get_item"
  webkit_dom_storage_get_item :: ((Ptr Storage) -> ((Ptr CChar) -> ((Ptr (Ptr ())) -> (IO (Ptr CChar)))))

foreign import ccall safe "dist/build/Graphics/UI/Gtk/WebKit/DOM/Storage.h webkit_dom_storage_set_item"
  webkit_dom_storage_set_item :: ((Ptr Storage) -> ((Ptr CChar) -> ((Ptr CChar) -> ((Ptr (Ptr ())) -> (IO ())))))

foreign import ccall safe "dist/build/Graphics/UI/Gtk/WebKit/DOM/Storage.h webkit_dom_storage_remove_item"
  webkit_dom_storage_remove_item :: ((Ptr Storage) -> ((Ptr CChar) -> ((Ptr (Ptr ())) -> (IO ()))))

foreign import ccall safe "dist/build/Graphics/UI/Gtk/WebKit/DOM/Storage.h webkit_dom_storage_clear"
  webkit_dom_storage_clear :: ((Ptr Storage) -> ((Ptr (Ptr ())) -> (IO ())))

foreign import ccall safe "dist/build/Graphics/UI/Gtk/WebKit/DOM/Storage.h webkit_dom_storage_get_length"
  webkit_dom_storage_get_length :: ((Ptr Storage) -> ((Ptr (Ptr ())) -> (IO CULong)))