Function parse

Synopsis

#include <include/cpptoml.h>

std::shared_ptr< table > parse()

Description

Parses the stream this parser was created on until EOF.

Exceptions

parse_exception - if there are errors in parsing

Source

Lines 1892-1919 in include/cpptoml.h.

std::shared_ptr<table> parse()
{
    std::shared_ptr<table> root = make_table();
    table* curr_table = root.get();
    while (detail::getline(input_, line_))
    {
        line_number_++;
        auto it = line_.begin();
        auto end = line_.end();
        consume_whitespace(it, end);
        if (it == end || *it == '#')
            continue;
        if (*it == '[')
        {
            curr_table = root.get();
            parse_table(it, end, curr_table);
        }
        else
        {
            parse_key_value(it, end, curr_table);
            consume_whitespace(it, end);
            eol_or_comment(it, end);
        }
    }
    return root;
}





Add Discussion as Guest

Log in