Coverage Report

Created: 2022-08-24 06:32

/src/solidity/libsolidity/interface/ReadFile.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
  This file is part of solidity.
3
4
  solidity is free software: you can redistribute it and/or modify
5
  it under the terms of the GNU General Public License as published by
6
  the Free Software Foundation, either version 3 of the License, or
7
  (at your option) any later version.
8
9
  solidity is distributed in the hope that it will be useful,
10
  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
  GNU General Public License for more details.
13
14
  You should have received a copy of the GNU General Public License
15
  along with solidity.  If not, see <http://www.gnu.org/licenses/>.
16
*/
17
// SPDX-License-Identifier: GPL-3.0
18
19
#pragma once
20
21
#include <liblangutil/Exceptions.h>
22
23
#include <functional>
24
#include <string>
25
26
namespace solidity::frontend
27
{
28
29
class ReadCallback
30
{
31
public:
32
  /// Noncopyable.
33
  ReadCallback(ReadCallback const&) = delete;
34
  ReadCallback& operator=(ReadCallback const&) = delete;
35
36
  /// File reading or generic query result.
37
  struct Result
38
  {
39
    bool success;
40
    std::string responseOrErrorMessage;
41
  };
42
43
  enum class Kind
44
  {
45
    ReadFile,
46
    SMTQuery
47
  };
48
49
  static std::string kindString(Kind _kind)
50
0
  {
51
0
    switch (_kind)
52
0
    {
53
0
    case Kind::ReadFile:
54
0
      return "source";
55
0
    case Kind::SMTQuery:
56
0
      return "smt-query";
57
0
    default:
58
0
      solAssert(false, "");
59
0
    }
60
0
  }
61
62
  /// File reading or generic query callback.
63
  using Callback = std::function<Result(std::string const&, std::string const&)>;
64
};
65
66
}