[go: up one dir, main page]

File: check.cpp

package info (click to toggle)
toml11 3.7.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,120 kB
  • sloc: cpp: 17,500; sh: 6; makefile: 4
file content (41 lines) | stat: -rw-r--r-- 795 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "toml.hpp"
#include <iostream>
#include <iomanip>

int main(int argc, char **argv)
{
    if(argc != 3)
    {
        std::cerr << "usage: ./check [filename] [valid|invalid]" << std::endl;
        return 1;
    }

    const std::string file_kind(argv[2]);

    try
    {
        const auto data = toml::parse(argv[1]);
        std::cout << std::setprecision(16) << std::setw(80) << data;
        if(file_kind == "valid")
        {
            return 0;
        }
        else
        {
            return 1;
        }
    }
    catch(const toml::syntax_error& err)
    {
        std::cout << "what(): " << err.what() << std::endl;
        if(file_kind == "invalid")
        {
            return 0;
        }
        else
        {
            return 1;
        }
    }
    return 127;
}