{
  "name": "ref-struct",
  "description": "Create ABI-compliant \"struct\" instances on top of Buffers",
  "keywords": [
    "struct",
    "ref",
    "abi",
    "c",
    "c++",
    "ffi"
  ],
  "version": "0.0.6",
  "author": {
    "name": "Nathan Rajlich",
    "email": "nathan@tootallnate.net",
    "url": "http://tootallnate.net"
  },
  "repository": {
    "type": "git",
    "url": "git://github.com/TooTallNate/ref-struct.git"
  },
  "main": "./lib/struct.js",
  "scripts": {
    "test": "node-gyp rebuild --directory test && mocha -gc --reporter spec"
  },
  "dependencies": {
    "debug": "~1.0.1",
    "ref": "~0.3.2"
  },
  "devDependencies": {
    "bindings": "~1.2.0",
    "nan": "~1.1.0",
    "mocha": "*",
    "ref-array": "~0.0.3"
  },
  "readme": "ref-struct\n==========\n### Create ABI-compliant \"[struct][]\" instances on top of Buffers\n[![Build Status](https://secure.travis-ci.org/TooTallNate/ref-struct.svg)](https://travis-ci.org/TooTallNate/ref-struct)\n[![Build Status](https://ci.appveyor.com/api/projects/status/6v4h5v5kh9kmtke8)](https://ci.appveyor.com/project/TooTallNate/ref-struct)\n\n\nThis module offers a \"struct\" implementation on top of Node.js Buffers\nusing the ref \"type\" interface.\n\nInstallation\n------------\n\nInstall with `npm`:\n\n``` bash\n$ npm install ref-struct\n```\n\n\nExamples\n--------\n\nSay you wanted to emulate the `timeval` struct from the stdlib:\n\n``` c\nstruct timeval {\n  time_t       tv_sec;   /* seconds since Jan. 1, 1970 */\n  suseconds_t  tv_usec;  /* and microseconds */\n};\n```\n\n``` js\nvar ref = require('ref')\nvar StructType = require('ref-struct')\n\n// define the time types\nvar time_t = ref.types.long\nvar suseconds_t = ref.types.long\n\n// define the \"timeval\" struct type\nvar timeval = StructType({\n  tv_sec: time_t,\n  tv_usec: suseconds_t\n})\n\n// now we can create instances of it\nvar tv = new timeval\n```\n\n#### With `node-ffi`\n\nThis gets very powerful when combined with `node-ffi` to invoke C functions:\n\n``` js\nvar ffi = require('ffi')\n\nvar tv = new timeval\ngettimeofday(tv.ref(), null)\n```\n\n#### Progressive API\n\nYou can build up a Struct \"type\" incrementally (useful when interacting with a\nparser) using the `defineProperty()` function. But as soon as you _create_ an\ninstance of the struct type, then the struct type is finalized, and no more\nproperties may be added to it.\n\n``` js\nvar ref = require('ref')\nvar StructType = require('ref-struct')\n\nvar MyStruct = Struct()\nMyStruct.defineProperty('width', ref.types.int)\nMyStruct.defineProperty('height', ref.types.int)\n\nvar i = new MyStruct({ width: 5, height: 10 })\n\nMyStruct.defineProperty('weight', ref.types.int)\n// AssertionError: an instance of this Struct type has already been created, cannot add new \"fields\" anymore\n//      at Function.defineProperty (/Users/nrajlich/ref-struct/lib/struct.js:180:3)\n```\n\n\nLicense\n-------\n\n(The MIT License)\n\nCopyright (c) 2012 Nathan Rajlich &lt;nathan@tootallnate.net&gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n[struct]: http://wikipedia.org/wiki/Struct_(C_programming_language)\n",
  "readmeFilename": "README.md",
  "bugs": {
    "url": "https://github.com/TooTallNate/ref-struct/issues"
  },
  "_id": "ref-struct@0.0.6",
  "dist": {
    "shasum": "49721312f8d22d4f4dc7d3d1b1f872eb535dc8a7"
  },
  "_from": "ref-struct@*",
  "_resolved": "https://registry.npmjs.org/ref-struct/-/ref-struct-0.0.6.tgz"
}
