YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
NetUint32.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <yarp/os/NetUint32.h>
8
9#ifndef YARP_LITTLE_ENDIAN
10
11using namespace yarp;
12using namespace yarp::os;
13
14
15std::uint32_t NetUint32::swap(std::uint32_t x) const
16{
17 return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24);
18}
19
20std::uint32_t NetUint32::get() const
21{
22 return (std::uint32_t)swap(raw_value);
23}
24
25void NetUint32::set(std::uint32_t v)
26{
27 raw_value = (std::uint32_t)swap((std::uint32_t)v);
28}
29
30NetUint32::NetUint32()
31{
32}
33
34NetUint32::NetUint32(std::uint32_t val)
35{
36 set(val);
37}
38
39NetUint32::operator std::uint32_t() const
40{
41 return get();
42}
43
44std::uint32_t NetUint32::operator+(std::uint32_t v) const
45{
46 return get() + v;
47}
48
49std::uint32_t NetUint32::operator-(std::uint32_t v) const
50{
51 return get() - v;
52}
53
54std::uint32_t NetUint32::operator*(std::uint32_t v) const
55{
56 return get() * v;
57}
58
59std::uint32_t NetUint32::operator/(std::uint32_t v) const
60{
61 return get() / v;
62}
63
64void NetUint32::operator+=(std::uint32_t v)
65{
66 set(get() + v);
67}
68
69void NetUint32::operator-=(std::uint32_t v)
70{
71 set(get() - v);
72}
73
74void NetUint32::operator*=(std::uint32_t v)
75{
76 set(get() * v);
77}
78
79void NetUint32::operator/=(std::uint32_t v)
80{
81 set(get() / v);
82}
83
84void NetUint32::operator++(int)
85{
86 set(get() + 1);
87}
88
89void NetUint32::operator--(int)
90{
91 set(get() - 1);
92}
93
94
95#endif // YARP_LITTLE_ENDIAN
A mini-server for performing network communication in the background.
An interface to the operating system, including Port based communication.
The main, catch-all namespace for YARP.
Definition dirs.h:16