Re: Using C with libyaml
Ingy dot Net <[email protected]>
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <CAHJtQJ7oXz4pB+6=K5FW2yDiFJd3kDS67_w=3_XyBbLg9k31og@mail.gmail.com> |
On Mon, Sep 16, 2013 at 12:03 PM, Bob Henz <[email protected]> wrote: > Hi all, > > I have been looking into using libyaml (the C library) for some > configuration files on a project I'm working on. First, let me say, it is a > very impressive bit of parsing code and I really appreciate what is already > in libyaml. > > That said, after digging into what is provided for a C interface in > libyaml (we're developing our app in C for various reasons) and thinking > about what I needed to do to use this library I came up with some "helper" > functions I think would be a good addition to the API for us users of the > library who don't have the luxury of using python or some other high level > language to interface to it. > > Here is an example list of the functions I have implemented or at least > partially implemented... > > yaml_node_t *yaml_document_find_node(yaml_document_t *doc, yaml_node_t > *parent, yaml_node_t *current, const char *name); > bool yaml_document_get_value_as_boolean(yaml_document_t *doc, yaml_node_t > *node); > const char *yaml_document_get_value_as_string(yaml_document_t *doc, > yaml_node_t *node); > size_t yaml_document_get_value_as_integer_array(yaml_document_t *doc, > yaml_node_t *node, size_t max_size, int *array); > size_t yaml_document_get_value_as_integer(yaml_document_t *doc, > yaml_node_t *node, int *value); > > An example of usage could be something like... > > .p file looks like... > > window: > startup: > origin: [14, 128] > size: [1024, 300] > maximize: true > > Then you could grab parameters like this... > > int count; > int origin[2]; > > ... > > root = yaml_document_get_root_node(&doc); > > count = yaml_document_get_value_as_integer_array(&doc, > yaml_document_find_node(&doc, > yaml_document_find_node(&doc, > yaml_document_find_node(&doc, root, > NULL, "window"), > NULL, "startup"), > NULL, "origin"), > 2, origin); > ... > > So now for my questions: > 1) Has someone already implemented/started this on the trunk? As far as I > could tell such functions are not implemented in the repo, but I very well > may have missed it. > 2) Are the owner(s) of libyaml interested in taking such functions into > the repo? If yes, then I will put more effort into making the interface > complete and documented. > > Hi Bob, Can you fork https://github.com/yaml and submit a pull request on a branch? Thanks, Ingy Thanks, > Bob > > > > ------------------------------------------------------------------------------ > LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99! > 1,500+ hours of tutorials including VisualStudio 2012, Windows 8, > SharePoint > 2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack > includes > Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13. > http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk > _______________________________________________ > Yaml-core mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/yaml-core > > ------------------------------------------------------------------------------ LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99! 1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint 2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/22/13. http://pubads.g.doubleclick.net/gampad/clk?id=64545871&iu=/4140/ostg.clktrk _______________________________________________ Yaml-core mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/yaml-core