aboutsummaryrefslogtreecommitdiff
path: root/libbutl/manifest-parser.ixx
blob: bc5246cfceb6f279eac245be7114a3508fcfde60 (plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// file      : libbutl/manifest-parser.ixx -*- C++ -*-
// license   : MIT; see accompanying LICENSE file

namespace butl
{

  inline auto manifest_parser::
  get (const char* what) -> xchar
  {
    xchar c (base::get (ebuf_));

    if (invalid (c))
      throw manifest_parsing (name_,
                              c.line, c.column,
                              std::string ("invalid ") + what + ": " + ebuf_);
    return c;
  }

  inline void manifest_parser::
  get (const xchar& peeked)
  {
    base::get (peeked);
  }

  inline auto manifest_parser::
  peek (const char* what) -> xchar
  {
    xchar c (base::peek (ebuf_));

    if (invalid (c))
      throw manifest_parsing (name_,
                              c.line, c.column,
                              std::string ("invalid ") + what + ": " + ebuf_);
    return c;
  }

  inline manifest_name_value manifest_parser::
  next ()
  {
    manifest_name_value r;
    do { parse_next (r); } while (filter_ && !filter_ (r));
    return r;
  }

  inline optional<std::vector<manifest_name_value>>
  try_parse_manifest (manifest_parser& p)
  {
    std::vector<manifest_name_value> r;
    return try_parse_manifest (p, r)
           ? optional<std::vector<manifest_name_value>> (move (r))
           : nullopt;
  }

  inline std::vector<manifest_name_value>
  parse_manifest (manifest_parser& p)
  {
    std::vector<manifest_name_value> r;
    parse_manifest (p, r);
    return r;
  }
}