Copyright | (c) Mattias Jakobsson 2015 |
---|---|
License | GPL-3 |
Maintainer | mjakob422@gmail.com |
Stability | unstable |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
The grib_handle is the structure giving access to parsed grib values by keys.
Most of the documentation herein was copied from the official documentation of grib_api.
- newtype GribHandle = GribHandle (ForeignPtr GribHandle)
- gribHandleNewFromFile :: GribContext -> CFilePtr -> IO GribHandle
- gribHandleNewFromTemplate :: GribContext -> String -> IO GribHandle
- gribHandleNewFromSamples :: GribContext -> String -> IO GribHandle
- gribHandleClone :: GribHandle -> IO GribHandle
- gribWriteMessage :: GribHandle -> FilePath -> String -> IO ()
- withGribHandle :: GribHandle -> (Ptr GribHandle -> IO b) -> IO b
- gribGetMessage :: GribHandle -> IO (Message, Int)
- gribGetMessageCopy :: GribHandle -> Message -> Int -> IO (Message, Int)
- gribHandleNewFromMessage :: GribContext -> Message -> Int -> IO GribHandle
- gribHandleNewFromMessageCopy :: GribContext -> Message -> Int -> IO GribHandle
- gribHandleNewFromMultiMessage :: GribContext -> Message -> Int -> IO (GribHandle, Message, Int)
- newtype GribMultiHandle = GribMultiHandle (ForeignPtr GribMultiHandle)
- gribMultiHandleNew :: GribContext -> IO GribMultiHandle
- gribMultiHandleAppend :: GribHandle -> Int -> GribMultiHandle -> IO ()
- gribMultiHandleWrite :: GribMultiHandle -> CFilePtr -> IO ()
- withGribMultiHandle :: GribMultiHandle -> (Ptr GribMultiHandle -> IO b) -> IO b
- gribCountInFile :: GribContext -> CFilePtr -> IO Int
The GRIB Handle
newtype GribHandle Source
Grib handle, structure giving access to parsed grib values by keys.
gribHandleNewFromFile :: GribContext -> CFilePtr -> IO GribHandle Source
Create a handle from a file resource.
The file is read until a message is found. The message is then copied.
gribHandleNewFromTemplate :: GribContext -> String -> IO GribHandle Source
This function has been deprecated in GRIB API.
Create a handle from a read_only template resource.
The message is copied at the creation of the handle.
This operation may fail with:
NullPtrReturned
if the resource is invalid or a problem is encountered.
gribHandleNewFromSamples Source
:: GribContext | the context from which the handle will be created (NULL for default context) |
-> String | the resource name |
-> IO GribHandle |
Create a handle from a message contained in a samples directory.
The message is copied at the creation of the handle.
This operation may fail with:
NullPtrReturned
if the resource is invalid or a problem is encountered.
gribHandleClone :: GribHandle -> IO GribHandle Source
Clone an existing handle using the context of the original handle.
The message is copied and reparsed.
This operation may fail with:
NullPtrReturned
if the message is invalid or a problem is encountered.
gribWriteMessage :: GribHandle -> FilePath -> String -> IO () Source
Write a coded message to a file given its name and the C file mode string, in that order.
withGribHandle :: GribHandle -> (Ptr GribHandle -> IO b) -> IO b Source
Operations on raw messages
gribGetMessage :: GribHandle -> IO (Message, Int) Source
Getting the message attached to a handle.
:: GribHandle | the grib handle to which the buffer should be returned |
-> Message | the pointer to the data buffer to be filled |
-> Int | the size in number of bytes of the allocated empty message |
-> IO (Message, Int) | an IO action that will return the pointer to the data buffer and the number of bytes retrieved |
Getting a copy of the message attached to a handle.
This operation may fail with:
isGribException GribBufferTooSmall
if the allocated message is too small.
gribHandleNewFromMessage :: GribContext -> Message -> Int -> IO GribHandle Source
Create a handle from a user message in memory.
The message will not be freed at the end. The message will be copied as soon as a modification is needed.
This operation may fail with:
NullPtrReturned
if the message is invalid or a problem is encountered.
WARNING! This method does not handle a message of zero length gracefully.
gribHandleNewFromMessageCopy :: GribContext -> Message -> Int -> IO GribHandle Source
Create a handle from a user message.
The message is copied and will be freed with the handle.
This operation may fail with:
NullPtrReturned
if the message is invalid or a problem is encountered.
gribHandleNewFromMultiMessage :: GribContext -> Message -> Int -> IO (GribHandle, Message, Int) Source
Create a handle from a user message in memory.
The message will not be freed at the end. The message will be copied as soon as a modification is needed. This function works also with multi field messages.
The GRIB Multi Field Handle
newtype GribMultiHandle Source
Grib multi field handle, structure used to build multi fields messages.
gribMultiHandleNew :: GribContext -> IO GribMultiHandle Source
Create an empty multi field handle.
This operation may fail with:
NullPtrReturned
if a problem is encountered.
gribMultiHandleAppend :: GribHandle -> Int -> GribMultiHandle -> IO () Source
Append the sections starting with start_section of the message pointed by h at the end of the multi field handle mh.
gribMultiHandleWrite :: GribMultiHandle -> CFilePtr -> IO () Source
Write a multi field handle in a file.
withGribMultiHandle :: GribMultiHandle -> (Ptr GribMultiHandle -> IO b) -> IO b Source
Utilities
gribCountInFile :: GribContext -> CFilePtr -> IO Int Source
Counts the messages contained in a file resource.