Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CoMISo
Base
Commits
e876c815
Commit
e876c815
authored
Jun 16, 2016
by
Martin Marinov
Browse files
Improved portability inc. support for x32 platforms. Various minor fixes.
parent
3e56d034
Changes
5
Hide whitespace changes
Inline
Side-by-side
Config/BaseDefines.hh
View file @
e876c815
...
...
@@ -32,3 +32,9 @@
#endif
// configure some defines based on the platform
#if (_MSC_VER >= 1700 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__))
#define STD_ARRAY_AVAILABLE
#endif
Debug/DebFile.cc
View file @
e876c815
...
...
@@ -95,10 +95,9 @@ public:
return
priority_
;
}
const
char
*
filename
()
const
{
if
(
this
&&
(
!
flnm_
.
empty
()))
return
flnm_
.
c_str
();
return
NULL
;
const
char
*
filename
()
const
{
return
flnm_
.
empty
()
?
NULL
:
flnm_
.
c_str
();
}
void
clear
()
...
...
Debug/DebOut.hh
View file @
e876c815
...
...
@@ -31,9 +31,10 @@
#include
<sstream>
#include
<vector>
#if (_MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__))
#include
<array>
#endif
// ERROR is occasionally defined in system headers, e.g., windows.h
#ifdef ERROR
#undef ERROR
#endif//ERROR
namespace
Debug
{
...
...
@@ -115,6 +116,15 @@ private:
BASEDLLEXPORT
extern
void
warning
(
const
std
::
string
&
_wrng
,
const
::
Base
::
CodeLink
&
_lnk
);
BASEDLLEXPORT
extern
void
error
(
const
std
::
string
&
_err
,
const
::
Base
::
CodeLink
&
_lnk
);
// TODO: Move this upstream to namespace Base?!
template
<
typename
T
>
std
::
string
to_string
(
const
T
&
_t
)
{
std
::
ostringstream
ss
;
ss
<<
_t
;
return
ss
.
str
();
}
}
//namespace Debug
// Obsolete, use gradually removed
...
...
@@ -147,27 +157,12 @@ BASEDLLEXPORT extern void error(const std::string& _err, const ::Base::CodeLink&
::Debug::error(strm.str, BASE_CODELINK); }
#define DEB_error_if(CC, AA) { if (CC) DEB_error(AA); }
// Stream does not fulfill ostream. If you want to exploit an existing
//
Debug::
Stream does not fulfill ostream. If you want to exploit an existing
// ostream streamer to DEB_out a class as text without exploiting any
// numeric processing or custom Stream streamers then use this macro thus
// DEB_out(1, "my_class is " << DEB_os_str(my_c) )
#if (_MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__))
#define DEB_os_str(AA) \
dynamic_cast<std::ostringstream &&>((std::ostringstream() << AA )).str()
#else
namespace
Debug
{
template
<
typename
T
>
std
::
string
toString
(
const
T
&
t
)
{
std
::
ostringstream
ss
;
ss
<<
t
;
return
ss
.
str
();
}
}
// namespace Debug
#define DEB_os_str(AA) \
Debug::toString(AA)
#endif
#define DEB_os_str(AA) Debug::to_string(AA)
#endif // DEB_ON
...
...
Utils/IOutputStream.cc
View file @
e876c815
...
...
@@ -35,10 +35,12 @@ IOutputStream& operator<<(IOutputStream& _os, const size_t _i)
return
_os
.
print
(
_i
);
}
#ifdef UINT_SIZET_DIFFER
IOutputStream
&
operator
<<
(
IOutputStream
&
_os
,
const
unsigned
int
_i
)
{
return
_os
.
print
(
size_t
(
_i
));
}
#endif//UINT_SIZET_DIFFER
IOutputStream
&
operator
<<
(
IOutputStream
&
_os
,
const
float
_f
)
{
...
...
Utils/IOutputStream.hh
View file @
e876c815
...
...
@@ -5,14 +5,20 @@
#include
<string>
#include
<vector>
#include
<stdint.h>
#if (_MSC_VER >= 1700 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__))
#define STD_ARRAY_AVAILABLE
#include
<array>
#include
<limits.h>
// Find out if we need separate streaming operators for uint and size_t
#if ((UINT_MAX) != (SIZE_MAX))
#define UINT_SIZET_DIFFER
#endif
#include
<Base/Config/BaseDefines.hh>
#ifdef STD_ARRAY_AVAILABLE
#include
<array>
#endif//STD_ARRAY_AVAILABLE
namespace
boost
{
namespace
filesystem
{
class
path
;
...
...
@@ -77,7 +83,9 @@ BASEDLLEXPORT IOutputStream& operator<<(IOutputStream& _os, const char _c);
BASEDLLEXPORT
IOutputStream
&
operator
<<
(
IOutputStream
&
_os
,
const
size_t
_i
);
#ifdef UINT_SIZET_DIFFER
BASEDLLEXPORT
IOutputStream
&
operator
<<
(
IOutputStream
&
_os
,
const
unsigned
int
_i
);
#endif//UINT_SIZET_DIFFER
BASEDLLEXPORT
IOutputStream
&
operator
<<
(
IOutputStream
&
_os
,
const
float
_f
);
...
...
@@ -183,16 +191,18 @@ private:
Old Style secure print function, should be used directly only in exceptional
cases. Note: Defined in OStringStream.cc.
*/
extern
int
print
(
char
*
_bffr
,
const
size_t
_bffr_size
,
const
char
*
_frmt
,
...);
extern
int
print
(
char
*
_bffr
,
const
size_t
_bffr_size
,
const
char
*
const
_frmt
,
...);
//! Format a variable for streaming
template
<
typename
T
,
const
size_t
_bffr_size
=
128
>
template
<
const
size_t
_bffr_size
=
128
>
struct
FormatT
{
public:
typedef
FormatT
<
T
,
_bffr_size
>
Self
;
typedef
FormatT
<
_bffr_size
>
Self
;
FormatT
(
const
char
*
_frmt
,
const
T
&
_vrbl
)
template
<
typename
T
>
FormatT
(
const
char
*
const
_frmt
,
const
T
&
_vrbl
)
{
print
(
bffr_
,
_bffr_size
,
_frmt
,
_vrbl
);
}
...
...
@@ -208,21 +218,21 @@ private:
//! Convenient access to format a variable for streaming
template
<
typename
T
>
inline
FormatT
<
T
>
format
(
const
char
*
_frmt
,
const
T
&
_vrbl
)
inline
FormatT
<>
format
(
const
char
*
const
_frmt
,
const
T
&
_vrbl
)
{
return
FormatT
<
T
>
(
_frmt
,
_vrbl
);
return
FormatT
<>
(
_frmt
,
_vrbl
);
}
//! Format a
64
bit
size_
t variable for streaming in hex (e.g. for hash)
inline
FormatT
<
size_t
>
format_hex
(
const
size
_t
_vrbl
)
{
return
FormatT
<
size_t
>
(
"%
I64
x"
,
_vrbl
);
//! Format a
32
bit
uin
t variable for streaming in hex (e.g. for hash)
inline
FormatT
<>
format_hex
(
const
uint32
_t
_vrbl
)
{
return
FormatT
<>
(
"%x"
,
_vrbl
);
}
//! Format a
32
bit
uin
t variable for streaming in hex (e.g. for hash)
inline
FormatT
<
uint
>
format_hex
(
const
uint
_vrbl
)
//! Format a
64
bit
size_
t variable for streaming in hex (e.g. for hash)
inline
FormatT
<>
format_hex
(
const
uint
64_t
_vrbl
)
{
return
FormatT
<
uint
>
(
"%x"
,
_vrbl
);
return
FormatT
<>
(
"%
I64
x"
,
_vrbl
);
}
}
//namespace Base
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment