From: Oliver F. <o.b...@sw...> - 2021-08-15 08:53:03
|
Hi David, did you have a look at the available libraries for C and C++ listed at https://yaml.org/? Oliver Am 13.08.21 um 23:22 schrieb David Todd: > Apologies in advance: couldn't see a way to reply to prior thread on > the Sourceforge mailing list site so I'm repeating here. > > In 2011 (!), @wuttke and @simonov exchanged email about simpler ways > of loading yaml files. > > *Re: [Yaml-core] can I load entire node trees with the C library > libyaml ? <https://sourceforge.net/p/yaml/mailman/message/28445947/>* > From: Kirill Simonov <xi@re...> - 2011-11-24 15:23:20 > Hi Joachim, > > A high-level API for libyaml was planned, but never finished. I wasn't > able to design a satisfactory high-level API for C and it appeared to be > easier to expose the low-level interface and construct the document tree > in a scripting language. > > On 11/17/2011 03:37 AM, Joachim Wuttke<j.wuttke@...> wrote: > > So far, the best introduction to libyaml I found is > > the tutorial by Andrew Poelstra at > > http://wpsoftware.net/andrew/pages/libyaml.html <http://wpsoftware.net/andrew/pages/libyaml.html> > > It explains two ways of parsing a YAML file, by > > token or by event. Both are pretty low level; if > > I understand correctly, parsing by event is just > > a little less low level than parsing by token. > > > > In contrast, scripting languages offer a much > > simpler way of loading YAML files, basically: > > y = YAML.load( URL.open("http://yaml.org";) ) > > print y["Projects"]["C/C++ Libraries"][0] > > would yield "libyaml". > > > > Is it possible under C to load in a similar way > > an entire YAML file into a node tree? > > > > There is a yaml_node_type_t, is there any example > > how to use it? > > > > Thanks in advance, Joachim > > > > > I have a similar question, but in a C program context. I'm interested > in parsing YAML into a tree of key:value nodes for subsequent > retrieval and processing. > > For a prior project I used XML and libxml2 > (http://xmlsoft.org/example.html), and while XML has some advantages, > YAML is much more readable and (perhaps) easier to code. > > libxml2 has a number of tools, including an XML parser that yields a > tree and functions to retrieve values from the tree given a key and > starting node. > > Has anyone created such a package for YAML? If so, would you be > willing to share it? > > If not, would there be any value to others (apparently not, if no one > has done it). It seems that it might be relatively easy to generate > the tree from the existing run-parse-tree-suite.c code (though I'm > sufficiently new to YAML, and have a very limited use case, that > that's probably a naive statement). > > Thanks for any help you can offer. > > David > > > > > > _______________________________________________ > Yaml-core mailing list > Yam...@li... > https://lists.sourceforge.net/lists/listinfo/yaml-core -- N Oliver B. Fischer A Schönhauser Allee 64, 10437 Berlin, Deutschland/Germany P +49 30 44793251 M +49 178 7903538 E o.b...@sw... S oliver.b.fischer J oli...@ja... X http://xing.to/obf |