Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure and Nim type wrappers for inq and some inq_dim functions #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

hendrikgit
Copy link
Contributor

I want to split the functions for dimensions, variables and attributes into their own modules. That is what the new structure is about. I think it is similar to nimhdf5 but I keep some functions in the main file, at least for now.

The variables and attributes will come in a later commit or PR.

My plan at the moment is to write what I called "Nim type wrappers" for the procs that bind to the C functions, at least some of them, but otherwise keep them the same. Then implement a higher level API on top of that.

I did add a few procs though for added convenience that differ from the C bindings (don't exist there) but are not really the high level API I want to eventually write either. At the moment I put them after a comment in the code.

# Additional convenience procs

proc inqDimnames*(ncid: NCId): seq[string] =
  for dimid in 0 ..< inqNdims(ncid):
    result.add inqDimname(ncid, dimid.DimId)

proc inqDimlen*(ncid: NCId, name: string): int =
  inqDimlen(ncid, inqDimid(ncid, name))

Maybe you have a suggestion on where to put those or how to separate them? Or maybe I should just not do that and come up with a good high level API (which I want to do anyway) and skip these half measures?

I'm not clear on when it is better to use tuple and when object. Specifically in this PR in this proc.

proc inq*(ncid: NCid): tuple[ndims, nvars, natts, unlimdimid: int] =
  var ndims, nvars, natts, unlimdimid: cint
  handleError inq(ncid.cint, ndims, nvars, natts, unlimdimid)
  (ndims.int, nvars.int, natts.int, unlimdimid.int)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant