hgrib-0.1.0.0: Unofficial bindings for GRIB API

Copyright(c) Mattias Jakobsson 2015
LicenseGPL-3
Maintainermjakob422@gmail.com
Stabilityunstable
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Data.Grib.Raw.Handle

Contents

Description

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.

Synopsis

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

Arguments

:: 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.

Operations on raw messages

gribGetMessage :: GribHandle -> IO (Message, Int) Source

Getting the message attached to a handle.

gribGetMessageCopy Source

Arguments

:: 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.

Utilities

gribCountInFile :: GribContext -> CFilePtr -> IO Int Source

Counts the messages contained in a file resource.