Merge pull request #600 from LegalizeAdulthood/cppcheck-format-operator

Prefer Format::operator<< over Format::operator,
pull/602/head
Kim Kulling 2015-07-04 09:29:47 +02:00
commit bd0b58d906
1 changed files with 9 additions and 10 deletions

View File

@ -84,29 +84,29 @@ const char* TokenTypeString(TokenType t)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
std::string AddOffset(const std::string& prefix, const std::string& text, unsigned int offset) std::string AddOffset(const std::string& prefix, const std::string& text, unsigned int offset)
{ {
return static_cast<std::string>( (Formatter::format(),prefix," (offset 0x",std::hex,offset,") ",text) ); return static_cast<std::string>( (Formatter::format() << prefix << " (offset 0x" << std::hex << offset << ") " << text) );
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
std::string AddLineAndColumn(const std::string& prefix, const std::string& text, unsigned int line, unsigned int column) std::string AddLineAndColumn(const std::string& prefix, const std::string& text, unsigned int line, unsigned int column)
{ {
return static_cast<std::string>( (Formatter::format(),prefix," (line ",line,", col ",column,") ",text) ); return static_cast<std::string>( (Formatter::format() << prefix << " (line " << line << " << col " << column << ") " << text) );
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
std::string AddTokenText(const std::string& prefix, const std::string& text, const Token* tok) std::string AddTokenText(const std::string& prefix, const std::string& text, const Token* tok)
{ {
if(tok->IsBinary()) { if(tok->IsBinary()) {
return static_cast<std::string>( (Formatter::format(),prefix, return static_cast<std::string>( (Formatter::format() << prefix <<
" (",TokenTypeString(tok->Type()), " (" << TokenTypeString(tok->Type()) <<
", offset 0x", std::hex, tok->Offset(),") ", ", offset 0x" << std::hex << tok->Offset() << ") " <<
text) ); text) );
} }
return static_cast<std::string>( (Formatter::format(),prefix, return static_cast<std::string>( (Formatter::format() << prefix <<
" (",TokenTypeString(tok->Type()), " (" << TokenTypeString(tok->Type()) <<
", line ",tok->Line(), ", line " << tok->Line() <<
", col ",tok->Column(),") ", ", col " << tok->Column() << ") " <<
text) ); text) );
} }
@ -115,4 +115,3 @@ std::string AddTokenText(const std::string& prefix, const std::string& text, con
} // !Assimp } // !Assimp
#endif #endif