highlighter application
1.1
HCE project utils : highlighter
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
ErrorStruct.cpp
Go to the documentation of this file.
1
12
#include "
ErrorStruct.hpp
"
13
14
std::vector<std::string>
errorCodesStrings
= {
"ERR_Hlt_timeout"
,
"ERR_Bad_regular_expr"
};
15
16
ErrorStruct::ErrorStruct
()
17
{
18
errorMask = 0;
19
}
20
21
ErrorStruct::~ErrorStruct
()
22
{
23
}
24
25
void
ErrorStruct::addErrorCode
(
unsigned
long
long
errorCode)
26
{
27
mutex.lock();
28
errorMask |= errorCode;
29
mutex.unlock();
30
}
31
32
unsigned
long
long
ErrorStruct::getErrorCode
()
33
{
34
unsigned
long
long
ret = 0;
35
mutex.lock();
36
ret = errorMask;
37
mutex.unlock();
38
return
ret;
39
}
40
41
std::string
ErrorStruct::resolveErrorString
(
unsigned
long
long
errorCode)
42
{
43
for
(
unsigned
int
i = 0; i < (
sizeof
(errorCode) * 8); i++)
44
{
45
if
(errorCode &
LONG_LONG_MASK
)
46
{
47
return
errorCodesStrings
[i];
48
}
49
errorCode >>= 1;
50
}
51
return
""
;
52
}
53
54
std::string
ErrorStruct::resolveErrorString
()
55
{
56
return
resolveErrorString
(errorMask);
57
}
58
59
std::string
ErrorStruct::concatenateErrorStrings
(
unsigned
long
long
errorCode)
60
{
61
std::string ret =
""
;
62
for
(
unsigned
int
i = 0; i < (
sizeof
(errorCode) * 8); i++)
63
{
64
if
(errorCode &
LONG_LONG_MASK
)
65
{
66
ret +=
errorCodesStrings
[i];
67
ret +=
SEPARATOR_STRING
;
68
}
69
errorCode >>= 1;
70
}
71
if
(ret.length() > 0)
72
{
73
ret.erase(ret.length() -
SEPARATOR_STRING_LENGTH
,
SEPARATOR_STRING_LENGTH
);
74
}
75
return
ret;
76
}
77
78
std::string
ErrorStruct::concatenateErrorStrings
()
79
{
80
return
concatenateErrorStrings
(errorMask);
81
}
sources
src
ErrorStruct.cpp
Generated on Mon Jan 13 2014 16:16:16 for highlighter application by
1.8.1.2