Git Product home page Git Product logo

yaml-to-struct's Introduction

yaml-to-struct

An example of data parsing to C struct from YAML file

Scope

This code present a way for parsing data, from a YAML format configuration file, to a C data structure, using libyaml.

Use

As an example we use a configuration file which describes a 2D thin-wire coil. The coil is made from circular loops, each with 4 attributes (radius,x and y position and current flow direction). Also there are 2 global attributes for the coil (current and frequency). The executable nees one argument which denotes the number of the circular loops (yaml mappings) which are going to be parsed in the structure. After a succesfull parsing the parsed data from the structure are printed in the stdout.

Reallocation

Since the number of the mappings inside the sequence of the config.yaml file are not previously known, the data structure is dynamicaly allocated using the user's defined argument of the mappings which are going to be parsed. If the user denoted number of mappings is not the same with the number of the mappings in the config file then:

  • If the are more mappings in the config.yaml the parsing stops and a warning message is printed in the stdout.

  • If there are less mappings the parsing stops and the dynamic memory allocated arrays are reallocated to the lenght of the existing and parsed mappings. Also a warning message is printed in the stdout.

In the two previous cases the parsing is considered succesfull.

Additional Information

yaml-to-struct's People

Contributors

smavros avatar

Watchers

 avatar  avatar

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.