Skip to content

Commit bece337

Browse files
authored
Merge pull request #1515 from johnhaddon/formatFollowup
Boost format stray roundup
2 parents 75d4aea + c022231 commit bece337

File tree

14 files changed

+26
-74
lines changed

14 files changed

+26
-74
lines changed

Changes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Breaking Changes
1919
----------------
2020

2121
- Canceller : Changed base class.
22+
- MessageHandler : Removed support for passing `boost::format` objects to `msg()`. Use `fmt::format()` instead.
23+
- FileSequence : Removed `fileNameTemplate()` protected method. Use `fileNameForFrame()` instead.
2224

2325
Build
2426
-----

include/IECore/FileSequence.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include "IECore/FrameList.h"
4040
#include "IECore/RunTimeTyped.h"
4141

42-
#include "boost/format.hpp"
4342
#include "boost/regex.hpp"
4443

4544
#include <string>
@@ -132,11 +131,6 @@ class IECORE_API FileSequence : public RunTimeTyped
132131
std::string m_fileName;
133132
FrameListPtr m_frameList;
134133

135-
/// Returns a boost::format for expanding out the filename with a frame number. Due to limitations in boost::format
136-
/// we need use a different template depending on the sign of the frame number.
137-
boost::format fileNameTemplate( bool negativeFrame ) const;
138-
139-
140134
};
141135

142136
} // namespace IECore

include/IECore/MessageHandler.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include "IECore/Export.h"
3939
#include "IECore/RefCounted.h"
4040

41-
#include "boost/format.hpp"
4241
#include "boost/noncopyable.hpp"
4342

4443
#include "fmt/format.h"
@@ -82,8 +81,6 @@ class IECORE_API MessageHandler : public RefCounted
8281
//@{
8382
/// Output a message to the current handler.
8483
static void output( Level level, const std::string &context, const std::string &message );
85-
/// Output a message to the current handler.
86-
static void output( Level level, const std::string &context, const boost::format &message );
8784
//@}
8885

8986
//! @name Default handler
@@ -156,7 +153,6 @@ typedef MessageHandler Msg;
156153
/// Free functions which calls MessageHandler::output() with their arguments. These are provided
157154
/// for brevity.
158155
IECORE_API void msg( MessageHandler::Level level, const std::string &context, const std::string &message );
159-
IECORE_API void msg( MessageHandler::Level level, const std::string &context, const boost::format &message );
160156
/// Inline templated convenience function which formats the message using the provided arguments.
161157
template <typename... Args>
162158
inline void msg( MessageHandler::Level level, const std::string &context, fmt::format_string<Args...> message, Args&&... args )

src/IECore/FileSequence.cpp

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include "IECore/Exception.h"
3838

3939
#include "boost/algorithm/string.hpp"
40-
#include "boost/format.hpp"
4140
#include "boost/lexical_cast.hpp"
4241
#include "boost/regex.hpp"
4342

@@ -198,7 +197,9 @@ void FileSequence::setSuffix( const std::string &suffix )
198197

199198
std::string FileSequence::fileNameForFrame( FrameList::Frame frameNumber ) const
200199
{
201-
return ( fileNameTemplate( frameNumber < 0 ) % frameNumber ).str();
200+
return fmt::format(
201+
"{0}{1:0{2}}{3}", getPrefix(), frameNumber, getPadding() + ( frameNumber < 0 ? 1 : 0 ), getSuffix()
202+
);
202203
}
203204

204205
FrameList::Frame FileSequence::frameForFileName( const std::string &fileName ) const
@@ -225,41 +226,29 @@ void FileSequence::fileNames( std::vector< std::string > &f ) const
225226
{
226227
f.clear();
227228

228-
boost::format posFmt = fileNameTemplate( false );
229-
boost::format negFmt = fileNameTemplate( true );
230-
231229
std::vector< FrameList::Frame > frames;
232-
233230
m_frameList->asList( frames );
234231

235-
for ( std::vector< FrameList::Frame >::const_iterator it = frames.begin(); it != frames.end(); ++it )
232+
for( auto frame : frames )
236233
{
237-
boost::format &fmt = *it < 0 ? negFmt : posFmt ;
238-
f.push_back( ( fmt % *it ).str() );
234+
f.push_back( fileNameForFrame( frame ) );
239235
}
240236
}
241237

