diff --git a/Changes b/Changes index dee3877b30..8df251f0d6 100644 --- a/Changes +++ b/Changes @@ -14,6 +14,8 @@ Breaking Changes ---------------- - Canceller : Changed base class. +- MessageHandler : Removed support for passing `boost::format` objects to `msg()`. Use `fmt::format()` instead. +- FileSequence : Removed `fileNameTemplate()` protected method. Use `fileNameForFrame()` instead. Build ----- diff --git a/include/IECore/FileSequence.h b/include/IECore/FileSequence.h index 1df824527c..6d38643124 100644 --- a/include/IECore/FileSequence.h +++ b/include/IECore/FileSequence.h @@ -39,7 +39,6 @@ #include "IECore/FrameList.h" #include "IECore/RunTimeTyped.h" -#include "boost/format.hpp" #include "boost/regex.hpp" #include @@ -132,11 +131,6 @@ class IECORE_API FileSequence : public RunTimeTyped std::string m_fileName; FrameListPtr m_frameList; - /// Returns a boost::format for expanding out the filename with a frame number. Due to limitations in boost::format - /// we need use a different template depending on the sign of the frame number. - boost::format fileNameTemplate( bool negativeFrame ) const; - - }; } // namespace IECore diff --git a/include/IECore/MessageHandler.h b/include/IECore/MessageHandler.h index ec4889066e..8030a3bdf8 100644 --- a/include/IECore/MessageHandler.h +++ b/include/IECore/MessageHandler.h @@ -38,7 +38,6 @@ #include "IECore/Export.h" #include "IECore/RefCounted.h" -#include "boost/format.hpp" #include "boost/noncopyable.hpp" #include "fmt/format.h" @@ -82,8 +81,6 @@ class IECORE_API MessageHandler : public RefCounted //@{ /// Output a message to the current handler. static void output( Level level, const std::string &context, const std::string &message ); - /// Output a message to the current handler. - static void output( Level level, const std::string &context, const boost::format &message ); //@} //! @name Default handler @@ -156,7 +153,6 @@ typedef MessageHandler Msg; /// Free functions which calls MessageHandler::output() with their arguments. These are provided /// for brevity. IECORE_API void msg( MessageHandler::Level level, const std::string &context, const std::string &message ); -IECORE_API void msg( MessageHandler::Level level, const std::string &context, const boost::format &message ); /// Inline templated convenience function which formats the message using the provided arguments. template inline void msg( MessageHandler::Level level, const std::string &context, fmt::format_string message, Args&&... args ) diff --git a/src/IECore/FileSequence.cpp b/src/IECore/FileSequence.cpp index c04a5ecfc2..7a359e8a8c 100644 --- a/src/IECore/FileSequence.cpp +++ b/src/IECore/FileSequence.cpp @@ -37,7 +37,6 @@ #include "IECore/Exception.h" #include "boost/algorithm/string.hpp" -#include "boost/format.hpp" #include "boost/lexical_cast.hpp" #include "boost/regex.hpp" @@ -198,7 +197,9 @@ void FileSequence::setSuffix( const std::string &suffix ) std::string FileSequence::fileNameForFrame( FrameList::Frame frameNumber ) const { - return ( fileNameTemplate( frameNumber < 0 ) % frameNumber ).str(); + return fmt::format( + "{0}{1:0{2}}{3}", getPrefix(), frameNumber, getPadding() + ( frameNumber < 0 ? 1 : 0 ), getSuffix() + ); } FrameList::Frame FileSequence::frameForFileName( const std::string &fileName ) const @@ -225,17 +226,12 @@ void FileSequence::fileNames( std::vector< std::string > &f ) const { f.clear(); - boost::format posFmt = fileNameTemplate( false ); - boost::format negFmt = fileNameTemplate( true ); - std::vector< FrameList::Frame > frames; - m_frameList->asList( frames ); - for ( std::vector< FrameList::Frame >::const_iterator it = frames.begin(); it != frames.end(); ++it ) + for( auto frame : frames ) { - boost::format &fmt = *it < 0 ? negFmt : posFmt ; - f.push_back( ( fmt % *it ).str() ); + f.push_back( fileNameForFrame( frame ) ); } } @@ -243,23 +239,16 @@ void FileSequence::clumpedFileNames( unsigned clumpSize, std::vector< std::vecto { f.clear(); - boost::format posFmt = fileNameTemplate( false ); - boost::format negFmt = fileNameTemplate( true ); - std::vector< std::vector< FrameList::Frame > > clumpedFrames; m_frameList->asClumpedList( clumpedFrames, clumpSize ); - for ( std::vector< std::vector< FrameList::Frame > >::const_iterator it = clumpedFrames.begin(); it != clumpedFrames.end(); ++it ) + for( const auto &clump : clumpedFrames ) { - const std::vector< FrameList::Frame > &clump = *it; - f.push_back( std::vector< std::string >() ); - - for ( std::vector< FrameList::Frame > ::const_iterator cit = clump.begin(); cit != clump.end(); ++cit ) + for( auto frame : clump ) { - boost::format &fmt = *cit < 0 ? negFmt : posFmt ; - f.back().push_back( ( fmt % *cit ).str() ); + f.back().push_back( fileNameForFrame( frame ) ); } } } @@ -325,19 +314,3 @@ bool FileSequence::operator ==( const FileSequence &other ) const { return m_fileName == other.m_fileName && m_frameList->isEqualTo( other.m_frameList ); } - -boost::format FileSequence::fileNameTemplate( bool negativeFrame ) const -{ - unsigned padding = getPadding(); - std::string paddingStr = ""; - for ( unsigned i = 0; i < padding; i++) - { - paddingStr += "#"; - } - - std::string f = m_fileName; - boost::replace_all( f, "%", "%%" ); - boost::replace_all( f, paddingStr, ( boost::format( "%%0%dd" ) % ( negativeFrame ? padding + 1 : padding ) ).str() ); - - return boost::format( f ); -} diff --git a/src/IECore/MessageHandler.cpp b/src/IECore/MessageHandler.cpp index 73f4e673e3..834fd04491 100644 --- a/src/IECore/MessageHandler.cpp +++ b/src/IECore/MessageHandler.cpp @@ -56,12 +56,6 @@ void MessageHandler::output( Level level, const std::string &context, const std: currentHandler()->handle( level, context, message ); } -void MessageHandler::output( Level level, const std::string &context, const boost::format &message ) -{ - string m = message.str(); - output( level, context, m ); -} - /////////////////////////////////////////////////////////////////////////////////////// // default handler /////////////////////////////////////////////////////////////////////////////////////// @@ -173,8 +167,3 @@ void IECore::msg( MessageHandler::Level level, const std::string &context, const { MessageHandler::output( level, context, message ); } - -void IECore::msg( MessageHandler::Level level, const std::string &context, const boost::format &message ) -{ - MessageHandler::output( level, context, message ); -} diff --git a/src/IECoreGL/Selector.cpp b/src/IECoreGL/Selector.cpp index 5a2ce33f2c..ecf8317ae9 100644 --- a/src/IECoreGL/Selector.cpp +++ b/src/IECoreGL/Selector.cpp @@ -306,7 +306,7 @@ class Selector::Implementation : public IECore::RefCounted ////////////////////////////////////////////////////////////////////////// FrameBufferPtr m_frameBuffer; - boost::shared_ptr m_frameBufferBinding; + std::unique_ptr m_frameBufferBinding; GLint m_prevProgram; ConstShaderPtr m_currentIDShader; std::stack m_IDShaderStack; @@ -325,7 +325,7 @@ class Selector::Implementation : public IECore::RefCounted } m_frameBuffer->setDepth( new DepthTexture( 128, 128 ) ); m_frameBuffer->validate(); - m_frameBufferBinding = boost::shared_ptr( new FrameBuffer::ScopedBinding( *m_frameBuffer ) ); + m_frameBufferBinding = std::make_unique( *m_frameBuffer ); glGetIntegerv( GL_VIEWPORT, m_prevViewport ); glViewport( 0, 0, 128, 128 ); diff --git a/src/IECoreImage/ImagePrimitive.cpp b/src/IECoreImage/ImagePrimitive.cpp index 3257766067..7ce334a006 100644 --- a/src/IECoreImage/ImagePrimitive.cpp +++ b/src/IECoreImage/ImagePrimitive.cpp @@ -41,6 +41,8 @@ #include "boost/static_assert.hpp" +#include "fmt/format.h" + #include using namespace std; @@ -406,7 +408,7 @@ bool ImagePrimitive::channelValid( const IECore::Data *data, std::string *reason { if( reason ) { - *reason = str( format( "Channel has wrong size (%d but should be %d)." ) % size % numPixels ); + *reason = fmt::format( "Channel has wrong size ({} but should be {}).", size, numPixels ); } return false; } @@ -421,7 +423,7 @@ bool ImagePrimitive::channelValid( const std::string &name, std::string *reason { if( reason ) { - *reason = str( format( "Channel \"%s\" does not exist." ) % name ); + *reason = fmt::format( "Channel \"{}\" does not exist.", name ); } return false; } diff --git a/src/IECoreScene/Font.cpp b/src/IECoreScene/Font.cpp index ce2241fc4a..df124742fe 100644 --- a/src/IECoreScene/Font.cpp +++ b/src/IECoreScene/Font.cpp @@ -476,9 +476,7 @@ class Font::Implementation : public IECore::RefCounted V2f advance; }; - typedef boost::shared_ptr MeshPtr; - typedef boost::shared_ptr ConstMeshPtr; - mutable std::vector m_meshes; + mutable std::vector> m_meshes; const Mesh *cachedMesh( char c ) const { @@ -511,11 +509,11 @@ class Font::Implementation : public IECore::RefCounted transformOp->operate(); // put it in the cache - MeshPtr mesh( new Mesh ); + auto &mesh = m_meshes[c]; + mesh = std::make_unique(); mesh->primitive = primitive; mesh->bound = primitive->bound(); mesh->advance = V2f( m_face->glyph->advance.x, m_face->glyph->advance.y ) / m_face->units_per_EM; - m_meshes[c] = mesh; // return it return mesh.get(); diff --git a/src/IECoreScene/PDCParticleReader.cpp b/src/IECoreScene/PDCParticleReader.cpp index 0057c5ef81..6942e77ce5 100644 --- a/src/IECoreScene/PDCParticleReader.cpp +++ b/src/IECoreScene/PDCParticleReader.cpp @@ -124,7 +124,7 @@ bool PDCParticleReader::open() if( m_header.version > 1 ) { - msg( Msg::Warning, "PDCParticleReader::open()", format( "File \"%s\" has unknown version %d." ) % fileName() % m_header.version ); + msg( Msg::Warning, "PDCParticleReader::open()", "File \"{}\" has unknown version {}.", fileName(), m_header.version ); } int unused = 0; @@ -262,7 +262,7 @@ DataPtr PDCParticleReader::readAttribute( const std::string &name ) const Data *idAttr = idAttribute(); if ( !idAttr && particlePercentage() < 100.0f ) { - msg( Msg::Warning, "PDCParticleReader::filterAttr", format( "Percentage filtering requested but file \"%s\" contains no particle Id attribute." ) % fileName() ); + msg( Msg::Warning, "PDCParticleReader::filterAttr", "Percentage filtering requested but file \"{}\" contains no particle Id attribute.", fileName() ); } DataPtr result = nullptr; diff --git a/src/IECoreScene/PDCParticleWriter.cpp b/src/IECoreScene/PDCParticleWriter.cpp index 073d9ecf5b..cf85853db3 100644 --- a/src/IECoreScene/PDCParticleWriter.cpp +++ b/src/IECoreScene/PDCParticleWriter.cpp @@ -152,7 +152,7 @@ void PDCParticleWriter::doWrite( const CompoundObject *operands ) } else { - msg( Msg::Warning, "PDCParticleWriter::write", format( "Attribute \"%s\" is of unsupported type \"%s\"." ) % *it % attr->typeName() ); + msg( Msg::Warning, "PDCParticleWriter::write", "Attribute \"{}\" is of unsupported type \"{}\".", *it, attr->typeName() ); } } diff --git a/src/IECoreScene/ParticleReader.cpp b/src/IECoreScene/ParticleReader.cpp index 4f78a76b21..ac061b0ac6 100644 --- a/src/IECoreScene/ParticleReader.cpp +++ b/src/IECoreScene/ParticleReader.cpp @@ -190,7 +190,7 @@ ObjectPtr ParticleReader::doOperation( const CompoundObject * operands ) } else { - msg( Msg::Warning, "ParticleReader::doOperation", format( "Ignoring attribute \"%s\" due to insufficient elements (expected %d but found %d)." ) % *it % result->getNumPoints() % s ); + msg( Msg::Warning, "ParticleReader::doOperation", "Ignoring attribute \"{}\" due to insufficient elements (expected {} but found {}).", *it, result->getNumPoints(), s ); } } else if ( testTypedData( d.get() ) ) diff --git a/src/IECoreScene/ParticleWriter.cpp b/src/IECoreScene/ParticleWriter.cpp index b7bd3ff572..0368514c15 100644 --- a/src/IECoreScene/ParticleWriter.cpp +++ b/src/IECoreScene/ParticleWriter.cpp @@ -95,7 +95,7 @@ void ParticleWriter::particleAttributes( std::vector &names ) } else { - msg( Msg::Warning, "ParticleWriter::particleAttributes", format( "Ignoring attribute \"%s\" due to insufficient elements (expected %d but found %d)." ) % it->first % numParticles % s ); + msg( Msg::Warning, "ParticleWriter::particleAttributes", "Ignoring attribute \"{}\" due to insufficient elements (expected {} but found {}).", it->first, numParticles, s ); } } else if ( testTypedData( it->second.data.get() ) ) @@ -124,7 +124,7 @@ void ParticleWriter::particleAttributes( std::vector &names ) } else { - msg( Msg::Warning, "ParticleWriter::particleAttributes", format( "Attribute \"%s\" requested via parameters but is not available." ) % *it ); + msg( Msg::Warning, "ParticleWriter::particleAttributes", "Attribute \"{}\" requested via parameters but is not available.", *it ); } } } diff --git a/src/IECoreScene/PointsAlgoSegment.cpp b/src/IECoreScene/PointsAlgoSegment.cpp index 39a9f20ad9..b1151d2ff4 100644 --- a/src/IECoreScene/PointsAlgoSegment.cpp +++ b/src/IECoreScene/PointsAlgoSegment.cpp @@ -39,8 +39,6 @@ #include "IECore/DespatchTypedData.h" #include "IECore/TypeTraits.h" -#include "boost/format.hpp" - using namespace IECore; using namespace IECoreScene; using namespace Imath; diff --git a/src/IECoreScene/SceneCache.cpp b/src/IECoreScene/SceneCache.cpp index 84d8493a94..35ec4e9dd7 100644 --- a/src/IECoreScene/SceneCache.cpp +++ b/src/IECoreScene/SceneCache.cpp @@ -1403,7 +1403,7 @@ class SceneCache::WriterImplementation : public SceneCache::Implementation { std::string prefix = "SceneCache::writeObject"; std::string details = fmt::format( - "object written at previous time: %1%,\nSample times must be written sequentially for each object.", + "object written at previous time: {},\nSample times must be written sequentially for each object.", *(m_objectSampleTimes.rbegin()) ); throwException( prefix, time, details );