Commit 41fdc166 authored by Marco Clemencic's avatar Marco Clemencic

Merge branch '112-add-example-of-use-of-fmtlib'

Use fmtlib instead of boost::format (where possible)

Closes #112

See merge request !1046
parents f967f29d 784ab199
Pipeline #1730393 passed with stages
in 29 minutes and 17 seconds
#####################################################################################
# (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2020 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -39,6 +39,14 @@ include(${CMAKE_SOURCE_DIR}/cmake/externals.cmake)
# Declare project name and version
gaudi_project(Gaudi v33r1)
# Special hack to make sure downstream projects see fmt::fmt
# This is going to be much cleaner with gaudi/Gaudi!986 (CMake modernization)
if(EXISTS ${CMAKE_CONFIG_OUTPUT_DIRECTORY}/GaudiPlatformConfig.cmake)
file(APPEND ${CMAKE_CONFIG_OUTPUT_DIRECTORY}/GaudiPlatformConfig.cmake "
find_package(fmt REQUIRED)
")
endif()
# These tests do not really fit in a subdirectory.
add_test(NAME cmake.CMakeModules
COMMAND nosetests ${CMAKE_SOURCE_DIR}/cmake/tests)
......
/***********************************************************************************\
* (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
* (c) Copyright 1998-2020 CERN for the benefit of the LHCb and ATLAS collaborations *
* *
* This software is distributed under the terms of the Apache version 2 licence, *
* copied verbatim in the file "LICENSE". *
......@@ -9,14 +9,6 @@
* or submit itself to any jurisdiction. *
\***********************************************************************************/
// ============================================================================
// include files
// ============================================================================
// STL & STD
// ============================================================================
#include <algorithm>
#include <cstdlib>
#include <numeric>
// ============================================================================
/* @file GaudiCommon.cpp
*
* Implementation file for class : GaudiCommon
......@@ -26,8 +18,12 @@
* @author Rob Lambert Rob.Lambert@cern.ch
* @date 2009-08-04
*/
// GaudiKernel
// ============================================================================
#include "GaudiAlg/GaudiCommon.h"
#include "GaudiAlg/GaudiAlgorithm.h"
#include "GaudiAlg/GaudiTool.h"
#include "GaudiAlg/Print.h"
#include "GaudiKernel/AlgTool.h"
#include "GaudiKernel/Algorithm.h"
#include "GaudiKernel/IDataManagerSvc.h"
......@@ -45,28 +41,11 @@
#include "GaudiKernel/StatEntity.h"
#include "GaudiKernel/System.h"
#include "GaudiKernel/reverse.h"
// ============================================================================
// GaudiAlg
// ============================================================================
#include "GaudiAlg/GaudiAlgorithm.h"
#include "GaudiAlg/GaudiCommon.h"
#include "GaudiAlg/GaudiTool.h"
#include "GaudiAlg/Print.h"
// ============================================================================
// GaudiUtils
// ============================================================================
#include "GaudiUtils/RegEx.h"
// ============================================================================
// Boost
// ============================================================================
#include "boost/format.hpp"
#include "boost/tokenizer.hpp"
// ============================================================================
// Disable warning on windows
#ifdef _WIN32
# pragma warning( disable : 4661 ) // incomplete explicit templates
#endif
// ============================================================================
#include <algorithm>
#include <cstdlib>
#include <fmt/format.h>
#include <numeric>
// ============================================================================
// constructor initialisation
......@@ -450,11 +429,11 @@ long GaudiCommon<PBASE>::printStat( const MSG::Level level ) const {
// ============================================================================
template <class PBASE>
long GaudiCommon<PBASE>::printErrors( const MSG::Level level ) const {
// format for printout
boost::format ftm( " #%|-10s| = %|.8s| %|23t| Message = '%s'" );
auto print = [&]( const Counter& c, const auto& label ) {
for ( const auto& i : c ) { this->msgStream( level ) << ( ftm % label % i.second % i.first ) << endmsg; }
for ( const auto& i : c ) {
this->msgStream( level ) << fmt::format( " #{:<10s} = {:<8d} Message = '{}'", label, i.second, i.first )
<< endmsg;
}
};
print( m_exceptions, "EXCEPTIONS" );
......
/***********************************************************************************\
* (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
* (c) Copyright 1998-2020 CERN for the benefit of the LHCb and ATLAS collaborations *
* *
* This software is distributed under the terms of the Apache version 2 licence, *
* copied verbatim in the file "LICENSE". *
......@@ -8,39 +8,23 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\***********************************************************************************/
// ============================================================================
// Include files
// ============================================================================
// STD & STL
// ============================================================================
#include <ctype.h>
#include <functional>
#include <string>
#include <vector>
// ============================================================================
// AIDA
// ============================================================================
#include "GaudiAlg/Print.h"
#include "AIDA/IHistogram1D.h"
#include "AIDA/IHistogram2D.h"
#include "AIDA/IHistogram3D.h"
#include "AIDA/IProfile1D.h"
#include "AIDA/IProfile2D.h"
// ============================================================================
// GaudiKernel
// ============================================================================
#include "GaudiAlg/HistoID.h"
#include "GaudiKernel/DataObject.h"
#include "GaudiKernel/INTuple.h"
#include "GaudiKernel/IRegistry.h"
#include "GaudiKernel/StatEntity.h"
// ============================================================================
// GaudiAlg
// ============================================================================
#include "GaudiAlg/HistoID.h"
#include "GaudiAlg/Print.h"
// ============================================================================
// Boost
// ============================================================================
#include "boost/format.hpp"
#include <ctype.h>
#include <fmt/format.h>
#include <fmt/ostream.h>
#include <functional>
#include <string>
#include <vector>
// ============================================================================
/** @file
* Implementation file for functions for namespace GaudiAlg::Print
......@@ -70,12 +54,9 @@ void GaudiAlg::Print1D::print( MsgStream& stream, const AIDA::IHistogram1D* aida
}
// ============================================================================
std::string GaudiAlg::Print1D::toString( const AIDA::IHistogram1D* aida, const GaudiAlg::HistoID& ID ) {
boost::format fmt( " ID=%|-25|%|30t| \"%|.45s|\" %|79t| Ents/All=%|5|/%|-5|<X>/sX=%|.5|/%|-.5|" );
fmt % ID.idAsString() % aida->title();
fmt % ( aida->allEntries() - aida->extraEntries() ) % aida->allEntries();
fmt % aida->mean() % aida->rms();
//
return fmt.str();
return fmt::format( " ID={:25} {:47} Ents/All={:>5}/{:<5}<X>/sX={:.5g}/{:<.5g}", ID.idAsString(),
fmt::format( "\"{:.45}\"", aida->title() ), ( aida->allEntries() - aida->extraEntries() ),
aida->allEntries(), aida->mean(), aida->rms() );
}
// ============================================================================
void GaudiAlg::Print2D::print( MsgStream& stream, const AIDA::IHistogram2D* aida, const GaudiAlg::HistoID& ID ) {
......@@ -83,13 +64,10 @@ void GaudiAlg::Print2D::print( MsgStream& stream, const AIDA::IHistogram2D* aida
}
// ============================================================================
std::string GaudiAlg::Print2D::toString( const AIDA::IHistogram2D* aida, const GaudiAlg::HistoID& ID ) {
boost::format fmt( " ID=%|-25|%|30t| \"%|.45s|\" %|79t| Ents/All=%|5|/%|-5|<X>/sX=%|.5|/%|-.5|,<Y>/sY=%|.5|/%|-.5|" );
fmt % ID.idAsString() % aida->title();
fmt % ( aida->allEntries() - aida->extraEntries() ) % aida->allEntries();
fmt % aida->meanX() % aida->rmsX();
fmt % aida->meanY() % aida->rmsY();
//
return fmt.str();
return fmt::format( " ID={:25} {:47} Ents/All={:>5}/{:<5}<X>/sX={:.5g}/{:<.5g},<Y>/sY={:.5g}/{:<.5g}",
ID.idAsString(), fmt::format( "\"{:.45}\"", aida->title() ),
( aida->allEntries() - aida->extraEntries() ), aida->allEntries(), aida->meanX(), aida->rmsX(),
aida->meanY(), aida->rmsY() );
}
// ============================================================================
void GaudiAlg::Print3D::print( MsgStream& stream, const AIDA::IHistogram3D* aida, const GaudiAlg::HistoID& ID ) {
......@@ -97,15 +75,10 @@ void GaudiAlg::Print3D::print( MsgStream& stream, const AIDA::IHistogram3D* aida
}
// ============================================================================
std::string GaudiAlg::Print3D::toString( const AIDA::IHistogram3D* aida, const GaudiAlg::HistoID& ID ) {
boost::format fmt( " ID=%|-25|%|30t| \"%|.45s|\" %|79t| "
"Ents/All=%|5|/%|-5|<X>/sX=%|.5|/%|-.5|,<Y>/sY=%|.5|/%|-.5|,<Z>/sZ=%|.5|/%|-.5|" );
fmt % ID.idAsString() % aida->title();
fmt % ( aida->allEntries() - aida->extraEntries() ) % aida->allEntries();
fmt % aida->meanX() % aida->rmsX();
fmt % aida->meanY() % aida->rmsY();
fmt % aida->meanZ() % aida->rmsZ();
//
return fmt.str();
return fmt::format(
" ID={:25} {:47} Ents/All={:>5}/{:<5}<X>/sX={:.5g}/{:<.5g},<Y>/sY={:.5g}/{:<.5g},<Z>/sZ={:.5g}/{:<.5g}",
ID.idAsString(), fmt::format( "\"{:.45}\"", aida->title() ), ( aida->allEntries() - aida->extraEntries() ),
aida->allEntries(), aida->meanX(), aida->rmsX(), aida->meanY(), aida->rmsY(), aida->meanZ(), aida->rmsZ() );
}
// ============================================================================
void GaudiAlg::Print1DProf::print( MsgStream& stream, const AIDA::IProfile1D* aida, const GaudiAlg::HistoID& ID ) {
......@@ -113,12 +86,9 @@ void GaudiAlg::Print1DProf::print( MsgStream& stream, const AIDA::IProfile1D* ai
}
// ============================================================================
std::string GaudiAlg::Print1DProf::toString( const AIDA::IProfile1D* aida, const GaudiAlg::HistoID& ID ) {
boost::format fmt( " ID=%|-25|%|30t| \"%|.55s|\" %|79t| Ents/All=%|5|/%|-5|<X>/sX=%|.5|/%|-.5|" );
fmt % ID.idAsString() % aida->title();
fmt % ( aida->allEntries() - aida->extraEntries() ) % aida->allEntries();
fmt % aida->mean() % aida->rms();
//
return fmt.str();
return fmt::format( " ID={:25} {:47} Ents/All={:>5}/{:<5}<X>/sX={:.5g}/{:<.5g}", ID.idAsString(),
fmt::format( "\"{:.45}\"", aida->title() ), ( aida->allEntries() - aida->extraEntries() ),
aida->allEntries(), aida->mean(), aida->rms() );
}
// ============================================================================
void GaudiAlg::Print2DProf::print( MsgStream& stream, const AIDA::IProfile2D* aida, const GaudiAlg::HistoID& ID ) {
......@@ -126,13 +96,10 @@ void GaudiAlg::Print2DProf::print( MsgStream& stream, const AIDA::IProfile2D* ai
}
// ============================================================================
std::string GaudiAlg::Print2DProf::toString( const AIDA::IProfile2D* aida, const GaudiAlg::HistoID& ID ) {
boost::format fmt( " ID=%|-25|%|30t| \"%|.55s|\" %|79t| Ents/All=%|5|/%|-5|<X>/sX=%|.5|/%|-.5|,<Y>/sY=%|.5|/%|-.5|" );
fmt % ID.idAsString() % aida->title();
fmt % ( aida->allEntries() - aida->extraEntries() ) % aida->allEntries();
fmt % aida->meanX() % aida->rmsX();
fmt % aida->meanY() % aida->rmsY();
//
return fmt.str();
return fmt::format( " ID={:25} {:47} Ents/All={:>5}/{:<5}<X>/sX={:.5g}/{:<.5g},<Y>/sY={:.5g}/{:<.5g}",
ID.idAsString(), fmt::format( "\"{:.45}\"", aida->title() ),
( aida->allEntries() - aida->extraEntries() ), aida->allEntries(), aida->meanX(), aida->rmsX(),
aida->meanY(), aida->rmsY() );
}
// ============================================================================
std::string GaudiAlg::PrintStat::print( const StatEntity& stat, const std::string& tag ) {
......@@ -142,9 +109,7 @@ std::string GaudiAlg::PrintStat::print( const StatEntity& stat, const std::strin
}
// ============================================================================
std::string GaudiAlg::PrintTuple::print( const INTuple* tuple, const GaudiAlg::TupleID& ID ) {
boost::format fmt( " ID=%|-12|%|18t|%|-s|" );
fmt % ID.idAsString() % print( tuple );
return fmt.str();
return fmt::format( " ID={:<14}{}", ID.idAsString(), print( tuple ) );
}
// ============================================================================
namespace {
......@@ -162,11 +127,8 @@ namespace {
} // namespace
// ============================================================================
std::string GaudiAlg::PrintTuple::print( const INTuple* tuple ) {
boost::format fmt( "Title=\"%|.39s|\" %|48t|#items=%|-3|%|50t|{%|.81s|}" );
fmt % tuple->title();
fmt % tuple->items().size();
fmt % _print( tuple->items() );
return fmt.str();
return fmt::format( "Title={:41} #items={:<3}{{{:.81}}}", fmt::format( "\"{:.39}\"", tuple->title() ),
tuple->items().size(), _print( tuple->items() ) );
}
// ============================================================================
......
/***********************************************************************************\
* (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
* (c) Copyright 1998-2020 CERN for the benefit of the LHCb and ATLAS collaborations *
* *
* This software is distributed under the terms of the Apache version 2 licence, *
* copied verbatim in the file "LICENSE". *
......@@ -8,18 +8,7 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\***********************************************************************************/
// ============================================================================
// Include files
// ============================================================================
// STD & STL
// ============================================================================
#include <map>
#include <math.h>
#include <set>
#include <string>
// ============================================================================
// GaudiKernel
// ============================================================================
#include "DataOnDemandSvc.h"
#include "GaudiKernel/AttribStringParser.h"
#include "GaudiKernel/Chrono.h"
#include "GaudiKernel/DataIncident.h"
......@@ -36,15 +25,11 @@
#include "GaudiKernel/ThreadLocalContext.h"
#include "GaudiKernel/ToStream.h"
#include "GaudiKernel/TypeNameString.h"
// ============================================================================
// Local
// ============================================================================
#include "DataOnDemandSvc.h"
// ============================================================================
// Boost
// ============================================================================
#include "boost/algorithm/string/predicate.hpp"
#include "boost/format.hpp"
#include <fmt/format.h>
#include <map>
#include <math.h>
#include <set>
#include <string>
// ============================================================================
// anonymous namespace to hide few local functions
// ============================================================================
......@@ -664,26 +649,17 @@ void DataOnDemandSvc::dump( const MSG::Level level, const bool mode ) const {
//
if ( _m.empty() ) { return; }
// find the correct formats
size_t n1 = 0;
size_t n2 = 0;
// set width of the columns
size_t n1 = 10; // minimum width
size_t n2 = 10; // minimum width
size_t n3 = 0;
for ( const auto& i : _m ) {
n1 = std::max( n1, i.first.size() );
n2 = std::max( n2, i.second.first.size() );
n3 = std::max( n3, i.second.second.size() );
}
if ( 10 > n1 ) { n1 = 10; }
if ( 10 > n2 ) { n2 = 10; }
if ( 60 < n1 ) { n1 = 60; }
if ( 60 < n2 ) { n2 = 60; }
//
const std::string _f = " | %%1$-%1%.%1%s | %%2$-%2%.%2%s | %%3$%3%.%3%s |";
boost::format _ff( _f );
_ff % n1 % n2 % n3;
const std::string _format = _ff.str();
n1 = std::min( n1, size_t{60} ); // maximum width
n2 = std::min( n2, size_t{60} ); // maximum width
auto& msg = msgStream( level );
......@@ -693,19 +669,15 @@ void DataOnDemandSvc::dump( const MSG::Level level, const bool mode ) const {
msg << "Data-On-Demand Actions has been used for:";
}
boost::format fmt1( _format );
fmt1 % "Address" % "Creator" % ( mode ? "S" : "#" );
//
const std::string header = fmt1.str();
std::string line = std::string( header.size(), '-' );
line[0] = ' ';
const auto header = fmt::format( " | {3:<{0}.{0}s} | {4:<{1}.{1}s} | {5:>{2}.{2}s} |", n1, n2, n3, "Address",
"Creator", ( mode ? "S" : "#" ) );
const auto line = fmt::format( " {0:-^{1}}", "", header.size() - 1 );
msg << '\n' << line << '\n' << header << '\n' << line;
// make the actual printout:
for ( const auto& item : _m ) {
boost::format fmt( _format );
msg << '\n' << ( fmt % item.first % item.second.first % item.second.second );
msg << fmt::format( "\n | {3:<{0}.{0}s} | {4:<{1}.{1}s} | {5:>{2}.{2}s} |", n1, n2, n3, item.first,
item.second.first, item.second.second );
}
msg << '\n' << line << endmsg;
......
/***********************************************************************************\
* (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
* (c) Copyright 1998-2020 CERN for the benefit of the LHCb and ATLAS collaborations *
* *
* This software is distributed under the terms of the Apache version 2 licence, *
* copied verbatim in the file "LICENSE". *
......@@ -8,18 +8,9 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\***********************************************************************************/
// ============================================================================
// STD:
// ============================================================================
#include <iostream>
#include <memory>
// ============================================================================
// BOOST:
// ============================================================================
#include <boost/format.hpp>
// ============================================================================
#include "Analyzer.h"
#include "Catalog.h"
#include "GaudiKernel/Environment.h"
#include "IncludedFiles.h"
#include "Messages.h"
#include "Node.h"
......@@ -28,11 +19,12 @@
#include "PropertyName.h"
#include "PropertyValue.h"
#include "Units.h"
// ============================================================================
#include "GaudiKernel/Environment.h"
// ============================================================================
#include <fmt/format.h>
#include <iostream>
#include <memory>
namespace gp = Gaudi::Parsers;
// ============================================================================
static bool IncludeNode( gp::Node* node, const std::string& search_path, gp::IncludedFiles* included,
gp::Messages* messages ) {
gp::Node include_root;
......@@ -203,9 +195,10 @@ static bool AssignNode( const gp::Node* node, gp::Messages* messages, gp::Catalo
// ----------------------------------------------------------------------
try {
if ( node->children[1].type == gp::Node::kEqual ) {
std::string message = str( boost::format( "Reassignment of option '%1%' ." ) % property->FullName() );
std::string message = fmt::format( "Reassignment of option '{}'.", property->FullName() );
if ( exists->HasDefinedPosition() ) {
message += " Previously defined at " + exists->DefinedPosition().ToString() + ".";
message += fmt::format( " Previously defined at {}.", exists->DefinedPosition().ToString() );
}
reassign = true;
// INFO: we don't need this warning
......@@ -218,7 +211,7 @@ static bool AssignNode( const gp::Node* node, gp::Messages* messages, gp::Catalo
} catch ( const gp::PropertyValueException& ex ) {
std::string message = ex.what();
if ( exists->HasDefinedPosition() ) {
message += " Previously defined at " + exists->DefinedPosition().ToString() + ".";
message += fmt::format( " Previously defined at {}.", exists->DefinedPosition().ToString() );
}
messages->AddError( node->position, message );
return false;
......@@ -228,9 +221,9 @@ static bool AssignNode( const gp::Node* node, gp::Messages* messages, gp::Catalo
bool result = true;
if ( !exists || reassign ) { result = catalog->Add( new gp::Property( *property, *value ) ); }
if ( result && is_print ) { /*;%|72t|%2% %3%*/
std::string message = str( boost::format( "%1% %2% %3%" ) % property->FullName() %
SignString( node->children[1].type ) % value->ToString() );
if ( result && is_print ) {
std::string message =
fmt::format( "{} {} {}", property->FullName(), SignString( node->children[1].type ), value->ToString() );
messages->AddInfo( node->position, message );
}
return result;
......@@ -244,7 +237,7 @@ static bool UnitNode( const gp::Node* node, gp::Messages* messages, gp::Units* u
// --------------------------------------------------------------------------
gp::Units::Container::mapped_type exists;
if ( units->Find( name, exists ) ) {
std::string message = str( boost::format( "Unit '%1%' already defined" ) % name );
std::string message = fmt::format( "Unit '{}' already defined", name );
if ( exists.second.Exists() ) { message += " at " + exists.second.ToString(); }
messages->AddError( node->children[1].position, message );
return false;
......@@ -252,7 +245,7 @@ static bool UnitNode( const gp::Node* node, gp::Messages* messages, gp::Units* u
// --------------------------------------------------------------------------
bool result = units->Add( name, right / left, node->children[1].position );
if ( result && is_print ) {
std::string message = str( boost::format( "%1% %2% = %3%" ) % left % name % right );
std::string message = fmt::format( "{} {} = {}", left, name, right );
messages->AddInfo( node->position, message );
}
return result;
......
/***********************************************************************************\
* (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
* (c) Copyright 1998-2020 CERN for the benefit of the LHCb and ATLAS collaborations *
* *
* This software is distributed under the terms of the Apache version 2 licence, *
* copied verbatim in the file "LICENSE". *
......@@ -8,17 +8,10 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\***********************************************************************************/
// ============================================================================
#include "Catalog.h"
// ============================================================================
// Boost:
// ============================================================================
#include <boost/format.hpp>
// ============================================================================
// Namesapce aliases:
// ============================================================================
#include <fmt/format.h>
namespace gp = Gaudi::Parsers;
// ============================================================================
namespace {
constexpr struct select1st_t {
template <typename S, typename T>
......@@ -31,7 +24,7 @@ namespace {
}
} select1st{};
} // namespace
// ============================================================================
std::vector<std::string> gp::Catalog::ClientNames() const {
std::vector<std::string> result;
std::transform( std::begin( catalog_ ), std::end( catalog_ ), std::back_inserter( result ), select1st );
......@@ -72,23 +65,26 @@ std::string gp::Catalog::ToString() const {
// print the content of the catalogue to std::ostream
// ============================================================================
std::ostream& Gaudi::Parsers::Catalog::fillStream( std::ostream& o ) const {
o << "// " << std::string( 82, '=' ) << std::endl
<< "// Parser catalog " << std::endl
<< "// " << std::string( 82, '=' ) << std::endl;
o << R"(// ==================================================================================
// Parser catalog
// ==================================================================================
)";
size_t nComponents = 0;
size_t nProperties = 0;
for ( const auto& client : catalog_ ) {
o << boost::format( "// Properties of '%1%' %|43t|# = %2%" ) % client.first % client.second.size() << std::endl;
o << fmt::format( "// Properties of {:<25} # = {}", fmt::format( "'{}'", client.first ), client.second.size() );
++nComponents;
nProperties += client.second.size();
for ( const auto& current : client.second ) {
o << boost::format( "%1% %|44t| = %2% ; " ) % current.FullName() % current.ValueAsString() << '\n';
o << fmt::format( "{:<44} = {} ;", current.FullName(), current.ValueAsString() );
}
}
o << "// " << std::string( 82, '=' ) << '\n'
<< boost::format( "// End parser catalog #Components=%1% #Properties=%2%" ) % nComponents % nProperties << '\n'
<< "// " << std::string( 82, '=' ) << std::endl;
o << fmt::format( R"(// ==================================================================================
// End parser catalog #Components={1} #Properties={2}
// ==================================================================================
)",
nComponents, nProperties );
return o;
}
/***********************************************************************************\
* (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
* (c) Copyright 1998-2020 CERN for the benefit of the LHCb and ATLAS collaborations *
* *
* This software is distributed under the terms of the Apache version 2 licence, *
* copied verbatim in the file "LICENSE". *
......@@ -8,27 +8,18 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\***********************************************************************************/
// ============================================================================
// INCLUDE
// ============================================================================
#include "Messages.h"
// ============================================================================
// BOOST:
// ============================================================================
#include <boost/format.hpp>
// ============================================================================
// Namespaces:
// ============================================================================
#include <fmt/format.h>
namespace gp = Gaudi::Parsers;
// ============================================================================
// ============================================================================
void gp::Messages::AddMessage( MSG::Level level, const std::string& message ) { stream_ << level << message << endmsg; }
// ============================================================================
void gp::Messages::AddMessage( MSG::Level level, const Position& pos, const std::string& message ) {
if ( pos.filename() != m_currentFilename ) {
stream_ << level << "# =======> " << pos.filename() << endmsg;
m_currentFilename = pos.filename();
}
stream_ << level << "# " << boost::format( "(%1%,%2%): %3%" ) % pos.line() % pos.column() % message << endmsg;
stream_ << level << fmt::format( "# ({},{}): {}", pos.line(), pos.column(), message ) << endmsg;
}
// ============================================================================
/***********************************************************************************\
* (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
* (c) Copyright 1998-2020 CERN for the benefit of the LHCb and ATLAS collaborations *
* *
* This software is distributed under the terms of the Apache version 2 licence, *
* copied verbatim in the file "LICENSE". *
......@@ -8,27 +8,18 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\***********************************************************************************/
// ============================================================================
// STD:
// ============================================================================
#include <fstream>
// ============================================================================
// BOOST:
// ============================================================================
#include <boost/filesystem.hpp>
#include <boost/format.hpp>
// ============================================================================
#include "Parser.h"
#include "GaudiKernel/PathResolver.h"
#include "Grammar.h"
#include "IncludedFiles.h"
#include "Iterator.h"
#include "Messages.h"
#include "Node.h"
#include "Parser.h"
#include "Utils.h"
// ============================================================================
// Gaudi:
// ============================================================================
#include "GaudiKernel/PathResolver.h"
#include <boost/filesystem.hpp>
#include <fmt/format.h>
#include <fstream>
// ============================================================================
namespace classic = boost::spirit::classic;
namespace bf = boost::filesystem;
......@@ -113,8 +104,8 @@ namespace {
return ParseStream<Grammar>( file, absolute_path, messages, root );
} else {
assert( included_from != NULL );
messages->AddWarning( from, str( boost::format( "File %1% already included from %2%" ) % absolute_path %
included_from->ToString() ) );
messages->AddWarning(
from, fmt::format( "File {} already included from {}", absolute_path, included_from->ToString() ) );
return true;
}
}
......
/***********************************************************************************\
* (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
* (c) Copyright 1998-2020 CERN for the benefit of the LHCb and ATLAS collaborations *
* *
* This software is distributed under the terms of the Apache version 2 licence, *
* copied verbatim in the file "LICENSE". *
......@@ -8,18 +8,9 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\***********************************************************************************/
// ============================================================================
// Include files
// ============================================================================
#include "Position.h"
// ============================================================================
// STD & STL:
// ============================================================================
#include <fmt/format.h>
#include <string>
// ============================================================================
// Boost:
// ============================================================================
#include <boost/format.hpp>
std::string Gaudi::Parsers::Position::ToString() const {
return str( boost::format( "%1%: (%2%, %3%)" ) % filename_ % line_ % column_ );
return fmt::format( "{}: ({}, {})", filename_, line_, column_ );
}
......@@ -14,34 +14,21 @@
# pragma warning( disable : 2259 )
#endif
// ============================================================================
// Include files
// ============================================================================
// ROOT
// ============================================================================
#include "TH1D.h"
#include "TH2D.h"
#include "TH3D.h"
#include "TProfile.h"
#include "TProfile2D.h"
// ============================================================================
// AIDA
// ============================================================================
#include "GaudiUtils/Aida2ROOT.h"
#include "AIDA/IHistogram1D.h"
#include "AIDA/IHistogram2D.h"
#include "AIDA/IHistogram3D.h"
#include "AIDA/IProfile1D.h"
#include "AIDA/IProfile2D.h"
// ============================================================================
// GaudiAlg
// ============================================================================
#include "GaudiAlg/GaudiHistoAlg.h"
#include "GaudiUtils/Aida2ROOT.h"
#include "GaudiUtils/HistoStats.h"
// ============================================================================