libDwm-0.9.45
DwmXDRUtils.hh
Go to the documentation of this file.
1//===========================================================================
2// @(#) $DwmPath$
3//===========================================================================
4// Copyright (c) Daniel W. McRobb 2020
5// All rights reserved.
6//
7// Redistribution and use in source and binary forms, with or without
8// modification, are permitted provided that the following conditions
9// are met:
10//
11// 1. Redistributions of source code must retain the above copyright
12// notice, this list of conditions and the following disclaimer.
13// 2. Redistributions in binary form must reproduce the above copyright
14// notice, this list of conditions and the following disclaimer in the
15// documentation and/or other materials provided with the distribution.
16// 3. The names of the authors and copyright holders may not be used to
17// endorse or promote products derived from this software without
18// specific prior written permission.
19//
20// IN NO EVENT SHALL DANIEL W. MCROBB BE LIABLE TO ANY PARTY FOR
21// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
22// INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE,
23// EVEN IF DANIEL W. MCROBB HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
24// DAMAGE.
25//
26// THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND
27// DANIEL W. MCROBB HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
28// UPDATES, ENHANCEMENTS, OR MODIFICATIONS. DANIEL W. MCROBB MAKES NO
29// REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND, EITHER
30// IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31// WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE,
32// OR THAT THE USE OF THIS SOFTWARE WILL NOT INFRINGE ANY PATENT,
33// TRADEMARK OR OTHER RIGHTS.
34//===========================================================================
35
36//---------------------------------------------------------------------------
40//---------------------------------------------------------------------------
41
42#ifndef _DWMXDRUTILS_HH_
43#define _DWMXDRUTILS_HH_
44
45#include <array>
46#include <cstdint>
47
48namespace Dwm {
49
50 //--------------------------------------------------------------------------
52 //--------------------------------------------------------------------------
54 {
55 public:
56 //------------------------------------------------------------------------
59 //------------------------------------------------------------------------
60 static bool Encode(float val, std::array<char,4> & buf);
61
62 //------------------------------------------------------------------------
65 //------------------------------------------------------------------------
66 static bool Decode(const std::array<char,4> & buf, float & val);
67
68 //------------------------------------------------------------------------
71 //------------------------------------------------------------------------
72 static bool Encode(double val, std::array<char,8> & buf);
73
74 //------------------------------------------------------------------------
77 //------------------------------------------------------------------------
78 static bool Decode(const std::array<char,8> & buf, double & val);
79
80 //------------------------------------------------------------------------
84 //------------------------------------------------------------------------
85 static uint32_t Encode(float val, char **buf);
86
87 //------------------------------------------------------------------------
89 //------------------------------------------------------------------------
90 static void Decode(char *buf, float & val);
91
92 //------------------------------------------------------------------------
96 //------------------------------------------------------------------------
97 static uint32_t Encode(double val, char **buf);
98
99 //------------------------------------------------------------------------
101 //------------------------------------------------------------------------
102 static void Decode(char *buf, double & val);
103 };
104
105} // namespace Dwm
106
107#endif // _DWMXDRUTILS_HH_
108
109
110//---------------------------- emacs settings -----------------------------
111// Local Variables:
112// mode: C++
113// tab-width: 2
114// indent-tabs-mode: nil
115// c-basic-offset: 2
116// End:
117//-------------------------------------------------------------------------
Wrapper for XDR encode/decode functions.
Definition DwmXDRUtils.hh:54
static bool Encode(double val, std::array< char, 8 > &buf)
Encode the given double val into the given buffer buf.
static bool Encode(float val, std::array< char, 4 > &buf)
Encode the given float val into the given buffer buf.
static uint32_t Encode(float val, char **buf)
Encodes the given float val into *buf.
static bool Decode(const std::array< char, 4 > &buf, float &val)
Decodes the given buffer buf into the given value val.
static bool Decode(const std::array< char, 8 > &buf, double &val)
Decodes the given buffer buf into the given double value val.
static void Decode(char *buf, float &val)
Decodes the given buf into the given float value val.
static void Decode(char *buf, double &val)
Decodes the given buf into the given double value val.
static uint32_t Encode(double val, char **buf)
Encodes the given double val into *buf.