blob: a44e1bbd8608b85711b29e45e729e073239e168d (
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
|
// file : libbuild2/script/timeout.cxx -*- C++ -*-
// license : MIT; see accompanying LICENSE file
#include <libbuild2/script/timeout.hxx>
#include <chrono>
#include <libbuild2/diagnostics.hxx>
using namespace std;
namespace build2
{
optional<duration>
parse_timeout (const string& s, const char* what, const location& l)
{
if (optional<uint64_t> n = parse_number (s))
{
return *n != 0
? chrono::duration_cast<duration> (chrono::seconds (*n))
: optional<duration> ();
}
else
fail (l) << "invalid " << what << " '" << s << "'" << endf;
}
}
|