PLCnext API Documentation 25.0.2.69
Byte.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include <iosfwd>
9#include <cstddef>
10#include <fmt/format.h>
11#include <fmt/ostream.h>
12
13#ifndef ARP_INSIDE_ARP_BASE_CORE_ARP_H
14 #error Never include 'Byte.hpp' directly, just include 'Arp.hpp'
15#endif
16
17namespace Arp::Base::Core
18{
19
22
25
29constexpr Arp::Base::Core::byte operator""_b(unsigned long long int value)
30{
31 return static_cast<Arp::Base::Core::byte>(value);
32}
33
37constexpr Arp::Base::Core::byte operator""_B(unsigned long long int value)
38{
39 return static_cast<Arp::Base::Core::byte>(value);
40}
41
43
44// Helper class for promoting Arp::byte to a unique type due to formatting purpose
45struct Byte
46{
47 explicit Byte(byte value) : Value(value) {};
48 byte Value = 0_b;
49};
50
51// stream operators for Byte
52ARP_EXPORT std::ostream& operator<<(std::ostream& os, Arp::Base::Core::Byte value);
53ARP_EXPORT std::istream& operator>>(std::istream& is, Arp::Base::Core::Byte& value);
54
55} // end of namespace Arp::Base::Core
56
57namespace std
58{
59
60// stream operators for byte
61ARP_EXPORT ostream& operator<<(ostream& os, Arp::Base::Core::byte value);
62ARP_EXPORT istream& operator>>(istream& is, Arp::Base::Core::byte& value);
63
64} // end of namespace std
65
67// byte formatter support
69template<> struct fmt::formatter<Arp::Base::Core::Byte> : public fmt::ostream_formatter {};
std::byte byte
The Arp byte type.
Definition: Byte.hpp:24
Root namespace for the PLCnext API
Namespace of the C++ standard library
Definition: Byte.hpp:46