Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
Enum.hpp
1/*
2** Copyright 2007-2023 RTE
3** Authors: Antares_Simulator Team
4**
5** This file is part of Antares_Simulator.
6**
7** Antares_Simulator is free software: you can redistribute it and/or modify
8** it under the terms of the Mozilla Public Licence 2.0 as published by
9** the Mozilla Foundation, either version 2 of the License, or
10** (at your option) any later version.
11**
12** There are special exceptions to the terms and conditions of the
13** license as they are applied to this software. View the full text of
14** the exceptions in file COPYING.txt in the directory of this software
15** distribution
16**
17** Antares_Simulator is distributed in the hope that it will be useful,
18** but WITHOUT ANY WARRANTY; without even the implied warranty of
19** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20** Mozilla Public Licence 2.0 for more details.
21**
22** You should have received a copy of the Mozilla Public Licence 2.0
23** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
24**
25** SPDX-License-Identifier: MPL-2.0
26*/
27#ifndef ANTARES_DATA_ENUM_HPP
28#define ANTARES_DATA_ENUM_HPP
29
30#include <initializer_list>
31#include <list>
32#include <string>
33#include <type_traits>
34
35namespace Antares
36{
37namespace Data
38{
39namespace Enum
40{
41template<typename E, typename = typename std::enable_if<std::is_enum<E>::value>::type>
42const std::initializer_list<std::string>& getNames();
43
44template<typename E, typename = typename std::enable_if<std::is_enum<E>::value>::type>
45std::string toString(const E& value);
46
47template<typename E, typename = typename std::enable_if<std::is_enum<E>::value>::type>
48E fromString(const std::string& name);
49
50template<typename E, typename = typename std::enable_if<std::is_enum<E>::value>::type>
51std::list<E> enumList();
52
53} // namespace Enum
54
55template<typename E>
56inline typename std::enable_if<std::is_enum<E>::value, std::ostream&>::type operator<<(
57 std::ostream& stream,
58 const E& value)
59{
60 stream << Data::Enum::toString(value);
61 return stream;
62}
63
64} // namespace Data
65
66} // namespace Antares
67
68#include <antares/antares/Enum.hxx>
69
70#endif // ANTARES_DATA_ENUM_HPP