1
0
mirror of https://github.com/wfjm/w11.git synced 2026-02-02 15:11:46 +00:00

use std::boolalpha; add and use RosPrintf(bool)

This commit is contained in:
wfjm
2018-12-23 09:07:25 +01:00
parent 93bf5ce03b
commit 5bf5d405c3
28 changed files with 182 additions and 100 deletions

View File

@@ -1,4 +1,4 @@
// $Id: RlogFile.cpp 1089 2018-12-19 10:45:41Z mueller $
// $Id: RlogFile.cpp 1090 2018-12-21 12:17:35Z mueller $
//
// Copyright 2011-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-12-19 1090 1.2.4 use RosPrintf(bool)
// 2018-12-18 1089 1.2.3 use c++ style casts
// 2018-12-17 1085 1.2.2 use std::lock_guard instead of boost
// 2017-03-04 858 2.2.1 use clock_gettime instead of gettimeofday
@@ -180,7 +181,7 @@ void RlogFile::Dump(std::ostream& os, int ind, const char* text) const
os << bl << (text?text:"--") << "RlogFile @ " << this << endl;
os << bl << " fpExtStream: " << fpExtStream << endl;
os << bl << " fIntStream.isopen " << fIntStream.is_open() << endl;
os << bl << " fNew " << fNew << endl;
os << bl << " fNew " << RosPrintf(fNew) << endl;
os << bl << " fName " << fName << endl;
os << bl << " fTagYr,Mo,Dy " << fTagYear << ", " << fTagMonth
<< ", " << fTagDay << endl;

View File

@@ -1,6 +1,6 @@
// $Id: RosPrintf.hpp 983 2018-01-02 20:35:59Z mueller $
// $Id: RosPrintf.hpp 1088 2018-12-17 17:37:00Z mueller $
//
// Copyright 2000-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2000-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-12-17 1088 1.1 add bool specialization (use c++11 std::boolalpha)
// 2011-01-30 357 1.0 Adopted from CTBprintf
// 2000-12-18 - - Last change on CTBprintf
// ---------------------------------------------------------------------------
@@ -32,6 +33,9 @@
namespace Retro {
RosPrintfS<bool> RosPrintf(bool value, const char* form=0,
int width=0, int prec=0);
RosPrintfS<char> RosPrintf(char value, const char* form=0,
int width=0, int prec=0);

View File

@@ -1,6 +1,6 @@
// $Id: RosPrintf.ipp 983 2018-01-02 20:35:59Z mueller $
// $Id: RosPrintf.ipp 1088 2018-12-17 17:37:00Z mueller $
//
// Copyright 2000-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2000-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-12-17 1088 1.1 add bool specialization (use c++11 std::boolalpha)
// 2011-01-30 357 1.0 Adopted from CTBprintf
// 2000-12-18 - - Last change on CTBprintf
// ---------------------------------------------------------------------------
@@ -29,6 +30,26 @@ namespace Retro {
/*!
\defgroup RosPrintf RosPrintf -- print format object creators
*/
//------------------------------------------+-----------------------------------
//! Creates a print object for the formatted output of a \c bool value.
/*!
\ingroup RosPrintf
For a full description of the of the \c RosPrintf system look into
\ref using_rosprintf.
\param value variable or expression to be printed
\param form format descriptor string
\param width field width
\param prec precision
*/
inline RosPrintfS<bool>
RosPrintf(bool value, const char* form, int width, int prec)
{
return RosPrintfS<bool>(value, form, width, prec);
}
//------------------------------------------+-----------------------------------
//! Creates a print object for the formatted output of a \c char value.
/*!

View File

@@ -1,6 +1,6 @@
// $Id: RosPrintfS.cpp 983 2018-01-02 20:35:59Z mueller $
// $Id: RosPrintfS.cpp 1089 2018-12-19 10:45:41Z mueller $
//
// Copyright 2000-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2000-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -13,6 +13,8 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-12-18 1089 1.1.1 use c++ style casts
// 2018-12-17 1088 1.1 add bool specialization (use c++11 std::boolalpha)
// 2011-02-25 364 1.0.1 allow NULL ptr for const char*, output <NULL>
// 2011-01-30 357 1.0 Adopted from CTBprintfS
// 2000-10-29 - - Last change on CTBprintfS
@@ -62,6 +64,14 @@ void RosPrintfS<T>::ToStream(std::ostream& os) const
os << setw(fWidth) << fValue;
}
//------------------------------------------+-----------------------------------
template <>
void RosPrintfS<bool>::ToStream(std::ostream& os) const
{
RiosState iostate(os, fForm, fPrec);
os << std::boolalpha << fValue;
}
//------------------------------------------+-----------------------------------
template <>
void RosPrintfS<char>::ToStream(std::ostream& os) const
@@ -73,7 +83,7 @@ void RosPrintfS<char>::ToStream(std::ostream& os) const
if (ctype == 0 || ctype == 'c') {
os << fValue;
} else {
os << (int) fValue;
os << int(fValue);
}
}
@@ -86,7 +96,7 @@ void RosPrintfS<int>::ToStream(std::ostream& os) const
os.width(fWidth);
if (ctype == 'c') {
os << (char) fValue;
os << char(fValue);
} else {
os << fValue;
}
@@ -101,7 +111,7 @@ void RosPrintfS<const char *>::ToStream(std::ostream& os) const
os.width(fWidth);
if (ctype == 'p') {
os << (const void*) fValue;
os << reinterpret_cast<const void*>(fValue);
} else {
os << (fValue?fValue:"<NULL>");
}
@@ -118,7 +128,7 @@ void RosPrintfS<const void *>::ToStream(std::ostream& os) const
if (ctype == 0 || ctype == 'p') {
os << fValue;
} else {
os << (unsigned long) fValue;
os << reinterpret_cast<unsigned long>(fValue);
}
}
@@ -128,6 +138,7 @@ void RosPrintfS<const void *>::ToStream(std::ostream& os) const
// finally do an explicit instantiation of the required RosPrintfS
template class RosPrintfS<bool>;
template class RosPrintfS<char>;
template class RosPrintfS<int>;
template class RosPrintfS<unsigned int>;

View File

@@ -1,6 +1,6 @@
// $Id: RosPrintfS.hpp 983 2018-01-02 20:35:59Z mueller $
// $Id: RosPrintfS.hpp 1088 2018-12-17 17:37:00Z mueller $
//
// Copyright 2000-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2000-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2018-12-17 1088 1.1 add bool specialization (use c++11 std::boolalpha)
// 2011-01-30 357 1.0 Adopted from CTBprintfS
// 2000-10-29 - - Last change on CTBprintfS
// ---------------------------------------------------------------------------
@@ -40,6 +41,8 @@ namespace Retro {
T fValue; //!< value to be printed
};
template <>
void RosPrintfS<bool>::ToStream(std::ostream& os) const;
template <>
void RosPrintfS<char>::ToStream(std::ostream& os) const;
template <>