-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial TINI parser implementation #5
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks mostly good! Memory management needs a couple fixes in places
…private for better encapsulation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally looks good to me, so I'll approve this :) There's a couple minor changes that could be made, but that's up to you.
The move assigment/constructor implementations also don't really utilize the move semantic to it's potential, but looks functionally correct. std::exchange is a pretty nice way to utilize the semantics a little better, the page has decent examples too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will approve it first.
Valgrind shows no leaks, static analysis from scan-build shows no issues, merging. |
Work done
This is the primary implementation of a parser to the TINI format, a format, which is somewhere between INI and TOML.
The basic premise of the format goes as follows:
You have context switches, which determine at which point in the tree you are inserting and how. Then you have insertions to those contexts via simple key-value insertion.
As an example
[a.b.c]
first checks if a map 'a' exists, if it doesn't, it will create it and repeat the process until all the maps have been created. This means the "context" of the parser points at map c, which is nested inside of b and a. Then any subsequent key-value pairs in the following lines will append to that context.So if we have
Maps a, b will be created and map b will contain the aforementioned two key value pairs.
TINI also has vectors. Vectors are denoted via two square brackets.
[[vector]]
A repetition of a vector with the same name denotes a new map appended to the vector's context. This can be seen in the servers example within the
main.cpp
file.This statment creates a vector of TiniNodes. TiniNodes are effectively an optional type of one of the following types:
Within the TiniNode class, they are tagged by an enum. Before TiniNodes are created at all, there's a validation loop, that runs on the input, which checks for errors in the configuration and gives detailed line by line analysis on where those errors are and what category they are.
The basic validation loop
Demonstration
Input:
Output:
Usage of TINI in code
I provided an example usage of TINI in the main.cpp file.