Skip to content

Commit e43df6a

Browse files
committed
Switch some std::endl -> "\n" (reduces need for <iostream>)
In a couple of cases I found we needed to include iostream simply because we used std::endl Switching to "\n" reduces the scope of that reoccurring. I did not replace all of them in this pass - care needs to be taken with the lack of flush() when using std::cout, etc. Signed-off-by: Kevin Wheatley <kevin.wheatley@framestore.com>
1 parent 747ade0 commit e43df6a

File tree

15 files changed

+76
-84
lines changed

15 files changed

+76
-84
lines changed

include/OpenColorIO/OpenColorIO.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ C++ API
5252
}
5353
catch(OCIO::Exception & exception)
5454
{
55-
std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
55+
std::cerr << "OpenColorIO Error: " << exception.what() << "\n";
5656
}
5757
5858
*/

src/OpenColorIO/ColorSpace.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ void ColorSpace::setInteropID(const char * interopID)
257257
{
258258
std::ostringstream oss;
259259
oss << "InteropID '" << id << "' contains invalid characters. "
260-
"Only lowercase a-z, 0-9 and . - _ ~ / * # % ^ + ( ) [ ] | are allowed." <<
261-
std::endl;
260+
"Only lowercase a-z, 0-9 and . - _ ~ / * # % ^ + ( ) [ ] | are allowed.\n";
262261
throw Exception(oss.str().c_str());
263262
}
264263

@@ -275,8 +274,7 @@ void ColorSpace::setInteropID(const char * interopID)
275274
{
276275
std::ostringstream oss;
277276
oss << "InteropID '" << id << "' is not valid. "
278-
"If ':' is used, both the namespace and the color space parts must be non-empty." <<
279-
std::endl;
277+
"If ':' is used, both the namespace and the color space parts must be non-empty.\n";
280278
throw Exception(oss.str().c_str());
281279
}
282280

@@ -285,8 +283,7 @@ void ColorSpace::setInteropID(const char * interopID)
285283
{
286284
std::ostringstream oss;
287285
oss << "ERROR: InteropID '" << id << "' is not valid. "
288-
"Only one ':' is allowed to separate the namespace and the color space." <<
289-
std::endl;
286+
"Only one ':' is allowed to separate the namespace and the color space.\n";
290287
throw Exception(oss.str().c_str());
291288
}
292289
}

src/OpenColorIO/GpuShaderUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ void GpuShaderText::flushLine()
338338

339339
m_ossText << std::string(tabSize * m_indent, ' ')
340340
<< m_ossLine.str()
341-
<< std::endl;
341+
<< "\n";
342342

343343
m_ossLine.str("");
344344
m_ossLine.clear();

src/OpenColorIO/Logging.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: BSD-3-Clause
22
// Copyright Contributors to the OpenColorIO Project.
33

4-
#include <cstdlib>
4+
#include <string>
55
#include <iostream>
66

77
#include <OpenColorIO/OpenColorIO.h>
@@ -42,8 +42,8 @@ void InitLogging()
4242

4343
if(g_logginglevel == LOGGING_LEVEL_UNKNOWN)
4444
{
45-
std::cerr << "[OpenColorIO Warning]: Invalid $OCIO_LOGGING_LEVEL specified. ";
46-
std::cerr << "Options: none (0), warning (1), info (2), debug (3)" << std::endl;
45+
std::cerr << "[OpenColorIO Warning]: Invalid $OCIO_LOGGING_LEVEL specified. "
46+
"Options: none (0), warning (1), info (2), debug (3)\n";
4747
g_logginglevel = LOGGING_LEVEL_DEFAULT;
4848
}
4949
}

