Git Product home page Git Product logo

ogdl's People

Contributors

rveen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ogdl's Issues

Enhancement: Path parser should support UTF-8

The path parser uses the same byte parser used for OGDL text streams, but OGDL paths should be allowed to be UTF-8 strings. A new parser is needed, or an adaptation of the current one (ReadChar and UnreadChar functions are needed, and those require multibyte temporal storage).

wishlist: Support an encoding/* style "decode into a struct / encode a struct" api

I wish I had an OGDL library that looked like everything else under encoding/*.

Yes, it'll lose information, and can't round-trip all OGDL data. But it's way more convenient to use than needing to run "queries" on a thing on every access, or writing a function that runs all those queries and returns a struct with the results..

Think of it as ogdl.Graph being the moral equivalent of decoding JSON to interface{}. Used when you know you need to round-trip, but otherwise painful.

It could use struct tags in a way vary similar to encoding/xml, and allow the user to put ogdl paths in them. Something like

network
  eth0
    ip   192.168.0.10
    mask 255.255.255.0
    gw   192.168.0.1

hostname crispin
nameserver 8.8.8.8
nameserver 8.8.4.4
type Config struct {
    Hostname string
    // decoding to a map type knows that the subgraph should be >=2
    // levels deep, first level becomes the keys
    Network map[string]*Interface
    // decoding to a slice value appends every matching subgraph
    Nameserver []net.IP
}

type Interface struct {
    IP      net.IP `ogdl:"ip"`
    Netmask net.IP `ogdl:"mask"`
    Gateway net.IP `ogdl:"gw"`
}

And naturally each field would use encoding/text to actually parse the string. And if the value isn't a string but a subgraph, you could see if the field has a UnmarshalOGDL / MarshalOGDL method, just like JSON; the input to such unmarshal would be a Graph, not []byte.

Even more ideally, this would tie into a streaming parser and avoid holding the graph in memory all at once. And the above UnmarshalOGDL could tie into EventHandler or Parser somehow, too.

Proposal: Let OGDL become an elegant but complete data representation of all Go data types.

I'm quite excited about the potential that OGDL has. It might be able to become an elegant but complete data representation of all Go data types. (XML is ugly but JSON lacks enough ability, YAML is also too heavy).

The only format that is able to represent complete Go types is encoding/gob, but it is a binary format. Go just lacks a pretty text format to do it.

  1. OGDL can now support reference cycle, right? So pointer or interface is not a problem.
  2. It just need a standard way to represent map, array and struct, as extension to current OGDL standard.
  3. Then it can implements methods like Marshal, marshalIndent and Unmarshal as in encoding/json.

If you are interested in my proposal, I'd like to contribute to its implementation.

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.