242238
void FileSequence::clumpedFileNames( unsigned clumpSize, std::vector< std::vector < std::string > > &f ) const
243239
{
244240
f.clear();
245241

246-
boost::format posFmt = fileNameTemplate( false );
247-
boost::format negFmt = fileNameTemplate( true );
248-
249242
std::vector< std::vector< FrameList::Frame > > clumpedFrames;
250243

251244
m_frameList->asClumpedList( clumpedFrames, clumpSize );
252245

253-
for ( std::vector< std::vector< FrameList::Frame > >::const_iterator it = clumpedFrames.begin(); it != clumpedFrames.end(); ++it )
246+
for( const auto &clump : clumpedFrames )
254247
{
255-
const std::vector< FrameList::Frame > &clump = *it;
256-
257248
f.push_back( std::vector< std::string >() );
258-
259-
for ( std::vector< FrameList::Frame > ::const_iterator cit = clump.begin(); cit != clump.end(); ++cit )
249+
for( auto frame : clump )
260250
{
261-
boost::format &fmt = *cit < 0 ? negFmt : posFmt ;
262-
f.back().push_back( ( fmt % *cit ).str() );
251+
f.back().push_back( fileNameForFrame( frame ) );
263252
}
264253
}
265254
}
@@ -325,19 +314,3 @@ bool FileSequence::operator ==( const FileSequence &other ) const
325314
{
326315
return m_fileName == other.m_fileName && m_frameList->isEqualTo( other.m_frameList );
327316
}
328-
329-
boost::format FileSequence::fileNameTemplate( bool negativeFrame ) const
330-
{
331-
unsigned padding = getPadding();
332-
std::string paddingStr = "";
333-
for ( unsigned i = 0; i < padding; i++)
334-
{
335-
paddingStr += "#";
336-
}
337-
338-
std::string f = m_fileName;
339-
boost::replace_all( f, "%", "%%" );
340-
boost::replace_all( f, paddingStr, ( boost::format( "%%0%dd" ) % ( negativeFrame ? padding + 1 : padding ) ).str() );
341-
342-
return boost::format( f );
343-
}

src/IECore/MessageHandler.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ void MessageHandler::output( Level level, const std::string &context, const std:
5656
currentHandler()->handle( level, context, message );
5757
}
5858

59-
void MessageHandler::output( Level level, const std::string &context, const boost::format &message )
60-
{
61-
string m = message.str();
62-
output( level, context, m );
63-
}
64-
6559
///////////////////////////////////////////////////////////////////////////////////////
6660
// default handler
6761
///////////////////////////////////////////////////////////////////////////////////////
@@ -173,8 +167,3 @@ void IECore::msg( MessageHandler::Level level, const std::string &context, const
173167
{
174168
MessageHandler::output( level, context, message );
175169
}
176-
177-
void IECore::msg( MessageHandler::Level level, const std::string &context, const boost::format &message )
178-
{
179-
MessageHandler::output( level, context, message );
180-
}

src/IECoreGL/Selector.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ class Selector::Implementation : public IECore::RefCounted
306306
//////////////////////////////////////////////////////////////////////////
307307

308308
FrameBufferPtr m_frameBuffer;
309-
boost::shared_ptr<FrameBuffer::ScopedBinding> m_frameBufferBinding;
309+
std::unique_ptr<FrameBuffer::ScopedBinding> m_frameBufferBinding;
310310
GLint m_prevProgram;
311311
ConstShaderPtr m_currentIDShader;
312312
std::stack<ConstShaderPtr> m_IDShaderStack;
@@ -325,7 +325,7 @@ class Selector::Implementation : public IECore::RefCounted
325325
}
326326
m_frameBuffer->setDepth( new DepthTexture( 128, 128 ) );
327327
m_frameBuffer->validate();
328-
m_frameBufferBinding = boost::shared_ptr<FrameBuffer::ScopedBinding>( new FrameBuffer::ScopedBinding( *m_frameBuffer ) );
328+
m_frameBufferBinding = std::make_unique<FrameBuffer::ScopedBinding>( *m_frameBuffer );
329329