src/OpenColorIO/fileformats/FileFormatCTF.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,7 @@ void LocalFileFormat::write(const ConstConfigRcPtr & config,
15841584
CTFReaderTransformPtr transform = std::make_shared<CTFReaderTransform>(ops, metadata);
15851585

15861586
// Write XML Header.
1587-
ostream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
1587+
ostream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
15881588
XmlFormatter fmt(ostream);
15891589

15901590
TransformWriter writer(fmt, transform, isCLF);

src/OpenColorIO/transforms/FileTransform.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,7 @@ void LoadFileUncached(FileFormat * & returnFormat,
601601

602602
{
603603
std::ostringstream oss;
604-
oss << "**" << std::endl
605-
<< "Opening " << filepath;
604+
oss << "**\nOpening " << filepath;
606605
LogDebug(oss.str());
607606
}
608607

@@ -637,9 +636,9 @@ void LoadFileUncached(FileFormat * & returnFormat,
637636
{
638637
std::ostringstream os;
639638
os << "The specified FileTransform srcfile, '";
640-
os << filepath << "', could not be opened. ";
641-
os << "Please confirm the file exists with ";
642-
os << "appropriate read permissions.";
639+
os << filepath << "', could not be opened. "
640+
"Please confirm the file exists with "
641+
"appropriate read permissions.";
643642
throw Exception(os.str().c_str());
644643
}
645644

@@ -649,7 +648,7 @@ void LoadFileUncached(FileFormat * & returnFormat,
649648
{
650649
std::ostringstream os;
651650
os << " Loaded primary format ";
652-
os << tryFormat->getName() << std::endl;
651+
os << tryFormat->getName() << "\n";
653652
LogDebug(os.str());
654653
}
655654

@@ -706,10 +705,10 @@ void LoadFileUncached(FileFormat * & returnFormat,
706705
{
707706
std::ostringstream os;
708707
os << "The specified FileTransform srcfile, '";
709-
os << filepath << "', could not be opened. ";
710-
os << "Please confirm the file exists with ";
711-
os << "appropriate read";
712-
os << " permissions.";
708+
os << filepath << "', could not be opened. "
709+
"Please confirm the file exists with "
710+
"appropriate read"
711+
" permissions.";
713712
throw Exception(os.str().c_str());
714713
}
715714

src/libutils/imageioapphelpers/imageio_exr.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ class ImageIO::Impl
9090
{
9191
std::ostringstream ss;
9292

93-
ss << std::endl;
94-
ss << "Image: [" << getWidth() << "x" << getHeight() << "] "
93+
ss << "\nImage: [" << getWidth() << "x" << getHeight() << "] "
9594
<< BitDepthToString(getBitDepth()) << " ";
9695

9796
const std::vector<std::string> chanNames = getChannelNames();
@@ -111,7 +110,7 @@ class ImageIO::Impl
111110
ss << ", ";
112111
}
113112
}
114-
ss << std::endl;
113+
ss << "\n";
115114

116115
return ss.str();
117116
}

src/libutils/imageioapphelpers/imageio_oiio.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ class ImageIO::Impl
9292
{
9393
std::ostringstream ss;
9494

95-
ss << std::endl;
96-
ss << "Image: [" << getWidth() << "x" << getHeight() << "] "
95+
ss << "\nImage: [" << getWidth() << "x" << getHeight() << "] "
9796
<< BitDepthToString(getBitDepth()) << " ";
9897

9998
const std::vector<std::string> chanNames = getChannelNames();
@@ -113,7 +112,7 @@ class ImageIO::Impl
113112
ss << ", ";
114113
}
115114
}
116-
ss << std::endl;
115+
ss << "\n";
117116

118117
return ss.str();
119118
}

src/libutils/oglapphelpers/glsl.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#endif
2020

21+
#include <string>
2122
#include <sstream>
2223
#include <iostream>
2324

@@ -491,9 +492,9 @@ unsigned OpenGLBuilder::buildProgram(const std::string & clientShaderProgram, bo
491492
}
492493

493494
std::ostringstream oss;
494-
oss << getGLSLVersionString() << std::endl
495-
<< (!standaloneShader ? m_shaderDesc->getShaderText() : "") << std::endl
496-
<< clientShaderProgram << std::endl;
495+
oss << getGLSLVersionString() << "\n"
496+
<< (!standaloneShader ? m_shaderDesc->getShaderText() : "") << "\n"
497+
<< clientShaderProgram << "\n";
497498

498499
if(m_verbose)
499500
{

src/libutils/oglapphelpers/metalapp.mm

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@
9696

9797
std::ostringstream main;
9898

99-
main << std::endl
100-
<< "uniform sampler2DRect img;" << std::endl
101-
<< std::endl
102-
<< "void main()" << std::endl
103-
<< "{" << std::endl
104-
<< " gl_FragColor = texture2DRect(img, gl_TexCoord[0].st * "
105-
<< "vec2(" << m_outputImage->getWidth() << ", " << m_outputImage->getHeight() << "));"
106-
<< std::endl
107-
<< "}" << std::endl;
99+
main << "\n"
100+
"uniform sampler2DRect img;\n"
101+
"\n"
102+
"void main()\n"
103+
"{\n"
104+
" gl_FragColor = texture2DRect(img, gl_TexCoord[0].st * "
105+
"vec2(" << m_outputImage->getWidth() << ", " << m_outputImage->getHeight() << "));"
106+
"\n"
107+
"}\n";
108108

109109

110110
glActiveTexture(GL_TEXTURE0);
@@ -339,7 +339,7 @@ vertex VertexOut ColorCorrectionVS(unsigned int vId [[ vertex_id ]])
339339
<< shaderDesc->getFunctionName() << "(" << params.str() << uniformParams.str() << separator << "inPixel);\n"
340340
<< "}\n";
341341

342-
main << std::endl;
342+
main << "\n";
343343
}
344344
else
345345
{
@@ -348,11 +348,8 @@ vertex VertexOut ColorCorrectionVS(unsigned int vId [[ vertex_id ]])
348348

349349
if(printShader())
350350
{
351-
std::cout << std::endl;
352-
std::cout << "GPU Shader Program:" << std::endl;
353-
std::cout << std::endl;
354-
std::cout << main.str() << std::endl;
355-
std::cout << std::endl;
351+
std::cout << "\nGPU Shader Program:\n\n";
352+
std::cout << main.str() << "\n\n";
356353
}
357354

358355
// Build the fragment shader program.

0 commit comments

Comments
 (0)