| 1 | // SPDX-License-Identifier: LGPL-2.1-or-later |
| 2 | // SPDX-FileCopyrightText: 2021-2022 Bartosz Golaszewski <[email protected]> |
| 3 | |
| 4 | #include <ostream> |
| 5 | #include <utility> |
| 6 | |
| 7 | #include "internal.hpp" |
| 8 | |
| 9 | namespace gpiod { |
| 10 | |
| 11 | void chip_info::impl::set_info_ptr(chip_info_ptr& new_info) |
| 12 | { |
| 13 | this->info = ::std::move(new_info); |
| 14 | } |
| 15 | |
| 16 | GPIOD_CXX_API chip_info::chip_info() |
| 17 | : _m_priv(new impl) |
| 18 | { |
| 19 | |
| 20 | } |
| 21 | |
| 22 | GPIOD_CXX_API chip_info::chip_info(const chip_info& other) |
| 23 | : _m_priv(other._m_priv) |
| 24 | { |
| 25 | |
| 26 | } |
| 27 | |
| 28 | GPIOD_CXX_API chip_info::chip_info(chip_info&& other) noexcept |
| 29 | : _m_priv(::std::move(other._m_priv)) |
| 30 | { |
| 31 | |
| 32 | } |
| 33 | |
| 34 | GPIOD_CXX_API chip_info::~chip_info() |
| 35 | { |
| 36 | |
| 37 | } |
| 38 | |
| 39 | GPIOD_CXX_API chip_info& chip_info::operator=(const chip_info& other) |
| 40 | { |
| 41 | this->_m_priv = other._m_priv; |
| 42 | |
| 43 | return *this; |
| 44 | } |
| 45 | |
| 46 | GPIOD_CXX_API chip_info& chip_info::operator=(chip_info&& other) noexcept |
| 47 | { |
| 48 | this->_m_priv = ::std::move(other._m_priv); |
| 49 | |
| 50 | return *this; |
| 51 | } |
| 52 | |
| 53 | GPIOD_CXX_API ::std::string chip_info::name() const noexcept |
| 54 | { |
| 55 | return ::gpiod_chip_info_get_name(this->_m_priv->info.get()); |
| 56 | } |
| 57 | |
| 58 | GPIOD_CXX_API ::std::string chip_info::label() const noexcept |
| 59 | { |
| 60 | return ::gpiod_chip_info_get_label(this->_m_priv->info.get()); |
| 61 | } |
| 62 | |
| 63 | GPIOD_CXX_API ::std::size_t chip_info::num_lines() const noexcept |
| 64 | { |
| 65 | return ::gpiod_chip_info_get_num_lines(this->_m_priv->info.get()); |
| 66 | } |
| 67 | |
| 68 | GPIOD_CXX_API ::std::ostream& operator<<(::std::ostream& out, const chip_info& info) |
| 69 | { |
| 70 | out << "gpiod::chip_info(name=\"" << info.name() << |
| 71 | "\", label=\"" << info.label() << |
| 72 | "\", num_lines=" << info.num_lines() << ")"; |
| 73 | |
| 74 | return out; |
| 75 | } |
| 76 | |
| 77 | } /* namespace gpiod */ |