parse/value: add tribool support
This commit is contained in:
parent
680e67eb77
commit
8b9ac3d599
@ -3,11 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Copyright 2017-2018 Danny Robson <danny@nerdcruft.net>
|
||||
* Copyright 2017-2018, 2022 Danny Robson <danny@nerdcruft.net>
|
||||
*/
|
||||
|
||||
#include "value.hpp"
|
||||
|
||||
#include "../bool.hpp"
|
||||
#include "../cast.hpp"
|
||||
|
||||
#include "preprocessor.hpp"
|
||||
@ -184,3 +185,12 @@ cruft::parse::value<bool> (cruft::view<char const*> &str)
|
||||
|
||||
throw std::invalid_argument ("invalid boolean string");
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <>
|
||||
cruft::tribool
|
||||
cruft::parse::value<cruft::tribool> (cruft::view< char const*> &str)
|
||||
{
|
||||
return tribool (parse::value<bool> (str));
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Copyright 2017-2018 Danny Robson <danny@nerdcruft.net>
|
||||
* Copyright 2017-2018, 2022 Danny Robson <danny@nerdcruft.net>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@ -11,6 +11,7 @@
|
||||
#include "../view.hpp"
|
||||
#include "enum.hpp"
|
||||
|
||||
|
||||
namespace cruft::parse {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/// Extracts an instance of a native type T from the string [first, last).
|
||||
|
Loading…
Reference in New Issue
Block a user