Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
ff1db4d3
Commit
ff1db4d3
authored
Feb 15, 2016
by
Steven Murray
Browse files
Changed Utils class into a namespace
parent
1faed310
Changes
18
Hide whitespace changes
Inline
Side-by-side
common/Configuration.hpp
View file @
ff1db4d3
...
...
@@ -142,7 +142,7 @@ namespace cta { namespace common {
return
defaultValue
;
}
if
(
!
U
tils
::
isValidUInt
(
strValue
.
c_str
()))
{
if
(
!
u
tils
::
isValidUInt
(
strValue
.
c_str
()))
{
InvalidConfigEntry
ex
(
category
.
c_str
(),
key
.
c_str
(),
strValue
.
c_str
());
ex
.
getMessage
()
<<
"Failed to get configuration entry "
<<
category
<<
...
...
@@ -184,7 +184,7 @@ namespace cta { namespace common {
const
std
::
string
&
key
,
log
::
Logger
*
const
log
=
NULL
)
{
const
std
::
string
strValue
=
getConfEntString
(
category
,
key
);
if
(
!
U
tils
::
isValidUInt
(
strValue
.
c_str
()))
{
if
(
!
u
tils
::
isValidUInt
(
strValue
.
c_str
()))
{
InvalidConfigEntry
ex
(
category
.
c_str
(),
key
.
c_str
(),
strValue
.
c_str
());
ex
.
getMessage
()
<<
"Failed to get configuration entry "
<<
category
<<
...
...
common/ProcessCap.cpp
View file @
ff1db4d3
...
...
@@ -55,7 +55,7 @@ cap_t castor::server::ProcessCap::getProc() {
castor
::
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Failed to get the capabilities of the process: "
<<
cta
::
U
tils
::
errnoToString
(
errno
);
<<
cta
::
u
tils
::
errnoToString
(
errno
);
throw
ex
;
}
return
cap
;
...
...
@@ -72,7 +72,7 @@ std::string castor::server::ProcessCap::toText(
castor
::
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Failed to create string representation of capability state: "
<<
cta
::
U
tils
::
errnoToString
(
errno
);
<<
cta
::
u
tils
::
errnoToString
(
errno
);
throw
ex
;
}
std
::
string
result
(
text
);
...
...
@@ -82,7 +82,7 @@ std::string castor::server::ProcessCap::toText(
castor
::
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Failed to free string representation of capability state: "
<<
cta
::
U
tils
::
errnoToString
(
errno
);
<<
cta
::
u
tils
::
errnoToString
(
errno
);
throw
ex
;
}
...
...
@@ -114,7 +114,7 @@ cap_t castor::server::ProcessCap::fromText(const std::string &text) {
castor
::
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Failed to create capability state from string representation"
": text='"
<<
text
<<
"': "
<<
cta
::
U
tils
::
errnoToString
(
errno
);
": text='"
<<
text
<<
"': "
<<
cta
::
u
tils
::
errnoToString
(
errno
);
throw
ex
;
}
...
...
@@ -129,7 +129,7 @@ void castor::server::ProcessCap::setProc(const cap_t cap) {
castor
::
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Failed to set the capabilities of the process: "
<<
cta
::
U
tils
::
errnoToString
(
errno
);
<<
cta
::
u
tils
::
errnoToString
(
errno
);
throw
ex
;
}
}
common/exception/Errnum.cpp
View file @
ff1db4d3
...
...
@@ -35,7 +35,7 @@ Errnum::Errnum(int err, std::string what):Exception("") {
}
void
Errnum
::
ErrnumConstructorBottomHalf
(
const
std
::
string
&
what
)
{
m_strerror
=
U
tils
::
errnoToString
(
m_errnum
);
m_strerror
=
u
tils
::
errnoToString
(
m_errnum
);
std
::
stringstream
w2
;
if
(
what
.
size
())
w2
<<
what
<<
" "
;
...
...
common/log/SyslogLogger.cpp
View file @
ff1db4d3
...
...
@@ -55,7 +55,7 @@ cta::log::SyslogLogger::SyslogLogger(const std::string &socketName,
struct
stat
fileStatus
;
bzero
(
&
fileStatus
,
sizeof
(
fileStatus
));
if
(
stat
(
socketName
.
c_str
(),
&
fileStatus
))
{
const
std
::
string
errMsg
=
cta
::
U
tils
::
errnoToString
(
errno
);
const
std
::
string
errMsg
=
cta
::
u
tils
::
errnoToString
(
errno
);
cta
::
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Failed to instantiate syslog logger: Failed to stat"
" socket
\"
"
<<
socketName
<<
"
\"
"
": "
<<
errMsg
;
...
...
@@ -378,7 +378,7 @@ void cta::log::SyslogLogger::writeHeader(
std
::
string
cta
::
log
::
SyslogLogger
::
cleanString
(
const
std
::
string
&
s
,
const
bool
replaceUnderscores
)
{
// Trim both left and right white-space
std
::
string
result
=
U
tils
::
trimString
(
s
);
std
::
string
result
=
u
tils
::
trimString
(
s
);
for
(
std
::
string
::
iterator
it
=
result
.
begin
();
it
!=
result
.
end
();
++
it
)
{
...
...
common/processCap/ProcessCap.cpp
View file @
ff1db4d3
...
...
@@ -58,7 +58,7 @@ cap_t cta::server::ProcessCap::getProc() {
cta
::
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Failed to get the capabilities of the process: "
<<
cta
::
U
tils
::
errnoToString
(
errno
);
<<
cta
::
u
tils
::
errnoToString
(
errno
);
throw
ex
;
}
return
cap
;
...
...
@@ -75,7 +75,7 @@ std::string cta::server::ProcessCap::toText(
cta
::
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Failed to create string representation of capability state: "
<<
cta
::
U
tils
::
errnoToString
(
errno
);
<<
cta
::
u
tils
::
errnoToString
(
errno
);
throw
ex
;
}
std
::
string
result
(
text
);
...
...
@@ -85,7 +85,7 @@ std::string cta::server::ProcessCap::toText(
cta
::
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Failed to free string representation of capability state: "
<<
cta
::
U
tils
::
errnoToString
(
errno
);
<<
cta
::
u
tils
::
errnoToString
(
errno
);
throw
ex
;
}
...
...
@@ -117,7 +117,7 @@ cap_t cta::server::ProcessCap::fromText(const std::string &text) {
cta
::
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Failed to create capability state from string representation"
": text='"
<<
text
<<
"': "
<<
cta
::
U
tils
::
errnoToString
(
errno
);
": text='"
<<
text
<<
"': "
<<
cta
::
u
tils
::
errnoToString
(
errno
);
throw
ex
;
}
...
...
@@ -132,7 +132,7 @@ void cta::server::ProcessCap::setProc(const cap_t cap) {
cta
::
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Failed to set the capabilities of the process: "
<<
cta
::
U
tils
::
errnoToString
(
errno
);
<<
cta
::
u
tils
::
errnoToString
(
errno
);
throw
ex
;
}
}
common/utils/Utils.cpp
View file @
ff1db4d3
...
...
@@ -101,7 +101,7 @@ static void assertPathContainsValidChars(const std::string &path) {
//------------------------------------------------------------------------------
// assertAbsolutePathSyntax
//------------------------------------------------------------------------------
void
cta
::
U
tils
::
assertAbsolutePathSyntax
(
const
std
::
string
&
path
)
{
void
cta
::
u
tils
::
assertAbsolutePathSyntax
(
const
std
::
string
&
path
)
{
try
{
assertPathStartsWithASlash
(
path
);
assertPathContainsValidChars
(
path
);
...
...
@@ -117,7 +117,7 @@ void cta::Utils::assertAbsolutePathSyntax(const std::string &path) {
//------------------------------------------------------------------------------
// getEnclosingPath
//------------------------------------------------------------------------------
std
::
string
cta
::
U
tils
::
getEnclosingPath
(
const
std
::
string
&
path
)
{
std
::
string
cta
::
u
tils
::
getEnclosingPath
(
const
std
::
string
&
path
)
{
if
(
path
==
"/"
)
{
throw
Exception
(
"Root directory does not have a parent"
);
}
...
...
@@ -132,7 +132,7 @@ std::string cta::Utils::getEnclosingPath(const std::string &path) {
//------------------------------------------------------------------------------
// getEnclosedName
//------------------------------------------------------------------------------
std
::
string
cta
::
U
tils
::
getEnclosedName
(
const
std
::
string
&
path
)
{
std
::
string
cta
::
u
tils
::
getEnclosedName
(
const
std
::
string
&
path
)
{
const
std
::
string
::
size_type
last_slash_idx
=
path
.
find_last_of
(
'/'
);
if
(
std
::
string
::
npos
==
last_slash_idx
)
{
return
path
;
...
...
@@ -148,7 +148,7 @@ std::string cta::Utils::getEnclosedName(const std::string &path) {
//-----------------------------------------------------------------------------
// getEnclosedNames
//-----------------------------------------------------------------------------
std
::
list
<
std
::
string
>
cta
::
U
tils
::
getEnclosedNames
(
std
::
list
<
std
::
string
>
cta
::
u
tils
::
getEnclosedNames
(
const
std
::
list
<
std
::
string
>
&
paths
)
{
std
::
list
<
std
::
string
>
names
;
...
...
@@ -163,7 +163,7 @@ std::list<std::string> cta::Utils::getEnclosedNames(
//-----------------------------------------------------------------------------
// trimSlashes
//-----------------------------------------------------------------------------
std
::
string
cta
::
U
tils
::
trimSlashes
(
const
std
::
string
&
s
)
{
std
::
string
cta
::
u
tils
::
trimSlashes
(
const
std
::
string
&
s
)
{
// Find first non slash character
size_t
beginpos
=
s
.
find_first_not_of
(
"/"
);
std
::
string
::
const_iterator
it1
;
...
...
@@ -188,7 +188,7 @@ std::string cta::Utils::trimSlashes(const std::string &s) {
//-----------------------------------------------------------------------------
// trimFinalSlashes
//-----------------------------------------------------------------------------
std
::
string
cta
::
U
tils
::
trimFinalSlashes
(
const
std
::
string
&
s
)
{
std
::
string
cta
::
u
tils
::
trimFinalSlashes
(
const
std
::
string
&
s
)
{
// Find last non slash chararacter
std
::
string
::
const_iterator
it2
;
size_t
endpos
=
s
.
find_last_not_of
(
"/"
);
...
...
@@ -204,7 +204,7 @@ std::string cta::Utils::trimFinalSlashes(const std::string &s) {
//-----------------------------------------------------------------------------
// splitString
//-----------------------------------------------------------------------------
void
cta
::
U
tils
::
splitString
(
const
std
::
string
&
str
,
const
char
separator
,
void
cta
::
u
tils
::
splitString
(
const
std
::
string
&
str
,
const
char
separator
,
std
::
vector
<
std
::
string
>
&
result
)
{
if
(
str
.
empty
())
{
...
...
@@ -230,7 +230,7 @@ void cta::Utils::splitString(const std::string &str, const char separator,
//-----------------------------------------------------------------------------
// trimString
//-----------------------------------------------------------------------------
std
::
string
cta
::
U
tils
::
trimString
(
const
std
::
string
&
s
)
throw
()
{
std
::
string
cta
::
u
tils
::
trimString
(
const
std
::
string
&
s
)
throw
()
{
const
std
::
string
&
spaces
=
"
\t\n\v\f\r
"
;
// Find first non white character
...
...
@@ -257,7 +257,7 @@ std::string cta::Utils::trimString(const std::string &s) throw() {
//-----------------------------------------------------------------------------
// generateUuid
//-----------------------------------------------------------------------------
std
::
string
cta
::
U
tils
::
generateUuid
()
{
std
::
string
cta
::
u
tils
::
generateUuid
()
{
uuid_t
uuid
;
char
str
[
36
+
1
];
...
...
@@ -270,7 +270,7 @@ std::string cta::Utils::generateUuid() {
//-----------------------------------------------------------------------------
// endsWith
//-----------------------------------------------------------------------------
bool
cta
::
U
tils
::
endsWith
(
const
std
::
string
&
str
,
const
char
c
)
{
bool
cta
::
u
tils
::
endsWith
(
const
std
::
string
&
str
,
const
char
c
)
{
if
(
str
.
empty
())
{
return
false
;
}
else
{
...
...
@@ -281,13 +281,13 @@ bool cta::Utils::endsWith(const std::string &str, const char c) {
//------------------------------------------------------------------------------
// setXattr
//------------------------------------------------------------------------------
void
cta
::
U
tils
::
setXattr
(
const
std
::
string
&
path
,
const
std
::
string
&
name
,
void
cta
::
u
tils
::
setXattr
(
const
std
::
string
&
path
,
const
std
::
string
&
name
,
const
std
::
string
&
value
)
{
if
(
setxattr
(
path
.
c_str
(),
name
.
c_str
(),
value
.
c_str
(),
value
.
length
(),
0
))
{
const
int
savedErrno
=
errno
;
std
::
ostringstream
msg
;
msg
<<
"Call to setxattr() failed: path="
<<
path
<<
" name="
<<
name
<<
" value="
<<
value
<<
": "
<<
Utils
::
errnoToString
(
savedErrno
);
" value="
<<
value
<<
": "
<<
errnoToString
(
savedErrno
);
throw
exception
::
Exception
(
msg
.
str
());
}
}
...
...
@@ -295,14 +295,14 @@ void cta::Utils::setXattr(const std::string &path, const std::string &name,
//------------------------------------------------------------------------------
// getXattr
//------------------------------------------------------------------------------
std
::
string
cta
::
U
tils
::
getXattr
(
const
std
::
string
&
path
,
std
::
string
cta
::
u
tils
::
getXattr
(
const
std
::
string
&
path
,
const
std
::
string
&
name
)
{
const
auto
sizeOfValue
=
getxattr
(
path
.
c_str
(),
name
.
c_str
(),
NULL
,
0
);
if
(
0
>
sizeOfValue
)
{
const
int
savedErrno
=
errno
;
std
::
stringstream
msg
;
msg
<<
"Call to getxattr() failed: path="
<<
path
<<
" name="
<<
name
<<
": "
<<
Utils
::
errnoToString
(
savedErrno
);
": "
<<
errnoToString
(
savedErrno
);
throw
exception
::
Exception
(
msg
.
str
());
}
...
...
@@ -318,7 +318,7 @@ std::string cta::Utils::getXattr(const std::string &path,
const
int
savedErrno
=
errno
;
std
::
stringstream
msg
;
msg
<<
"Call to getxattr() failed: path="
<<
path
<<
" name="
<<
name
<<
": "
<<
Utils
::
errnoToString
(
savedErrno
);
": "
<<
errnoToString
(
savedErrno
);
throw
exception
::
Exception
(
msg
.
str
());
}
...
...
@@ -328,7 +328,7 @@ std::string cta::Utils::getXattr(const std::string &path,
//------------------------------------------------------------------------------
// errnoToString
//------------------------------------------------------------------------------
std
::
string
cta
::
U
tils
::
errnoToString
(
const
int
errnoValue
)
throw
()
{
std
::
string
cta
::
u
tils
::
errnoToString
(
const
int
errnoValue
)
throw
()
{
char
buf
[
100
];
if
(
!
strerror_r_wrapper
(
errnoValue
,
buf
,
sizeof
(
buf
)))
{
...
...
@@ -362,7 +362,7 @@ std::string cta::Utils::errnoToString(const int errnoValue) throw() {
//------------------------------------------------------------------------------
// toUint16
//------------------------------------------------------------------------------
uint16_t
cta
::
U
tils
::
toUint16
(
const
std
::
string
&
str
)
{
uint16_t
cta
::
u
tils
::
toUint16
(
const
std
::
string
&
str
)
{
if
(
str
.
empty
())
{
std
::
ostringstream
msg
;
msg
<<
"Failed to convert empty string to uint16_t: An empty string is not"
...
...
@@ -398,7 +398,7 @@ uint16_t cta::Utils::toUint16(const std::string &str) {
//------------------------------------------------------------------------------
// toUid
//------------------------------------------------------------------------------
uid_t
cta
::
U
tils
::
toUid
(
const
std
::
string
&
str
)
{
uid_t
cta
::
u
tils
::
toUid
(
const
std
::
string
&
str
)
{
if
(
str
.
empty
())
{
std
::
ostringstream
msg
;
msg
<<
"Failed to convert empty string to uid_t: An empty string is not"
...
...
@@ -434,7 +434,7 @@ uid_t cta::Utils::toUid(const std::string &str) {
//------------------------------------------------------------------------------
// toGid
//------------------------------------------------------------------------------
gid_t
cta
::
U
tils
::
toGid
(
const
std
::
string
&
str
)
{
gid_t
cta
::
u
tils
::
toGid
(
const
std
::
string
&
str
)
{
if
(
str
.
empty
())
{
std
::
ostringstream
msg
;
msg
<<
"Failed to convert empty string to gid_t: An empty string is not"
...
...
@@ -470,7 +470,7 @@ gid_t cta::Utils::toGid(const std::string &str) {
//------------------------------------------------------------------------------
// isValidUInt
//------------------------------------------------------------------------------
bool
cta
::
U
tils
::
isValidUInt
(
const
std
::
string
&
str
)
bool
cta
::
u
tils
::
isValidUInt
(
const
std
::
string
&
str
)
throw
()
{
// An empty string is not a valid unsigned integer
if
(
str
.
empty
())
{
...
...
@@ -493,7 +493,7 @@ bool cta::Utils::isValidUInt(const std::string &str)
//------------------------------------------------------------------------------
// getAdler32
//------------------------------------------------------------------------------
uint32_t
cta
::
U
tils
::
getAdler32
(
const
uint8_t
*
buf
,
const
uint32_t
len
)
uint32_t
cta
::
u
tils
::
getAdler32
(
const
uint8_t
*
buf
,
const
uint32_t
len
)
throw
()
{
const
uint32_t
checksum
=
adler32
(
0L
,
Z_NULL
,
0
);
return
adler32
(
checksum
,
(
const
Bytef
*
)
buf
,
len
);
...
...
@@ -502,7 +502,7 @@ uint32_t cta::Utils::getAdler32(const uint8_t *buf, const uint32_t len)
//------------------------------------------------------------------------------
// getShortHostname
//------------------------------------------------------------------------------
std
::
string
cta
::
U
tils
::
getShortHostname
()
{
std
::
string
cta
::
u
tils
::
getShortHostname
()
{
struct
utsname
un
;
exception
::
Errnum
::
throwOnMinusOne
(
uname
(
&
un
));
std
::
vector
<
std
::
string
>
snn
;
...
...
@@ -513,7 +513,7 @@ std::string cta::Utils::getShortHostname() {
//------------------------------------------------------------------------------
// getDumpableProcessAttribute
//------------------------------------------------------------------------------
bool
cta
::
U
tils
::
getDumpableProcessAttribute
()
{
bool
cta
::
u
tils
::
getDumpableProcessAttribute
()
{
const
int
rc
=
prctl
(
PR_GET_DUMPABLE
);
switch
(
rc
)
{
case
-
1
:
...
...
@@ -541,7 +541,7 @@ bool cta::Utils::getDumpableProcessAttribute() {
//------------------------------------------------------------------------------
// setDumpableProcessAttribute
//------------------------------------------------------------------------------
void
cta
::
U
tils
::
setDumpableProcessAttribute
(
const
bool
dumpable
)
{
void
cta
::
u
tils
::
setDumpableProcessAttribute
(
const
bool
dumpable
)
{
const
int
rc
=
prctl
(
PR_SET_DUMPABLE
,
dumpable
?
1
:
0
);
switch
(
rc
)
{
case
-
1
:
...
...
@@ -563,5 +563,3 @@ bool cta::Utils::getDumpableProcessAttribute() {
}
}
}
common/utils/Utils.hpp
View file @
ff1db4d3
...
...
@@ -27,11 +27,7 @@
namespace
cta
{
/**
* Class of utility methods.
*/
class
Utils
{
public:
namespace
utils
{
/**
* Throws an exception if the specified absolute path constains a
...
...
@@ -39,7 +35,7 @@ public:
*
* @param path The Absolute path.
*/
static
void
assertAbsolutePathSyntax
(
const
std
::
string
&
path
);
void
assertAbsolutePathSyntax
(
const
std
::
string
&
path
);
/**
* Returns the path of the enclosing directory of the specified path.
...
...
@@ -54,7 +50,7 @@ public:
* @param path The path.
* @return The path of the enclosing directory.
*/
static
std
::
string
getEnclosingPath
(
const
std
::
string
&
path
);
std
::
string
getEnclosingPath
(
const
std
::
string
&
path
);
/**
* Returns the name of the enclosed file or directory of the specified path.
...
...
@@ -62,7 +58,7 @@ public:
* @param path The path.
* @return The name of the enclosed file or directory.
*/
static
std
::
string
getEnclosedName
(
const
std
::
string
&
path
);
std
::
string
getEnclosedName
(
const
std
::
string
&
path
);
/**
* Returns the names of the enclosed file or directory of each of the
...
...
@@ -72,7 +68,7 @@ public:
* @return The names of the enclosed file or directory of each of the
* specified paths.
*/
static
std
::
list
<
std
::
string
>
getEnclosedNames
(
std
::
list
<
std
::
string
>
getEnclosedNames
(
const
std
::
list
<
std
::
string
>
&
paths
);
/**
...
...
@@ -82,7 +78,7 @@ public:
* @param s The string to be trimmed.
* @return The result of trimming the string.
*/
static
std
::
string
trimSlashes
(
const
std
::
string
&
s
);
std
::
string
trimSlashes
(
const
std
::
string
&
s
);
/**
* Returns the result of trimming right slashes from the
...
...
@@ -91,7 +87,7 @@ public:
* @param s The string to be trimmed.
* @return The result of trimming the string.
*/
static
std
::
string
trimFinalSlashes
(
const
std
::
string
&
s
);
std
::
string
trimFinalSlashes
(
const
std
::
string
&
s
);
/**
* Splits the specified string into a vector of strings using the specified
...
...
@@ -104,7 +100,7 @@ public:
* @param result The vector when the result of spliting the string will be
* stored.
*/
static
void
splitString
(
const
std
::
string
&
str
,
const
char
separator
,
void
splitString
(
const
std
::
string
&
str
,
const
char
separator
,
std
::
vector
<
std
::
string
>
&
result
);
...
...
@@ -115,7 +111,7 @@ public:
* @param s The string to be trimmed.
* @return The result of trimming the string.
*/
static
std
::
string
trimString
(
const
std
::
string
&
s
)
throw
();
std
::
string
trimString
(
const
std
::
string
&
s
)
throw
();
/**
* Creates and returns an std::string which is the result of replacing each
...
...
@@ -125,14 +121,14 @@ public:
* @param str The original string.
* @return The newly created string with single spaces.
*/
static
std
::
string
singleSpaceString
(
const
std
::
string
&
str
)
throw
();
std
::
string
singleSpaceString
(
const
std
::
string
&
str
)
throw
();
/**
* Returns uuid in the form of a string.
*
* @return uuid in the form of a string.
*/
static
std
::
string
generateUuid
();
std
::
string
generateUuid
();
/**
* Returns true if the specified string ends with the specifie character.
...
...
@@ -141,7 +137,7 @@ public:
* @param c The character to be looked for at the end of the string.
* @return True if the specified string ends with the specified character.
*/
static
bool
endsWith
(
const
std
::
string
&
str
,
const
char
c
);
bool
endsWith
(
const
std
::
string
&
str
,
const
char
c
);
/**
* Returns the string reprsentation of the specified value.
...
...
@@ -149,7 +145,7 @@ public:
* @param value The value whose string representation is to be returned.
* @return The string reprsentation of the specified value.
*/
template
<
typename
T
>
static
std
::
string
toString
(
const
T
&
value
)
{
template
<
typename
T
>
std
::
string
toString
(
const
T
&
value
)
{
std
::
ostringstream
oss
;
oss
<<
value
;
return
oss
.
str
();
...
...
@@ -162,7 +158,7 @@ public:
* @param name The name of the extended attribute.
* @param value The value of the extended attribute.
*/
static
void
setXattr
(
const
std
::
string
&
path
,
const
std
::
string
&
name
,
void
setXattr
(
const
std
::
string
&
path
,
const
std
::
string
&
name
,
const
std
::
string
&
value
);
/**
...
...
@@ -172,7 +168,7 @@ public:
* @param name The name of the extended attribute.
* @return The value of the extended attribute.
*/
static
std
::
string
getXattr
(
const
std
::
string
&
path
,
const
std
::
string
&
name
);
std
::
string
getXattr
(
const
std
::
string
&
path
,
const
std
::
string
&
name
);
/**
* Determines the string representation of the specified error number.
...
...
@@ -182,7 +178,7 @@ public:
* @param errnoValue The errno value.
* @return The string representation.
*/
static
std
::
string
errnoToString
(
const
int
errnoValue
)
throw
();
std
::
string
errnoToString
(
const
int
errnoValue
)
throw
();
/**
* Converts the specified string to an unsigned integer.
...
...
@@ -190,7 +186,7 @@ public:
* @param str The string.
* @return The unisgned integer.
*/
static
uint16_t
toUint16
(
const
std
::
string
&
str
);
uint16_t
toUint16
(
const
std
::
string
&
str
);
/**
* Converts the specified string to a uid.
...
...
@@ -198,7 +194,7 @@ public:
* @param str The string.
* @return The uid.
*/
static
uid_t
toUid
(
const
std
::
string
&
str
);
uid_t
toUid
(
const
std
::
string
&
str
);
/**
* Converts the specified string to a gid.
...
...
@@ -206,7 +202,7 @@ public:
* @param str The string.
* @return The gid.
*/
static
gid_t
toGid
(
const
std
::
string
&
str
);
gid_t
toGid
(
const
std
::
string
&
str
);
/**
* Checks if the specified string is a valid unsigned integer.
...
...
@@ -214,14 +210,14 @@ public:
* @param str The string to be checked.
* @returns true if the string is a valid unsigned integer, else false.
*/
static
bool
isValidUInt
(
const
std
::
string
&
str
)
throw
();
bool
isValidUInt
(
const
std
::
string
&
str
)
throw
();
/**
* Gets the short host name from the system
*
* @return the short host name
*/
static
std
::
string
getShortHostname
();
std
::
string
getShortHostname
();
/**
* Returns the alder32 checksum of the specified buffer.
...
...
@@ -230,7 +226,7 @@ public:
* @param len The length of the buffer in bytes.
* @return the alder32 checksum of the specified buffer.
*/
static
uint32_t
getAdler32
(
const
uint8_t
*
buf
,
const
uint32_t
len
)
throw
();
uint32_t
getAdler32
(
const
uint8_t
*
buf
,
const
uint32_t
len
)
throw
();
/**
* Returns true if the attributes of the current process indicate that it will
...
...
@@ -241,7 +237,7 @@ public:
*
* @return true if the current program is dumpable.
*/
static
bool
getDumpableProcessAttribute
();
bool
getDumpableProcessAttribute
();
/**
* Sets the attributes of the current process to indicate hat it will produce a
...
...
@@ -249,7 +245,8 @@ public:
*
* @param dumpable true if the current program should be dumpable.
*/
static
void
setDumpableProcessAttribute
(
const
bool
dumpable
);
};
// class Utils
void
setDumpableProcessAttribute
(
const
bool
dumpable
);
}
// namespace utils
}
// namespace cta
common/utils/UtilsTest.cpp
View file @
ff1db4d3
...
...
@@ -36,7 +36,7 @@ TEST_F(cta_UtilsTest, trimSlashes_emptyString) {
using
namespace
cta
;
const
std
::
string
s
;
const
std
::
string
trimmedString
=
U
tils
::
trimSlashes
(
s
);
const
std
::
string
trimmedString
=
u
tils
::
trimSlashes
(
s
);
ASSERT_EQ
(
s
,
trimmedString
);
}
...
...
@@ -44,7 +44,7 @@ TEST_F(cta_UtilsTest, trimSlashes_noSlashes) {
using
namespace
cta
;
const
std
::
string
s
(
"NO_SLASHES"
);
const
std
::
string
trimmedString
=
U
tils
::
trimSlashes
(
s
);
const
std
::
string
trimmedString
=
u
tils
::
trimSlashes
(
s
);
ASSERT_EQ
(
s
,
trimmedString
);
}
...
...
@@ -52,7 +52,7 @@ TEST_F(cta_UtilsTest, trimSlashes_oneLeftSlash) {
using
namespace
cta
;
const
std
::
string
s
(
"/VALUE"
);
const
std
::
string
trimmedString
=
U
tils
::
trimSlashes
(
s
);
const
std
::
string
trimmedString
=
u
tils
::
trimSlashes
(
s
);
ASSERT_EQ
(
std
::
string
(
"VALUE"
),
trimmedString
);
}
...
...
@@ -60,7 +60,7 @@ TEST_F(cta_UtilsTest, trimSlashes_twoLeftSlashes) {
using
namespace
cta
;
const
std
::
string
s
(
"//VALUE"
);
const
std
::
string
trimmedString
=
U
tils
::
trimSlashes
(
s
);
const
std
::
string
trimmedString
=
u
tils
::
trimSlashes
(
s
);
ASSERT_EQ
(
std
::
string
(
"VALUE"
),
trimmedString
);
}
...
...
@@ -68,7 +68,7 @@ TEST_F(cta_UtilsTest, trimSlashes_oneRightSlash) {
using
namespace
cta
;
const
std
::
string
s
(
"VALUE/"
);
const
std
::
string
trimmedString
=
U
tils
::
trimSlashes
(
s
);
const
std
::
string
trimmedString
=
u
tils
::
trimSlashes
(
s
);
ASSERT_EQ
(
std
::
string
(
"VALUE"
),
trimmedString
);
}
...
...
@@ -76,7 +76,7 @@ TEST_F(cta_UtilsTest, trimSlashes_twoRightSlashes) {
using
namespace
cta
;
const
std
::
string
s
(
"VALUE//"
);
const
std
::
string
trimmedString
=
U
tils
::
trimSlashes
(
s
);
const
std
::
string
trimmedString
=
u
tils
::
trimSlashes
(
s
);
ASSERT_EQ
(
std
::
string
(
"VALUE"
),
trimmedString
);
}
...
...
@@ -85,7 +85,7 @@ TEST_F(cta_UtilsTest,
using
namespace
cta
;
const
std
::
string
s
(
"/VALUE/"
);
const
std
::
string
trimmedString
=
U
tils
::
trimSlashes
(
s
);
const
std
::
string
trimmedString
=
u
tils
::
trimSlashes
(
s
);
ASSERT_EQ
(
std
::
string
(
"VALUE"
),
trimmedString
);
}
...
...
@@ -94,7 +94,7 @@ TEST_F(cta_UtilsTest,
using
namespace
cta
;
const
std
::
string
s
(
"//VALUE//"
);
const
std
::
string
trimmedString
=
U
tils
::
trimSlashes
(
s
);
const
std
::
string
trimmedString
=
u
tils
::
trimSlashes
(
s
);
ASSERT_EQ
(
std
::
string
(
"VALUE"
),
trimmedString
);
}
...
...
@@ -103,7 +103,7 @@ TEST_F(cta_UtilsTest, getEnclosingPath_empty_string) {
const
std
::
string
dirPath
=
""
;