Using C with libyaml
Bob Henz <[email protected]>
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <CAKfMajP8j9WkwyYVOx=L-qBb5=Atm2FiyQ1gy5YivBQfr7oRVg@mail.gmail.com> |
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.
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