Leosac  0.8.0
Open Source Access Control
Auth.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-2016 Leosac
3 
4  This file is part of Leosac.
5 
6  Leosac is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Affero General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Leosac is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Affero General Public License for more details.
15 
16  You should have received a copy of the GNU Affero General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "Auth.hpp"
21 
22 zmqpp::message &operator<<(zmqpp::message &msg, const Leosac::Auth::SourceType &t)
23 {
24  static_assert(std::is_same<std::underlying_type<Leosac::Auth::SourceType>::type,
25  uint8_t>::value,
26  "Bad underlying type for enum");
27  msg << static_cast<uint8_t>(t);
28  return msg;
29 }
30 
31 zmqpp::message &operator>>(zmqpp::message &msg, Leosac::Auth::SourceType &t)
32 {
33  static_assert(std::is_same<std::underlying_type<Leosac::Auth::SourceType>::type,
34  uint8_t>::value,
35  "Bad underlying type for enum");
36  uint8_t tmp;
37  msg >> tmp;
38  t = static_cast<Leosac::Auth::SourceType>(tmp);
39  return msg;
40 }
41 
42 zmqpp::message &operator<<(zmqpp::message &msg, const Leosac::Auth::AccessStatus &st)
43 {
44  static_assert(
45  std::is_same<std::underlying_type<Leosac::Auth::AccessStatus>::type,
46  uint8_t>::value,
47  "Bad underlying type for enum");
48  msg << static_cast<uint8_t>(st);
49  return msg;
50 }
51 
52 zmqpp::message &operator>>(zmqpp::message &msg, Leosac::Auth::AccessStatus &st)
53 {
54  static_assert(
55  std::is_same<std::underlying_type<Leosac::Auth::AccessStatus>::type,
56  uint8_t>::value,
57  "Bad underlying type for enum");
58  uint8_t tmp;
59  msg >> tmp;
60  st = static_cast<Leosac::Auth::AccessStatus>(tmp);
61  return msg;
62 }
operator>>
zmqpp::message & operator>>(zmqpp::message &msg, Leosac::Auth::SourceType &t)
Definition: Auth.cpp:31
Auth.hpp
Leosac::Auth::AccessStatus
AccessStatus
Definition: Auth.hpp:54
operator<<
zmqpp::message & operator<<(zmqpp::message &msg, const Leosac::Auth::SourceType &t)
Definition: Auth.cpp:22
Leosac::Auth::SourceType
SourceType
Definition: Auth.hpp:29