OpenZWave Library
1.4.0
Toggle main menu visibility
Loading...
Searching...
No Matches
cpp
src
Utils.h
Go to the documentation of this file.
1
//-----------------------------------------------------------------------------
2
//
3
// Utils.h
4
//
5
// Miscellaneous helper functions
6
//
7
// Copyright (c) 2010 Mal Lansell <openzwave@lansell.org>
8
//
9
// SOFTWARE NOTICE AND LICENSE
10
//
11
// This file is part of OpenZWave.
12
//
13
// OpenZWave is free software: you can redistribute it and/or modify
14
// it under the terms of the GNU Lesser General Public License as published
15
// by the Free Software Foundation, either version 3 of the License,
16
// or (at your option) any later version.
17
//
18
// OpenZWave is distributed in the hope that it will be useful,
19
// but WITHOUT ANY WARRANTY; without even the implied warranty of
20
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
// GNU Lesser General Public License for more details.
22
//
23
// You should have received a copy of the GNU Lesser General Public License
24
// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
25
//
26
//-----------------------------------------------------------------------------
27
28
#ifndef _Utils_H
29
#define _Utils_H
30
31
#include "
platform/Mutex.h
"
32
#include "
platform/Log.h
"
33
34
#include <string>
35
#include <locale>
36
#include <algorithm>
37
#include <sstream>
38
#include <vector>
39
40
namespace
OpenZWave
41
{
48
string
ToUpper
(
string
const
& _str );
49
56
string
ToLower
(
string
const
& _str );
57
65
void
split
(std::vector<std::string>& lst,
const
std::string& input,
const
std::string& separators,
bool
remove_empty =
true
);
66
72
std::string &
trim
( std::string &
s
);
73
74
75
void
PrintHex
(std::string prefix, uint8_t
const
*data,
uint32
const
length);
76
string
PktToString
(
uint8
const
*data,
uint32
const
length);
77
78
struct
LockGuard
79
{
80
LockGuard
(
Mutex
* mutex) : _ref(mutex)
81
{
82
//std::cout << "Locking" << std::endl;
83
_ref->Lock();
84
};
85
86
~LockGuard
()
87
{
88
#if 0
89
if
(_ref->IsSignalled())
90
std::cout <<
"Already Unlocked"
<< std::endl;
91
else
92
std::cout <<
"Unlocking"
<< std::endl;
93
#endif
94
if
(!_ref->IsSignalled())
95
_ref->Unlock();
96
}
97
void
Unlock
()
98
{
99
// std::cout << "Unlocking" << std::endl;
100
_ref->Unlock();
101
}
102
private
:
103
LockGuard
(
const
LockGuard
&);
104
LockGuard
& operator = (
LockGuard
const
& );
105
106
107
Mutex
* _ref;
108
};
109
110
111
112
}
// namespace OpenZWave
113
114
#endif
115
116
117
uint32
unsigned int uint32
Definition
Defs.h:80
uint8
unsigned char uint8
Definition
Defs.h:74
Log.h
Mutex.h
s
#define s(x, c)
Definition
aesopt.h:483
OpenZWave::Mutex
Implements a platform-independent mutex–for serializing access to a shared resource.
Definition
Mutex.h:40
OpenZWave
Definition
Bitfield.h:35
OpenZWave::split
void split(std::vector< std::string > &lst, const std::string &input, const std::string &separators, bool remove_empty=true)
Definition
Utils.cpp:95
OpenZWave::PrintHex
void PrintHex(std::string prefix, uint8_t const *data, uint32 const length)
Definition
Utils.cpp:118
OpenZWave::ToUpper
string ToUpper(string const &_str)
Definition
Utils.cpp:39
OpenZWave::trim
std::string & trim(std::string &s)
Definition
Utils.cpp:68
OpenZWave::PktToString
string PktToString(uint8 const *data, uint32 const length)
Definition
Utils.cpp:122
OpenZWave::ToLower
string ToLower(string const &_str)
Definition
Utils.cpp:53
OpenZWave::LockGuard
Definition
Utils.h:79
OpenZWave::LockGuard::Unlock
void Unlock()
Definition
Utils.h:97
OpenZWave::LockGuard::LockGuard
LockGuard(Mutex *mutex)
Definition
Utils.h:80
OpenZWave::LockGuard::~LockGuard
~LockGuard()
Definition
Utils.h:86
Generated on
for OpenZWave Library by
1.18.0