Giter Club home page Giter Club logo

Comments (4)

dmendel avatar dmendel commented on July 30, 2024

http://github.com/dmendel/bindata/wiki/FAQ#how-do-i-model-this-complex-nested-format

There are examples of implementing tagged structures here:

The difficulty working out how to implement these types of nestings is understanding that tag belongs outside the structure, not inside. Think table-oriented rather than object-oriented.

Your implementation should look something like:

class CONSTANT_Methodref_info < BinData::Record
  endian  :big
  uint16  :class_index
  uint16  :name_and_type_index
end

class CONSTANT_NameAndType_info < BinData::Record
  endian  :big
  uint16  :name_index
  uint16  :descriptor_index
end

class Cp_info < BinData::Record
  endian  :big
  uint8   :tag
  choice  :payload, :selection => :tag do
    constant_methodref_info 10
    constant_name_and_type_info 12
  end
end

from bindata.

korun avatar korun commented on July 30, 2024

@dmendel, missed do keyword in choice line?

from bindata.

dmendel avatar dmendel commented on July 30, 2024

@korun fixed. Thanks.

from bindata.

hakanai avatar hakanai commented on July 30, 2024

Yeah, I was already aware of that workaround but was hoping there might be a way which didn't require me to change from the documented structure.

I guess I can always extend and add different type of choice, if need be.

from bindata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.