This repository has been archived by the owner on Jul 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUtils.h
99 lines (86 loc) · 3.78 KB
/
Utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/**
* Digital Voice Modem - Transcode Software
* GPLv2 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Transcode Software
*
*/
//
// Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost)
// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0)
//
/*
* Copyright (C) 2009,2014,2015 by Jonathan Naylor, G4KLX
* Copyright (C) 2018-2019 Bryan Biedenkapp N2PLL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#if !defined(__UTILS_H__)
#define __UTILS_H__
#include "Defines.h"
#include <string>
#if !defined(_UTILS_NO_INCLUDE_CPP)
// ---------------------------------------------------------------------------
// Externs
// ---------------------------------------------------------------------------
extern "C" {
/// <summary>Displays the host version.</summary>
HOST_SW_API void getHostVersion();
/// <summary></summary>
HOST_SW_API void cDump(int level, const char* title, const uint8_t* data, uint32_t length);
}
// ---------------------------------------------------------------------------
// Class Declaration
// Implements various helper utilities.
// ---------------------------------------------------------------------------
class HOST_SW_API Utils {
public:
/// <summary></summary>
static void dump(const std::string& title, const uint8_t* data, uint32_t length);
/// <summary></summary>
static void dump(int level, const std::string& title, const uint8_t* data, uint32_t length);
/// <summary></summary>
static void dump(const std::string& title, const bool* bits, uint32_t length);
/// <summary></summary>
static void dump(int level, const std::string& title, const bool* bits, uint32_t length);
/// <summary></summary>
static void byteToBitsBE(uint8_t byte, bool* bits);
/// <summary></summary>
static void byteToBitsLE(uint8_t byte, bool* bits);
/// <summary></summary>
static void bitsToByteBE(const bool* bits, uint8_t& byte);
/// <summary></summary>
static void bitsToByteLE(const bool* bits, uint8_t& byte);
/// <summary></summary>
static uint32_t getBits(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t stop);
/// <summary></summary>
static uint32_t getBitRange(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t length);
/// <summary></summary>
static uint32_t setBits(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t stop);
/// <summary></summary>
static uint32_t setBitRange(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t length);
/// <summary>Returns the count of bits in the passed 8 byte value.</summary>
static uint8_t countBits8(uint8_t bits);
/// <summary>Returns the count of bits in the passed 32 byte value.</summary>
static uint8_t countBits32(uint32_t bits);
/// <summary>Returns the count of bits in the passed 64 byte value.</summary>
static uint8_t countBits64(ulong64_t bits);
};
#else
// ---------------------------------------------------------------------------
// Externs
// ---------------------------------------------------------------------------
/// <summary>Displays the host version.</summary>
extern HOST_SW_API void getHostVersion();
/// <summary></summary>
extern HOST_SW_API void cDump(int level, const char* title, const uint8_t* data, uint32_t length);
#endif
#endif // __UTILS_H__