330330
glGetIntegerv( GL_VIEWPORT, m_prevViewport );
331331
glViewport( 0, 0, 128, 128 );

src/IECoreImage/ImagePrimitive.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
#include "IECore/MurmurHash.h"
4040
#include "IECore/TypeTraits.h"
4141

42+
#include "fmt/format.h"
43+
4244
#include <cassert>
4345

4446
using namespace std;
@@ -404,7 +406,7 @@ bool ImagePrimitive::channelValid( const IECore::Data *data, std::string *reason
404406
{
405407
if( reason )
406408
{
407-
*reason = str( format( "Channel has wrong size (%d but should be %d)." ) % size % numPixels );
409+
*reason = fmt::format( "Channel has wrong size ({} but should be {}).", size, numPixels );
408410
}
409411
return false;
410412
}
@@ -419,7 +421,7 @@ bool ImagePrimitive::channelValid( const std::string &name, std::string *reason
419421
{
420422
if( reason )
421423
{
422-
*reason = str( format( "Channel \"%s\" does not exist." ) % name );
424+
*reason = fmt::format( "Channel \"{}\" does not exist.", name );
423425
}
424426
return false;
425427
}

src/IECoreScene/Font.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,7 @@ class Font::Implementation : public IECore::RefCounted
476476
V2f advance;
477477
};
478478

479-
typedef boost::shared_ptr<Mesh> MeshPtr;
480-
typedef boost::shared_ptr<const Mesh> ConstMeshPtr;
481-
mutable std::vector<MeshPtr> m_meshes;
479+
mutable std::vector<std::unique_ptr<Mesh>> m_meshes;
482480

483481
const Mesh *cachedMesh( char c ) const
484482
{
@@ -511,11 +509,11 @@ class Font::Implementation : public IECore::RefCounted
511509
transformOp->operate();
512510

513511
// put it in the cache
514-
MeshPtr mesh( new Mesh );
512+
auto &mesh = m_meshes[c];
513+
mesh = std::make_unique<Mesh>();
515514
mesh->primitive = primitive;
516515
mesh->bound = primitive->bound();
517516
mesh->advance = V2f( m_face->glyph->advance.x, m_face->glyph->advance.y ) / m_face->units_per_EM;
518-
m_meshes[c] = mesh;
519517

520518
// return it
521519
return mesh.get();

src/IECoreScene/PDCParticleReader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ bool PDCParticleReader::open()
124124

125125
if( m_header.version > 1 )
126126
{
127-
msg( Msg::Warning, "PDCParticleReader::open()", format( "File \"%s\" has unknown version %d." ) % fileName() % m_header.version );
127+
msg( Msg::Warning, "PDCParticleReader::open()", "File \"{}\" has unknown version {}.", fileName(), m_header.version );
128128
}
129129

130130
int unused = 0;
@@ -262,7 +262,7 @@ DataPtr PDCParticleReader::readAttribute( const std::string &name )
262262
const Data *idAttr = idAttribute();
263263
if ( !idAttr && particlePercentage() < 100.0f )
264264
{
265-
msg( Msg::Warning, "PDCParticleReader::filterAttr", format( "Percentage filtering requested but file \"%s\" contains no particle Id attribute." ) % fileName() );
265+
msg( Msg::Warning, "PDCParticleReader::filterAttr", "Percentage filtering requested but file \"{}\" contains no particle Id attribute.", fileName() );
266266
}
267267

268268
DataPtr result = nullptr;

src/IECoreScene/PDCParticleWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void PDCParticleWriter::doWrite( const CompoundObject *operands )
152152
}
153153
else
154154
{
155-
msg( Msg::Warning, "PDCParticleWriter::write", format( "Attribute \"%s\" is of unsupported type \"%s\"." ) % *it % attr->typeName() );
155+
msg( Msg::Warning, "PDCParticleWriter::write", "Attribute \"{}\" is of unsupported type \"{}\".", *it, attr->typeName() );
156156
}
157157
}
158158

0 commit comments

Comments
 (0)