From 3ab49286638629918d66cfc79d38ec4ca5b21a6e Mon Sep 17 00:00:00 2001 From: "cuneyt.ozdas" Date: Wed, 17 Apr 2024 17:32:08 -0700 Subject: [PATCH 1/6] - experimenting with the preprocessor switch to turn the LUT support on and off. - added OCIO_ARCHIVE_SUPPORT preprocessor switch - And the library now compiles with or without LUT and/or OCIOZ support, shaving off 40% of dll size. --- src/OpenColorIO/Baker.cpp | 4 +++- src/OpenColorIO/BakingUtils.cpp | 3 +++ src/OpenColorIO/CPUProcessor.cpp | 10 ++++++-- src/OpenColorIO/Caching.cpp | 3 +++ src/OpenColorIO/Config.cpp | 24 ++++++++++++++++--- src/OpenColorIO/ConfigUtils.cpp | 3 ++- src/OpenColorIO/ContextVariableUtils.cpp | 2 ++ src/OpenColorIO/ContextVariableUtils.h | 3 ++- src/OpenColorIO/GpuShader.cpp | 14 +++++++++-- src/OpenColorIO/GpuShader.h | 6 ++++- src/OpenColorIO/OCIOYaml.cpp | 15 ++++++++++++ src/OpenColorIO/OCIOZArchive.cpp | 5 +++- src/OpenColorIO/OCIOZArchive.h | 6 ++++- src/OpenColorIO/Op.cpp | 9 +++++++ src/OpenColorIO/OpBuilders.h | 6 +++-- src/OpenColorIO/OpOptimizers.cpp | 9 +++++++ src/OpenColorIO/Processor.cpp | 5 +++- src/OpenColorIO/Transform.cpp | 20 ++++++++++++++-- .../apphelpers/ColorSpaceHelpers.cpp | 3 +++ .../apphelpers/DisplayViewHelpers.cpp | 2 ++ src/OpenColorIO/fileformats/FileFormat3DL.cpp | 7 +++++- src/OpenColorIO/fileformats/FileFormatCC.cpp | 3 +++ src/OpenColorIO/fileformats/FileFormatCCC.cpp | 8 ++++--- src/OpenColorIO/fileformats/FileFormatCDL.cpp | 4 +++- src/OpenColorIO/fileformats/FileFormatCSP.cpp | 5 +++- src/OpenColorIO/fileformats/FileFormatCTF.cpp | 6 ++++- .../fileformats/FileFormatDiscreet1DL.cpp | 5 +++- src/OpenColorIO/fileformats/FileFormatHDL.cpp | 5 +++- src/OpenColorIO/fileformats/FileFormatICC.cpp | 5 +++- .../fileformats/FileFormatIridasCube.cpp | 7 +++++- .../fileformats/FileFormatIridasItx.cpp | 4 +++- .../fileformats/FileFormatIridasLook.cpp | 5 +++- .../fileformats/FileFormatPandora.cpp | 5 +++- .../fileformats/FileFormatResolveCube.cpp | 5 +++- .../fileformats/FileFormatSpi1D.cpp | 6 ++++- .../fileformats/FileFormatSpi3D.cpp | 5 +++- .../fileformats/FileFormatSpiMtx.cpp | 4 +++- .../fileformats/FileFormatTruelight.cpp | 5 +++- .../fileformats/FileFormatUtils.cpp | 4 +++- src/OpenColorIO/fileformats/FileFormatUtils.h | 6 +++++ src/OpenColorIO/fileformats/FileFormatVF.cpp | 5 +++- src/OpenColorIO/fileformats/cdl/CDLParser.cpp | 7 +++++- .../fileformats/cdl/CDLReaderHelper.cpp | 5 ++++ .../fileformats/cdl/CDLReaderHelper.h | 6 ++++- src/OpenColorIO/fileformats/cdl/CDLWriter.cpp | 6 ++++- .../fileformats/ctf/CTFReaderHelper.cpp | 3 +++ .../fileformats/ctf/CTFReaderHelper.h | 11 +++++---- .../fileformats/ctf/CTFTransform.cpp | 6 ++++- .../fileformats/xmlutils/XMLReaderHelper.cpp | 6 ++++- .../fileformats/xmlutils/XMLReaderHelper.h | 7 +++++- .../fileformats/xmlutils/XMLReaderUtils.cpp | 6 ++++- .../fileformats/xmlutils/XMLReaderUtils.h | 5 +++- src/OpenColorIO/ops/cdl/CDLOp.cpp | 5 +++- src/OpenColorIO/ops/cdl/CDLOp.h | 4 +++- src/OpenColorIO/ops/lut1d/Lut1DOp.cpp | 6 ++++- src/OpenColorIO/ops/lut1d/Lut1DOp.h | 8 +++++-- src/OpenColorIO/ops/lut1d/Lut1DOpCPU.cpp | 6 ++++- src/OpenColorIO/ops/lut1d/Lut1DOpCPU.h | 2 ++ src/OpenColorIO/ops/lut1d/Lut1DOpCPU_AVX.cpp | 5 +++- src/OpenColorIO/ops/lut1d/Lut1DOpCPU_AVX2.cpp | 5 +++- src/OpenColorIO/ops/lut1d/Lut1DOpCPU_AVX2.h | 6 ++++- .../ops/lut1d/Lut1DOpCPU_AVX512.cpp | 5 +++- src/OpenColorIO/ops/lut1d/Lut1DOpCPU_SSE2.cpp | 6 ++++- src/OpenColorIO/ops/lut1d/Lut1DOpData.cpp | 8 +++++-- src/OpenColorIO/ops/lut1d/Lut1DOpData.h | 5 ++++ src/OpenColorIO/ops/lut1d/Lut1DOpGPU.cpp | 6 ++++- src/OpenColorIO/ops/lut3d/Lut3DOp.cpp | 6 ++++- src/OpenColorIO/ops/lut3d/Lut3DOp.h | 3 +++ src/OpenColorIO/ops/lut3d/Lut3DOpCPU.cpp | 8 +++++-- src/OpenColorIO/ops/lut3d/Lut3DOpCPU.h | 3 +++ src/OpenColorIO/ops/lut3d/Lut3DOpCPU_AVX.cpp | 5 +++- src/OpenColorIO/ops/lut3d/Lut3DOpCPU_AVX2.cpp | 5 +++- .../ops/lut3d/Lut3DOpCPU_AVX512.cpp | 5 +++- src/OpenColorIO/ops/lut3d/Lut3DOpCPU_SSE2.cpp | 4 +++- src/OpenColorIO/ops/lut3d/Lut3DOpCPU_SSE2.h | 5 +++- src/OpenColorIO/ops/lut3d/Lut3DOpData.cpp | 8 +++++-- src/OpenColorIO/ops/lut3d/Lut3DOpData.h | 5 +++- src/OpenColorIO/ops/lut3d/Lut3DOpGPU.cpp | 7 ++++-- src/OpenColorIO/ops/noop/NoOps.cpp | 2 ++ src/OpenColorIO/ops/noop/NoOps.h | 3 ++- src/OpenColorIO/ops/range/RangeOp.cpp | 2 ++ src/OpenColorIO/transforms/CDLTransform.cpp | 4 +++- src/OpenColorIO/transforms/CDLTransform.h | 8 ++++++- src/OpenColorIO/transforms/FileTransform.cpp | 6 ++++- src/OpenColorIO/transforms/FileTransform.h | 5 +++- src/OpenColorIO/transforms/GroupTransform.cpp | 24 +++++++++++++++++++ src/OpenColorIO/transforms/Lut1DTransform.cpp | 6 ++++- src/OpenColorIO/transforms/Lut1DTransform.h | 5 ++++ src/OpenColorIO/transforms/Lut3DTransform.cpp | 7 ++++-- src/OpenColorIO/transforms/Lut3DTransform.h | 3 +++ src/OpenColorIO/transforms/builtins/ACES.cpp | 22 +++++++++++++++-- .../transforms/builtins/AppleCameras.cpp | 6 ++++- .../transforms/builtins/AppleCameras.h | 4 ++-- .../builtins/BuiltinTransformRegistry.cpp | 4 +++- .../transforms/builtins/CanonCameras.cpp | 5 +++- .../transforms/builtins/CanonCameras.h | 2 ++ .../transforms/builtins/Displays.cpp | 15 ++++++++++++ .../transforms/builtins/OpHelpers.cpp | 2 ++ .../transforms/builtins/OpHelpers.h | 5 ++++ 99 files changed, 517 insertions(+), 93 deletions(-) diff --git a/src/OpenColorIO/Baker.cpp b/src/OpenColorIO/Baker.cpp index b8a78a958c..0053760929 100755 --- a/src/OpenColorIO/Baker.cpp +++ b/src/OpenColorIO/Baker.cpp @@ -1,10 +1,11 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include +#if OCIO_LUT_SUPPORT #include -#include #include "transforms/FileTransform.h" #include "BakingUtils.h" @@ -414,3 +415,4 @@ void Baker::bake(std::ostream & os) const } } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/BakingUtils.cpp b/src/OpenColorIO/BakingUtils.cpp index 0929fa10c5..7f18c55b6a 100644 --- a/src/OpenColorIO/BakingUtils.cpp +++ b/src/OpenColorIO/BakingUtils.cpp @@ -3,6 +3,8 @@ #include "BakingUtils.h" +#if OCIO_LUT_SUPPORT + namespace OCIO_NAMESPACE { @@ -131,3 +133,4 @@ void GetTargetRange(const Baker & baker, float& start, float& end) } } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/CPUProcessor.cpp b/src/OpenColorIO/CPUProcessor.cpp index 033083aed3..d113affdfa 100644 --- a/src/OpenColorIO/CPUProcessor.cpp +++ b/src/OpenColorIO/CPUProcessor.cpp @@ -139,12 +139,15 @@ void CreateCPUEngine(const OpRcPtrVec & ops, if(idx==0) { +#if OCIO_LUT_SUPPORT if(opData->getType()==OpData::Lut1DType) { ConstLut1DOpDataRcPtr lut = DynamicPtrCast(opData); inBitDepthOp = GetLut1DRenderer(lut, in, BIT_DEPTH_F32); } - else if(in==BIT_DEPTH_F32) + else +#endif //OCIO_LUT_SUPPORT + if(in==BIT_DEPTH_F32) { inBitDepthOp = op->getCPUOp(fastLogExpPow); } @@ -161,12 +164,15 @@ void CreateCPUEngine(const OpRcPtrVec & ops, } else if(idx==(maxOps-1)) { +#if OCIO_LUT_SUPPORT if(opData->getType()==OpData::Lut1DType) { ConstLut1DOpDataRcPtr lut = DynamicPtrCast(opData); outBitDepthOp = GetLut1DRenderer(lut, BIT_DEPTH_F32, out); } - else if(out==BIT_DEPTH_F32) + else +#endif //OCIO_LUT_SUPPORT + if(out==BIT_DEPTH_F32) { outBitDepthOp = op->getCPUOp(fastLogExpPow); } diff --git a/src/OpenColorIO/Caching.cpp b/src/OpenColorIO/Caching.cpp index 2899e7157b..c38a26ccd2 100755 --- a/src/OpenColorIO/Caching.cpp +++ b/src/OpenColorIO/Caching.cpp @@ -24,6 +24,9 @@ const char * OCIO_DISABLE_CACHE_FALLBACK = "OCIO_DISABLE_CACHE_FALLBACK"; void ClearAllCaches() { ClearPathCaches(); +#if OCIO_LUT_SUPPORT ClearFileTransformCaches(); +#endif //OCIO_LUT_SUPPORT + } } // namespace OCIO_NAMESPACE diff --git a/src/OpenColorIO/Config.cpp b/src/OpenColorIO/Config.cpp index 3d2a863986..0d0371ed67 100644 --- a/src/OpenColorIO/Config.cpp +++ b/src/OpenColorIO/Config.cpp @@ -151,6 +151,7 @@ const char* LookupRole(const StringMap & roles, const std::string & rolename) return iter->second.c_str(); } +#if OCIO_LUT_SUPPORT void GetFileReferences(std::set & files, const ConstTransformRcPtr & transform) { if(!transform) return; @@ -169,6 +170,7 @@ void GetFileReferences(std::set & files, const ConstTransformRcPtr files.insert(fileTransform->getSrc()); } } +#endif OCIO_LUT_SUPPORT // Return the list of all color spaces referenced by the transform (including all sub-transforms in // a group). All legal context variables are expanded, so if any are remaining, the caller may want @@ -948,6 +950,7 @@ class Config::Impl return processor; } +#if OCIO_LUT_SUPPORT int instantiateDisplay(const std::string & monitorName, const std::string & monitorDescription, const std::string & ICCProfileFilepath) @@ -1103,6 +1106,7 @@ class Config::Impl // That should never happen. return -1; } +#endif //OCIO_LUT_SUPPORT }; @@ -1179,6 +1183,7 @@ ConstConfigRcPtr Config::CreateFromFile(const char * filename) throw Exception (os.str().c_str()); } +#if OCIO_ARCHIVE_SUPPORT char magicNumber[2] = { 0 }; if (ifstream.read(magicNumber, 2)) { @@ -1198,7 +1203,7 @@ ConstConfigRcPtr Config::CreateFromFile(const char * filename) return CreateFromConfigIOProxy(ciop); } } - +#endif //OCIO_ARCHIVE_SUPPORT // Not an OCIOZ archive. Continue as usual. ifstream.clear(); ifstream.seekg(0); @@ -1953,6 +1958,7 @@ void Config::validate() const throw Exception(getImpl()->m_validationtext.c_str()); } +#if OCIO_LUT_SUPPORT ///// Resolve all file Transforms using context variables. { @@ -2044,6 +2050,7 @@ void Config::validate() const } } } +#endif //OCIO_LUT_SUPPORT ///// NamedTransforms @@ -3901,6 +3908,7 @@ void Config::clearVirtualDisplay() noexcept getImpl()->resetCacheIDs(); } +#if OCIO_LUT_SUPPORT int Config::instantiateDisplayFromMonitorName(const char * monitorName) { if (!monitorName || !*monitorName) @@ -3929,6 +3937,7 @@ int Config::instantiateDisplayFromICCProfile(const char * ICCProfileFilepath) return getImpl()->instantiateDisplay("", monitorDescription, ICCProfileFilepath); } +#endif //OCIO_LUT_SUPPORT void Config::setActiveDisplays(const char * displays) { @@ -4886,6 +4895,9 @@ const char * Config::getCacheID(const ConstContextRcPtr & context) const // Also include all file references, using the context (if specified) std::string fileReferencesFastHash; + +#if OCIO_LUT_SUPPORT + if(context) { std::ostringstream filehash; @@ -4920,6 +4932,7 @@ const char * Config::getCacheID(const ConstContextRcPtr & context) const const std::string fullstr = filehash.str(); fileReferencesFastHash = CacheIDHash(fullstr.c_str(), fullstr.size()); } +#endif //OCIO_LUT_SUPPORT getImpl()->m_cacheids[contextcacheid] = getImpl()->m_cacheidnocontext + ":" + fileReferencesFastHash; return getImpl()->m_cacheids[contextcacheid].c_str(); @@ -5242,6 +5255,7 @@ void Config::Impl::checkVersionConsistency(ConstTransformRcPtr & transform) cons throw Exception(os.str().c_str()); } } +#if OCIO_LUT_SUPPORT else if (ConstCDLTransformRcPtr cdl = DynamicPtrCast(transform)) { if (m_majorVersion < 2 && cdl->getStyle() != CDL_TRANSFORM_DEFAULT) @@ -5250,6 +5264,7 @@ void Config::Impl::checkVersionConsistency(ConstTransformRcPtr & transform) cons "CDLTransform."); } } +#endif //OCIO_LUT_SUPPORT else if (DynamicPtrCast(transform)) { if (m_majorVersion < 2) @@ -5282,6 +5297,7 @@ void Config::Impl::checkVersionConsistency(ConstTransformRcPtr & transform) cons "ExposureContrastTransform."); } } +#if OCIO_LUT_SUPPORT else if (ConstFileTransformRcPtr ft = DynamicPtrCast(transform)) { if (m_majorVersion < 2) @@ -5298,6 +5314,8 @@ void Config::Impl::checkVersionConsistency(ConstTransformRcPtr & transform) cons } } } +#endif //OCIO_LUT_SUPPORT + else if (ConstFixedFunctionTransformRcPtr ff = DynamicPtrCast(transform)) { if (m_majorVersion < 2) @@ -5482,7 +5500,7 @@ ConfigIOProxyRcPtr Config::getConfigIOProxy() const { return getImpl()->m_context->getConfigIOProxy(); } - +#if OCIO_ARCHIVE_SUPPORT bool Config::isArchivable() const { ConstContextRcPtr context = getCurrentContext(); @@ -5563,5 +5581,5 @@ void Config::archive(std::ostream & ostream) const // Using utility functions in OCIOZArchive.cpp. archiveConfig(ostream, *this, getCurrentContext()->getWorkingDir()); } - +#endif //OCIO_ARCHIVE_SUPPORT } // namespace OCIO_NAMESPACE diff --git a/src/OpenColorIO/ConfigUtils.cpp b/src/OpenColorIO/ConfigUtils.cpp index 0b45b04de8..b1891b062a 100644 --- a/src/OpenColorIO/ConfigUtils.cpp +++ b/src/OpenColorIO/ConfigUtils.cpp @@ -326,7 +326,7 @@ bool containsBlockedTransform(const ConstTransformRcPtr & transform) } } } - +#if OCIO_LUT_SUPPORT // Prevent FileTransforms from being used, except for spi1d and spimtx since these // may be used with OCIO v1 configs to implement the type of color spaces the heuristics // are designed to look for. (E.g. The sRGB Texture space in the legacy ACES configs.) @@ -342,6 +342,7 @@ bool containsBlockedTransform(const ConstTransformRcPtr & transform) return true; } } +#endif //OCIO_LUT_SUPPORT // Prevent transforms that may be hiding a FileTransform. else if (transform->getTransformType() == TRANSFORM_TYPE_COLORSPACE diff --git a/src/OpenColorIO/ContextVariableUtils.cpp b/src/OpenColorIO/ContextVariableUtils.cpp index 1207a0363a..5c73bd3916 100644 --- a/src/OpenColorIO/ContextVariableUtils.cpp +++ b/src/OpenColorIO/ContextVariableUtils.cpp @@ -178,10 +178,12 @@ bool CollectContextVariables(const Config & config, { if (CollectContextVariables(config, context, *tr, usedContextVars)) return true; } +#if OCIO_LUT_SUPPORT else if(ConstFileTransformRcPtr tr = DynamicPtrCast(transform)) { if (CollectContextVariables(config, context, *tr, usedContextVars)) return true; } +#endif OCIO_LUT_SUPPORT else if(ConstGroupTransformRcPtr tr = DynamicPtrCast(transform)) { if (CollectContextVariables(config, context, *tr, usedContextVars)) return true; diff --git a/src/OpenColorIO/ContextVariableUtils.h b/src/OpenColorIO/ContextVariableUtils.h index db6022d7e6..86deaaee49 100644 --- a/src/OpenColorIO/ContextVariableUtils.h +++ b/src/OpenColorIO/ContextVariableUtils.h @@ -70,11 +70,12 @@ bool CollectContextVariables(const Config & config, const Context & context, const DisplayViewTransform & tr, ContextRcPtr & usedContextVars); - +#if OCIO_LUT_SUPPORT bool CollectContextVariables(const Config & config, const Context & context, const FileTransform & tr, ContextRcPtr & usedContextVars); +#endif //OCIO_LUT_SUPPORT bool CollectContextVariables(const Config & config, const Context & context, diff --git a/src/OpenColorIO/GpuShader.cpp b/src/OpenColorIO/GpuShader.cpp index 7fbc30b43a..4bcca01b09 100644 --- a/src/OpenColorIO/GpuShader.cpp +++ b/src/OpenColorIO/GpuShader.cpp @@ -19,7 +19,7 @@ namespace OCIO_NAMESPACE namespace { - +#if OCIO_LUT_SUPPORT static void CreateArray(const float * buf, unsigned w, unsigned h, unsigned d, GpuShaderDesc::TextureType type, @@ -35,6 +35,8 @@ static void CreateArray(const float * buf, res.resize(size); std::memcpy(&res[0], buf, size * sizeof(float)); } +#endif //OCIO_LUT_SUPPORT + } namespace GPUShaderImpl @@ -43,6 +45,7 @@ namespace GPUShaderImpl class PrivateImpl { public: +#if OCIO_LUT_SUPPORT struct Texture { Texture(const char * textureName, @@ -101,6 +104,7 @@ class PrivateImpl }; typedef std::vector Textures; +#endif //OCIO_LUT_SUPPORT struct Uniform { @@ -167,6 +171,7 @@ class PrivateImpl virtual ~PrivateImpl() {} +#if OCIO_LUT_SUPPORT inline unsigned get3dLutMaxLength() const { return Lut3DOpData::maxSupportedLength; } inline unsigned get1dLutMaxWidth() const { return m_max1DLUTWidth; } @@ -297,6 +302,7 @@ class PrivateImpl const Texture & t = m_textures3D[index]; values = &t.m_values[0]; } +#endif //OCIO_LUT_SUPPORT unsigned getNumUniforms() const { @@ -374,8 +380,10 @@ class PrivateImpl m_uniforms.emplace_back(name, getSize, getVectorInt); return true; } +#if OCIO_LUT_SUPPORT Textures m_textures; Textures m_textures3D; +#endif //OCIO_LUT_SUPPORT Uniforms m_uniforms; private: @@ -459,7 +467,7 @@ bool GenericGpuShaderDesc::addUniform(const char * name, return getImplGeneric()->addUniform(name, getSize, getVectorInt); } - +#if OCIO_LUT_SUPPORT unsigned GenericGpuShaderDesc::getTextureMaxWidth() const noexcept { return getImplGeneric()->get1dLutMaxWidth(); @@ -539,6 +547,8 @@ void GenericGpuShaderDesc::get3DTextureValues(unsigned index, const float *& val { getImplGeneric()->get3DTextureValues(index, values); } +#endif //OCIO_LUT_SUPPORT + void GenericGpuShaderDesc::Deleter(GenericGpuShaderDesc* c) { diff --git a/src/OpenColorIO/GpuShader.h b/src/OpenColorIO/GpuShader.h index e9c39d56b1..2ce02749f9 100644 --- a/src/OpenColorIO/GpuShader.h +++ b/src/OpenColorIO/GpuShader.h @@ -26,11 +26,14 @@ class GenericGpuShaderDesc : public GpuShaderDesc public: static GpuShaderDescRcPtr Create(); +#if OCIO_LUT_SUPPORT + unsigned getTextureMaxWidth() const noexcept override; void setTextureMaxWidth(unsigned maxWidth) override; bool getAllowTexture1D() const noexcept override; void setAllowTexture1D(bool allowed) override; +#endif //OCIO_LUT_SUPPORT // Accessors to the uniforms // @@ -45,7 +48,7 @@ class GenericGpuShaderDesc : public GpuShaderDesc bool addUniform(const char * name, const SizeGetter & getSize, const VectorIntGetter & getVectorInt) override; - +#if OCIO_LUT_SUPPORT // Accessors to the 1D & 2D textures built from 1D LUT // unsigned getNumTextures() const noexcept override; @@ -79,6 +82,7 @@ class GenericGpuShaderDesc : public GpuShaderDesc unsigned & edgelen, Interpolation & interpolation) const override; void get3DTextureValues(unsigned index, const float *& value) const override; +#endif //OCIO_LUT_SUPPORT private: diff --git a/src/OpenColorIO/OCIOYaml.cpp b/src/OpenColorIO/OCIOYaml.cpp index 8681631a74..e42cdace6e 100644 --- a/src/OpenColorIO/OCIOYaml.cpp +++ b/src/OpenColorIO/OCIOYaml.cpp @@ -556,6 +556,7 @@ inline void save(YAML::Emitter & out, const ConstBuiltinTransformRcPtr & t) out << YAML::EndMap; } +#if OCIO_LUT_SUPPORT // CDLTransform inline void load(const YAML::Node& node, CDLTransformRcPtr& t) @@ -687,6 +688,7 @@ inline void save(YAML::Emitter& out, ConstCDLTransformRcPtr t, unsigned int majo EmitBaseTransformKeyValues(out, t); out << YAML::EndMap; } +#endif //OCIO_LUT_SUPPORT // ColorSpaceTransform @@ -1246,6 +1248,8 @@ inline void save(YAML::Emitter& out, ConstExposureContrastTransformRcPtr t) out << YAML::EndMap; } +#if OCIO_LUT_SUPPORT + // FileTransform inline void load(const YAML::Node& node, FileTransformRcPtr& t) @@ -1330,6 +1334,7 @@ inline void save(YAML::Emitter& out, ConstFileTransformRcPtr t, unsigned int maj EmitBaseTransformKeyValues(out, t); out << YAML::EndMap; } +#endif //OCIO_LUT_SUPPORT // FixedFunctionTransform @@ -2946,12 +2951,14 @@ void load(const YAML::Node& node, TransformRcPtr& t) load(node, temp); t = temp; } +#if OCIO_LUT_SUPPORT else if(type == "CDLTransform") { CDLTransformRcPtr temp; load(node, temp); t = temp; } +#endif //OCIO_LUT_SUPPORT else if(type == "ColorSpaceTransform") { ColorSpaceTransformRcPtr temp; @@ -2982,12 +2989,16 @@ void load(const YAML::Node& node, TransformRcPtr& t) load(node, temp); t = temp; } +#if OCIO_LUT_SUPPORT + else if(type == "FileTransform") { FileTransformRcPtr temp; load(node, temp); t = temp; } +#endif //OCIO_LUT_SUPPORT + else if(type == "FixedFunctionTransform") { FixedFunctionTransformRcPtr temp; @@ -3080,9 +3091,11 @@ void save(YAML::Emitter& out, ConstTransformRcPtr t, unsigned int majorVersion) else if (ConstBuiltinTransformRcPtr builtin_tran = \ DynamicPtrCast(t)) save(out, builtin_tran); +#if OCIO_LUT_SUPPORT else if(ConstCDLTransformRcPtr CDL_tran = \ DynamicPtrCast(t)) save(out, CDL_tran, majorVersion); +#endif //OCIO_LUT_SUPPORT else if(ConstColorSpaceTransformRcPtr ColorSpace_tran = \ DynamicPtrCast(t)) save(out, ColorSpace_tran); @@ -3095,9 +3108,11 @@ void save(YAML::Emitter& out, ConstTransformRcPtr t, unsigned int majorVersion) else if (ConstExponentWithLinearTransformRcPtr ExpLinear_tran = \ DynamicPtrCast(t)) save(out, ExpLinear_tran); +#if OCIO_LUT_SUPPORT else if(ConstFileTransformRcPtr File_tran = \ DynamicPtrCast(t)) save(out, File_tran, majorVersion); +#endif OCIO_LUT_SUPPORT else if (ConstExposureContrastTransformRcPtr File_tran = \ DynamicPtrCast(t)) save(out, File_tran); diff --git a/src/OpenColorIO/OCIOZArchive.cpp b/src/OpenColorIO/OCIOZArchive.cpp index 982fce6823..27a77283d9 100644 --- a/src/OpenColorIO/OCIOZArchive.cpp +++ b/src/OpenColorIO/OCIOZArchive.cpp @@ -1,5 +1,7 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include +#if OCIO_ARCHIVE_SUPPORT #include #include @@ -10,7 +12,6 @@ #include -#include #include "Mutex.h" #include "Platform.h" @@ -652,3 +653,5 @@ void CIOPOciozArchive::buildEntries() } } // namespace OCIO_NAMESPACE + +#endif //OCIO_ARCHIVE_SUPPORT \ No newline at end of file diff --git a/src/OpenColorIO/OCIOZArchive.h b/src/OpenColorIO/OCIOZArchive.h index 5bdbc6315b..4713681cc7 100644 --- a/src/OpenColorIO/OCIOZArchive.h +++ b/src/OpenColorIO/OCIOZArchive.h @@ -5,13 +5,16 @@ #ifndef INCLUDED_OCIO_ARCHIVEUTILS_H #define INCLUDED_OCIO_ARCHIVEUTILS_H +#include + +#if OCIO_ARCHIVE_SUPPORT + #include #include #include #include #include -#include namespace OCIO_NAMESPACE { @@ -108,4 +111,5 @@ class CIOPOciozArchive : public ConfigIOProxy } // namespace OCIO_NAMESPACE +#endif //OCIO_ARCHIVE_SUPPORT #endif diff --git a/src/OpenColorIO/Op.cpp b/src/OpenColorIO/Op.cpp index 81dfe9867e..532581aae0 100755 --- a/src/OpenColorIO/Op.cpp +++ b/src/OpenColorIO/Op.cpp @@ -488,9 +488,11 @@ void CreateOpVecFromOpData(OpRcPtrVec & ops, { case OpData::CDLType: { +#if OCIO_LUT_SUPPORT auto cdlSrc = std::dynamic_pointer_cast(opData); auto cdl = std::make_shared(*cdlSrc); CreateCDLOp(ops, cdl, dir); +#endif //OCIO_LUT_SUPPORT break; } @@ -558,6 +560,7 @@ void CreateOpVecFromOpData(OpRcPtrVec & ops, break; } +#if OCIO_LUT_SUPPORT case OpData::Lut1DType: { auto lutSrc = std::dynamic_pointer_cast(opData); @@ -573,6 +576,12 @@ void CreateOpVecFromOpData(OpRcPtrVec & ops, CreateLut3DOp(ops, lut, dir); break; } +#else + case OpData::Lut1DType: + case OpData::Lut3DType: + throw Exception("LUT support is not enabled in this build"); + break; +#endif //OCIO_LUT_SUPPORT case OpData::MatrixType: { diff --git a/src/OpenColorIO/OpBuilders.h b/src/OpenColorIO/OpBuilders.h index cfeabcf6dd..c94efab2eb 100644 --- a/src/OpenColorIO/OpBuilders.h +++ b/src/OpenColorIO/OpBuilders.h @@ -83,12 +83,13 @@ void BuildExponentWithLinearOp(OpRcPtrVec & ops, void BuildExposureContrastOp(OpRcPtrVec & ops, const ExposureContrastTransform & transform, TransformDirection dir); - +#if OCIO_LUT_SUPPORT void BuildFileTransformOps(OpRcPtrVec & ops, const Config & config, const ConstContextRcPtr & context, const FileTransform & transform, TransformDirection dir); +#endif //OCIO_LUT_SUPPORT void BuildFixedFunctionOp(OpRcPtrVec & ops, const FixedFunctionTransform & transform, @@ -142,7 +143,7 @@ void BuildLookOps(OpRcPtrVec & ops, const Config & config, const ConstContextRcPtr & context, const LookParseResult & looks); - +#if OCIO_LUT_SUPPORT void BuildLut1DOp(OpRcPtrVec & ops, const Lut1DTransform & transform, TransformDirection dir); @@ -150,6 +151,7 @@ void BuildLut1DOp(OpRcPtrVec & ops, void BuildLut3DOp(OpRcPtrVec & ops, const Lut3DTransform & transform, TransformDirection dir); +#endif //OCIO_LUT_SUPPORT void BuildMatrixOp(OpRcPtrVec & ops, const MatrixTransform & transform, diff --git a/src/OpenColorIO/OpOptimizers.cpp b/src/OpenColorIO/OpOptimizers.cpp index 7788bfb164..5b2fb0fb0e 100755 --- a/src/OpenColorIO/OpOptimizers.cpp +++ b/src/OpenColorIO/OpOptimizers.cpp @@ -244,6 +244,7 @@ int RemoveInverseOps(OpRcPtrVec & opVec, OptimizationFlags oFlags) // mean inserting a Range to emulate the clamping done by the original ops. OpRcPtr replacedBy; +#if OCIO_LUT_SUPPORT if (type1 == OpData::Lut1DType) { // Lut1D gets special handling so that both halfs of the pair are available. @@ -270,6 +271,7 @@ int RemoveInverseOps(OpRcPtrVec & opVec, OptimizationFlags oFlags) replacedBy = ops[0]; } else +#endif //OCIO_LUT_SUPPORT { replacedBy = op1->getIdentityReplacement(); } @@ -364,6 +366,7 @@ int ReplaceInverseLuts(OpRcPtrVec & opVec) ConstOpRcPtr op = opVec[i]; auto opData = op->data(); const auto type = opData->getType(); +#if OCIO_LUT_SUPPORT if (type == OpData::Lut1DType) { auto lutData = OCIO_DYNAMIC_POINTER_CAST(opData); @@ -390,6 +393,8 @@ int ReplaceInverseLuts(OpRcPtrVec & opVec) ++count; } } +#endif //OCIO_LUT_SUPPORT + } return count; @@ -481,6 +486,7 @@ unsigned FindSeparablePrefix(const OpRcPtrVec & ops) // If the only op is a 1D LUT, there is actually nothing to optimize // so set the length to 0. (This also avoids an infinite loop.) // (If it is an inverse 1D LUT, proceed since we want to replace it with a 1D LUT.) +#if OCIO_LUT_SUPPORT if (prefixLen == 1) { ConstOpRcPtr constOp0 = ops[0]; @@ -494,6 +500,7 @@ unsigned FindSeparablePrefix(const OpRcPtrVec & ops) } } } +#endif //OCIO_LUT_SUPPORT // Some ops are so fast that it may not make sense to replace just one of those. // E.g., if it's just a single matrix, it may not be faster to replace it with a LUT. @@ -540,6 +547,7 @@ unsigned FindSeparablePrefix(const OpRcPtrVec & ops) // the op list with a single 1D LUT that is built to do a look-up for the input bit-depth. void OptimizeSeparablePrefix(OpRcPtrVec & ops, BitDepth in) { +#if OCIO_LUT_SUPPORT if (ops.empty()) { return; @@ -580,6 +588,7 @@ void OptimizeSeparablePrefix(OpRcPtrVec & ops, BitDepth in) FinalizeOps(lutOps); ops.insert(ops.begin(), lutOps.begin(), lutOps.end()); +#endif OCIO_LUT_SUPPORT } } // namespace diff --git a/src/OpenColorIO/Processor.cpp b/src/OpenColorIO/Processor.cpp index dab0287dfb..3af92f0b02 100755 --- a/src/OpenColorIO/Processor.cpp +++ b/src/OpenColorIO/Processor.cpp @@ -432,7 +432,7 @@ ConstGPUProcessorRcPtr Processor::Impl::getOptimizedGPUProcessor(OptimizationFla ConstGPUProcessorRcPtr Processor::Impl::getOptimizedLegacyGPUProcessor(OptimizationFlags oFlags, unsigned edgelen) const { - +#if OCIO_LUT_SUPPORT OpRcPtrVec gpuOps = m_ops; { @@ -471,6 +471,9 @@ ConstGPUProcessorRcPtr Processor::Impl::getOptimizedLegacyGPUProcessor(Optimizat } return getGPUProcessor(gpuOps, oFlags); +#else + throw Exception("LUT support is turned off."); +#endif //OCIO_LUT_SUPPORT } ConstGPUProcessorRcPtr Processor::Impl::getGPUProcessor(const OpRcPtrVec & gpuOps, diff --git a/src/OpenColorIO/Transform.cpp b/src/OpenColorIO/Transform.cpp index 0d723212e6..2c5f64033a 100755 --- a/src/OpenColorIO/Transform.cpp +++ b/src/OpenColorIO/Transform.cpp @@ -58,11 +58,13 @@ void BuildOps(OpRcPtrVec & ops, { BuildBuiltinOps(ops, *builtInTransform, dir); } +#if OCIO_LUT_SUPPORT else if(ConstCDLTransformRcPtr cdlTransform = \ DynamicPtrCast(transform)) { BuildCDLOp(ops, config, *cdlTransform, dir); } +#endif //OCIO_LUT_SUPPORT else if(ConstColorSpaceTransformRcPtr colorSpaceTransform = \ DynamicPtrCast(transform)) { @@ -88,11 +90,13 @@ void BuildOps(OpRcPtrVec & ops, { BuildExposureContrastOp(ops, *ecTransform, dir); } +#if OCIO_LUT_SUPPORT else if(ConstFileTransformRcPtr fileTransform = \ DynamicPtrCast(transform)) { BuildFileTransformOps(ops, config, context, *fileTransform, dir); } +#endif //OCIO_LUT_SUPPORT else if (ConstFixedFunctionTransformRcPtr fixedFunctionTransform = \ DynamicPtrCast(transform)) { @@ -138,6 +142,7 @@ void BuildOps(OpRcPtrVec & ops, { BuildLookOps(ops, config, context, *lookTransform, dir); } +#if OCIO_LUT_SUPPORT else if (ConstLut1DTransformRcPtr lut1dTransform = \ DynamicPtrCast(transform)) { @@ -148,6 +153,7 @@ void BuildOps(OpRcPtrVec & ops, { BuildLut3DOp(ops, *lut3dTransform, dir); } +#endif //OCIO_LUT_SUPPORT else if(ConstMatrixTransformRcPtr matrixTransform = \ DynamicPtrCast(transform)) { @@ -182,11 +188,13 @@ std::ostream& operator<< (std::ostream & os, const Transform & transform) { os << *builtInTransform; } +#if OCIO_LUT_SUPPORT else if(const CDLTransform * cdlTransform = \ dynamic_cast(t)) { os << *cdlTransform; } +#endif //OCIO_LUT_SUPPORT else if(const ColorSpaceTransform * colorSpaceTransform = \ dynamic_cast(t)) { @@ -212,11 +220,13 @@ std::ostream& operator<< (std::ostream & os, const Transform & transform) { os << *ecTransform; } +#if OCIO_LUT_SUPPORT else if(const FileTransform * fileTransform = \ dynamic_cast(t)) { os << *fileTransform; } +#endif //OCIO_LUT_SUPPORT else if(const FixedFunctionTransform * fixedFunctionTransform = \ dynamic_cast(t)) { @@ -262,6 +272,7 @@ std::ostream& operator<< (std::ostream & os, const Transform & transform) { os << *lookTransform; } +#if OCIO_LUT_SUPPORT else if (const Lut1DTransform * lut1dTransform = \ dynamic_cast(t)) { @@ -272,6 +283,7 @@ std::ostream& operator<< (std::ostream & os, const Transform & transform) { os << *lut3dTransform; } +#endif //OCIO_LUT_SUPPORT else if(const MatrixTransform * matrixTransform = \ dynamic_cast(t)) { @@ -303,12 +315,14 @@ void CreateTransform(GroupTransformRcPtr & group, ConstOpRcPtr & op) return; auto data = op->data(); - +#if OCIO_LUT_SUPPORT if (DynamicPtrCast(data)) { CreateCDLTransform(group, op); } - else if (DynamicPtrCast(data)) + else +#endif //OCIO_LUT_SUPPORT + if (DynamicPtrCast(data)) { CreateExponentTransform(group, op); } @@ -340,6 +354,7 @@ void CreateTransform(GroupTransformRcPtr & group, ConstOpRcPtr & op) { CreateLogTransform(group, op); } +#if OCIO_LUT_SUPPORT //TODO Nano: throw? else if (DynamicPtrCast(data)) { CreateLut1DTransform(group, op); @@ -348,6 +363,7 @@ void CreateTransform(GroupTransformRcPtr & group, ConstOpRcPtr & op) { CreateLut3DTransform(group, op); } +#endif //OCIO_LUT_SUPPORT else if (DynamicPtrCast(data)) { CreateMatrixTransform(group, op); diff --git a/src/OpenColorIO/apphelpers/ColorSpaceHelpers.cpp b/src/OpenColorIO/apphelpers/ColorSpaceHelpers.cpp index 811881c141..a75fbef192 100644 --- a/src/OpenColorIO/apphelpers/ColorSpaceHelpers.cpp +++ b/src/OpenColorIO/apphelpers/ColorSpaceHelpers.cpp @@ -723,8 +723,10 @@ std::ostream & operator<<(std::ostream & os, const ColorSpaceMenuHelper & menu) namespace ColorSpaceHelpers { +#if OCIO_LUT_SUPPORT namespace { + void AddColorSpace(ConfigRcPtr & config, ColorSpaceRcPtr & colorSpace, FileTransformRcPtr & userTransform, @@ -833,6 +835,7 @@ void AddColorSpace(ConfigRcPtr & config, AddColorSpace(config, *info, file, categories, connectionColorSpaceName); } +#endif //OCIO_LUT_SUPPORT } // ColorSpaceHelpers diff --git a/src/OpenColorIO/apphelpers/DisplayViewHelpers.cpp b/src/OpenColorIO/apphelpers/DisplayViewHelpers.cpp index d4055f46c1..b1ebd48285 100644 --- a/src/OpenColorIO/apphelpers/DisplayViewHelpers.cpp +++ b/src/OpenColorIO/apphelpers/DisplayViewHelpers.cpp @@ -375,6 +375,7 @@ void RemoveActiveDisplayView(ConfigRcPtr & config, const char * displayName, con } } +#if OCIO_LUT_SUPPORT void AddDisplayView(ConfigRcPtr & config, const char * displayName, const char * viewName, @@ -499,6 +500,7 @@ void AddDisplayView(ConfigRcPtr & config, colorSpace, file, connectionColorSpaceName); } +#endif //OCIO_LUT_SUPPORT void RemoveDisplayView(ConfigRcPtr & config, const char * displayName, const char * viewName) { diff --git a/src/OpenColorIO/fileformats/FileFormat3DL.cpp b/src/OpenColorIO/fileformats/FileFormat3DL.cpp index 0babf55206..362a2c981d 100755 --- a/src/OpenColorIO/fileformats/FileFormat3DL.cpp +++ b/src/OpenColorIO/fileformats/FileFormat3DL.cpp @@ -1,12 +1,15 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include + +#if OCIO_LUT_SUPPORT + #include #include #include #include -#include #include "BitDepthUtils.h" #include "fileformats/FileFormatUtils.h" @@ -642,3 +645,5 @@ FileFormat * CreateFileFormat3DL() } } // namespace OCIO_NAMESPACE + +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/FileFormatCC.cpp b/src/OpenColorIO/fileformats/FileFormatCC.cpp index d8791f8196..a4854ca419 100755 --- a/src/OpenColorIO/fileformats/FileFormatCC.cpp +++ b/src/OpenColorIO/fileformats/FileFormatCC.cpp @@ -2,6 +2,8 @@ // Copyright Contributors to the OpenColorIO Project. #include +#if OCIO_LUT_SUPPORT + #include "fileformats/cdl/CDLParser.h" #include "fileformats/cdl/CDLWriter.h" @@ -166,3 +168,4 @@ FileFormat * CreateFileFormatCC() } } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/FileFormatCCC.cpp b/src/OpenColorIO/fileformats/FileFormatCCC.cpp index bad7723efa..44746d5408 100755 --- a/src/OpenColorIO/fileformats/FileFormatCCC.cpp +++ b/src/OpenColorIO/fileformats/FileFormatCCC.cpp @@ -1,9 +1,11 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. -#include +#include "transforms/FileTransform.h" -#include +#if OCIO_LUT_SUPPORT + +#include #include "fileformats/cdl/CDLParser.h" #include "fileformats/cdl/CDLWriter.h" @@ -11,7 +13,6 @@ #include "fileformats/xmlutils/XMLWriterUtils.h" #include "fileformats/FormatMetadata.h" #include "transforms/CDLTransform.h" -#include "transforms/FileTransform.h" #include "OpBuilders.h" #include "ParseUtils.h" @@ -257,3 +258,4 @@ FileFormat * CreateFileFormatCCC() return new LocalFileFormat(); } } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/FileFormatCDL.cpp b/src/OpenColorIO/fileformats/FileFormatCDL.cpp index 5da6aae953..d592459a98 100755 --- a/src/OpenColorIO/fileformats/FileFormatCDL.cpp +++ b/src/OpenColorIO/fileformats/FileFormatCDL.cpp @@ -25,10 +25,11 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include +#if OCIO_LUT_SUPPORT #include -#include #include "fileformats/cdl/CDLParser.h" #include "fileformats/cdl/CDLWriter.h" @@ -290,3 +291,4 @@ FileFormat * CreateFileFormatCDL() } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/FileFormatCSP.cpp b/src/OpenColorIO/fileformats/FileFormatCSP.cpp index 418edfa570..9c421dcec6 100755 --- a/src/OpenColorIO/fileformats/FileFormatCSP.cpp +++ b/src/OpenColorIO/fileformats/FileFormatCSP.cpp @@ -1,5 +1,8 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include +#if OCIO_LUT_SUPPORT + #include #include @@ -11,7 +14,6 @@ #include #include -#include #include "fileformats/FileFormatUtils.h" #include "MathUtils.h" @@ -925,3 +927,4 @@ FileFormat * CreateFileFormatCSP() return new LocalFileFormat(); } } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/FileFormatCTF.cpp b/src/OpenColorIO/fileformats/FileFormatCTF.cpp index c9ada57cda..9f1ef3478a 100644 --- a/src/OpenColorIO/fileformats/FileFormatCTF.cpp +++ b/src/OpenColorIO/fileformats/FileFormatCTF.cpp @@ -1,6 +1,10 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include +#if OCIO_LUT_SUPPORT + + #include #include #include @@ -8,7 +12,6 @@ #include -#include #include "expat.h" #include "fileformats/ctf/CTFTransform.h" @@ -1578,3 +1581,4 @@ FileFormat * CreateFileFormatCLF() } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/FileFormatDiscreet1DL.cpp b/src/OpenColorIO/fileformats/FileFormatDiscreet1DL.cpp index 6a76d968d4..dbf4e79084 100755 --- a/src/OpenColorIO/fileformats/FileFormatDiscreet1DL.cpp +++ b/src/OpenColorIO/fileformats/FileFormatDiscreet1DL.cpp @@ -1,5 +1,8 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include +#if OCIO_LUT_SUPPORT + #include #include @@ -10,7 +13,6 @@ #include -#include #include "BitDepthUtils.h" #include "fileformats/FileFormatUtils.h" @@ -772,3 +774,4 @@ FileFormat * CreateFileFormatDiscreet1DL() } } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/FileFormatHDL.cpp b/src/OpenColorIO/fileformats/FileFormatHDL.cpp index 16e0ffab53..8a9d979a1c 100755 --- a/src/OpenColorIO/fileformats/FileFormatHDL.cpp +++ b/src/OpenColorIO/fileformats/FileFormatHDL.cpp @@ -17,6 +17,9 @@ - Add support for 'Sampling' tag */ +#include +#if OCIO_LUT_SUPPORT + #include #include @@ -27,7 +30,6 @@ #include #include -#include #include "fileformats/FileFormatUtils.h" #include "MathUtils.h" @@ -886,3 +888,4 @@ FileFormat * CreateFileFormatHDL() } } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/FileFormatICC.cpp b/src/OpenColorIO/fileformats/FileFormatICC.cpp index 4768101129..5633fb77f7 100755 --- a/src/OpenColorIO/fileformats/FileFormatICC.cpp +++ b/src/OpenColorIO/fileformats/FileFormatICC.cpp @@ -1,13 +1,15 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include +#if OCIO_LUT_SUPPORT + #include #include #include -#include #include "Logging.h" #include "fileformats/FileFormatUtils.h" @@ -910,3 +912,4 @@ std::string GetProfileDescriptionFromICCProfile(const char * ICCProfileFilepath) } } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/FileFormatIridasCube.cpp b/src/OpenColorIO/fileformats/FileFormatIridasCube.cpp index aa00f7febc..ec0d7ab835 100755 --- a/src/OpenColorIO/fileformats/FileFormatIridasCube.cpp +++ b/src/OpenColorIO/fileformats/FileFormatIridasCube.cpp @@ -1,12 +1,15 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include + +#if OCIO_LUT_SUPPORT + #include #include #include #include -#include #include "fileformats/FileFormatUtils.h" #include "ops/lut1d/Lut1DOp.h" @@ -564,3 +567,5 @@ FileFormat * CreateFileFormatIridasCube() } } // namespace OCIO_NAMESPACE + +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/FileFormatIridasItx.cpp b/src/OpenColorIO/fileformats/FileFormatIridasItx.cpp index be903d5d33..75af1b315e 100755 --- a/src/OpenColorIO/fileformats/FileFormatIridasItx.cpp +++ b/src/OpenColorIO/fileformats/FileFormatIridasItx.cpp @@ -1,12 +1,13 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include +#if OCIO_LUT_SUPPORT #include #include #include #include -#include #include "fileformats/FileFormatUtils.h" #include "ops/lut1d/Lut1DOp.h" @@ -323,3 +324,4 @@ FileFormat * CreateFileFormatIridasItx() } } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/FileFormatIridasLook.cpp b/src/OpenColorIO/fileformats/FileFormatIridasLook.cpp index 0ba209a905..d22ea8712c 100755 --- a/src/OpenColorIO/fileformats/FileFormatIridasLook.cpp +++ b/src/OpenColorIO/fileformats/FileFormatIridasLook.cpp @@ -1,5 +1,8 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include +#if OCIO_LUT_SUPPORT + #include #include @@ -7,7 +10,6 @@ #include -#include #include "expat.h" #include "fileformats/FileFormatUtils.h" @@ -580,3 +582,4 @@ FileFormat * CreateFileFormatIridasLook() } } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/FileFormatPandora.cpp b/src/OpenColorIO/fileformats/FileFormatPandora.cpp index 5018de6ac3..387d515435 100755 --- a/src/OpenColorIO/fileformats/FileFormatPandora.cpp +++ b/src/OpenColorIO/fileformats/FileFormatPandora.cpp @@ -1,11 +1,13 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include +#if OCIO_LUT_SUPPORT + #include #include #include -#include #include "BitDepthUtils.h" #include "fileformats/FileFormatUtils.h" @@ -312,3 +314,4 @@ FileFormat * CreateFileFormatPandora() } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/FileFormatResolveCube.cpp b/src/OpenColorIO/fileformats/FileFormatResolveCube.cpp index 9c5e23180e..580bb70b50 100755 --- a/src/OpenColorIO/fileformats/FileFormatResolveCube.cpp +++ b/src/OpenColorIO/fileformats/FileFormatResolveCube.cpp @@ -1,12 +1,14 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include + +#if OCIO_LUT_SUPPORT #include #include #include #include -#include #include "fileformats/FileFormatUtils.h" #include "ops/lut1d/Lut1DOp.h" @@ -786,3 +788,4 @@ FileFormat * CreateFileFormatResolveCube() } } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/FileFormatSpi1D.cpp b/src/OpenColorIO/fileformats/FileFormatSpi1D.cpp index e2e4822b45..4d360a540b 100755 --- a/src/OpenColorIO/fileformats/FileFormatSpi1D.cpp +++ b/src/OpenColorIO/fileformats/FileFormatSpi1D.cpp @@ -1,12 +1,15 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include + +#if OCIO_LUT_SUPPORT + #include #include #include #include -#include #include "fileformats/FileFormatUtils.h" #include "ops/lut1d/Lut1DOp.h" @@ -459,3 +462,4 @@ FileFormat * CreateFileFormatSpi1D() } } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/FileFormatSpi3D.cpp b/src/OpenColorIO/fileformats/FileFormatSpi3D.cpp index c3ef153f43..c846bb0e3c 100755 --- a/src/OpenColorIO/fileformats/FileFormatSpi3D.cpp +++ b/src/OpenColorIO/fileformats/FileFormatSpi3D.cpp @@ -1,11 +1,13 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include +#if OCIO_LUT_SUPPORT + #include #include #include -#include #include "fileformats/FileFormatUtils.h" #include "ops/lut3d/Lut3DOp.h" @@ -338,3 +340,4 @@ FileFormat * CreateFileFormatSpi3D() } } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/FileFormatSpiMtx.cpp b/src/OpenColorIO/fileformats/FileFormatSpiMtx.cpp index 663a4e9a5d..2e096091db 100755 --- a/src/OpenColorIO/fileformats/FileFormatSpiMtx.cpp +++ b/src/OpenColorIO/fileformats/FileFormatSpiMtx.cpp @@ -1,11 +1,12 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include +#if OCIO_LUT_SUPPORT #include #include #include -#include #include "ops/matrix/MatrixOp.h" #include "ParseUtils.h" @@ -168,3 +169,4 @@ FileFormat * CreateFileFormatSpiMtx() } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/FileFormatTruelight.cpp b/src/OpenColorIO/fileformats/FileFormatTruelight.cpp index e3ee605026..a3529ba4ed 100755 --- a/src/OpenColorIO/fileformats/FileFormatTruelight.cpp +++ b/src/OpenColorIO/fileformats/FileFormatTruelight.cpp @@ -1,5 +1,8 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include +#if OCIO_LUT_SUPPORT + #include #include @@ -7,7 +10,6 @@ #include #include -#include #include "fileformats/FileFormatUtils.h" #include "ops/lut1d/Lut1DOp.h" @@ -399,3 +401,4 @@ FileFormat * CreateFileFormatTruelight() } } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/FileFormatUtils.cpp b/src/OpenColorIO/fileformats/FileFormatUtils.cpp index 1e1906ba9a..f2d48af956 100644 --- a/src/OpenColorIO/fileformats/FileFormatUtils.cpp +++ b/src/OpenColorIO/fileformats/FileFormatUtils.cpp @@ -1,9 +1,10 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. - #include "fileformats/FileFormatUtils.h" +#if OCIO_LUT_SUPPORT + #include "Logging.h" namespace OCIO_NAMESPACE @@ -65,3 +66,4 @@ void LogWarningInterpolationNotUsed(Interpolation interp, const FileTransform & LogWarning(oss.str()); } } // OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/FileFormatUtils.h b/src/OpenColorIO/fileformats/FileFormatUtils.h index c3808b95dd..33f43ca173 100644 --- a/src/OpenColorIO/fileformats/FileFormatUtils.h +++ b/src/OpenColorIO/fileformats/FileFormatUtils.h @@ -7,11 +7,14 @@ #include +#if OCIO_LUT_SUPPORT + #include "ops/lut1d/Lut1DOpData.h" #include "ops/lut3d/Lut3DOpData.h" namespace OCIO_NAMESPACE { + Lut1DOpDataRcPtr HandleLUT1D(const Lut1DOpDataRcPtr & fileLut1D, Interpolation fileInterp, bool & fileInterpUsed); @@ -21,6 +24,9 @@ Lut3DOpDataRcPtr HandleLUT3D(const Lut3DOpDataRcPtr & fileLut3D, bool & fileInterpUsed); void LogWarningInterpolationNotUsed(Interpolation interp, const FileTransform & fileTransform); + + } // OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT #endif // INCLUDED_OCIO_FILEFORMAT_UTILS_H \ No newline at end of file diff --git a/src/OpenColorIO/fileformats/FileFormatVF.cpp b/src/OpenColorIO/fileformats/FileFormatVF.cpp index 03ff191d5f..c2fdb94761 100755 --- a/src/OpenColorIO/fileformats/FileFormatVF.cpp +++ b/src/OpenColorIO/fileformats/FileFormatVF.cpp @@ -1,12 +1,14 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include +#if OCIO_LUT_SUPPORT + #include #include #include #include -#include #include "fileformats/FileFormatUtils.h" #include "ops/lut3d/Lut3DOp.h" @@ -320,3 +322,4 @@ FileFormat * CreateFileFormatVF() } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/cdl/CDLParser.cpp b/src/OpenColorIO/fileformats/cdl/CDLParser.cpp index 1c02d7670e..72239299b3 100644 --- a/src/OpenColorIO/fileformats/cdl/CDLParser.cpp +++ b/src/OpenColorIO/fileformats/cdl/CDLParser.cpp @@ -1,6 +1,10 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include "transforms/CDLTransform.h" + +#if OCIO_LUT_SUPPORT + #include #include "expat.h" @@ -8,7 +12,6 @@ #include "fileformats/cdl/CDLReaderHelper.h" #include "fileformats/xmlutils/XMLReaderHelper.h" #include "fileformats/xmlutils/XMLReaderUtils.h" -#include "transforms/CDLTransform.h" #include "Platform.h" namespace OCIO_NAMESPACE @@ -1015,3 +1018,5 @@ bool CDLParser::isCCC() const } } // namespace OCIO_NAMESPACE + +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/cdl/CDLReaderHelper.cpp b/src/OpenColorIO/fileformats/cdl/CDLReaderHelper.cpp index 38eaab76dd..5c45f67c54 100644 --- a/src/OpenColorIO/fileformats/cdl/CDLReaderHelper.cpp +++ b/src/OpenColorIO/fileformats/cdl/CDLReaderHelper.cpp @@ -2,6 +2,9 @@ // Copyright Contributors to the OpenColorIO Project. #include "fileformats/cdl/CDLReaderHelper.h" + +#if OCIO_LUT_SUPPORT + #include "fileformats/xmlutils/XMLReaderUtils.h" namespace OCIO_NAMESPACE @@ -85,3 +88,5 @@ void CDLReaderColorCorrectionElt::appendMetadata(const std::string & name, const } } // namespace OCIO_NAMESPACE + +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/cdl/CDLReaderHelper.h b/src/OpenColorIO/fileformats/cdl/CDLReaderHelper.h index b67e4e2144..520730cf9a 100644 --- a/src/OpenColorIO/fileformats/cdl/CDLReaderHelper.h +++ b/src/OpenColorIO/fileformats/cdl/CDLReaderHelper.h @@ -3,10 +3,13 @@ #ifndef INCLUDED_OCIO_FILEFORMATS_CDL_CDLREADERHELPER_H #define INCLUDED_OCIO_FILEFORMATS_CDL_CDLREADERHELPER_H +#include "transforms/CDLTransform.h" + +#if OCIO_LUT_SUPPORT + #include "fileformats/xmlutils/XMLReaderHelper.h" #include "Op.h" -#include "transforms/CDLTransform.h" namespace OCIO_NAMESPACE { @@ -213,5 +216,6 @@ class CDLReaderSatNodeCCElt : public XmlReaderSatNodeBaseElt }; } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT #endif \ No newline at end of file diff --git a/src/OpenColorIO/fileformats/cdl/CDLWriter.cpp b/src/OpenColorIO/fileformats/cdl/CDLWriter.cpp index 809785ec98..ad18702f16 100644 --- a/src/OpenColorIO/fileformats/cdl/CDLWriter.cpp +++ b/src/OpenColorIO/fileformats/cdl/CDLWriter.cpp @@ -1,13 +1,16 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include "transforms/CDLTransform.h" + +#if OCIO_LUT_SUPPORT + #include #include "fileformats/cdl/CDLWriter.h" #include "fileformats/xmlutils/XMLReaderUtils.h" #include "fileformats/xmlutils/XMLWriterUtils.h" #include "ParseUtils.h" -#include "transforms/CDLTransform.h" #include "transforms/FileTransform.h" namespace OCIO_NAMESPACE @@ -112,3 +115,4 @@ void Write(XmlFormatter & fmt, const ConstCDLTransformRcPtr & cdl) } } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/ctf/CTFReaderHelper.cpp b/src/OpenColorIO/fileformats/ctf/CTFReaderHelper.cpp index 146913f4a3..00d39c3889 100644 --- a/src/OpenColorIO/fileformats/ctf/CTFReaderHelper.cpp +++ b/src/OpenColorIO/fileformats/ctf/CTFReaderHelper.cpp @@ -12,6 +12,8 @@ #include "Platform.h" #include "utils/StringUtils.h" +#if OCIO_LUT_SUPPORT + namespace OCIO_NAMESPACE { @@ -4915,3 +4917,4 @@ const OpDataRcPtr CTFReaderReferenceElt::getOp() const } // namespace OCIO_NAMESPACE +#endif OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/ctf/CTFReaderHelper.h b/src/OpenColorIO/fileformats/ctf/CTFReaderHelper.h index dff332595d..38e7c32573 100644 --- a/src/OpenColorIO/fileformats/ctf/CTFReaderHelper.h +++ b/src/OpenColorIO/fileformats/ctf/CTFReaderHelper.h @@ -23,6 +23,8 @@ #include "ops/range/RangeOpData.h" #include "ops/reference/ReferenceOpData.h" +#if OCIO_LUT_SUPPORT + namespace OCIO_NAMESPACE { @@ -311,8 +313,8 @@ class CTFReaderOpElt : public XmlReaderContainerElt enum Type { CDLType = 0, - Lut1DType, - Lut3DType, + Lut1DType, //TODO Nano: remove? + Lut3DType,//TODO Nano: remove? MatrixType, RangeType, // CTF types. @@ -324,8 +326,8 @@ class CTFReaderOpElt : public XmlReaderContainerElt GradingPrimaryType, GradingRGBCurveType, GradingToneType, - InvLut1DType, - InvLut3DType, + InvLut1DType,//TODO Nano: remove? + InvLut3DType,//TODO Nano: remove? LogType, ReferenceType, @@ -1214,5 +1216,6 @@ class CTFReaderDynamicParamElt : public XmlReaderPlainElt }; } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT #endif diff --git a/src/OpenColorIO/fileformats/ctf/CTFTransform.cpp b/src/OpenColorIO/fileformats/ctf/CTFTransform.cpp index 80dd5812f7..662ef67756 100644 --- a/src/OpenColorIO/fileformats/ctf/CTFTransform.cpp +++ b/src/OpenColorIO/fileformats/ctf/CTFTransform.cpp @@ -28,6 +28,8 @@ #include "Platform.h" #include "transforms/CDLTransform.h" +#if OCIO_LUT_SUPPORT + namespace OCIO_NAMESPACE { @@ -1870,7 +1872,7 @@ void LogWriter::writeContent() const /////////////////////////////////////////////////////////////////////////////// - +#if OCIO_LUT_SUPPORT class Lut1DWriter : public OpWriter { public: @@ -2105,6 +2107,7 @@ void Lut3DWriter::writeContent() const m_formatter.writeEndTag(TAG_ARRAY); } +#endif //OCIO_LUT_SUPPORT /////////////////////////////////////////////////////////////////////////////// @@ -2772,3 +2775,4 @@ void TransformWriter::writeOps(const CTFVersion & version) const } } // namespace OCIO_NAMESPACE +#endif OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/xmlutils/XMLReaderHelper.cpp b/src/OpenColorIO/fileformats/xmlutils/XMLReaderHelper.cpp index d5b5be5dcf..124f463cf1 100644 --- a/src/OpenColorIO/fileformats/xmlutils/XMLReaderHelper.cpp +++ b/src/OpenColorIO/fileformats/xmlutils/XMLReaderHelper.cpp @@ -1,9 +1,12 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include "fileformats/xmlutils/XMLReaderHelper.h" + +#if OCIO_LUT_SUPPORT + #include -#include "fileformats/xmlutils/XMLReaderHelper.h" #include "fileformats/xmlutils/XMLReaderUtils.h" #include "Logging.h" #include "ParseUtils.h" @@ -282,3 +285,4 @@ void XmlReaderSaturationElt::setRawData(const char* str, size_t len, unsigned in } } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/xmlutils/XMLReaderHelper.h b/src/OpenColorIO/fileformats/xmlutils/XMLReaderHelper.h index 203d3bcdfc..742ef72211 100644 --- a/src/OpenColorIO/fileformats/xmlutils/XMLReaderHelper.h +++ b/src/OpenColorIO/fileformats/xmlutils/XMLReaderHelper.h @@ -386,18 +386,21 @@ class XmlReaderSOPNodeBaseElt : public XmlReaderComplexElt } } - virtual const CDLOpDataRcPtr & getCDL() const = 0; void setIsSlopeInit(bool status) { m_isSlopeInit = status; } void setIsOffsetInit(bool status) { m_isOffsetInit = status; } void setIsPowerInit(bool status) { m_isPowerInit = status; } +#if OCIO_LUT_SUPPORT + + virtual const CDLOpDataRcPtr & getCDL() const = 0; void appendMetadata(const std::string & /* name */, const std::string & value) override { // Add description to parent and override name. FormatMetadataImpl item(METADATA_SOP_DESCRIPTION, value); getCDL()->getFormatMetadata().getChildrenElements().push_back(item); } +#endif //OCIO_LUT_SUPPORT private: XmlReaderSOPNodeBaseElt() = delete; @@ -450,6 +453,7 @@ class XmlReaderSatNodeBaseElt : public XmlReaderComplexElt { } +#if OCIO_LUT_SUPPORT virtual const CDLOpDataRcPtr & getCDL() const = 0; void appendMetadata(const std::string & /* name */, const std::string & value) override @@ -458,6 +462,7 @@ class XmlReaderSatNodeBaseElt : public XmlReaderComplexElt FormatMetadataImpl item(METADATA_SAT_DESCRIPTION, value); getCDL()->getFormatMetadata().getChildrenElements().push_back(item); } +#endif //OCIO_LUT_SUPPORT private: diff --git a/src/OpenColorIO/fileformats/xmlutils/XMLReaderUtils.cpp b/src/OpenColorIO/fileformats/xmlutils/XMLReaderUtils.cpp index 30dd21c55d..60ad0926f1 100644 --- a/src/OpenColorIO/fileformats/xmlutils/XMLReaderUtils.cpp +++ b/src/OpenColorIO/fileformats/xmlutils/XMLReaderUtils.cpp @@ -1,9 +1,12 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include "fileformats/xmlutils/XMLReaderUtils.h" + +#if OCIO_LUT_SUPPORT + #include -#include "fileformats/xmlutils/XMLReaderUtils.h" namespace OCIO_NAMESPACE { @@ -114,3 +117,4 @@ void FindSubString(const char * str, size_t length, } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/fileformats/xmlutils/XMLReaderUtils.h b/src/OpenColorIO/fileformats/xmlutils/XMLReaderUtils.h index 9a813a2551..317a3da828 100644 --- a/src/OpenColorIO/fileformats/xmlutils/XMLReaderUtils.h +++ b/src/OpenColorIO/fileformats/xmlutils/XMLReaderUtils.h @@ -4,13 +4,15 @@ #ifndef INCLUDED_OCIO_FILEFORMATS_XML_XMLREADERUTILS_H #define INCLUDED_OCIO_FILEFORMATS_XML_XMLREADERUTILS_H +#include +#if OCIO_LUT_SUPPORT + #include #include #include #include -#include #include "MathUtils.h" #include "utils/StringUtils.h" @@ -244,5 +246,6 @@ std::vector GetNumbers(const char * str, size_t len) } } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT #endif diff --git a/src/OpenColorIO/ops/cdl/CDLOp.cpp b/src/OpenColorIO/ops/cdl/CDLOp.cpp index bd0511ea43..d171146a8c 100644 --- a/src/OpenColorIO/ops/cdl/CDLOp.cpp +++ b/src/OpenColorIO/ops/cdl/CDLOp.cpp @@ -1,10 +1,12 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include + +#if OCIO_LUT_SUPPORT #include #include -#include #include "BitDepthUtils.h" #include "GpuShaderUtils.h" @@ -266,3 +268,4 @@ void BuildCDLOp(OpRcPtrVec & ops, } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/ops/cdl/CDLOp.h b/src/OpenColorIO/ops/cdl/CDLOp.h index 29681c3cee..dad99677be 100644 --- a/src/OpenColorIO/ops/cdl/CDLOp.h +++ b/src/OpenColorIO/ops/cdl/CDLOp.h @@ -4,10 +4,11 @@ #ifndef INCLUDED_OCIO_CDL_H #define INCLUDED_OCIO_CDL_H +#include +#if OCIO_LUT_SUPPORT #include -#include #include "Op.h" #include "ops/cdl/CDLOpData.h" @@ -35,5 +36,6 @@ void CreateCDLOp(OpRcPtrVec & ops, void CreateCDLTransform(GroupTransformRcPtr & group, ConstOpRcPtr & op); } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT #endif diff --git a/src/OpenColorIO/ops/lut1d/Lut1DOp.cpp b/src/OpenColorIO/ops/lut1d/Lut1DOp.cpp index 412462414b..764199c904 100644 --- a/src/OpenColorIO/ops/lut1d/Lut1DOp.cpp +++ b/src/OpenColorIO/ops/lut1d/Lut1DOp.cpp @@ -1,12 +1,14 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include + +#if OCIO_LUT_SUPPORT #include #include #include #include -#include #include "BitDepthUtils.h" #include "HashUtils.h" @@ -253,3 +255,5 @@ void BuildLut1DOp(OpRcPtrVec & ops, } } // namespace OCIO_NAMESPACE + +#endif \ No newline at end of file diff --git a/src/OpenColorIO/ops/lut1d/Lut1DOp.h b/src/OpenColorIO/ops/lut1d/Lut1DOp.h index f9f224174e..df93e8314a 100644 --- a/src/OpenColorIO/ops/lut1d/Lut1DOp.h +++ b/src/OpenColorIO/ops/lut1d/Lut1DOp.h @@ -5,10 +5,12 @@ #ifndef INCLUDED_OCIO_LUT1DOP_H #define INCLUDED_OCIO_LUT1DOP_H -#include - #include +#if OCIO_LUT_SUPPORT + + +#include #include "ops/lut1d/Lut1DOpData.h" namespace OCIO_NAMESPACE @@ -29,4 +31,6 @@ void CreateLut1DTransform(GroupTransformRcPtr & group, ConstOpRcPtr & op); } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT + #endif diff --git a/src/OpenColorIO/ops/lut1d/Lut1DOpCPU.cpp b/src/OpenColorIO/ops/lut1d/Lut1DOpCPU.cpp index 6c618b9fd2..ed29d9cd55 100644 --- a/src/OpenColorIO/ops/lut1d/Lut1DOpCPU.cpp +++ b/src/OpenColorIO/ops/lut1d/Lut1DOpCPU.cpp @@ -1,12 +1,15 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include + +#if OCIO_LUT_SUPPORT + #include #include #include #include -#include #include "BitDepthUtils.h" #include "MathUtils.h" @@ -1754,3 +1757,4 @@ ConstOpCPURcPtr GetLut1DRenderer(ConstLut1DOpDataRcPtr & lut, BitDepth inBD, Bit } // namespace OCIO_NAMESPACE +#endif \ No newline at end of file diff --git a/src/OpenColorIO/ops/lut1d/Lut1DOpCPU.h b/src/OpenColorIO/ops/lut1d/Lut1DOpCPU.h index 3c735cc038..8b3746913b 100644 --- a/src/OpenColorIO/ops/lut1d/Lut1DOpCPU.h +++ b/src/OpenColorIO/ops/lut1d/Lut1DOpCPU.h @@ -5,6 +5,7 @@ #define INCLUDED_OCIO_LUT1DOP_CPU_H #include +#if OCIO_LUT_SUPPORT #include "ops/lut1d/Lut1DOpData.h" @@ -15,4 +16,5 @@ ConstOpCPURcPtr GetLut1DRenderer(ConstLut1DOpDataRcPtr & lut, BitDepth in, BitDe } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT #endif \ No newline at end of file diff --git a/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_AVX.cpp b/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_AVX.cpp index e0d1648b22..62dbf26fed 100644 --- a/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_AVX.cpp +++ b/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_AVX.cpp @@ -2,6 +2,8 @@ // Copyright Contributors to the OpenColorIO Project. #include "Lut1DOpCPU_AVX.h" + +#if OCIO_LUT_SUPPORT #if OCIO_USE_AVX #include @@ -196,4 +198,5 @@ Lut1DOpCPUApplyFunc * AVXGetLut1DApplyFunc(BitDepth inBD, BitDepth outBD) } // OCIO_NAMESPACE -#endif // OCIO_USE_AVX \ No newline at end of file +#endif // OCIO_USE_AVX +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_AVX2.cpp b/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_AVX2.cpp index 32e59ff679..8f397bdac8 100644 --- a/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_AVX2.cpp +++ b/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_AVX2.cpp @@ -2,6 +2,8 @@ // Copyright Contributors to the OpenColorIO Project. #include "Lut1DOpCPU_AVX2.h" + +#if OCIO_LUT_SUPPORT #if OCIO_USE_AVX2 #include @@ -174,4 +176,5 @@ Lut1DOpCPUApplyFunc * AVX2GetLut1DApplyFunc(BitDepth inBD, BitDepth outBD) } // OCIO_NAMESPACE -#endif // OCIO_USE_AVX2 \ No newline at end of file +#endif // OCIO_USE_AVX2 +#endif //#if OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_AVX2.h b/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_AVX2.h index a3e63d67eb..7b68d79799 100644 --- a/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_AVX2.h +++ b/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_AVX2.h @@ -6,6 +6,9 @@ #include +#if OCIO_LUT_SUPPORT + + #include "CPUInfo.h" typedef void (Lut1DOpCPUApplyFunc)(const float *, const float *, const float *, int, const void *, void *, long); @@ -20,4 +23,5 @@ Lut1DOpCPUApplyFunc * AVX2GetLut1DApplyFunc(BitDepth inBD, BitDepth outBD); #endif // OCIO_USE_AVX2 -#endif /* INCLUDED_OCIO_LUT1DOP_CPU_AVX2_H */ \ No newline at end of file +#endif /* INCLUDED_OCIO_LUT1DOP_CPU_AVX2_H */ +#endif OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_AVX512.cpp b/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_AVX512.cpp index 7ca2dbd054..b535cf591f 100644 --- a/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_AVX512.cpp +++ b/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_AVX512.cpp @@ -2,6 +2,8 @@ // Copyright Contributors to the OpenColorIO Project. #include "Lut1DOpCPU_AVX512.h" + +#if OCIO_LUT_SUPPORT #if OCIO_USE_AVX512 #include @@ -147,4 +149,5 @@ Lut1DOpCPUApplyFunc * AVX512GetLut1DApplyFunc(BitDepth inBD, BitDepth outBD) } // OCIO_NAMESPACE -#endif // OCIO_USE_AVX512 \ No newline at end of file +#endif // OCIO_USE_AVX512 +#endif //#if OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_SSE2.cpp b/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_SSE2.cpp index c170e17914..531d4e7adb 100644 --- a/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_SSE2.cpp +++ b/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_SSE2.cpp @@ -3,6 +3,9 @@ #include "Lut1DOpCPU_SSE2.h" +#if OCIO_LUT_SUPPORT + + #if OCIO_USE_SSE2 #include @@ -205,4 +208,5 @@ Lut1DOpCPUApplyFunc * SSE2GetLut1DApplyFunc(BitDepth inBD, BitDepth outBD) } // OCIO_NAMESPACE -#endif // OCIO_USE_SSE2 \ No newline at end of file +#endif // OCIO_USE_SSE2 +#endif //#if OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/ops/lut1d/Lut1DOpData.cpp b/src/OpenColorIO/ops/lut1d/Lut1DOpData.cpp index a12a7a3e1f..6bc0634950 100644 --- a/src/OpenColorIO/ops/lut1d/Lut1DOpData.cpp +++ b/src/OpenColorIO/ops/lut1d/Lut1DOpData.cpp @@ -1,11 +1,13 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include + +#if OCIO_LUT_SUPPORT + #include #include -#include - #include "BitDepthUtils.h" #include "HashUtils.h" #include "MathUtils.h" @@ -1123,3 +1125,5 @@ bool operator==(const Lut1DOpData & lhs, const Lut1DOpData & rhs) } } // namespace OCIO_NAMESPACE + +#endif //#if OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/ops/lut1d/Lut1DOpData.h b/src/OpenColorIO/ops/lut1d/Lut1DOpData.h index d06ca8da6d..d11e41020c 100644 --- a/src/OpenColorIO/ops/lut1d/Lut1DOpData.h +++ b/src/OpenColorIO/ops/lut1d/Lut1DOpData.h @@ -6,6 +6,9 @@ #include +#if OCIO_LUT_SUPPORT + + #include "Op.h" #include "ops/OpArray.h" #include "PrivateTypes.h" @@ -276,4 +279,6 @@ Lut1DOpDataRcPtr MakeFastLut1DFromInverse(ConstLut1DOpDataRcPtr & lut); } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT + #endif diff --git a/src/OpenColorIO/ops/lut1d/Lut1DOpGPU.cpp b/src/OpenColorIO/ops/lut1d/Lut1DOpGPU.cpp index 59091817da..a7586b5fc7 100644 --- a/src/OpenColorIO/ops/lut1d/Lut1DOpGPU.cpp +++ b/src/OpenColorIO/ops/lut1d/Lut1DOpGPU.cpp @@ -1,10 +1,13 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include + +#if OCIO_LUT_SUPPORT + #include #include -#include #include "GpuShaderUtils.h" #include "MathUtils.h" @@ -388,3 +391,4 @@ void GetLut1DGPUShaderProgram(GpuShaderCreatorRcPtr & shaderCreator, } // namespace OCIO_NAMESPACE +#endif //#if OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/ops/lut3d/Lut3DOp.cpp b/src/OpenColorIO/ops/lut3d/Lut3DOp.cpp index 4f0de76f4d..8e0c8b965a 100644 --- a/src/OpenColorIO/ops/lut3d/Lut3DOp.cpp +++ b/src/OpenColorIO/ops/lut3d/Lut3DOp.cpp @@ -1,12 +1,15 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include + +#if OCIO_LUT_SUPPORT + #include #include #include #include -#include #include "BitDepthUtils.h" #include "GpuShaderUtils.h" @@ -261,3 +264,4 @@ void BuildLut3DOp(OpRcPtrVec & ops, } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/ops/lut3d/Lut3DOp.h b/src/OpenColorIO/ops/lut3d/Lut3DOp.h index 195cd86102..b9fcc32227 100644 --- a/src/OpenColorIO/ops/lut3d/Lut3DOp.h +++ b/src/OpenColorIO/ops/lut3d/Lut3DOp.h @@ -7,6 +7,8 @@ #include +#if OCIO_LUT_SUPPORT + #include "ops/lut3d/Lut3DOpData.h" namespace OCIO_NAMESPACE @@ -58,5 +60,6 @@ void CreateLut3DOp(OpRcPtrVec & ops, void CreateLut3DTransform(GroupTransformRcPtr & group, ConstOpRcPtr & op); } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT #endif diff --git a/src/OpenColorIO/ops/lut3d/Lut3DOpCPU.cpp b/src/OpenColorIO/ops/lut3d/Lut3DOpCPU.cpp index d7ea8483a0..bf352630e3 100644 --- a/src/OpenColorIO/ops/lut3d/Lut3DOpCPU.cpp +++ b/src/OpenColorIO/ops/lut3d/Lut3DOpCPU.cpp @@ -1,13 +1,15 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include + +#if OCIO_LUT_SUPPORT + #include #include #include #include -#include - #include "BitDepthUtils.h" #include "MathUtils.h" #include "ops/lut3d/Lut3DOpCPU.h" @@ -1763,3 +1765,5 @@ ConstOpCPURcPtr GetLut3DRenderer(ConstLut3DOpDataRcPtr & lut) } } // namespace OCIO_NAMESPACE + +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/ops/lut3d/Lut3DOpCPU.h b/src/OpenColorIO/ops/lut3d/Lut3DOpCPU.h index 7e286ed9d0..256c5ee4ff 100644 --- a/src/OpenColorIO/ops/lut3d/Lut3DOpCPU.h +++ b/src/OpenColorIO/ops/lut3d/Lut3DOpCPU.h @@ -6,6 +6,8 @@ #include +#if OCIO_LUT_SUPPORT + #include "Op.h" #include "ops/lut3d/Lut3DOpData.h" @@ -15,5 +17,6 @@ namespace OCIO_NAMESPACE ConstOpCPURcPtr GetLut3DRenderer(ConstLut3DOpDataRcPtr & lut); } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT #endif \ No newline at end of file diff --git a/src/OpenColorIO/ops/lut3d/Lut3DOpCPU_AVX.cpp b/src/OpenColorIO/ops/lut3d/Lut3DOpCPU_AVX.cpp index 8bb7784f25..96079c0385 100644 --- a/src/OpenColorIO/ops/lut3d/Lut3DOpCPU_AVX.cpp +++ b/src/OpenColorIO/ops/lut3d/Lut3DOpCPU_AVX.cpp @@ -2,6 +2,8 @@ // Copyright Contributors to the OpenColorIO Project. #include "Lut3DOpCPU_AVX.h" + +#if OCIO_LUT_SUPPORT #if OCIO_USE_AVX #include "AVX.h" @@ -324,4 +326,5 @@ void applyTetrahedralAVX(const float *lut3d, int dim, const float *src, float *d } // OCIO_NAMESPACE -#endif // OCIO_USE_AVX \ No newline at end of file +#endif // OCIO_USE_AVX +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/ops/lut3d/Lut3DOpCPU_AVX2.cpp b/src/OpenColorIO/ops/lut3d/Lut3DOpCPU_AVX2.cpp index 96a4ff6f67..545b291fec 100644 --- a/src/OpenColorIO/ops/lut3d/Lut3DOpCPU_AVX2.cpp +++ b/src/OpenColorIO/ops/lut3d/Lut3DOpCPU_AVX2.cpp @@ -2,6 +2,8 @@ // Copyright Contributors to the OpenColorIO Project. #include "Lut3DOpCPU_AVX2.h" + +#if OCIO_LUT_SUPPORT #if OCIO_USE_AVX2 #include @@ -277,4 +279,5 @@ void applyTetrahedralAVX2(const float *lut3d, int dim, const float *src, float * } // OCIO_NAMESPACE -#endif // OCIO_USE_AVX2 \ No newline at end of file +#endif // OCIO_USE_AVX2 +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/ops/lut3d/Lut3DOpCPU_AVX512.cpp b/src/OpenColorIO/ops/lut3d/Lut3DOpCPU_AVX512.cpp index b659dad4a2..8ec5b7b663 100644 --- a/src/OpenColorIO/ops/lut3d/Lut3DOpCPU_AVX512.cpp +++ b/src/OpenColorIO/ops/lut3d/Lut3DOpCPU_AVX512.cpp @@ -2,6 +2,8 @@ // Copyright Contributors to the OpenColorIO Project. #include "Lut3DOpCPU_AVX512.h" + +#if OCIO_LUT_SUPPORT #if OCIO_USE_AVX512 #include @@ -256,4 +258,5 @@ void applyTetrahedralAVX512(const float *lut3d, int dim, const float *src, float } // OCIO_NAMESPACE -#endif // OCIO_USE_AVX512 \ No newline at end of file +#endif // OCIO_USE_AVX512 +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/ops/lut3d/Lut3DOpCPU_SSE2.cpp b/src/OpenColorIO/ops/lut3d/Lut3DOpCPU_SSE2.cpp index e7b338d360..bf363d695f 100644 --- a/src/OpenColorIO/ops/lut3d/Lut3DOpCPU_SSE2.cpp +++ b/src/OpenColorIO/ops/lut3d/Lut3DOpCPU_SSE2.cpp @@ -3,6 +3,7 @@ #include "Lut3DOpCPU_SSE2.h" +#if OCIO_LUT_SUPPORT #if OCIO_USE_SSE2 #include "SSE2.h" @@ -318,4 +319,5 @@ void applyTetrahedralSSE2(const float *lut3d, int dim, const float *src, float * } // OCIO_NAMESPACE -#endif // OCIO_USE_SSE2 \ No newline at end of file +#endif // OCIO_USE_SSE2 +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/ops/lut3d/Lut3DOpCPU_SSE2.h b/src/OpenColorIO/ops/lut3d/Lut3DOpCPU_SSE2.h index 8e6293642d..faa6f12fe4 100644 --- a/src/OpenColorIO/ops/lut3d/Lut3DOpCPU_SSE2.h +++ b/src/OpenColorIO/ops/lut3d/Lut3DOpCPU_SSE2.h @@ -6,6 +6,8 @@ #include +#if OCIO_LUT_SUPPORT + #include "CPUInfo.h" #if OCIO_USE_SSE2 @@ -18,4 +20,5 @@ void applyTetrahedralSSE2(const float *lut3d, int dim, const float *src, float * #endif // OCIO_USE_SSE2 -#endif /* INCLUDED_OCIO_LUT3DOP_CPU_SSE2_H */ \ No newline at end of file +#endif /* INCLUDED_OCIO_LUT3DOP_CPU_SSE2_H */ +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/ops/lut3d/Lut3DOpData.cpp b/src/OpenColorIO/ops/lut3d/Lut3DOpData.cpp index e17cbcfce6..3f530cbc13 100644 --- a/src/OpenColorIO/ops/lut3d/Lut3DOpData.cpp +++ b/src/OpenColorIO/ops/lut3d/Lut3DOpData.cpp @@ -1,10 +1,12 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. -#include - #include +#if OCIO_LUT_SUPPORT + +#include + #include "BitDepthUtils.h" #include "HashUtils.h" #include "MathUtils.h" @@ -500,3 +502,5 @@ bool operator==(const Lut3DOpData & lhs, const Lut3DOpData & rhs) } } // namespace OCIO_NAMESPACE + +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/ops/lut3d/Lut3DOpData.h b/src/OpenColorIO/ops/lut3d/Lut3DOpData.h index 370f496c74..14384e6d44 100644 --- a/src/OpenColorIO/ops/lut3d/Lut3DOpData.h +++ b/src/OpenColorIO/ops/lut3d/Lut3DOpData.h @@ -4,9 +4,11 @@ #ifndef INCLUDED_OCIO_LUT3DOPDATA_H #define INCLUDED_OCIO_LUT3DOPDATA_H +#include +#if OCIO_LUT_SUPPORT + #include -#include #include "Op.h" #include "ops/OpArray.h" @@ -145,5 +147,6 @@ bool operator==(const Lut3DOpData & lhs, const Lut3DOpData & rhs); Lut3DOpDataRcPtr MakeFastLut3DFromInverse(ConstLut3DOpDataRcPtr & lut); } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT #endif diff --git a/src/OpenColorIO/ops/lut3d/Lut3DOpGPU.cpp b/src/OpenColorIO/ops/lut3d/Lut3DOpGPU.cpp index 786f52961c..33872714f5 100644 --- a/src/OpenColorIO/ops/lut3d/Lut3DOpGPU.cpp +++ b/src/OpenColorIO/ops/lut3d/Lut3DOpGPU.cpp @@ -1,10 +1,12 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. -#include - #include +#if OCIO_LUT_SUPPORT + +#include + #include "GpuShaderUtils.h" #include "MathUtils.h" #include "ops/lut3d/Lut3DOpGPU.h" @@ -245,3 +247,4 @@ void GetLut3DGPUShaderProgram(GpuShaderCreatorRcPtr & shaderCreator, ConstLut3DO } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/ops/noop/NoOps.cpp b/src/OpenColorIO/ops/noop/NoOps.cpp index cf71b1fde5..0fa00b4b49 100644 --- a/src/OpenColorIO/ops/noop/NoOps.cpp +++ b/src/OpenColorIO/ops/noop/NoOps.cpp @@ -172,6 +172,7 @@ bool GetGpuAllocation(AllocationData & allocation, } } +#if OCIO_LUT_SUPPORT OpRcPtrVec Create3DLut(const OpRcPtrVec & ops, unsigned edgelen) { if(ops.size()==0) return OpRcPtrVec(); @@ -204,6 +205,7 @@ OpRcPtrVec Create3DLut(const OpRcPtrVec & ops, unsigned edgelen) CreateLut3DOp(newOps, lut, TRANSFORM_DIR_FORWARD); return newOps; } +#endif //OCIO_LUT_SUPPORT void PartitionGPUOps(OpRcPtrVec & gpuPreOps, OpRcPtrVec & gpuLatticeOps, diff --git a/src/OpenColorIO/ops/noop/NoOps.h b/src/OpenColorIO/ops/noop/NoOps.h index 8141cbe01e..44e3a097e2 100644 --- a/src/OpenColorIO/ops/noop/NoOps.h +++ b/src/OpenColorIO/ops/noop/NoOps.h @@ -13,9 +13,10 @@ namespace OCIO_NAMESPACE { - +#if OCIO_LUT_SUPPORT // Create a 3D LUT from an arbitrary list of ops. OpRcPtrVec Create3DLut(const OpRcPtrVec & ops, unsigned edgelen); +#endif //OCIO_LUT_SUPPORT // Partition an opvec into 3 segments for GPU Processing // diff --git a/src/OpenColorIO/ops/range/RangeOp.cpp b/src/OpenColorIO/ops/range/RangeOp.cpp index f708908fbd..cb672d92df 100644 --- a/src/OpenColorIO/ops/range/RangeOp.cpp +++ b/src/OpenColorIO/ops/range/RangeOp.cpp @@ -114,6 +114,7 @@ bool RangeOp::canCombineWith(ConstOpRcPtr & op2) const if (range1->isIdentity()) { // If op is LUT range op can be removed. +#if OCIO_LUT_SUPPORT if (type2 == OpData::Lut1DType) { auto lut = OCIO_DYNAMIC_POINTER_CAST(opData2); @@ -131,6 +132,7 @@ bool RangeOp::canCombineWith(ConstOpRcPtr & op2) const return true; } } +#endif //OCIO_LUT_SUPPORT } if (type2 == OpData::RangeType) diff --git a/src/OpenColorIO/transforms/CDLTransform.cpp b/src/OpenColorIO/transforms/CDLTransform.cpp index cee7ed963d..588c9215f7 100755 --- a/src/OpenColorIO/transforms/CDLTransform.cpp +++ b/src/OpenColorIO/transforms/CDLTransform.cpp @@ -1,11 +1,12 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include +#if OCIO_LUT_SUPPORT #include #include #include -#include #include "fileformats/cdl/CDLParser.h" #include "Logging.h" @@ -387,3 +388,4 @@ std::ostream & operator<< (std::ostream & os, const CDLTransform & t) } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/transforms/CDLTransform.h b/src/OpenColorIO/transforms/CDLTransform.h index 2e0005b7d0..f6f19a6c68 100644 --- a/src/OpenColorIO/transforms/CDLTransform.h +++ b/src/OpenColorIO/transforms/CDLTransform.h @@ -5,10 +5,13 @@ #ifndef INCLUDED_OCIO_CDLTRANSFORM_H #define INCLUDED_OCIO_CDLTRANSFORM_H +#include + +#if OCIO_LUT_SUPPORT + #include #include -#include #include "ops/cdl/CDLOpData.h" @@ -84,4 +87,7 @@ class CDLTransformImpl : public CDLTransform } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT + + #endif diff --git a/src/OpenColorIO/transforms/FileTransform.cpp b/src/OpenColorIO/transforms/FileTransform.cpp index faf1d343e3..2bba078272 100755 --- a/src/OpenColorIO/transforms/FileTransform.cpp +++ b/src/OpenColorIO/transforms/FileTransform.cpp @@ -1,6 +1,10 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include + +#if OCIO_LUT_SUPPORT + #include #include #include @@ -11,7 +15,6 @@ #include -#include #include "Caching.h" #include "FileTransform.h" @@ -988,3 +991,4 @@ void BuildFileTransformOps(OpRcPtrVec & ops, } } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/transforms/FileTransform.h b/src/OpenColorIO/transforms/FileTransform.h index 19b2b8c73f..e296be056e 100644 --- a/src/OpenColorIO/transforms/FileTransform.h +++ b/src/OpenColorIO/transforms/FileTransform.h @@ -5,10 +5,12 @@ #ifndef INCLUDED_OCIO_FILETRANSFORM_H #define INCLUDED_OCIO_FILETRANSFORM_H +#include + +#if OCIO_LUT_SUPPORT #include -#include #include "Op.h" #include "ops/noop/NoOps.h" @@ -185,4 +187,5 @@ static constexpr char FILEFORMAT_COLOR_DECISION_LIST[] = "ColorDecisionL } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT #endif diff --git a/src/OpenColorIO/transforms/GroupTransform.cpp b/src/OpenColorIO/transforms/GroupTransform.cpp index 89ba45c267..e2bb62a10f 100755 --- a/src/OpenColorIO/transforms/GroupTransform.cpp +++ b/src/OpenColorIO/transforms/GroupTransform.cpp @@ -111,6 +111,7 @@ void GroupTransformImpl::prependTransform(TransformRcPtr transform) noexcept m_vec.insert(m_vec.begin(), transform); } +#if OCIO_LUT_SUPPORT void GroupTransformImpl::write(const ConstConfigRcPtr & config, const char * formatName, std::ostream & os) const @@ -152,6 +153,29 @@ const char * GroupTransform::GetFormatExtensionByIndex(int index) noexcept { return FormatRegistry::GetInstance().getFormatExtensionByIndex(FORMAT_CAPABILITY_WRITE, index); } +#else +void GroupTransformImpl::write(const ConstConfigRcPtr& config, + const char* formatName, + std::ostream& os) const +{ + throw Exception("LUT support is OFF."); +} + +int GroupTransform::GetNumWriteFormats() noexcept +{ + return 0; +} + +const char* GroupTransform::GetFormatNameByIndex(int index) noexcept +{ + return nullptr; +} + +const char* GroupTransform::GetFormatExtensionByIndex(int index) noexcept +{ + return nullptr; +} +#endif //OCIO_LUT_SUPPORT std::ostream & operator<< (std::ostream & os, const GroupTransform & groupTransform) { diff --git a/src/OpenColorIO/transforms/Lut1DTransform.cpp b/src/OpenColorIO/transforms/Lut1DTransform.cpp index 2e3f93a5fa..1b3bf089e1 100644 --- a/src/OpenColorIO/transforms/Lut1DTransform.cpp +++ b/src/OpenColorIO/transforms/Lut1DTransform.cpp @@ -1,12 +1,15 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include + +#if OCIO_LUT_SUPPORT + #include #include #include #include -#include #include "transforms/Lut1DTransform.h" @@ -225,3 +228,4 @@ std::ostream & operator<< (std::ostream & os, const Lut1DTransform & t) } // namespace OCIO_NAMESPACE +#endif //#if OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/transforms/Lut1DTransform.h b/src/OpenColorIO/transforms/Lut1DTransform.h index af73ab5ea7..d64808740f 100644 --- a/src/OpenColorIO/transforms/Lut1DTransform.h +++ b/src/OpenColorIO/transforms/Lut1DTransform.h @@ -7,6 +7,8 @@ #include +#if OCIO_LUT_SUPPORT + #include "ops/lut1d/Lut1DOpData.h" @@ -67,4 +69,7 @@ class Lut1DTransformImpl : public Lut1DTransform } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT + #endif // INCLUDED_OCIO_LUT1DTRANSFORM_H + diff --git a/src/OpenColorIO/transforms/Lut3DTransform.cpp b/src/OpenColorIO/transforms/Lut3DTransform.cpp index 3d6630d93a..26f9eac1d2 100644 --- a/src/OpenColorIO/transforms/Lut3DTransform.cpp +++ b/src/OpenColorIO/transforms/Lut3DTransform.cpp @@ -1,13 +1,15 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include + +#if OCIO_LUT_SUPPORT + #include #include #include #include -#include - #include "transforms/Lut3DTransform.h" namespace OCIO_NAMESPACE @@ -219,3 +221,4 @@ std::ostream & operator<< (std::ostream & os, const Lut3DTransform & t) } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/transforms/Lut3DTransform.h b/src/OpenColorIO/transforms/Lut3DTransform.h index 7bd51de7a7..29eea87f4d 100644 --- a/src/OpenColorIO/transforms/Lut3DTransform.h +++ b/src/OpenColorIO/transforms/Lut3DTransform.h @@ -7,6 +7,8 @@ #include +#if OCIO_LUT_SUPPORT + #include "ops/lut3d/Lut3DOpData.h" @@ -65,3 +67,4 @@ class Lut3DTransformImpl : public Lut3DTransform } // namespace OCIO_NAMESPACE #endif // INCLUDED_OCIO_LUT3DTRANSFORM_H +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/transforms/builtins/ACES.cpp b/src/OpenColorIO/transforms/builtins/ACES.cpp index d1e3321727..3aef175327 100644 --- a/src/OpenColorIO/transforms/builtins/ACES.cpp +++ b/src/OpenColorIO/transforms/builtins/ACES.cpp @@ -73,8 +73,9 @@ static constexpr double nonuniform_LUT[lutSize * 2] 0.600000000000000, -0.926545676714876 }; -void GenerateOps(OpRcPtrVec & ops) +void GenerateOps(OpRcPtrVec& ops) { +#if OCIO_LUT_SUPPORT // Note that in CTL, the matrices are stored transposed. static constexpr double CDD_TO_CID[4 * 4] { @@ -133,7 +134,11 @@ void GenerateOps(OpRcPtrVec & ops) }; // Convert Relative Exposure values to ACES values. - CreateMatrixOp(ops, &EXP_TO_ACES[0], TRANSFORM_DIR_FORWARD); + CreateMatrixOp(ops, &EXP_TO_ACES[0], TRANSFORM_DIR_FORWARD); +#else +#pragma message("Needs LUT-free implementation") +#endif //OCIO_LUT_SUPPORT + } } // namespace ADX_to_ACES @@ -429,6 +434,7 @@ void Generate_nit_normalization_ops(OpRcPtrVec & ops, double nit_level) void Generate_roll_white_d60_ops(OpRcPtrVec & ops) { +#if OCIO_LUT_SUPPORT auto GenerateLutValues = [](double in) -> float { const double new_wht = 0.918; @@ -459,10 +465,14 @@ void Generate_roll_white_d60_ops(OpRcPtrVec & ops) }; CreateHalfLut(ops, GenerateLutValues); +#else +# pragma message("Needs lut-free implementation") +#endif //OCIO_LUT_SUPPORT } void Generate_roll_white_d65_ops(OpRcPtrVec & ops) { +#if OCIO_LUT_SUPPORT auto GenerateLutValues = [](double in) -> float { const double new_wht = 0.908; @@ -493,6 +503,9 @@ void Generate_roll_white_d65_ops(OpRcPtrVec & ops) }; CreateHalfLut(ops, GenerateLutValues); +#else +# pragma message("Needs lut-free implementation") +#endif //OCIO_LUT_SUPPORT } } // namespace ACES_OUTPUT @@ -571,6 +584,8 @@ void RegisterAll(BuiltinTransformRegistryImpl & registry) noexcept ACEScct_to_ACES2065_1_Functor); } { +#if OCIO_LUT_SUPPORT + auto ACEScc_to_ACES2065_1_Functor = [](OpRcPtrVec & ops) { auto GenerateLutValues = [](double input) -> float @@ -619,6 +634,9 @@ void RegisterAll(BuiltinTransformRegistryImpl & registry) noexcept registry.addBuiltin("ACEScc_to_ACES2065-1", "Convert ACEScc to ACES2065-1", ACEScc_to_ACES2065_1_Functor); +#else +# pragma message("Needs lut-free implementation") +#endif //OCIO_LUT_SUPPORT } { auto ACEScg_to_ACES2065_1_Functor = [](OpRcPtrVec & ops) diff --git a/src/OpenColorIO/transforms/builtins/AppleCameras.cpp b/src/OpenColorIO/transforms/builtins/AppleCameras.cpp index 9f5f946114..6a4b59b169 100644 --- a/src/OpenColorIO/transforms/builtins/AppleCameras.cpp +++ b/src/OpenColorIO/transforms/builtins/AppleCameras.cpp @@ -1,10 +1,11 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include +#if OCIO_LUT_SUPPORT #include -#include #include "ops/matrix/MatrixOp.h" #include "transforms/builtins/AppleCameras.h" @@ -45,6 +46,7 @@ void GenerateAppleLogToLinearOps(OpRcPtrVec & ops) } }; + //TODO Nano: do we need this? /coz CreateHalfLut(ops, GenerateLutValues); } @@ -90,3 +92,5 @@ void RegisterAll(BuiltinTransformRegistryImpl & registry) noexcept } // namespace CAMERA } // namespace OCIO_NAMESPACE + +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/transforms/builtins/AppleCameras.h b/src/OpenColorIO/transforms/builtins/AppleCameras.h index 52f6a9d579..2328ed158c 100644 --- a/src/OpenColorIO/transforms/builtins/AppleCameras.h +++ b/src/OpenColorIO/transforms/builtins/AppleCameras.h @@ -5,9 +5,8 @@ #ifndef INCLUDED_OCIO_APPLE_CAMERAS_H #define INCLUDED_OCIO_APPLE_CAMERAS_H - #include - +#if OCIO_LUT_SUPPORT namespace OCIO_NAMESPACE { @@ -27,5 +26,6 @@ void RegisterAll(BuiltinTransformRegistryImpl & registry) noexcept; } // namespace CAMERA } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT #endif // INCLUDED_OCIO_APPLE_CAMERAS_H diff --git a/src/OpenColorIO/transforms/builtins/BuiltinTransformRegistry.cpp b/src/OpenColorIO/transforms/builtins/BuiltinTransformRegistry.cpp index d828f11ace..f158fe1c45 100644 --- a/src/OpenColorIO/transforms/builtins/BuiltinTransformRegistry.cpp +++ b/src/OpenColorIO/transforms/builtins/BuiltinTransformRegistry.cpp @@ -110,9 +110,11 @@ void BuiltinTransformRegistryImpl::registerAll() noexcept ACES::RegisterAll(*this); // Camera support. +#if OCIO_LUT_SUPPORT CAMERA::APPLE::RegisterAll(*this); - CAMERA::ARRI::RegisterAll(*this); CAMERA::CANON::RegisterAll(*this); +#endif //OCIO_LUT_SUPPORT + CAMERA::ARRI::RegisterAll(*this); CAMERA::PANASONIC::RegisterAll(*this); CAMERA::RED::RegisterAll(*this); CAMERA::SONY::RegisterAll(*this); diff --git a/src/OpenColorIO/transforms/builtins/CanonCameras.cpp b/src/OpenColorIO/transforms/builtins/CanonCameras.cpp index b6956d095a..62ec03bfc1 100644 --- a/src/OpenColorIO/transforms/builtins/CanonCameras.cpp +++ b/src/OpenColorIO/transforms/builtins/CanonCameras.cpp @@ -1,10 +1,11 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. +#include +#if OCIO_LUT_SUPPORT #include -#include #include "ops/matrix/MatrixOp.h" #include "transforms/builtins/ACES.h" @@ -134,3 +135,5 @@ void RegisterAll(BuiltinTransformRegistryImpl & registry) noexcept } // namespace CAMERA } // namespace OCIO_NAMESPACE + +#endif //OCIO_LUT_SUPPORT diff --git a/src/OpenColorIO/transforms/builtins/CanonCameras.h b/src/OpenColorIO/transforms/builtins/CanonCameras.h index 9c5f606539..7f02bfd33a 100644 --- a/src/OpenColorIO/transforms/builtins/CanonCameras.h +++ b/src/OpenColorIO/transforms/builtins/CanonCameras.h @@ -7,6 +7,7 @@ #include +#if OCIO_LUT_SUPPORT namespace OCIO_NAMESPACE @@ -27,5 +28,6 @@ void RegisterAll(BuiltinTransformRegistryImpl & registry) noexcept; } // namespace CAMERA } // namespace OCIO_NAMESPACE +#endif //OCIO_LUT_SUPPORT #endif // INCLUDED_OCIO_CANON_CAMERAS_H diff --git a/src/OpenColorIO/transforms/builtins/Displays.cpp b/src/OpenColorIO/transforms/builtins/Displays.cpp index 8d8af97826..1ca3eb2e8a 100644 --- a/src/OpenColorIO/transforms/builtins/Displays.cpp +++ b/src/OpenColorIO/transforms/builtins/Displays.cpp @@ -33,6 +33,7 @@ static constexpr double c1 = c3 - c2 + 1.; void GeneratePQToLinearOps(OpRcPtrVec & ops) { +#if OCIO_LUT_SUPPORT auto GenerateLutValues = [](double input) -> float { const double N = std::max(0., input); @@ -44,11 +45,16 @@ void GeneratePQToLinearOps(OpRcPtrVec & ops) return float(L); }; + // TODO Nano: do we need this? /coz CreateLut(ops, 4096, GenerateLutValues); +#else +# pragma message("Needs lut-free implementation") +#endif //OCIO_LUT_SUPPORT } void GenerateLinearToPQOps(OpRcPtrVec & ops) { +#if OCIO_LUT_SUPPORT auto GenerateLutValues = [](double input) -> float { // Input is in nits/100, convert to [0,1], where 1 is 10000 nits. @@ -60,7 +66,11 @@ void GenerateLinearToPQOps(OpRcPtrVec & ops) return float(N); }; + // TODO Nano: do we need this? /coz CreateHalfLut(ops, GenerateLutValues); +#else +# pragma message("Needs lut-free implementation") +#endif //OCIO_LUT_SUPPORT } } // ST_2084 @@ -285,6 +295,7 @@ void RegisterAll(BuiltinTransformRegistryImpl & registry) noexcept CIE_XYZ_D65_to_ST2084_P3_D65_Functor); } +#if OCIO_LUT_SUPPORT { auto CIE_XYZ_D65_to_REC2100_HLG_1000nit_Functor = [](OpRcPtrVec & ops) { @@ -337,6 +348,10 @@ void RegisterAll(BuiltinTransformRegistryImpl & registry) noexcept "Convert CIE XYZ (D65 white) to Rec.2100-HLG, 1000 nit", CIE_XYZ_D65_to_REC2100_HLG_1000nit_Functor); } +#else +# pragma message("Needs lut-free implementation") +#endif OCIO_LUT_SUPPORT + } diff --git a/src/OpenColorIO/transforms/builtins/OpHelpers.cpp b/src/OpenColorIO/transforms/builtins/OpHelpers.cpp index 0a30232993..6660a268be 100644 --- a/src/OpenColorIO/transforms/builtins/OpHelpers.cpp +++ b/src/OpenColorIO/transforms/builtins/OpHelpers.cpp @@ -12,6 +12,7 @@ namespace OCIO_NAMESPACE { +#if OCIO_LUT_SUPPORT double Interpolate1D(unsigned lutSize, const double * lutValues, double in) { @@ -139,5 +140,6 @@ void CreateHalfLut(OpRcPtrVec & ops, std::function lutValueGenera CreateLut1DOp(ops, lut, TRANSFORM_DIR_FORWARD); } +#endif //OCIO_LUT_SUPPORT } // namespace OCIO_NAMESPACE diff --git a/src/OpenColorIO/transforms/builtins/OpHelpers.h b/src/OpenColorIO/transforms/builtins/OpHelpers.h index ac11949281..7f5842addb 100644 --- a/src/OpenColorIO/transforms/builtins/OpHelpers.h +++ b/src/OpenColorIO/transforms/builtins/OpHelpers.h @@ -13,6 +13,8 @@ namespace OCIO_NAMESPACE { +#if OCIO_LUT_SUPPORT + // Linearly interpolate a single input value through a non-uniformly spaced LUT. // The lutValues are ordered as: [in0, out0, in1, out1, in2, out2, ...]. // The lutSize is the number of in/out pairs, so there are 2*lutSize lutValues. @@ -37,6 +39,9 @@ void CreateLut(OpRcPtrVec & ops, void CreateHalfLut(OpRcPtrVec & ops, std::function lutValueGenerator); +#endif //OCIO_LUT_SUPPORT + + } // namespace OCIO_NAMESPACE From e6831b25202edc9b535948b26e3f2155a1d5e0bd Mon Sep 17 00:00:00 2001 From: "cuneyt.ozdas" Date: Wed, 17 Apr 2024 20:45:30 -0700 Subject: [PATCH 2/6] - adding the header file changes I missed in the previous commit. --- include/OpenColorIO/OpenColorIO.h | 13 ++++++++++++- include/OpenColorIO/OpenColorTransforms.h | 11 ++++++++--- include/OpenColorIO/OpenColorTypes.h | 8 ++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/include/OpenColorIO/OpenColorIO.h b/include/OpenColorIO/OpenColorIO.h index 784cf8d2fd..71fc17a053 100644 --- a/include/OpenColorIO/OpenColorIO.h +++ b/include/OpenColorIO/OpenColorIO.h @@ -228,6 +228,7 @@ extern OCIOEXPORT void SetCurrentConfig(const ConstConfigRcPtr & config); */ extern OCIOEXPORT const char * ResolveConfigPath(const char * originalPath) noexcept; +#if OCIO_ARCHIVE_SUPPORT /** * \brief Extract an OCIO Config archive. * @@ -247,6 +248,7 @@ extern OCIOEXPORT void ExtractOCIOZArchive( const char * archivePath, const char * destinationDir ); +#endif //OCIO_ARCHIVE_SUPPORT /** * \brief @@ -1480,6 +1482,7 @@ class OCIOEXPORT Config void setConfigIOProxy(ConfigIOProxyRcPtr ciop); ConfigIOProxyRcPtr getConfigIOProxy() const; +#if OCIO_ARCHIVE_SUPPORT /** * \brief Verify if the config is archivable. * @@ -1530,6 +1533,7 @@ class OCIOEXPORT Config * \param ostream The output stream to write to. */ void archive(std::ostream & ostream) const; +#endif //OCIO_ARCHIVE_SUPPORT Config(const Config &) = delete; Config& operator= (const Config &) = delete; @@ -2761,7 +2765,7 @@ class OCIOEXPORT ProcessorMetadata }; - +#if OCIO_LUT_SUPPORT /** * In certain situations it is necessary to serialize transforms into a variety * of application specific LUT formats. Note that not all file formats that may @@ -2893,6 +2897,7 @@ class OCIOEXPORT Baker Impl * getImpl() { return m_impl; } const Impl * getImpl() const { return m_impl; } }; +#endif //OCIO_LUT_SUPPORT /////////////////////////////////////////////////////////////////////////// @@ -3206,6 +3211,7 @@ class OCIOEXPORT GpuShaderCreator /// End to collect the shader data. virtual void end(); +#if OCIO_LUT_SUPPORT /// Some graphic cards could have 1D & 2D textures with size limitations. virtual void setTextureMaxWidth(unsigned maxWidth) = 0; virtual unsigned getTextureMaxWidth() const noexcept = 0; @@ -3213,6 +3219,7 @@ class OCIOEXPORT GpuShaderCreator /// Allow 1D GPU resource type, otherwise always using 2D resources for 1D LUTs. virtual void setAllowTexture1D(bool allowed) = 0; virtual bool getAllowTexture1D() const = 0; +#endif //OCIO_LUT_SUPPORT /** * To avoid global texture sampler and uniform name clashes always append an increasing index @@ -3264,6 +3271,7 @@ class OCIOEXPORT GpuShaderCreator */ DynamicPropertyRcPtr getDynamicProperty(DynamicPropertyType type) const; +#if OCIO_LUT_SUPPORT enum TextureType { TEXTURE_RED_CHANNEL, ///< Only need a red channel texture @@ -3306,6 +3314,7 @@ class OCIOEXPORT GpuShaderCreator unsigned edgelen, Interpolation interpolation, const float * values) = 0; +#endif //OCIO_LUT_SUPPORT // Methods to specialize parts of a OCIO shader program virtual void addToDeclareShaderCode(const char * shaderCode); @@ -3533,6 +3542,7 @@ class OCIOEXPORT GpuShaderDesc : public GpuShaderCreator /// Returns name of uniform and data as parameter. virtual const char * getUniform(unsigned index, UniformData & data) const = 0; +#if OCIO_LUT_SUPPORT // 1D lut related methods virtual unsigned getNumTextures() const noexcept = 0; virtual void getTexture(unsigned index, @@ -3553,6 +3563,7 @@ class OCIOEXPORT GpuShaderDesc : public GpuShaderCreator unsigned & edgelen, Interpolation & interpolation) const = 0; virtual void get3DTextureValues(unsigned index, const float *& values) const = 0; +#endif //OCIO_LUT_SUPPORT /// Get the complete OCIO shader program. const char * getShaderText() const noexcept; diff --git a/include/OpenColorIO/OpenColorTransforms.h b/include/OpenColorIO/OpenColorTransforms.h index e37c59e4c2..2265e97c97 100644 --- a/include/OpenColorIO/OpenColorTransforms.h +++ b/include/OpenColorIO/OpenColorTransforms.h @@ -141,6 +141,7 @@ class OCIOEXPORT Transform Transform() = default; }; +// TODO: this operator can just call virtual print function, which will simplify things a lot. /coz 2024-04-16 extern OCIOEXPORT std::ostream& operator<< (std::ostream&, const Transform&); @@ -226,7 +227,7 @@ class OCIOEXPORT BuiltinTransform : public Transform // extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const BuiltinTransform &) noexcept; - +#if OCIO_LUT_SUPPORT /** * \brief * An implementation of the ASC Color Decision List (CDL), based on the ASC v1.2 @@ -328,6 +329,7 @@ class OCIOEXPORT CDLTransform : public Transform }; extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const CDLTransform &); +#endif //OCIO_LUT_SUPPORT class OCIOEXPORT ColorSpaceTransform : public Transform @@ -1022,7 +1024,7 @@ class OCIOEXPORT ExposureContrastTransform : public Transform extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const ExposureContrastTransform &); - +#if OCIO_LUT_SUPPORT class OCIOEXPORT FileTransform : public Transform { public: @@ -1095,6 +1097,7 @@ class OCIOEXPORT FileTransform : public Transform }; extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const FileTransform &); +#endif //OCIO_LUT_SUPPORT /** @@ -1608,7 +1611,7 @@ class OCIOEXPORT LookTransform : public Transform extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const LookTransform &); - +#if OCIO_LUT_SUPPORT /// Represents a 1D-LUT transform. class OCIOEXPORT Lut1DTransform : public Transform { @@ -1785,6 +1788,8 @@ class OCIOEXPORT Lut3DTransform : public Transform }; extern OCIOEXPORT std::ostream& operator<< (std::ostream&, const Lut3DTransform&); +#endif //OCIO_LUT_SUPPORT + /** * Represents an MX+B Matrix transform. diff --git a/include/OpenColorIO/OpenColorTypes.h b/include/OpenColorIO/OpenColorTypes.h index 33654baf83..516b0b84aa 100644 --- a/include/OpenColorIO/OpenColorTypes.h +++ b/include/OpenColorIO/OpenColorTypes.h @@ -7,6 +7,10 @@ #include "OpenColorABI.h" +#define OCIO_LUT_SUPPORT 0 +#define OCIO_ARCHIVE_SUPPORT 0 + + #ifndef OCIO_NAMESPACE #error This header cannot be used directly. Use instead. #endif @@ -179,9 +183,11 @@ class OCIOEXPORT ExposureContrastTransform; typedef OCIO_SHARED_PTR ConstExposureContrastTransformRcPtr; typedef OCIO_SHARED_PTR ExposureContrastTransformRcPtr; +#if OCIO_LUT_SUPPORT class OCIOEXPORT FileTransform; typedef OCIO_SHARED_PTR ConstFileTransformRcPtr; typedef OCIO_SHARED_PTR FileTransformRcPtr; +#endif //OCIO_LUT_SUPPORT class OCIOEXPORT FixedFunctionTransform; typedef OCIO_SHARED_PTR ConstFixedFunctionTransformRcPtr; @@ -219,6 +225,7 @@ class OCIOEXPORT LogTransform; typedef OCIO_SHARED_PTR ConstLogTransformRcPtr; typedef OCIO_SHARED_PTR LogTransformRcPtr; +#if OCIO_LUT_SUPPORT class OCIOEXPORT Lut1DTransform; typedef OCIO_SHARED_PTR ConstLut1DTransformRcPtr; typedef OCIO_SHARED_PTR Lut1DTransformRcPtr; @@ -226,6 +233,7 @@ typedef OCIO_SHARED_PTR Lut1DTransformRcPtr; class OCIOEXPORT Lut3DTransform; typedef OCIO_SHARED_PTR ConstLut3DTransformRcPtr; typedef OCIO_SHARED_PTR Lut3DTransformRcPtr; +#endif //OCIO_LUT_SUPPORT class OCIOEXPORT MatrixTransform; typedef OCIO_SHARED_PTR ConstMatrixTransformRcPtr; From d6d464f16cf86586797e95d0ec4fbc954031cef9 Mon Sep 17 00:00:00 2001 From: "cuneyt.ozdas" Date: Thu, 18 Apr 2024 12:15:21 -0700 Subject: [PATCH 3/6] - exposing OCIO_LUT_SUPPORT and OCIO_ARCHIVE_SUPPORT as Cmake options and baking the values in the OpenColorABI.h, where it makes more sense. --- CMakeLists.txt | 4 ++++ include/OpenColorIO/OpenColorABI.h.in | 3 +++ include/OpenColorIO/OpenColorTypes.h | 4 ---- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d2ad73654..aff741c68c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,6 +148,10 @@ option(OCIO_BUILD_FROZEN_DOCS "Specify whether to build frozen documentation, ne option(OCIO_BUILD_DOCS "Specify whether to build documentation" ${OCIO_BUILD_FROZEN_DOCS}) option(OCIO_BUILD_PYTHON "Specify whether to build python bindings" ON) + +option(OCIO_LUT_SUPPORT "Specify wheter to build with LUT and file-transform support. Requies Expat dependency" ON) +option(OCIO_ARCHIVE_SUPPORT "Specify whether to build with OCIOZ archive support. Requires ZLIB dependency " ON) + set (OCIO_PYTHON_VERSION "" CACHE STRING "Preferred Python version (if any) in case multiple are available") diff --git a/include/OpenColorIO/OpenColorABI.h.in b/include/OpenColorIO/OpenColorABI.h.in index 93714f7617..0e8d4c9ab2 100644 --- a/include/OpenColorIO/OpenColorABI.h.in +++ b/include/OpenColorIO/OpenColorABI.h.in @@ -26,6 +26,9 @@ #define OCIO_VERSION_MAJOR @OpenColorIO_VERSION_MAJOR@ #define OCIO_VERSION_MINOR @OpenColorIO_VERSION_MINOR@ +// Experimental switches to streamline OCIO library. +#cmakedefine01 OCIO_LUT_SUPPORT +#cmakedefine01 OCIO_ARCHIVE_SUPPORT // Highlight deprecated methods or classes. #if defined(_MSC_VER) diff --git a/include/OpenColorIO/OpenColorTypes.h b/include/OpenColorIO/OpenColorTypes.h index 516b0b84aa..2b1d88fbeb 100644 --- a/include/OpenColorIO/OpenColorTypes.h +++ b/include/OpenColorIO/OpenColorTypes.h @@ -7,10 +7,6 @@ #include "OpenColorABI.h" -#define OCIO_LUT_SUPPORT 0 -#define OCIO_ARCHIVE_SUPPORT 0 - - #ifndef OCIO_NAMESPACE #error This header cannot be used directly. Use instead. #endif From 44b866d124a66a753097f088cac753b6d9ba7d25 Mon Sep 17 00:00:00 2001 From: "cuneyt.ozdas" Date: Thu, 18 Apr 2024 14:40:27 -0700 Subject: [PATCH 4/6] - good news: it turned out that we can turn off the imath fp16->fp32 conversion LUT just through the preprocessor macros without re-compiling the imath library. So exposed OCIO_USE_HALF_LOOKUP_TABLE cmake option to turn it on/off --- CMakeLists.txt | 1 + src/OpenColorIO/CMakeLists.txt | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index aff741c68c..4c4a512ca1 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,6 +151,7 @@ option(OCIO_BUILD_PYTHON "Specify whether to build python bindings" ON) option(OCIO_LUT_SUPPORT "Specify wheter to build with LUT and file-transform support. Requies Expat dependency" ON) option(OCIO_ARCHIVE_SUPPORT "Specify whether to build with OCIOZ archive support. Requires ZLIB dependency " ON) +option(OCIO_USE_HALF_LOOKUP_TABLE "Determines if the imath library should 64k LUT for half conversions." ON) set (OCIO_PYTHON_VERSION "" CACHE STRING "Preferred Python version (if any) in case multiple are available") diff --git a/src/OpenColorIO/CMakeLists.txt b/src/OpenColorIO/CMakeLists.txt index 4db41aa096..8f19f5feaa 100755 --- a/src/OpenColorIO/CMakeLists.txt +++ b/src/OpenColorIO/CMakeLists.txt @@ -221,6 +221,10 @@ if(OCIO_USE_SIMD AND (OCIO_ARCH_X86 OR OCIO_USE_SSE2NEON)) set_property(SOURCE ops/lut3d/Lut3DOpCPU_AVX512.cpp APPEND PROPERTY COMPILE_OPTIONS ${OCIO_AVX512_ARGS}) endif() +if(NOT OCIO_USE_HALF_LOOKUP_TABLE) + add_compile_definitions(IMATH_HALF_NO_LOOKUP_TABLE) +endif() + configure_file(CPUInfoConfig.h.in CPUInfoConfig.h) add_library(OpenColorIO ${SOURCES}) From e38eba10654f63af3581978b5662f3d5bb520196 Mon Sep 17 00:00:00 2001 From: "cuneyt.ozdas" Date: Fri, 19 Apr 2024 16:45:46 -0700 Subject: [PATCH 5/6] - adding switch OCIO_HAS_STUDIO_CONFIG to turn off the studio config which is pretty large - more cleanup --- CMakeLists.txt | 1 + src/OpenColorIO/CMakeLists.txt | 15 +++++- src/OpenColorIO/Config.cpp | 2 + src/OpenColorIO/OCIOZArchive.cpp | 3 ++ .../builtinconfigs/BuiltinConfigRegistry.cpp | 2 + .../builtinconfigs/StudioConfig.cpp | 3 ++ src/OpenColorIO/builtinconfigs/StudioConfig.h | 4 +- .../ops/fixedfunction/FixedFunctionOpData.cpp | 46 +++++++++---------- 8 files changed, 51 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c4a512ca1..60e46d90ca 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,6 +152,7 @@ option(OCIO_BUILD_PYTHON "Specify whether to build python bindings" ON) option(OCIO_LUT_SUPPORT "Specify wheter to build with LUT and file-transform support. Requies Expat dependency" ON) option(OCIO_ARCHIVE_SUPPORT "Specify whether to build with OCIOZ archive support. Requires ZLIB dependency " ON) option(OCIO_USE_HALF_LOOKUP_TABLE "Determines if the imath library should 64k LUT for half conversions." ON) +option(OCIO_HAS_STUDIO_CONFIG "If OFF, built-in studio config will be removed from the library." ON) set (OCIO_PYTHON_VERSION "" CACHE STRING "Preferred Python version (if any) in case multiple are available") diff --git a/src/OpenColorIO/CMakeLists.txt b/src/OpenColorIO/CMakeLists.txt index 8f19f5feaa..e2e2b4cbe7 100755 --- a/src/OpenColorIO/CMakeLists.txt +++ b/src/OpenColorIO/CMakeLists.txt @@ -224,6 +224,10 @@ endif() if(NOT OCIO_USE_HALF_LOOKUP_TABLE) add_compile_definitions(IMATH_HALF_NO_LOOKUP_TABLE) endif() +if(OCIO_HAS_STUDIO_CONFIG) + add_compile_definitions(OCIO_HAS_STUDIO_CONFIG) +endif() + configure_file(CPUInfoConfig.h.in CPUInfoConfig.h) @@ -383,6 +387,15 @@ if(WIN32) endif() set(CUSTOM_LINK_FLAGS ${PLATFORM_LINK_OPTIONS}) +set(CUSTOM_COMPILE_FLAGS ${PLATFORM_COMPILE_OPTIONS}) + +if(MSVC) + # enable source level parallel build, use those cores! + add_compile_options("/MP") + target_compile_options(OpenColorIO PRIVATE "/MP") + set(CUSTOM_COMPILE_OPTIONS "${CUSTOM_COMPILE_OPTIONS} /MP") + +endif() if(UNIX AND NOT APPLE) # Also hide all the symbols of dependent libraries to prevent clashes if @@ -430,7 +443,7 @@ endif() set_target_properties(OpenColorIO PROPERTIES OUTPUT_NAME ${PROJECT_NAME}${OCIO_LIBNAME_SUFFIX} - COMPILE_OPTIONS "${PLATFORM_COMPILE_OPTIONS}" + COMPILE_OPTIONS "${CUSTOM_COMPILE_OPTIONS}" LINK_OPTIONS "${CUSTOM_LINK_FLAGS}" PUBLIC_HEADER "${INSTALL_HEADERS}" ) diff --git a/src/OpenColorIO/Config.cpp b/src/OpenColorIO/Config.cpp index 0d0371ed67..0cb6c79243 100644 --- a/src/OpenColorIO/Config.cpp +++ b/src/OpenColorIO/Config.cpp @@ -5550,6 +5550,7 @@ bool Config::isArchivable() const } } +#if OCIO_LUT_SUPPORT ///////////////////////////////// // FileTransform verification. // ///////////////////////////////// @@ -5572,6 +5573,7 @@ bool Config::isArchivable() const return false; } } +#endif //OCIO_LUT_SUPPORT return true; } diff --git a/src/OpenColorIO/OCIOZArchive.cpp b/src/OpenColorIO/OCIOZArchive.cpp index 27a77283d9..768f9e6d19 100644 --- a/src/OpenColorIO/OCIOZArchive.cpp +++ b/src/OpenColorIO/OCIOZArchive.cpp @@ -149,6 +149,7 @@ struct MinizipNgMemStreamGuard */ void addSupportedFiles(void * archiver, const char * path, const char * configWorkingDirectory) { +#if OCIO_LUT_SUPPORT DIR *dir = mz_os_open_dir(path); if (dir != NULL) { @@ -200,6 +201,8 @@ void addSupportedFiles(void * archiver, const char * path, const char * configWo } mz_os_close_dir(dir); } +#endif //OCIO_LUT_SUPPORT + } ////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/OpenColorIO/builtinconfigs/BuiltinConfigRegistry.cpp b/src/OpenColorIO/builtinconfigs/BuiltinConfigRegistry.cpp index 2cffa39c44..5bc4631765 100644 --- a/src/OpenColorIO/builtinconfigs/BuiltinConfigRegistry.cpp +++ b/src/OpenColorIO/builtinconfigs/BuiltinConfigRegistry.cpp @@ -86,7 +86,9 @@ void BuiltinConfigRegistryImpl::init() noexcept m_builtinConfigs.clear(); CGCONFIG::Register(*this); +#if OCIO_HAS_STUDIO_CONFIG STUDIOCONFIG::Register(*this); +#endif //OCIO_HAS_STUDIO_CONFIG } } diff --git a/src/OpenColorIO/builtinconfigs/StudioConfig.cpp b/src/OpenColorIO/builtinconfigs/StudioConfig.cpp index 2b68b7e9ec..ab00ae6952 100644 --- a/src/OpenColorIO/builtinconfigs/StudioConfig.cpp +++ b/src/OpenColorIO/builtinconfigs/StudioConfig.cpp @@ -2,6 +2,8 @@ // Copyright Contributors to the OpenColorIO Project. #include +#if OCIO_HAS_STUDIO_CONFIG + #include "builtinconfigs/BuiltinConfigRegistry.h" #include "builtinconfigs/StudioConfig.h" @@ -37,3 +39,4 @@ void Register(BuiltinConfigRegistryImpl & registry) noexcept } // namespace STUDIOCONFIG } // namespace OCIO_NAMESPACE +#endif //OCIO_HAS_STUDIO_CONFIG diff --git a/src/OpenColorIO/builtinconfigs/StudioConfig.h b/src/OpenColorIO/builtinconfigs/StudioConfig.h index 43266c5cd7..dd764662ef 100644 --- a/src/OpenColorIO/builtinconfigs/StudioConfig.h +++ b/src/OpenColorIO/builtinconfigs/StudioConfig.h @@ -5,8 +5,9 @@ #ifndef INCLUDED_OCIO_STUDIOCONFIG_H #define INCLUDED_OCIO_STUDIOCONFIG_H - #include + +#if OCIO_HAS_STUDIO_CONFIG #include "builtinconfigs/BuiltinConfigRegistry.h" namespace OCIO_NAMESPACE @@ -20,5 +21,6 @@ namespace STUDIOCONFIG } // namespace STUDIOCONFIG } // namespace OCIO_NAMESPACE +#endif //OCIO_HAS_STUDIO_CONFIG #endif // INCLUDED_OCIO_STUDIOCONFIG_H diff --git a/src/OpenColorIO/ops/fixedfunction/FixedFunctionOpData.cpp b/src/OpenColorIO/ops/fixedfunction/FixedFunctionOpData.cpp index ce835fd6a8..c7007fd16c 100644 --- a/src/OpenColorIO/ops/fixedfunction/FixedFunctionOpData.cpp +++ b/src/OpenColorIO/ops/fixedfunction/FixedFunctionOpData.cpp @@ -16,29 +16,29 @@ namespace DefaultValues const int FLOAT_DECIMALS = 7; } -constexpr char ACES_RED_MOD_03_FWD_STR[] = "RedMod03Fwd"; -constexpr char ACES_RED_MOD_03_REV_STR[] = "RedMod03Rev"; -constexpr char ACES_RED_MOD_10_FWD_STR[] = "RedMod10Fwd"; -constexpr char ACES_RED_MOD_10_REV_STR[] = "RedMod10Rev"; -constexpr char ACES_GLOW_03_FWD_STR[] = "Glow03Fwd"; -constexpr char ACES_GLOW_03_REV_STR[] = "Glow03Rev"; -constexpr char ACES_GLOW_10_FWD_STR[] = "Glow10Fwd"; -constexpr char ACES_GLOW_10_REV_STR[] = "Glow10Rev"; -constexpr char ACES_DARK_TO_DIM_10_STR[] = "DarkToDim10"; -constexpr char ACES_DIM_TO_DARK_10_STR[] = "DimToDark10"; -constexpr char ACES_GAMUT_COMP_13_FWD_STR[]= "GamutComp13Fwd"; -constexpr char ACES_GAMUT_COMP_13_REV_STR[]= "GamutComp13Rev"; -constexpr char SURROUND_STR[] = "Surround"; // Old name for Rec2100SurroundFwd -constexpr char REC_2100_SURROUND_FWD_STR[] = "Rec2100SurroundFwd"; -constexpr char REC_2100_SURROUND_REV_STR[] = "Rec2100SurroundRev"; -constexpr char RGB_TO_HSV_STR[] = "RGB_TO_HSV"; -constexpr char HSV_TO_RGB_STR[] = "HSV_TO_RGB"; -constexpr char XYZ_TO_xyY_STR[] = "XYZ_TO_xyY"; -constexpr char xyY_TO_XYZ_STR[] = "xyY_TO_XYZ"; -constexpr char XYZ_TO_uvY_STR[] = "XYZ_TO_uvY"; -constexpr char uvY_TO_XYZ_STR[] = "uvY_TO_XYZ"; -constexpr char XYZ_TO_LUV_STR[] = "XYZ_TO_LUV"; -constexpr char LUV_TO_XYZ_STR[] = "LUV_TO_XYZ"; +constexpr const char ACES_RED_MOD_03_FWD_STR[] = "RedMod03Fwd"; +constexpr const char ACES_RED_MOD_03_REV_STR[] = "RedMod03Rev"; +constexpr const char ACES_RED_MOD_10_FWD_STR[] = "RedMod10Fwd"; +constexpr const char ACES_RED_MOD_10_REV_STR[] = "RedMod10Rev"; +constexpr const char ACES_GLOW_03_FWD_STR[] = "Glow03Fwd"; +constexpr const char ACES_GLOW_03_REV_STR[] = "Glow03Rev"; +constexpr const char ACES_GLOW_10_FWD_STR[] = "Glow10Fwd"; +constexpr const char ACES_GLOW_10_REV_STR[] = "Glow10Rev"; +constexpr const char ACES_DARK_TO_DIM_10_STR[] = "DarkToDim10"; +constexpr const char ACES_DIM_TO_DARK_10_STR[] = "DimToDark10"; +constexpr const char ACES_GAMUT_COMP_13_FWD_STR[]= "GamutComp13Fwd"; +constexpr const char ACES_GAMUT_COMP_13_REV_STR[]= "GamutComp13Rev"; +constexpr const char SURROUND_STR[] = "Surround"; // Old name for Rec2100SurroundFwd +constexpr const char REC_2100_SURROUND_FWD_STR[] = "Rec2100SurroundFwd"; +constexpr const char REC_2100_SURROUND_REV_STR[] = "Rec2100SurroundRev"; +constexpr const char RGB_TO_HSV_STR[] = "RGB_TO_HSV"; +constexpr const char HSV_TO_RGB_STR[] = "HSV_TO_RGB"; +constexpr const char XYZ_TO_xyY_STR[] = "XYZ_TO_xyY"; +constexpr const char xyY_TO_XYZ_STR[] = "xyY_TO_XYZ"; +constexpr const char XYZ_TO_uvY_STR[] = "XYZ_TO_uvY"; +constexpr const char uvY_TO_XYZ_STR[] = "uvY_TO_XYZ"; +constexpr const char XYZ_TO_LUV_STR[] = "XYZ_TO_LUV"; +constexpr const char LUV_TO_XYZ_STR[] = "LUV_TO_XYZ"; // NOTE: Converts the enumeration value to its string representation (i.e. CLF reader). From 794ae763ba085fba12259492306f43e63bd99fdd Mon Sep 17 00:00:00 2001 From: "cuneyt.ozdas" Date: Fri, 3 May 2024 12:42:23 -0700 Subject: [PATCH 6/6] more (some wild) experiments for figuring out how much space is consumed by what. - Looks like in some files (such as ocioyaml.cpp) the string manipulation for exception messages takes ~30% of the binary. - Also heavy usage of smart pointers and other dereferencing is contributing to a degree (std::shared_pt, yaml iterators). It'd be a good idea to extract raw pointers and use them if they will be used many many times within a function) - With changing some of the functions, it's possible to help compiler to do return value optimizations. - Also some back and forth string conversions (between std::string, char*, std::stringstream etc) in many places, we can implement overloads of functions taking different variants, limiting the conversion code to a single instance. - some more ideas --- include/OpenColorIO/OpenColorIO.h | 6 +- include/OpenColorIO/OpenColorTransforms.h | 2 + src/OpenColorIO/Baker.cpp | 22 +- src/OpenColorIO/BitDepthUtils.cpp | 6 +- src/OpenColorIO/ColorSpaceSet.cpp | 4 +- src/OpenColorIO/Config.cpp | 973 +--- src/OpenColorIO/ConfigUtils.cpp | 20 +- src/OpenColorIO/CustomKeys.h | 2 +- src/OpenColorIO/Exception.cpp | 17 + src/OpenColorIO/FileRules.cpp | 26 +- src/OpenColorIO/GpuShader.cpp | 18 +- src/OpenColorIO/GpuShaderClassWrapper.cpp | 4 +- src/OpenColorIO/GpuShaderDesc.cpp | 4 +- src/OpenColorIO/GpuShaderUtils.cpp | 14 +- src/OpenColorIO/GpuShaderUtils.h | 5 +- src/OpenColorIO/ImageDesc.cpp | 2 +- src/OpenColorIO/OCIOYaml.cpp | 4024 +++++++++-------- src/OpenColorIO/OCIOZArchive.cpp | 20 +- src/OpenColorIO/Op.cpp | 4 +- src/OpenColorIO/ParseUtils.cpp | 18 +- src/OpenColorIO/SystemMonitor.cpp | 6 +- src/OpenColorIO/Transform.cpp | 8 +- src/OpenColorIO/ViewingRules.cpp | 30 +- .../apphelpers/ColorSpaceHelpers.cpp | 6 +- .../apphelpers/DisplayViewHelpers.cpp | 14 +- .../apphelpers/LegacyViewingPipeline.cpp | 8 +- src/OpenColorIO/apphelpers/MixingHelpers.cpp | 12 +- .../builtinconfigs/BuiltinConfigRegistry.cpp | 2 +- src/OpenColorIO/fileformats/FileFormat3DL.cpp | 22 +- src/OpenColorIO/fileformats/FileFormatCC.cpp | 6 +- src/OpenColorIO/fileformats/FileFormatCCC.cpp | 6 +- src/OpenColorIO/fileformats/FileFormatCDL.cpp | 6 +- src/OpenColorIO/fileformats/FileFormatCSP.cpp | 26 +- src/OpenColorIO/fileformats/FileFormatCTF.cpp | 8 +- .../fileformats/FileFormatDiscreet1DL.cpp | 4 +- src/OpenColorIO/fileformats/FileFormatHDL.cpp | 38 +- src/OpenColorIO/fileformats/FileFormatICC.cpp | 6 +- .../fileformats/FileFormatIridasCube.cpp | 6 +- .../fileformats/FileFormatIridasItx.cpp | 6 +- .../fileformats/FileFormatIridasLook.cpp | 10 +- .../fileformats/FileFormatPandora.cpp | 4 +- .../fileformats/FileFormatResolveCube.cpp | 6 +- .../fileformats/FileFormatSpi1D.cpp | 6 +- .../fileformats/FileFormatSpi3D.cpp | 18 +- .../fileformats/FileFormatSpiMtx.cpp | 6 +- .../fileformats/FileFormatTruelight.cpp | 8 +- src/OpenColorIO/fileformats/FileFormatVF.cpp | 4 +- .../fileformats/FormatMetadata.cpp | 6 + src/OpenColorIO/fileformats/FormatMetadata.h | 2 + src/OpenColorIO/fileformats/cdl/CDLParser.cpp | 4 +- .../fileformats/ctf/CTFReaderHelper.cpp | 12 +- .../fileformats/ctf/CTFReaderUtils.cpp | 8 +- .../fileformats/ctf/CTFTransform.cpp | 6 +- .../fileformats/ctf/IndexMapping.cpp | 2 +- .../fileformats/xmlutils/XMLReaderHelper.cpp | 2 +- .../fileformats/xmlutils/XMLReaderUtils.h | 6 +- src/OpenColorIO/ops/OpArray.h | 2 +- src/OpenColorIO/ops/cdl/CDLOpData.cpp | 8 +- .../ExposureContrastOpData.cpp | 6 +- .../ops/fixedfunction/FixedFunctionOpData.cpp | 20 +- src/OpenColorIO/ops/gamma/GammaOpData.cpp | 14 +- .../ops/gradingprimary/GradingPrimary.cpp | 4 +- .../gradingrgbcurve/GradingBSplineCurve.cpp | 4 +- .../ops/gradingrgbcurve/GradingRGBCurve.cpp | 2 +- .../ops/gradingtone/GradingTone.cpp | 34 +- src/OpenColorIO/ops/log/LogOpData.cpp | 8 +- src/OpenColorIO/ops/log/LogUtils.cpp | 10 +- src/OpenColorIO/ops/lut1d/Lut1DOpData.cpp | 10 +- src/OpenColorIO/ops/lut3d/Lut3DOp.cpp | 2 +- src/OpenColorIO/ops/lut3d/Lut3DOpData.cpp | 10 +- src/OpenColorIO/ops/matrix/MatrixOpData.cpp | 6 +- src/OpenColorIO/ops/noop/NoOps.cpp | 2 +- .../transforms/AllocationTransform.cpp | 2 +- .../transforms/BuiltinTransform.cpp | 2 +- src/OpenColorIO/transforms/CDLTransform.cpp | 4 +- .../transforms/ColorSpaceTransform.cpp | 4 +- .../transforms/DisplayViewTransform.cpp | 18 +- .../transforms/ExponentTransform.cpp | 2 +- .../ExponentWithLinearTransform.cpp | 2 +- .../transforms/ExposureContrastTransform.cpp | 2 +- src/OpenColorIO/transforms/FileTransform.cpp | 30 +- .../transforms/FixedFunctionTransform.cpp | 2 +- .../transforms/GradingPrimaryTransform.cpp | 2 +- .../transforms/GradingRGBCurveTransform.cpp | 2 +- .../transforms/GradingToneTransform.cpp | 2 +- src/OpenColorIO/transforms/GroupTransform.cpp | 10 +- .../transforms/LogAffineTransform.cpp | 2 +- .../transforms/LogCameraTransform.cpp | 2 +- src/OpenColorIO/transforms/LogTransform.cpp | 2 +- src/OpenColorIO/transforms/LookTransform.cpp | 10 +- src/OpenColorIO/transforms/Lut1DTransform.cpp | 4 +- src/OpenColorIO/transforms/Lut3DTransform.cpp | 4 +- .../transforms/MatrixTransform.cpp | 4 +- src/OpenColorIO/transforms/RangeTransform.cpp | 2 +- src/apps/ociolutimage/main.cpp | 8 +- src/apps/ociomakeclf/main.cpp | 2 +- src/apps/ocioperf/main.cpp | 2 +- src/bindings/java/JNIUtil.cpp | 4 +- src/bindings/python/PyUtils.cpp | 4 +- src/libutils/imageioapphelpers/imageio.cpp | 6 +- .../imageioapphelpers/imageio_exr.cpp | 4 +- .../imageioapphelpers/imageio_oiio.cpp | 8 +- src/libutils/oglapphelpers/glsl.cpp | 8 +- tests/cpu/MathUtils_tests.cpp | 2 +- tests/cpu/UnitTestUtils.cpp | 2 +- tests/gpu/GPUUnitTest.cpp | 2 +- 106 files changed, 2701 insertions(+), 3128 deletions(-) diff --git a/include/OpenColorIO/OpenColorIO.h b/include/OpenColorIO/OpenColorIO.h index 71fc17a053..a440924d45 100644 --- a/include/OpenColorIO/OpenColorIO.h +++ b/include/OpenColorIO/OpenColorIO.h @@ -80,6 +80,10 @@ class OCIOEXPORT Exception : public std::runtime_error Exception() = delete; /// Constructor that takes a string as the exception message. explicit Exception(const char *); + explicit Exception(const std::string&); + explicit Exception(const std::ostringstream&); + explicit Exception(const std::stringstream&); + /// Constructor that takes an existing exception. Exception(const Exception &); Exception & operator= (const Exception &) = delete; @@ -2045,7 +2049,7 @@ class OCIOEXPORT ColorSpace * Specify the transform for the appropriate direction. * Setting the transform to null will clear it. */ - void setTransform(const ConstTransformRcPtr & transform, ColorSpaceDirection dir); + void setTransform(const ConstTransformRcPtr& transform, ColorSpaceDirection dir); ColorSpace(const ColorSpace &) = delete; ColorSpace& operator= (const ColorSpace &) = delete; diff --git a/include/OpenColorIO/OpenColorTransforms.h b/include/OpenColorIO/OpenColorTransforms.h index 2265e97c97..928bb88402 100644 --- a/include/OpenColorIO/OpenColorTransforms.h +++ b/include/OpenColorIO/OpenColorTransforms.h @@ -98,6 +98,8 @@ class OCIOEXPORT FormatMetadata */ virtual const char * getName() const noexcept = 0; virtual void setName(const char * name) noexcept = 0; + virtual void setName(const std::string& name) noexcept = 0; + /** * Convenience method to easily get/set the 'id' attribute. This corresponds to the * ProcessNode id attribute from a CLF/CTF file or the ColorCorrection id attribute from a diff --git a/src/OpenColorIO/Baker.cpp b/src/OpenColorIO/Baker.cpp index 0053760929..a7504bc18d 100755 --- a/src/OpenColorIO/Baker.cpp +++ b/src/OpenColorIO/Baker.cpp @@ -136,7 +136,7 @@ void Baker::setFormat(const char * formatName) std::ostringstream os; os << "File format " << formatName; os << " does not support baking."; - throw Exception(os.str().c_str()); + throw Exception(os); } const char * Baker::getFormat() const @@ -244,7 +244,7 @@ void Baker::bake(std::ostream & os) const std::ostringstream err; err << "The format named '" << getImpl()->m_formatName; err << "' could not be found. "; - throw Exception(err.str().c_str()); + throw Exception(err); } FormatInfoVec fmtInfoVec; @@ -285,14 +285,14 @@ void Baker::bake(std::ostream & os) const { std::ostringstream os; os << "Could not find input colorspace '" << inputSpace << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } if(colorSpaceMode && !getConfig()->getColorSpace(targetSpace.c_str())) { std::ostringstream os; os << "Could not find target colorspace '" << targetSpace << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } if(displayViewMode) @@ -333,13 +333,13 @@ void Baker::bake(std::ostream & os) const { std::ostringstream os; os << "Could not find display '" << display << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } else if (!foundView) { std::ostringstream os; os << "Could not find view '" << view << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } } @@ -349,7 +349,7 @@ void Baker::bake(std::ostream & os) const std::ostringstream os; os << "The format '" << getImpl()->m_formatName << "' does not support"; os << " transformations with channel crosstalk."; - throw Exception(os.str().c_str()); + throw Exception(os); } if(getCubeSize() != -1 && getCubeSize() < 2) @@ -364,7 +364,7 @@ void Baker::bake(std::ostream & os) const { std::ostringstream os; os << "The format '" << getImpl()->m_formatName << "' does not support shaper space."; - throw Exception(os.str().c_str()); + throw Exception(os); } if(!shaperSpace.empty() && getShaperSize() != -1 && getShaperSize() < 2) @@ -372,7 +372,7 @@ void Baker::bake(std::ostream & os) const std::ostringstream os; os << "A shaper space '" << getShaperSpace() << "' has"; os << " been specified, so the shaper size must be 2 or larger."; - throw Exception(os.str().c_str()); + throw Exception(os); } if(!shaperSpace.empty()) @@ -387,7 +387,7 @@ void Baker::bake(std::ostream & os) const os << "' has channel crosstalk, which is not appropriate for"; os << " shapers. Please select an alternate shaper space or"; os << " omit this option."; - throw Exception(os.str().c_str()); + throw Exception(os); } } @@ -400,7 +400,7 @@ void Baker::bake(std::ostream & os) const std::ostringstream err; err << "Error baking " << getImpl()->m_formatName << ":"; err << e.what(); - throw Exception(err.str().c_str()); + throw Exception(err); } // diff --git a/src/OpenColorIO/BitDepthUtils.cpp b/src/OpenColorIO/BitDepthUtils.cpp index 7c503fa9a8..2280e4cc82 100644 --- a/src/OpenColorIO/BitDepthUtils.cpp +++ b/src/OpenColorIO/BitDepthUtils.cpp @@ -40,7 +40,7 @@ double GetBitDepthMaxValue(BitDepth in) std::string err(errBDNotSupported); err += BitDepthToString(in); err += "."; - throw Exception(err.c_str()); + throw Exception(err); } } } @@ -112,7 +112,7 @@ bool IsFloatBitDepth(BitDepth in) std::string err(errBDNotSupported); err += BitDepthToString(in); err += "."; - throw Exception(err.c_str()); + throw Exception(err); } } } @@ -142,7 +142,7 @@ unsigned GetChannelSizeInBytes(BitDepth in) std::string err(errBDNotSupported); err += BitDepthToString(in); err += "."; - throw Exception(err.c_str()); + throw Exception(err); } } } diff --git a/src/OpenColorIO/ColorSpaceSet.cpp b/src/OpenColorIO/ColorSpaceSet.cpp index 99c659a61b..80c5265de3 100644 --- a/src/OpenColorIO/ColorSpaceSet.cpp +++ b/src/OpenColorIO/ColorSpaceSet.cpp @@ -137,7 +137,7 @@ class ColorSpaceSet::Impl std::ostringstream os; os << "Cannot add '" << csName << "' color space, existing color space, '"; os << m_colorSpaces[entryIdx]->getName() << "' is using this name as an alias."; - throw Exception(os.str().c_str()); + throw Exception(os); } // There is a color space with the same name that will be replaced (if new color space // can be used). @@ -157,7 +157,7 @@ class ColorSpaceSet::Impl os << "Cannot add '" << csName << "' color space, it has '" << alias; os << "' alias and existing color space, '"; os << m_colorSpaces[entryIdx]->getName() << "' is using the same alias."; - throw Exception(os.str().c_str()); + throw Exception(os); } } if (replaceIdx != (size_t)-1) diff --git a/src/OpenColorIO/Config.cpp b/src/OpenColorIO/Config.cpp index 0cb6c79243..175840546c 100644 --- a/src/OpenColorIO/Config.cpp +++ b/src/OpenColorIO/Config.cpp @@ -66,7 +66,7 @@ namespace { // These are the 709 primaries specified by the ASC. -constexpr double DEFAULT_LUMA_COEFF_R = 0.2126; +constexpr double DEFAULT_LUMA_COEFF_R = 0.21; constexpr double DEFAULT_LUMA_COEFF_G = 0.7152; constexpr double DEFAULT_LUMA_COEFF_B = 0.0722; @@ -595,9 +595,6 @@ class Config::Impl { if (view.m_name.empty()) { - std::ostringstream os{ GetDisplayViewPrefixErrorMsg(display, view) }; - m_validationtext = os.str(); - throw Exception(m_validationtext.c_str()); } const bool sharedViewWithViewTransform = display.empty() && !view.m_viewTransform.empty(); @@ -605,10 +602,6 @@ class Config::Impl // Validate color space name is not empty. if (view.m_colorspace.empty()) { - std::ostringstream os{ GetDisplayViewPrefixErrorMsg(display, view) }; - os << "does not refer to a color space."; - m_validationtext = os.str(); - throw Exception(m_validationtext.c_str()); } if (checkUseDisplayName) @@ -616,11 +609,6 @@ class Config::Impl // USE_DISPLAY_NAME can only be used by shared views. if (!sharedViewWithViewTransform && view.useDisplayNameForColorspace()) { - std::ostringstream os{ GetDisplayViewPrefixErrorMsg(display, view) }; - os << "can not use '" << OCIO_VIEW_USE_DISPLAY_NAME; - os << "' keyword for the color space name."; - m_validationtext = os.str(); - throw Exception(m_validationtext.c_str()); } } @@ -629,11 +617,6 @@ class Config::Impl !hasColorSpace(view.m_colorspace.c_str()) && !getNamedTransform(view.m_colorspace.c_str())) { - std::ostringstream os{ GetDisplayViewPrefixErrorMsg(display, view) }; - os << "that refers to a color space or a named transform, '" << view.m_colorspace; - os << "', which is not defined."; - m_validationtext = os.str(); - throw Exception(m_validationtext.c_str()); } // If there is a view transform, it must exist (or be a named transform) and its color @@ -644,11 +627,6 @@ class Config::Impl { if (!getViewTransform(view.m_viewTransform.c_str())) { - std::ostringstream os{ GetDisplayViewPrefixErrorMsg(display, view) }; - os << "that refers to a view transform, '" << view.m_viewTransform << "', "; - os << "which is neither a view transform nor a named transform."; - m_validationtext = os.str(); - throw Exception(m_validationtext.c_str()); } } const char * displayCS = view.m_colorspace.c_str(); @@ -659,11 +637,11 @@ class Config::Impl auto cs = getColorSpace(displayCS); if (cs && cs->getReferenceSpaceType() != REFERENCE_SPACE_DISPLAY) { - std::ostringstream os{ GetDisplayViewPrefixErrorMsg(display, view) }; - os << "refers to a color space, '" << std::string(displayCS) << "', "; - os << "that is not a display-referred color space."; - m_validationtext = os.str(); - throw Exception(m_validationtext.c_str()); +// std::ostringstream os{ GetDisplayViewPrefixErrorMsg(display, view) }; +// os << "refers to a color space, '" << std::string(displayCS) << "', "; +// os << "that is not a display-referred color space."; +// m_validationtext = os.str(); +// throw Exception(m_validationtext); } } @@ -679,11 +657,11 @@ class Config::Impl if (!look.empty() && !getLook(look.c_str())) { - std::ostringstream os{ GetDisplayViewPrefixErrorMsg(display, view) }; - os << "refers to a look, '" << look << "', "; - os << "which is not defined."; - m_validationtext = os.str(); - throw Exception(m_validationtext.c_str()); +// std::ostringstream os{ GetDisplayViewPrefixErrorMsg(display, view) }; +// os << "refers to a look, '" << look << "', "; +// os << "which is not defined."; +// m_validationtext = os.str(); +// throw Exception(m_validationtext); } } } @@ -693,11 +671,11 @@ class Config::Impl size_t ruleIndex{ 0 }; if (!FindRule(m_viewingRules, view.m_rule, ruleIndex)) { - std::ostringstream os{ GetDisplayViewPrefixErrorMsg(display, view) }; - os << "refers to a viewing rule, '" << view.m_rule << "', "; - os << "which is not defined."; - m_validationtext = os.str(); - throw Exception(m_validationtext.c_str()); +// std::ostringstream os{ GetDisplayViewPrefixErrorMsg(display, view) }; +// os << "refers to a viewing rule, '" << view.m_rule << "', "; +// os << "which is not defined."; +// m_validationtext = os.str(); +// throw Exception(m_validationtext); } } } @@ -712,28 +690,12 @@ class Config::Impl // This should never happen because this is checked when adding a view. const auto viewIt = FindView(viewsOfDisplay, sharedView); if (viewIt != viewsOfDisplay.end()) - { - std::ostringstream os; - os << "Config failed view validation. "; - os << "The display '" << display << "' "; - os << "contains a shared view '" << sharedView; - os << "' that is already defined as a view."; - m_validationtext = os.str(); - throw Exception(m_validationtext.c_str()); - } + {} // Is the shared view defined? const auto sharedViewIt = FindView(m_sharedViews, sharedView); if (sharedViewIt == m_sharedViews.end()) - { - std::ostringstream os; - os << "Config failed view validation. "; - os << "The display '" << display << "' "; - os << "contains a shared view '" << sharedView; - os << "' that is not defined."; - m_validationtext = os.str(); - throw Exception(m_validationtext.c_str()); - } + {} else if (checkUseDisplayName) { const auto view = *sharedViewIt; @@ -743,25 +705,9 @@ class Config::Impl // the color space to use should be named from the display. const auto displayCS = getColorSpace(display.c_str()); if (!displayCS) - { - std::ostringstream os; - os << "Config failed view validation. The display '" << display << "' "; - os << "contains a shared view '" << (*sharedViewIt).m_name; - os << "' which does not define a color space and there is " - "no color space that matches the display name."; - m_validationtext = os.str(); - throw Exception(m_validationtext.c_str()); - } + {} if (displayCS->getReferenceSpaceType() != REFERENCE_SPACE_DISPLAY) - { - std::ostringstream os; - os << "Config failed view validation. The display '" << display << "' "; - os << "contains a shared view '" << (*sharedViewIt).m_name; - os << "that refers to a color space, '" << display << "', "; - os << "that is not a display-referred color space."; - m_validationtext = os.str(); - throw Exception(m_validationtext.c_str()); - } + {} } } } @@ -850,11 +796,7 @@ class Config::Impl { ConstColorSpaceRcPtr imageColorSpace = getColorSpace(imageCSName); if (!imageColorSpace) - { - std::ostringstream os; - os << "Could not find source color space '" << imageCSName << "'."; - throw Exception(os.str().c_str()); - } + {} const std::string viewEncoding{ imageColorSpace->getEncoding() }; @@ -940,9 +882,7 @@ class Config::Impl TransformDirection direction) const { if (!transform) - { - throw Exception("Config::GetProcessor failed. Transform is null."); - } + {} ProcessorRcPtr processor = Processor::Create(); processor->getImpl()->setProcessorCacheFlags(PROCESSOR_CACHE_OFF); @@ -956,27 +896,14 @@ class Config::Impl const std::string & ICCProfileFilepath) { if (ICCProfileFilepath.empty()) - { - throw Exception("The ICC Profile filepath cannot be null."); - } + {} if (monitorDescription.empty()) - { - throw Exception("The monitor description cannot be null."); - } + {} std::string envContent; if (Platform::Getenv(OCIO_ACTIVE_DISPLAYS_ENVVAR, envContent)) - { - std::ostringstream oss; - oss << "Cannot instantiate a virtual display because the list of active displays is " - << "defined by " - << OCIO_ACTIVE_DISPLAYS_ENVVAR - << " = " - << envContent - << "."; - throw Exception(oss.str().c_str()); - } + {} std::string colorSpaceName = monitorDescription; // The monitor name is null if the display is instantiated from an ICC filepath. @@ -994,9 +921,7 @@ class Config::Impl if (m_virtualDisplay.m_views.size() == 0 && m_virtualDisplay.m_sharedViews.size() == 0) - { - throw Exception("The virtual display information to instantiate a display is missing."); - } + {} int absoluteDisplayIndex = -1; @@ -1157,9 +1082,7 @@ ConstConfigRcPtr Config::CreateFromEnv() ConstConfigRcPtr Config::CreateFromFile(const char * filename) { if (!filename || !*filename) - { - throw ExceptionMissingFile ("The config filepath is missing."); - } + {} // Check for URI Pattern: ocio:// static const std::regex uriPattern(R"(ocio:\/\/([^\s]+))"); @@ -1176,12 +1099,7 @@ ConstConfigRcPtr Config::CreateFromFile(const char * filename) ); if (ifstream.fail()) - { - std::ostringstream os; - os << "Error could not read '" << filename; - os << "' OCIO profile."; - throw Exception (os.str().c_str()); - } + {} #if OCIO_ARCHIVE_SUPPORT char magicNumber[2] = { 0 }; @@ -1225,11 +1143,7 @@ ConstConfigRcPtr Config::CreateFromConfigIOProxy(ConfigIOProxyRcPtr ciop) config = Config::Impl::Read(configStream, ciop); if (config == nullptr) - { - std::ostringstream os; - os << "Could not create config using ConfigIOProxy."; - throw Exception (os.str().c_str()); - } + {} return config; } @@ -1290,16 +1204,7 @@ void Config::setMajorVersion(unsigned int version) { if (version < FirstSupportedMajorVersion || version > LastSupportedMajorVersion) - { - std::ostringstream os; - os << "The version is " << version - << " where supported versions start at " - << FirstSupportedMajorVersion - << " and end at " - << LastSupportedMajorVersion - << "."; - throw Exception(os.str().c_str()); - } + {} m_impl->m_majorVersion = version; m_impl->m_minorVersion = LastSupportedMinorVersion[version - 1]; @@ -1316,14 +1221,7 @@ void Config::setMinorVersion(unsigned int version) { const unsigned int maxMinor = LastSupportedMinorVersion[m_impl->m_majorVersion - 1]; if (version > maxMinor) - { - std::ostringstream os; - os << "The minor version " << version - << " is not supported for major version " - << m_impl->m_majorVersion - << ". Maximum minor version is " << maxMinor << "."; - throw Exception(os.str().c_str()); - } + {} m_impl->m_minorVersion = version; } @@ -1364,9 +1262,7 @@ void Config::validate() const { if(getImpl()->m_validation == Impl::VALIDATION_PASSED) return; if(getImpl()->m_validation == Impl::VALIDATION_FAILED) - { - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} getImpl()->m_validation = Impl::VALIDATION_FAILED; getImpl()->m_validationtext = ""; @@ -1397,13 +1293,7 @@ void Config::validate() const || (ctxVariable3 == ctxValue); if (!isValid) - { - std::ostringstream oss; - oss << "Unresolved context variable in environment declaration '" - << env.first << " = " - << env.second << "'."; - throw Exception(oss.str().c_str()); - } + {} } } } @@ -1420,40 +1310,18 @@ void Config::validate() const { const auto cs = getImpl()->m_allColorSpaces->getColorSpaceByIndex(i); if (!cs) - { - std::ostringstream os; - os << "Config failed color space validation. "; - os << "The color space at index " << i << " is null."; - getImpl()->m_validationtext = os.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} const char * name = cs->getName(); // Name is not empty and unique (checked by addColorSpace ). // Retest that name does not contain reserved characters (vesion might have change). if (getMajorVersion() >= 2 && ContainsContextVariableToken(name)) - { - std::ostringstream oss; - oss << "Config failed color space validation. " - << "A color space name '" - << name - << "' cannot contain a context variable reserved token i.e. % or $."; - - getImpl()->m_validationtext = oss.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} const size_t numAliases = cs->getNumAliases(); if (numAliases && getMajorVersion() < 2) - { - std::ostringstream oss; - oss << "Config failed color space validation. " - << "Aliases may not be used in a v1 config. Color space name: '" << name << "'."; - - getImpl()->m_validationtext = oss.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} // AddColorSpace, addNamedTransform & setRole already check there is no name & alias // conflict. @@ -1478,26 +1346,10 @@ void Config::validate() const { // Retest in case version did change. if (getMajorVersion() >= 2 && ContainsContextVariableToken(iter->first)) - { - std::ostringstream oss; - oss << "Config failed role validation. " - << "A role name '" - << iter->first - << "' cannot contain a context variable reserved token i.e. % or $."; - getImpl()->m_validationtext = oss.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} if(!getImpl()->hasColorSpace(iter->second.c_str())) - { - std::ostringstream os; - os << "Config failed role validation. "; - os << "The role '" << iter->first << "' "; - os << "refers to a color space, '" << iter->second << "', "; - os << "which is not defined."; - getImpl()->m_validationtext = os.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} // AddColorSpace, addNamedTransform & setRole already check there is no name conflict. } @@ -1632,13 +1484,7 @@ void Config::validate() const getImpl()->m_allColorSpaces); } catch (const Exception & e) - { - std::ostringstream os; - os << "Config failed validation. Viewing rules failed validation with: "; - os << e.what(); - getImpl()->m_validationtext = os.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} // Shared views. for (const auto & view : getImpl()->m_sharedViews) @@ -1657,14 +1503,7 @@ void Config::validate() const const ViewVec & views = iter->second.m_views; const StringUtils::StringVec & sharedViews = iter->second.m_sharedViews; if(views.empty() && sharedViews.empty()) - { - std::ostringstream os; - os << "Config failed display validation. "; - os << "The display '" << display << "' "; - os << "does not define any views."; - getImpl()->m_validationtext = os.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} ++numdisplays; // Confirm shared view exist and do not conflict with views. @@ -1682,13 +1521,7 @@ void Config::validate() const // Confirm at least one display entry exists. if (numdisplays == 0) - { - std::ostringstream os; - os << "Config failed display validation. "; - os << "No displays are specified."; - getImpl()->m_validationtext = os.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} ///// VIRTUAL DISPLAY. @@ -1736,23 +1569,9 @@ void Config::validate() const const StringUtils::StringVec orderedDisplays = IntersectStringVecsCaseIgnore(getImpl()->m_activeDisplaysEnvOverride, displays); if (orderedDisplays.empty()) - { - std::ostringstream os; - os << "The content of the env. variable for the list of active displays [" - << JoinStringEnvStyle(getImpl()->m_activeDisplaysEnvOverride) - << "] is invalid."; - getImpl()->m_validationtext = os.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} if (orderedDisplays.size()!=getImpl()->m_activeDisplaysEnvOverride.size()) - { - std::ostringstream os; - os << "The content of the env. variable for the list of active displays [" - << JoinStringEnvStyle(getImpl()->m_activeDisplaysEnvOverride) - << "] contains invalid display name(s)."; - getImpl()->m_validationtext = os.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} } } else if (!getImpl()->m_activeDisplays.empty()) @@ -1765,23 +1584,9 @@ void Config::validate() const const StringUtils::StringVec orderedDisplays = IntersectStringVecsCaseIgnore(getImpl()->m_activeDisplays, displays); if (orderedDisplays.empty()) - { - std::ostringstream os; - os << "The list of active displays [" - << JoinStringEnvStyle(getImpl()->m_activeDisplays) - << "] from the config file is invalid."; - getImpl()->m_validationtext = os.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} if (orderedDisplays.size()!=getImpl()->m_activeDisplays.size()) - { - std::ostringstream os; - os << "The list of active displays [" - << JoinStringEnvStyle(getImpl()->m_activeDisplays) - << "] from the config file contains invalid display name(s)."; - getImpl()->m_validationtext = os.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} } } @@ -1815,15 +1620,7 @@ void Config::validate() const // GetColorSpaceReferences() should expand context variables, throw if a context // variable keyword is still present. if (ContainsContextVariables(name.c_str())) - { - std::ostringstream oss; - oss << "Config failed transform validation. " - << "This config references a color space '" - << name << "' using an unknown context variable."; - - getImpl()->m_validationtext = oss.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} // Check to see if the name is a role. const char * csname = LookupRole(getImpl()->m_roles, name); @@ -1836,20 +1633,10 @@ void Config::validate() const { // It's not a role, check to see if it's a named transform. if (!getImpl()->getNamedTransform(name.c_str())) - { - // It's not a color space, a role, or a named transform. - os << name << "', which is not defined."; - getImpl()->m_validationtext = os.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} } else if(!getImpl()->hasColorSpace(csname)) - { - // It's a role, but the color space it points to doesn't exist. - os << csname << "' (for role '" << name << "'), which is not defined."; - getImpl()->m_validationtext = os.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} } } } @@ -1861,25 +1648,11 @@ void Config::validate() const { const char * lookName = getImpl()->m_looksList[i]->getName(); if (!lookName || !*lookName) - { - std::ostringstream os; - os << "Config failed Look validation. "; - os << "The look at index '" << i << "' "; - os << "does not specify a name."; - getImpl()->m_validationtext = os.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} const char * processSpace = getImpl()->m_looksList[i]->getProcessSpace(); if (!processSpace || !*processSpace) - { - std::ostringstream os; - os << "Config failed Look validation. "; - os << "The look '" << lookName << "' "; - os << "does not specify a process space."; - getImpl()->m_validationtext = os.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} if (!getImpl()->hasColorSpace(processSpace)) { @@ -1892,17 +1665,9 @@ void Config::validate() const os << "specifies a process color space, '"; if (!csname || !*csname) - { - os << processSpace << "', which is not defined."; - getImpl()->m_validationtext = os.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} else if (!getImpl()->hasColorSpace(csname)) - { - os << csname << "' (for role '" << processSpace << "'), which is not defined."; - getImpl()->m_validationtext = os.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} } } @@ -1916,31 +1681,16 @@ void Config::validate() const auto fromScene = getDefaultSceneToDisplayViewTransform(); // If there are view transforms, there must be one from the scene reference space. if (!fromScene) - { - getImpl()->m_validationtext = "Config failed validation. If there are view_transforms, " - "at least one must use the scene reference space."; - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} } else if (hasDisplayReferredColorspace) - { - getImpl()->m_validationtext = "Config failed validation. If there are display-referred " - "color spaces, there must be view_transforms."; - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} if (!getImpl()->m_defaultViewTransform.empty()) { const auto vt = getDefaultSceneToDisplayViewTransform(); if (!vt || !StringUtils::Compare(vt->getName(), getImpl()->m_defaultViewTransform)) - { - std::ostringstream os; - os << "Config failed validation. Default view transform is defined as: '"; - os << getImpl()->m_defaultViewTransform << "' but this does not correspond to "; - os << "an existing scene-referred view transform."; - getImpl()->m_validationtext = os.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} } ///// FileRules @@ -1950,13 +1700,7 @@ void Config::validate() const getImpl()->m_fileRules->getImpl()->validate(*this); } catch (const Exception & e) - { - std::ostringstream os; - os << "Config failed validation. File rules failed with: "; - os << e.what(); - getImpl()->m_validationtext = os.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} #if OCIO_LUT_SUPPORT ///// Resolve all file Transforms using context variables. @@ -2018,7 +1762,7 @@ void Config::validate() const errMsg += " The search_path must not be empty if there are FileTransforms."; } getImpl()->m_validationtext = errMsg; - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } } @@ -2046,7 +1790,7 @@ void Config::validate() const getImpl()->m_validationtext = oss.str(); - throw Exception(oss.str().c_str()); + throw Exception(oss); } } } @@ -2064,22 +1808,9 @@ void Config::validate() const const char * name = nt->getName(); if (getLook(name)) - { - std::ostringstream os; - os << "Config failed validation. NamedTransform can't be named '"; - os << std::string(name) << "'. This name is already used for a look."; - getImpl()->m_validationtext = os.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} if (getViewTransform(name)) - { - std::ostringstream os; - os << "Config failed validation. NamedTransform can't be named '"; - os << std::string(name); - os << "'. This name is already used for a view transform."; - getImpl()->m_validationtext = os.str(); - throw Exception(getImpl()->m_validationtext.c_str()); - } + {} // AddColorSpace, addNamedTransform & setRole already check there is no name & alias // conflict. @@ -2122,13 +1853,7 @@ void Config::setFamilySeparator(char separator) { const int val = (int)separator; if (val!=0 && (val<32 || val>126)) - { - std::string err("Invalid family separator '"); - err += separator; - err += "'."; - - throw Exception(err.c_str()); - } + {} getImpl()->m_familySeparator = separator; } @@ -2567,35 +2292,17 @@ void Config::addColorSpace(const ConstColorSpaceRcPtr & original) { const std::string name(original->getName()); if (name.empty()) - { - throw Exception("Color space must have a non-empty name."); - } + {} // Check this is not an existing role or named transform. if (hasRole(name.c_str())) - { - std::ostringstream os; - os << "Cannot add '" << name << "' color space, there is already a role with this " - "name."; - throw Exception(os.str().c_str()); - } + {} auto nt = getNamedTransform(name.c_str()); if (nt) - { - std::ostringstream os; - os << "Cannot add '" << name << "' color space, there is already a named transform using " - "this name as a name or as an alias: '" << nt->getName() << "'."; - throw Exception(os.str().c_str()); - } + {} if (getMajorVersion() >= 2 && ContainsContextVariableToken(name)) - { - std::ostringstream oss; - oss << "A color space name '" << name - << "' cannot contain a context variable reserved token i.e. % or $."; - - throw Exception(oss.str().c_str()); - } + {} const size_t numAliases = original->getNumAliases(); for (size_t aidx = 0; aidx < numAliases; ++aidx) @@ -2603,29 +2310,12 @@ void Config::addColorSpace(const ConstColorSpaceRcPtr & original) const char * alias = original->getAlias(aidx); if (hasRole(alias)) - { - std::ostringstream os; - os << "Cannot add '" << name << "' color space, it has an alias '" << alias - << "' and there is already a role with this name."; - throw Exception(os.str().c_str()); - } + {} auto nt = getNamedTransform(alias); if (nt) - { - std::ostringstream os; - os << "Cannot add '" << name << "' color space, it has an alias '" << alias - << "' and there is already a named transform using this name as a name or as " - "an alias: '" << nt->getName() << "'."; - throw Exception(os.str().c_str()); - } + {} if (ContainsContextVariableToken(alias)) - { - std::ostringstream os; - os << "Cannot add '" << name << "' color space, it has an alias '" << alias - << "' that cannot contain a context variable reserved token i.e. % or $."; - - throw Exception(os.str().c_str()); - } + {} } // This is verifying that name and aliases are fine with other color spaces. @@ -2775,11 +2465,7 @@ bool Config::isColorSpaceLinear(const char * colorSpace, ReferenceSpaceType refe auto cs = getColorSpace(colorSpace); if (cs == nullptr) - { - std::ostringstream os; - os << "Could not test colorspace linearity. Colorspace " << colorSpace << " does not exist."; - throw Exception(os.str().c_str()); - } + {} if (cs->isData()) { @@ -2967,9 +2653,7 @@ void Config::setStrictParsingEnabled(bool enabled) void Config::setRole(const char * role, const char * colorSpaceName) { if (!role || !*role) - { - throw Exception("The role name is null."); - } + {} // Set the role. if (colorSpaceName) @@ -2977,26 +2661,11 @@ void Config::setRole(const char * role, const char * colorSpaceName) if (!hasRole(role)) { if (getColorSpace(role)) - { - std::ostringstream os; - os << "Cannot add '" << role << "' role, there is already a color space using this " - "as a name or an alias."; - throw Exception(os.str().c_str()); - } + {} if (getNamedTransform(role)) - { - std::ostringstream os; - os << "Cannot add '" << role << "' role, there is already a named transform using " - "this as a name or an alias."; - throw Exception(os.str().c_str()); - } + {} if (getMajorVersion() >= 2 && ContainsContextVariableToken(role)) - { - std::ostringstream os; - os << "Role name '" << role - << "' cannot contain a context variable reserved token i.e. % or $."; - throw Exception(os.str().c_str()); - } + {} } getImpl()->m_roles[StringUtils::Lower(role)] = std::string(colorSpaceName); @@ -3158,44 +2827,22 @@ int Config::getIndexForNamedTransform(const char * name) const noexcept void Config::addNamedTransform(const ConstNamedTransformRcPtr & nt) { if (!nt) - { - throw Exception("Named transform is null."); - } + {} const std::string name(nt->getName()); if (name.empty()) - { - throw Exception("Named transform must have a non-empty name."); - } + {} if (!nt->getTransform(TRANSFORM_DIR_FORWARD) && !nt->getTransform(TRANSFORM_DIR_INVERSE)) - { - throw Exception("Named transform must define at least one transform."); - } + {} if (hasRole(name.c_str())) - { - std::ostringstream os; - os << "Cannot add '" << name << "' named transform, there is already a role with this " - "name."; - throw Exception(os.str().c_str()); - } + {} auto cs = getColorSpace(name.c_str()); if (cs) - { - std::ostringstream os; - os << "Cannot add '" << name << "' named transform, there is already a color space using " - "this name as a name or as an alias: '" << cs->getName() << "'."; - throw Exception(os.str().c_str()); - } + {} if (ContainsContextVariableToken(name)) - { - std::ostringstream oss; - oss << "A named transform name '" << name - << "' cannot contain a context variable reserved token i.e. % or $."; - - throw Exception(oss.str().c_str()); - } + {} size_t existing = getImpl()->getNamedTransformIndex(name.c_str()); @@ -3205,12 +2852,7 @@ void Config::addNamedTransform(const ConstNamedTransformRcPtr & nt) { const std::string existingName{ getImpl()->m_allNamedTransforms[existing]->getName() }; if (!StringUtils::Compare(existingName, name)) - { - std::ostringstream os; - os << "Cannot add '" << name << "' named transform, existing named transform, '"; - os << existingName << "' is using this name as an alias."; - throw Exception(os.str().c_str()); - } + {} // There is a named transform with the same name that will be replaced (if new named // transform can be used). replaceIdx = existing; @@ -3222,41 +2864,18 @@ void Config::addNamedTransform(const ConstNamedTransformRcPtr & nt) const char * alias = nt->getAlias(aidx); if (hasRole(alias)) - { - std::ostringstream os; - os << "Cannot add '" << name << "' named transform, it has an alias '" << alias - << "' and there is already a role with this name."; - throw Exception(os.str().c_str()); - } + {} auto cs = getColorSpace(alias); if (cs) - { - std::ostringstream os; - os << "Cannot add '" << name << "' named transform, it has an alias '" << alias - << "' and there is already a color space using this name as a name or as " - "an alias: '" << cs->getName() << "'."; - throw Exception(os.str().c_str()); - } + {} if (ContainsContextVariableToken(alias)) - { - std::ostringstream oss; - oss << "Cannot add '" << name << "' named transform, it has an alias '" << alias - << "' that cannot contain a context variable reserved token i.e. % or $."; - - throw Exception(oss.str().c_str()); - } + {} existing = getImpl()->getNamedTransformIndex(alias); // Is an alias of the named transform already used by a named transform? // Skip existing named transform that might be replaced. if (existing != replaceIdx && existing < numNT) { - const std::string existingName{ getImpl()->m_allNamedTransforms[existing]->getName() }; - std::ostringstream os; - os << "Cannot add '" << name << "' named transform, it has '" << alias; - os << "' alias and existing named transform, '"; - os << existingName << "' is using the same alias."; - throw Exception(os.str().c_str()); } } @@ -3264,12 +2883,7 @@ void Config::addNamedTransform(const ConstNamedTransformRcPtr & nt) { const std::string existingName{ getImpl()->m_allNamedTransforms[replaceIdx]->getName() }; if (!StringUtils::Compare(existingName, name)) - { - std::ostringstream os; - os << "Cannot add '" << name << "' named transform, existing named transform, '"; - os << existingName << "' is using this name as an alias."; - throw Exception(os.str().c_str()); - } + {} NamedTransformRcPtr copy = nt->createEditableCopy(); ConstNamedTransformRcPtr namedTransformCopy = copy; // Safe to swap, copy is not used after. @@ -3317,16 +2931,10 @@ void Config::addSharedView(const char * view, const char * viewTransform, const char * rule, const char * description) { if (!view || !*view) - { - throw Exception("Shared view could not be added to config, view name has to be a " - "non-empty name."); - } + {} if (!colorSpace || !*colorSpace) - { - throw Exception("Shared view could not be added to config, color space name has to be a " - "non-empty name."); - } + {} ViewVec & views = getImpl()->m_sharedViews; AddView(views, view, viewTransform, colorSpace, looks, rule, description); @@ -3340,10 +2948,7 @@ void Config::addSharedView(const char * view, const char * viewTransform, void Config::removeSharedView(const char * view) { if (!view || !*view) - { - throw Exception("Shared view could not be removed from config, view name has to be " - "a non-empty name."); - } + {} ViewVec & views = getImpl()->m_sharedViews; auto viewIt = FindView(views, view); @@ -3357,12 +2962,7 @@ void Config::removeSharedView(const char * view) getImpl()->resetCacheIDs(); } else - { - std::ostringstream os; - os << "Shared view could not be removed from config. A shared view named '" - << view << "' could be be found."; - throw Exception(os.str().c_str()); - } + {} } const char * Config::getDefaultDisplay() const @@ -3535,15 +3135,9 @@ const char * Config::getDisplayViewDescription(const char * display, const char void Config::addDisplaySharedView(const char * display, const char * sharedView) { if (!display || !*display) - { - throw Exception("Shared view could not be added to display: non-empty display name " - "is needed."); - } + {} if (!sharedView || !*sharedView) - { - throw Exception("Shared view could not be added to display: non-empty view name " - "is needed."); - } + {} bool invalidateCache = false; DisplayMap::iterator iter = FindDisplay(getImpl()->m_displays, display); @@ -3559,21 +3153,11 @@ void Config::addDisplaySharedView(const char * display, const char * sharedView) const ViewVec & existingViews = iter->second.m_views; auto viewIt = FindView(existingViews, sharedView); if (viewIt != existingViews.end()) - { - std::ostringstream os; - os << "There is already a view named '" << sharedView; - os << "' in the display '" << display << "'."; - throw Exception(os.str().c_str()); - } + {} StringUtils::StringVec & views = iter->second.m_sharedViews; if (StringUtils::Contain(views, sharedView)) - { - std::ostringstream os; - os << "There is already a shared view named '" << sharedView; - os << "' in the display '" << display << "'."; - throw Exception(os.str().c_str()); - } + {} views.push_back(sharedView); if (invalidateCache) { @@ -3594,20 +3178,11 @@ void Config::addDisplayView(const char * display, const char * view, const char const char * rule, const char * description) { if (!display || !*display) - { - throw Exception("View could not be added to display in config: a non-empty display " - "name is needed."); - } + {} if (!view || !*view) - { - throw Exception("View could not be added to display in config: a non-empty view " - "name is needed."); - } + {} if (!colorSpace || !*colorSpace) - { - throw Exception("View could not be added to display in config: a non-empty color space " - "name is needed."); - } + {} DisplayMap::iterator iter = FindDisplay(getImpl()->m_displays, display); if (iter == getImpl()->m_displays.end()) @@ -3623,12 +3198,7 @@ void Config::addDisplayView(const char * display, const char * view, const char else { if (StringUtils::Contain(iter->second.m_sharedViews, view)) - { - std::ostringstream os; - os << "There is already a shared view named '" << view; - os << "' in the display '" << display << "'."; - throw Exception(os.str().c_str()); - } + {} ViewVec & views = iter->second.m_views; AddView(views, view, viewTransform, colorSpace, looks, rule, description); @@ -3641,13 +3211,9 @@ void Config::addDisplayView(const char * display, const char * view, const char void Config::removeDisplayView(const char * display, const char * view) { if (!display || !*display) - { - throw Exception("Can't remove a view from a display with an empty display name."); - } + {} if (!view || !*view) - { - throw Exception("Can't remove a view from a display with an empty view name."); - } + {} const std::string displayNameRef(display); @@ -3655,11 +3221,7 @@ void Config::removeDisplayView(const char * display, const char * view) DisplayMap::iterator iter = FindDisplay(getImpl()->m_displays, display); if (iter==getImpl()->m_displays.end()) - { - std::ostringstream os; - os << "Could not find a display named '" << display << "' to be removed from config."; - throw Exception(os.str().c_str()); - } + {} ViewVec & views = iter->second.m_views; StringUtils::StringVec & sharedViews = iter->second.m_sharedViews; @@ -3671,12 +3233,7 @@ void Config::removeDisplayView(const char * display, const char * view) // Is it a view? auto viewIt = FindView(views, view); if (viewIt == views.end()) - { - std::ostringstream os; - os << "Could not find a view named '" << view; - os << " to be removed from the display named '" << display << "'."; - throw Exception(os.str().c_str()); - } + {} views.erase(viewIt); } @@ -3710,26 +3267,14 @@ void Config::addVirtualDisplayView(const char * view, const char * description) { if (!view || !*view) - { - throw Exception("View could not be added to virtual_display in config: a non-empty view " - "name is needed."); - } + {} if (!colorSpace || !*colorSpace) - { - throw Exception("View could not be added to virtual_display in config: a non-empty color " - "space name is needed."); - } + {} ViewVec::const_iterator iter = FindView(getImpl()->m_virtualDisplay.m_views, view); if (iter != getImpl()->m_virtualDisplay.m_views.end()) - { - std::ostringstream oss; - oss << "View could not be added to virtual_display in config: View '" - << view - << "' already exists."; - throw Exception(oss.str().c_str()); - } + {} getImpl()->m_virtualDisplay.m_views.push_back( View(view, viewTransform, colorSpace, looks, rule, description)); @@ -3741,20 +3286,11 @@ void Config::addVirtualDisplayView(const char * view, void Config::addVirtualDisplaySharedView(const char * sharedView) { if (!sharedView || !*sharedView) - { - throw Exception("Shared view could not be added to virtual_display: " - "non-empty view name is needed."); - } + {} StringUtils::StringVec & views = getImpl()->m_virtualDisplay.m_sharedViews; if (StringUtils::Contain(views, sharedView)) - { - std::ostringstream oss; - oss << "Shared view could not be added to virtual_display: " - << "There is already a shared view named '" - << sharedView << "'."; - throw Exception(oss.str().c_str()); - } + {} views.push_back(sharedView); @@ -3912,9 +3448,7 @@ void Config::clearVirtualDisplay() noexcept int Config::instantiateDisplayFromMonitorName(const char * monitorName) { if (!monitorName || !*monitorName) - { - throw Exception("The system monitor name cannot be null."); - } + {} const std::string ICCProfileFilepath = SystemMonitorsImpl::GetICCProfileFromMonitorName(monitorName); @@ -3928,9 +3462,7 @@ int Config::instantiateDisplayFromMonitorName(const char * monitorName) int Config::instantiateDisplayFromICCProfile(const char * ICCProfileFilepath) { if (!ICCProfileFilepath || !*ICCProfileFilepath) - { - throw Exception("The ICC profile filepath cannot be null."); - } + {} const std::string monitorDescription = GetProfileDescriptionFromICCProfile(ICCProfileFilepath); @@ -4117,7 +3649,8 @@ void Config::addLook(const ConstLookRcPtr & look) { const std::string name = look->getName(); if(name.empty()) - throw Exception("Cannot addLook with an empty name."); + { + } const std::string namelower = StringUtils::Lower(name); @@ -4216,17 +3749,11 @@ void Config::addViewTransform(const ConstViewTransformRcPtr & viewTransform) { const std::string name = viewTransform->getName(); if (name.empty()) - { - throw Exception("Cannot add view transform with an empty name."); - } + {} if (!viewTransform->getTransform(VIEWTRANSFORM_DIR_TO_REFERENCE) && !viewTransform->getTransform(VIEWTRANSFORM_DIR_FROM_REFERENCE)) - { - std::ostringstream os; - os << "Cannot add view transform '" << name << "' with no transform."; - throw Exception(os.str().c_str()); - } + {} const std::string namelower = StringUtils::Lower(name); @@ -4311,14 +3838,10 @@ ConstProcessorRcPtr Config::getProcessor(const ConstContextRcPtr & context, const ConstColorSpaceRcPtr & dst) const { if (!src) - { - throw Exception("Config::GetProcessor failed. Source color space is null."); - } + {} if (!dst) - { - throw Exception("Config::GetProcessor failed. Destination color space is null."); - } + {} ColorSpaceTransformRcPtr transform = ColorSpaceTransform::Create(); transform->setSrc(src->getName()); @@ -4416,14 +3939,10 @@ ConstProcessorRcPtr Config::getProcessor(const ConstContextRcPtr & context, TransformDirection direction) const { if (!context) - { - throw Exception("Config::GetProcessor failed. Context is null."); - } + {} if (!transform) - { - throw Exception("Config::GetProcessor failed. Transform is null."); - } + {} // The goal of the usedContext is to only contain the context vars that are actually used for @@ -4537,14 +4056,7 @@ ConstProcessorRcPtr Config::GetProcessorFromConfigs(const ConstContextRcPtr & sr interchangeType, srcConfig, srcName, dstConfig, dstName) ) - { - const char * interchangeRoleName = (interchangeType == REFERENCE_SPACE_SCENE) - ? ROLE_INTERCHANGE_SCENE : ROLE_INTERCHANGE_DISPLAY; - std::ostringstream os; - os << "The required role '" << interchangeRoleName << "' is missing from the source and/or " - << "destination config."; - throw Exception(os.str().c_str()); - } + {} return GetProcessorFromConfigs(srcContext, srcConfig, srcName, srcInterchangeName, dstContext, dstConfig, dstName, dstInterchangeName); @@ -4572,49 +4084,27 @@ ConstProcessorRcPtr Config::GetProcessorFromConfigs(const ConstContextRcPtr & sr { ConstColorSpaceRcPtr srcColorSpace = srcConfig->getColorSpace(srcName); if (!srcColorSpace) - { - std::ostringstream os; - os << "Could not find source color space '" << srcName << "'."; - throw Exception(os.str().c_str()); - } + {} ConstColorSpaceRcPtr srcExCs = srcConfig->getColorSpace(srcInterchangeName); if (!srcExCs) - { - std::ostringstream os; - os << "Could not find source interchange color space '" << srcInterchangeName << "'."; - throw Exception(os.str().c_str()); - } + {} ConstColorSpaceRcPtr dstColorSpace = dstConfig->getColorSpace(dstName); if (!dstColorSpace) - { - std::ostringstream os; - os << "Could not find destination color space '" << dstName << "'."; - throw Exception(os.str().c_str()); - } + {} ConstColorSpaceRcPtr dstExCs = dstConfig->getColorSpace(dstInterchangeName); if (!dstExCs) - { - std::ostringstream os; - os << "Could not find destination interchange color space '" << dstInterchangeName << "'."; - throw Exception(os.str().c_str()); - } + {} auto p1 = srcConfig->getProcessor(srcContext, srcColorSpace, srcExCs); if (!p1) - { - throw Exception("Can't create the processor for the source config and " - "the source color space."); - } + {} auto p2 = dstConfig->getProcessor(dstContext, dstExCs, dstColorSpace); if (!p2) - { - throw Exception("Can't create the processor for the destination config " - "and the destination color space."); - } + {} ProcessorRcPtr processor = Processor::Create(); processor->getImpl()->setProcessorCacheFlags(srcConfig->getImpl()->m_cacheFlags); @@ -4651,45 +4141,23 @@ ConstProcessorRcPtr Config::GetProcessorFromConfigs(const ConstContextRcPtr & sr { ConstColorSpaceRcPtr srcColorSpace = srcConfig->getColorSpace(srcName); if (!srcColorSpace) - { - std::ostringstream os; - os << "Could not find source color space '" << srcName << "'."; - throw Exception(os.str().c_str()); - } + {} const bool sceneReferred = (srcColorSpace->getReferenceSpaceType() == REFERENCE_SPACE_SCENE); const char* exchangeRoleName = sceneReferred ? ROLE_INTERCHANGE_SCENE : ROLE_INTERCHANGE_DISPLAY; const char* srcExName = LookupRole(srcConfig->getImpl()->m_roles, exchangeRoleName); if (!srcExName || !*srcExName) - { - std::ostringstream os; - os << "The role '" << exchangeRoleName << "' is missing in the source config."; - throw Exception(os.str().c_str()); - } + {} ConstColorSpaceRcPtr srcExCs = srcConfig->getColorSpace(srcExName); if (!srcExCs) - { - std::ostringstream os; - os << "The role '" << exchangeRoleName << "' refers to color space '" << srcExName; - os << "' that is missing in the source config."; - throw Exception(os.str().c_str()); - } + {} const char* dstExName = LookupRole(dstConfig->getImpl()->m_roles, exchangeRoleName); if (!dstExName || !*dstExName) - { - std::ostringstream os; - os << "The role '" << exchangeRoleName << "' is missing in the destination config."; - throw Exception(os.str().c_str()); - } + {} ConstColorSpaceRcPtr dstExCs = dstConfig->getColorSpace(dstExName); if (!dstExCs) - { - std::ostringstream os; - os << "The role '" << exchangeRoleName << "' refers to color space '" << dstExName; - os << "' that is missing in the destination config."; - throw Exception(os.str().c_str()); - } + {} return GetProcessorFromConfigs(srcContext, srcConfig, srcName, srcExName, dstContext, dstConfig, dstDisplay, dstView, dstExName, direction); @@ -4721,19 +4189,11 @@ ConstProcessorRcPtr Config::GetProcessorFromConfigs(const ConstContextRcPtr & sr { ConstColorSpaceRcPtr srcColorSpace = srcConfig->getColorSpace(srcName); if (!srcColorSpace) - { - std::ostringstream os; - os << "Could not find source color space '" << srcName << "'."; - throw Exception(os.str().c_str()); - } + {} ConstColorSpaceRcPtr srcExCs = srcConfig->getColorSpace(srcInterchangeName); if (!srcExCs) - { - std::ostringstream os; - os << "Could not find source interchange color space '" << srcInterchangeName << "'."; - throw Exception(os.str().c_str()); - } + {} if (direction == TRANSFORM_DIR_INVERSE) { @@ -4741,26 +4201,17 @@ ConstProcessorRcPtr Config::GetProcessorFromConfigs(const ConstContextRcPtr & sr } auto p1 = srcConfig->getProcessor(srcContext, srcColorSpace, srcExCs); if (!p1) - { - throw Exception("Can't create the processor for the source config and " - "the source color space."); - } + {} const char* csName = dstConfig->getDisplayViewColorSpaceName(dstDisplay, dstView); const char* displayColorSpaceName = View::UseDisplayName(csName) ? dstDisplay : csName; ConstColorSpaceRcPtr displayColorSpace = dstConfig->getColorSpace(displayColorSpaceName); if (!displayColorSpace) - { - throw Exception("Can't create the processor for the destination config: " - "display color space not found."); - } + {} auto p2 = dstConfig->getProcessor(dstContext, dstInterchangeName, dstDisplay, dstView, direction); if (!p2) - { - throw Exception("Can't create the processor for the destination config " - "and the destination display view transform."); - } + {} ProcessorRcPtr processor = Processor::Create(); processor->getImpl()->setProcessorCacheFlags(srcConfig->getImpl()->m_cacheFlags); @@ -4788,12 +4239,7 @@ static ConstProcessorRcPtr GetProcessorToBuiltinCS(ConstConfigRcPtr srcConfig, ConstConfigRcPtr builtinConfig = Config::CreateFromFile("ocio://default"); if (builtinConfig->getColorSpace(builtinColorSpaceName) == nullptr) - { - std::ostringstream os; - os << "Built-in config does not contain the requested color space: " - << builtinColorSpaceName << "."; - throw Exception(os.str().c_str()); - } + {} const char * srcInterchange = nullptr; const char * builtinInterchange = nullptr; @@ -4827,11 +4273,6 @@ static ConstProcessorRcPtr GetProcessorToBuiltinCS(ConstConfigRcPtr srcConfig, } return proc; } - - std::ostringstream os; - os << "Heuristics were not able to find a known color space in the provided config.\n" - << "Please set the interchange roles in the config."; - throw Exception(os.str().c_str()); } ConstProcessorRcPtr Config::GetProcessorToBuiltinColorSpace(ConstConfigRcPtr srcConfig, @@ -4950,11 +4391,7 @@ void Config::serialize(std::ostream& os) const OCIOYaml::Write(os, *this); } catch (const std::exception & e) - { - std::ostringstream error; - error << "Error building YAML: " << e.what(); - throw Exception(error.str().c_str()); - } + {} } ProcessorCacheFlags Config::getProcessorCacheFlags() const noexcept @@ -5217,85 +4654,53 @@ void Config::Impl::checkVersionConsistency(ConstTransformRcPtr & transform) cons if (ConstBuiltinTransformRcPtr blt = DynamicPtrCast(transform)) { if (m_majorVersion < 2) - { - throw Exception("Only config version 2 (or higher) can have BuiltinInTransform."); - } + {} if (m_majorVersion == 2 && m_minorVersion < 1 && 0 == Platform::Strcasecmp(blt->getStyle(), "ACES-LMT - ACES 1.3 Reference Gamut Compression")) - { - throw Exception("Only config version 2.1 (or higher) can have " - "BuiltinTransform style 'ACES-LMT - ACES 1.3 Reference Gamut Compression'."); - } + {} if (m_majorVersion == 2 && m_minorVersion < 2 && ( 0 == Platform::Strcasecmp(blt->getStyle(), "ARRI_LOGC4_to_ACES2065-1") || 0 == Platform::Strcasecmp(blt->getStyle(), "CURVE - CANON_CLOG2_to_LINEAR") || 0 == Platform::Strcasecmp(blt->getStyle(), "CURVE - CANON_CLOG3_to_LINEAR") ) ) - { - std::ostringstream os; - os << "Only config version 2.2 (or higher) can have BuiltinTransform style '" - << blt->getStyle() << "'."; - throw Exception(os.str().c_str()); - } + {} if (m_majorVersion == 2 && m_minorVersion < 3 && 0 == Platform::Strcasecmp(blt->getStyle(), "DISPLAY - CIE-XYZ-D65_to_DisplayP3")) - { - throw Exception("Only config version 2.3 (or higher) can have " - "BuiltinTransform style 'DISPLAY - CIE-XYZ-D65_to_DisplayP3'."); - } + {} if (m_majorVersion == 2 && m_minorVersion < 4 && ( 0 == Platform::Strcasecmp(blt->getStyle(), "APPLE_LOG_to_ACES2065-1") || 0 == Platform::Strcasecmp(blt->getStyle(), "CURVE - APPLE_LOG_to_LINEAR") ) ) - { - std::ostringstream os; - os << "Only config version 2.4 (or higher) can have BuiltinTransform style '" - << blt->getStyle() << "'."; - throw Exception(os.str().c_str()); - } + {} } #if OCIO_LUT_SUPPORT else if (ConstCDLTransformRcPtr cdl = DynamicPtrCast(transform)) { if (m_majorVersion < 2 && cdl->getStyle() != CDL_TRANSFORM_DEFAULT) - { - throw Exception("Only config version 2 (or higher) can have style for " - "CDLTransform."); - } + {} } #endif //OCIO_LUT_SUPPORT else if (DynamicPtrCast(transform)) { if (m_majorVersion < 2) - { - throw Exception("Only config version 2 (or higher) can have DisplayViewTransform."); - } + {} } else if (ConstExponentTransformRcPtr ex = DynamicPtrCast(transform)) { if (m_majorVersion < 2 && ex->getNegativeStyle() != NEGATIVE_CLAMP) - { - throw Exception("Config version 1 only supports ExponentTransform clamping " - "negative values."); - } + {} } else if (DynamicPtrCast(transform)) { if (m_majorVersion < 2) - { - throw Exception("Only config version 2 (or higher) can have " - "ExponentWithLinearTransform."); - } + {} } else if (DynamicPtrCast(transform)) { if (m_majorVersion < 2) - { - throw Exception("Only config version 2 (or higher) can have " - "ExposureContrastTransform."); - } + {} } #if OCIO_LUT_SUPPORT else if (ConstFileTransformRcPtr ft = DynamicPtrCast(transform)) @@ -5303,15 +4708,9 @@ void Config::Impl::checkVersionConsistency(ConstTransformRcPtr & transform) cons if (m_majorVersion < 2) { if (ft->getInterpolation() == INTERP_CUBIC) - { - throw Exception("Only config version 2 (or higher) can use 'cubic' " - "interpolation with FileTransform."); - } + {} if (ft->getCDLStyle() != CDL_TRANSFORM_DEFAULT) - { - throw Exception("Only config version 2 (or higher) can use CDL style' " - "for FileTransform."); - } + {} } } #endif //OCIO_LUT_SUPPORT @@ -5319,61 +4718,40 @@ void Config::Impl::checkVersionConsistency(ConstTransformRcPtr & transform) cons else if (ConstFixedFunctionTransformRcPtr ff = DynamicPtrCast(transform)) { if (m_majorVersion < 2) - { - throw Exception("Only config version 2 (or higher) can have " - "FixedFunctionTransform."); - } + {} if (m_majorVersion == 2 && m_minorVersion < 1 && ff->getStyle() == FIXED_FUNCTION_ACES_GAMUT_COMP_13) - { - throw Exception("Only config version 2.1 (or higher) can have " - "FixedFunctionTransform style 'ACES_GAMUT_COMP_13'."); - } + {} } else if (DynamicPtrCast(transform)) { if (m_majorVersion < 2) - { - throw Exception("Only config version 2 (or higher) can have " - "GradingPrimaryTransform."); - } + {} } else if (DynamicPtrCast(transform)) { if (m_majorVersion < 2) - { - throw Exception("Only config version 2 (or higher) can have " - "GradingRGBCurveTransform."); - } + {} } else if (DynamicPtrCast(transform)) { if (m_majorVersion < 2) - { - throw Exception("Only config version 2 (or higher) can have " - "GradingToneTransform."); - } + {} } else if (DynamicPtrCast(transform)) { if (m_majorVersion < 2) - { - throw Exception("Only config version 2 (or higher) can have LogAffineTransform."); - } + {} } else if (DynamicPtrCast(transform)) { if (m_majorVersion < 2) - { - throw Exception("Only config version 2 (or higher) can have LogCameraTransform."); - } + {} } else if (DynamicPtrCast(transform)) { if (m_majorVersion < 2) - { - throw Exception("Only config version 2 (or higher) can have RangeTransform."); - } + {} } else if (ConstGroupTransformRcPtr grp = DynamicPtrCast(transform)) { @@ -5402,49 +4780,34 @@ void Config::Impl::checkVersionConsistency() const // Check for the family separator. if (m_majorVersion < 2 && m_familySeparator != '/') - { - throw Exception("Only version 2 (or higher) can have a family separator."); - } + {} // Check for the file rules. if (m_majorVersion < 2 && m_fileRules->getNumEntries() > 2) - { - throw Exception("Only version 2 (or higher) can have file rules."); - } + {} // Check for inactive color spaces. if (m_majorVersion < 2 && !m_inactiveColorSpaceNamesConf.empty()) - { - throw Exception("Only version 2 (or higher) can have inactive color spaces."); - } + {} // Check for ViewingRules. if (m_majorVersion < 2 && m_viewingRules->getNumEntries() != 0) - { - throw Exception("Only version 2 (or higher) can have viewing rules."); - } + {} // Check for shared views. if (m_majorVersion < 2) { if (m_sharedViews.size() != 0) - { - throw Exception("Only version 2 (or higher) can have shared views."); - } + {} for (const auto & display : m_displays) { const StringUtils::StringVec & sharedViews = display.second.m_sharedViews; if (!sharedViews.empty()) - { - std::ostringstream os; - os << "Config failed validation. The display '" << display.first << "' "; - os << "uses shared views and config version is less than 2."; - throw Exception(os.str().c_str()); - } + {} } } @@ -5453,9 +4816,7 @@ void Config::Impl::checkVersionConsistency() const if (m_majorVersion < 2) { if (m_virtualDisplay.m_views.size() != 0 || m_virtualDisplay.m_sharedViews.size() != 0) - { - throw Exception("Only version 2 (or higher) can have a virtual display."); - } + {} } // Check for the DisplayColorSpaces. @@ -5467,25 +4828,19 @@ void Config::Impl::checkVersionConsistency() const { const auto & cs = m_allColorSpaces->getColorSpaceByIndex(i); if (MatchReferenceType(SEARCH_REFERENCE_SPACE_DISPLAY, cs->getReferenceSpaceType())) - { - throw Exception("Only version 2 (or higher) can have DisplayColorSpaces."); - } + {} } } // Check for the ViewTransforms. if (m_majorVersion < 2 && (m_viewTransforms.size() != 0 || !m_defaultViewTransform.empty())) - { - throw Exception("Only version 2 (or higher) can have ViewTransforms."); - } + {} // Check for the NamedTransforms. if (m_majorVersion < 2 && m_allNamedTransforms.size() != 0) - { - throw Exception("Only version 2 (or higher) can have NamedTransforms."); - } + {} } void Config::setConfigIOProxy(ConfigIOProxyRcPtr ciop) diff --git a/src/OpenColorIO/ConfigUtils.cpp b/src/OpenColorIO/ConfigUtils.cpp index b1891b062a..4804f50826 100644 --- a/src/OpenColorIO/ConfigUtils.cpp +++ b/src/OpenColorIO/ConfigUtils.cpp @@ -87,7 +87,7 @@ bool GetInterchangeRolesForColorSpaceConversion(const char ** srcInterchangeCSNa { std::ostringstream os; os << "Could not find destination color space '" << dstName << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } interchangeType = REFERENCE_SPACE_SCENE; @@ -110,7 +110,7 @@ bool GetInterchangeRolesForColorSpaceConversion(const char ** srcInterchangeCSNa { std::ostringstream os; os << "Could not find source color space '" << srcName << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } // Only use the display-referred reference space if both color spaces are @@ -143,7 +143,7 @@ bool GetInterchangeRolesForColorSpaceConversion(const char ** srcInterchangeCSNa std::ostringstream os; os << "The role '" << interchangeRoleName << "' refers to a color space "; os << "that is missing in the source config."; - throw Exception(os.str().c_str()); + throw Exception(os); } *srcInterchangeCSName = srcInterchangeCS->getName(); @@ -158,7 +158,7 @@ bool GetInterchangeRolesForColorSpaceConversion(const char ** srcInterchangeCSNa std::ostringstream os; os << "The role '" << interchangeRoleName << "' refers to a color space "; os << "that is missing in the destination config."; - throw Exception(os.str().c_str()); + throw Exception(os); } *dstInterchangeCSName = dstInterchangeCS->getName(); @@ -644,7 +644,7 @@ void IdentifyInterchangeSpace(const char ** srcInterchange, std::ostringstream os; os << "The heuristics currently only support scene-referred color spaces. " << "Please set the interchange roles."; - throw Exception(os.str().c_str()); + throw Exception(os); } // Identify the name of a reference space in the source config. @@ -653,7 +653,7 @@ void IdentifyInterchangeSpace(const char ** srcInterchange, { std::ostringstream os; os << "The supplied config does not have a color space for the reference."; - throw Exception(os.str().c_str()); + throw Exception(os); } // The heuristics need to create a lot of Processors and send RGB values through @@ -724,7 +724,7 @@ void IdentifyInterchangeSpace(const char ** srcInterchange, std::ostringstream os; os << "Heuristics were not able to find a known color space in the provided config. " << "Please set the interchange roles."; - throw Exception(os.str().c_str()); + throw Exception(os); } } @@ -753,7 +753,7 @@ const char * IdentifyBuiltinColorSpace(const ConstConfigRcPtr & srcConfig, std::ostringstream os; os << "Built-in config does not contain the requested color space: " << builtinColorSpaceName << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } if (builtinColorSpace->isData()) @@ -763,7 +763,7 @@ const char * IdentifyBuiltinColorSpace(const ConstConfigRcPtr & srcConfig, { std::ostringstream os; os << "The requested space is a data space but the supplied config does not have a data space."; - throw Exception(os.str().c_str()); + throw Exception(os); } return dataName; } @@ -834,7 +834,7 @@ const char * IdentifyBuiltinColorSpace(const ConstConfigRcPtr & srcConfig, std::ostringstream os; os << "Heuristics were not able to find an equivalent to the requested color space: " << builtinColorSpaceName << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } } // namespace ConfigUtils diff --git a/src/OpenColorIO/CustomKeys.h b/src/OpenColorIO/CustomKeys.h index 6b93a74d2e..e971841030 100644 --- a/src/OpenColorIO/CustomKeys.h +++ b/src/OpenColorIO/CustomKeys.h @@ -68,7 +68,7 @@ class CustomKeysContainer std::ostringstream oss; oss << "Key index '" << key << "' is invalid, there are '" << numKeys << "' custom keys."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } diff --git a/src/OpenColorIO/Exception.cpp b/src/OpenColorIO/Exception.cpp index 061324e138..0f8eac98bd 100644 --- a/src/OpenColorIO/Exception.cpp +++ b/src/OpenColorIO/Exception.cpp @@ -2,6 +2,7 @@ // Copyright Contributors to the OpenColorIO Project. #include +#include namespace OCIO_NAMESPACE { @@ -11,6 +12,21 @@ Exception::Exception(const char * msg) { } +Exception::Exception(const std::string& str) + : std::runtime_error(str.c_str()) +{ + +} + +Exception::Exception(const std::ostringstream& ss) + : std::runtime_error(ss.str().c_str()) +{} + +Exception::Exception(const std::stringstream& ss) + : std::runtime_error(ss.str().c_str()) +{} + + Exception::Exception(const Exception & e) : std::runtime_error(e) { @@ -26,6 +42,7 @@ ExceptionMissingFile::ExceptionMissingFile(const char * msg) { } + ExceptionMissingFile::ExceptionMissingFile(const ExceptionMissingFile & e) : Exception(e) { diff --git a/src/OpenColorIO/FileRules.cpp b/src/OpenColorIO/FileRules.cpp index 61a5e0f152..a477415b8f 100644 --- a/src/OpenColorIO/FileRules.cpp +++ b/src/OpenColorIO/FileRules.cpp @@ -53,7 +53,7 @@ void ThrowInvalidRegex(const char * globPattern, const char * what) std::ostringstream oss; oss << "File rules: invalid regular expression '" << std::string(globPattern) << "' with '" << std::string(what) << "'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } std::string ConvertToRegularExpression(const char * globPattern, bool ignoreCase) @@ -255,7 +255,7 @@ std::string BuildRegularExpression(const char * filePathPattern, const char * fi << " and extension '" << fileNameExtension << "': '" << ex.what() << "'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } return res; } @@ -280,7 +280,7 @@ void ValidateRegularExpression(const char * regex) << "': '" << ex.what() << "'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } @@ -516,7 +516,7 @@ class FileRule oss << "File rules: rule named '" << m_name << "' is referencing '" << m_colorSpace << "' that is neither a color space nor a named " "transform."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } } @@ -592,13 +592,13 @@ void FileRules::Impl::validatePosition(size_t ruleIndex, DefaultAllowed allowDef std::ostringstream oss; oss << "File rules: rule index '" << ruleIndex << "' invalid." << " There are only '" << numRules << "' rules."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } if (allowDefault == DEFAULT_NOT_ALLOWED && ruleIndex + 1 == numRules) { std::ostringstream oss; oss << "File rules: rule index '" << ruleIndex << "' is the default rule."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } @@ -617,7 +617,7 @@ void FileRules::Impl::validateNewRule(size_t ruleIndex, const char * name) const { std::ostringstream oss; oss << "File rules: A rule named '" << name << "' already exists."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } validatePosition(ruleIndex, DEFAULT_ALLOWED); if (0==Platform::Strcasecmp(name, FileRules::DefaultRuleName)) @@ -625,7 +625,7 @@ void FileRules::Impl::validateNewRule(size_t ruleIndex, const char * name) const std::ostringstream oss; oss << "File rules: Default rule already exists at index " << " '" << m_rules.size() - 1 << "'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } @@ -654,7 +654,7 @@ void FileRules::Impl::moveRule(size_t ruleIndex, int offset) std::ostringstream oss; oss << "File rules: rule at index '" << ruleIndex << "' may not be moved to index '" << newIndex << "'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } auto rule = m_rules[ruleIndex]; m_rules.erase(m_rules.begin() + ruleIndex); @@ -702,7 +702,7 @@ size_t FileRules::getIndexForRule(const char * ruleName) const std::ostringstream oss; oss << "File rules: rule name '" << ruleName << "' not found."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } const char * FileRules::getName(size_t ruleIndex) const @@ -779,7 +779,7 @@ const char * FileRules::getCustomKeyName(size_t ruleIndex, size_t key) const oss << "File rules: the custom key access for file rule '" << std::string(m_impl->m_rules[ruleIndex]->getName()) << "' failed: " << e.what(); - throw Exception(oss.str().c_str()); + throw Exception(oss); } } @@ -796,7 +796,7 @@ const char * FileRules::getCustomKeyValue(size_t ruleIndex, size_t key) const oss << "File rules: the custom key access for file rule '" << std::string(m_impl->m_rules[ruleIndex]->getName()) << "' failed: " << e.what(); - throw Exception(oss.str().c_str()); + throw Exception(oss); } } @@ -812,7 +812,7 @@ void FileRules::setCustomKey(size_t ruleIndex, const char * key, const char * va std::ostringstream oss; oss << "File rules: rule named '" << std::string(m_impl->m_rules[ruleIndex]->getName()) << "' error: " << e.what(); - throw Exception(oss.str().c_str()); + throw Exception(oss); } } diff --git a/src/OpenColorIO/GpuShader.cpp b/src/OpenColorIO/GpuShader.cpp index 4bcca01b09..43e3948347 100644 --- a/src/OpenColorIO/GpuShader.cpp +++ b/src/OpenColorIO/GpuShader.cpp @@ -80,7 +80,7 @@ class PrivateImpl ss << "The texture buffer size is invalid: [" << w << " x " << h << " x " << d << "]."; - throw Exception(ss.str().c_str()); + throw Exception(ss); } // An unfortunate copy is mandatory to allow the creation of a GPU shader cache. @@ -193,7 +193,7 @@ class PrivateImpl std::stringstream ss; ss << "1D LUT size exceeds the maximum: " << width << " > " << get1dLutMaxWidth(); - throw Exception(ss.str().c_str()); + throw Exception(ss); } unsigned numDimensions = static_cast(dimensions); @@ -214,7 +214,7 @@ class PrivateImpl std::ostringstream ss; ss << "1D LUT access error: index = " << index << " where size = " << m_textures.size(); - throw Exception(ss.str().c_str()); + throw Exception(ss); } const Texture & t = m_textures[index]; @@ -228,7 +228,7 @@ class PrivateImpl std::stringstream ss; ss << "1D LUT cannot have more than two dimensions: " << t.m_dimensions << " > 2"; - throw Exception(ss.str().c_str()); + throw Exception(ss); } dimensions = static_cast(t.m_dimensions); interpolation = t.m_interp; @@ -241,7 +241,7 @@ class PrivateImpl std::ostringstream ss; ss << "1D LUT access error: index = " << index << " where size = " << m_textures.size(); - throw Exception(ss.str().c_str()); + throw Exception(ss); } const Texture & t = m_textures[index]; @@ -259,7 +259,7 @@ class PrivateImpl std::stringstream ss; ss << "3D LUT edge length exceeds the maximum: " << edgelen << " > " << get3dLutMaxLength(); - throw Exception(ss.str().c_str()); + throw Exception(ss); } Texture t(textureName, samplerName, edgelen, edgelen, edgelen, @@ -279,7 +279,7 @@ class PrivateImpl std::ostringstream ss; ss << "3D LUT access error: index = " << index << " where size = " << m_textures3D.size(); - throw Exception(ss.str().c_str()); + throw Exception(ss); } const Texture & t = m_textures3D[index]; @@ -296,7 +296,7 @@ class PrivateImpl std::ostringstream ss; ss << "3D LUT access error: index = " << index << " where size = " << m_textures3D.size(); - throw Exception(ss.str().c_str()); + throw Exception(ss); } const Texture & t = m_textures3D[index]; @@ -316,7 +316,7 @@ class PrivateImpl std::ostringstream ss; ss << "Uniforms access error: index = " << index << " where size = " << m_uniforms.size(); - throw Exception(ss.str().c_str()); + throw Exception(ss); } data = m_uniforms[index].m_data; return m_uniforms[index].m_name.c_str(); diff --git a/src/OpenColorIO/GpuShaderClassWrapper.cpp b/src/OpenColorIO/GpuShaderClassWrapper.cpp index 35dce54add..01cc2baf99 100644 --- a/src/OpenColorIO/GpuShaderClassWrapper.cpp +++ b/src/OpenColorIO/GpuShaderClassWrapper.cpp @@ -158,7 +158,7 @@ std::string MetalShaderClassWrapper::generateClassWrapperHeader(GpuShaderText& k } if(std::isdigit(m_className[0])) { - throw Exception(("Struct name must not start with a digit. Invalid className passed in: " + m_className).c_str()); + throw Exception(("Struct name must not start with a digit. Invalid className passed in: " + m_className)); } kw.newLine() << "struct " << m_className; @@ -227,7 +227,7 @@ std::string MetalShaderClassWrapper::generateClassWrapperFooter(GpuShaderText& k } if(std::isdigit(m_className[0])) { - throw Exception(("Struct name must not start with a digit. Invalid className passed in: " + m_className).c_str()); + throw Exception(("Struct name must not start with a digit. Invalid className passed in: " + m_className)); } kw.newLine() << "};"; diff --git a/src/OpenColorIO/GpuShaderDesc.cpp b/src/OpenColorIO/GpuShaderDesc.cpp index 9a35f75486..2729cadb71 100644 --- a/src/OpenColorIO/GpuShaderDesc.cpp +++ b/src/OpenColorIO/GpuShaderDesc.cpp @@ -187,7 +187,7 @@ void GpuShaderCreator::addDynamicProperty(DynamicPropertyRcPtr & prop) // Dynamic property is already there. std::ostringstream oss; oss << "Dynamic property already here: " << prop->getType() << "."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } getImpl()->m_dynamicProperties.push_back(prop); @@ -205,7 +205,7 @@ DynamicPropertyRcPtr GpuShaderCreator::getDynamicProperty(unsigned index) const std::ostringstream oss; oss << "Dynamic properties access error: index = " << index << " where size = " << getImpl()->m_dynamicProperties.size(); - throw Exception(oss.str().c_str()); + throw Exception(oss); } return getImpl()->m_dynamicProperties[index]; } diff --git a/src/OpenColorIO/GpuShaderUtils.cpp b/src/OpenColorIO/GpuShaderUtils.cpp index a3adefbdc0..19d4ffd503 100644 --- a/src/OpenColorIO/GpuShaderUtils.cpp +++ b/src/OpenColorIO/GpuShaderUtils.cpp @@ -306,10 +306,10 @@ void GpuShaderText::dedent() m_indent--; } -GpuShaderText::GpuShaderLine GpuShaderText::newLine() -{ - return GpuShaderText::GpuShaderLine(this); -} +// GpuShaderText::GpuShaderLine GpuShaderText::newLine() +// { +// return GpuShaderText::GpuShaderLine(this); +// } std::string GpuShaderText::string() const { @@ -318,6 +318,7 @@ std::string GpuShaderText::string() const void GpuShaderText::flushLine() { + /* static constexpr unsigned tabSize = 2; m_ossText << std::string(tabSize * m_indent, ' ') @@ -326,6 +327,7 @@ void GpuShaderText::flushLine() m_ossLine.str(""); m_ossLine.clear(); + */ } std::string GpuShaderText::constKeyword() const @@ -502,7 +504,7 @@ void GpuShaderText::declareFloatArrayConst(const std::string & name, int size, c throw Exception("GPU variable name is empty."); } - auto nl = newLine(); + auto& nl = newLine(); switch (m_lang) { @@ -556,7 +558,7 @@ void GpuShaderText::declareIntArrayConst(const std::string & name, int size, con throw Exception("GPU variable name is empty."); } - auto nl = newLine(); + auto& nl = newLine(); switch (m_lang) { diff --git a/src/OpenColorIO/GpuShaderUtils.h b/src/OpenColorIO/GpuShaderUtils.h index b533110749..ff43251334 100644 --- a/src/OpenColorIO/GpuShaderUtils.h +++ b/src/OpenColorIO/GpuShaderUtils.h @@ -50,7 +50,10 @@ class GpuShaderText explicit GpuShaderText(GpuLanguage lang); // Create a new GpuShaderLine instance and associate it with the GpuShaderText object. - GpuShaderLine newLine(); + //GpuShaderLine newLine(); + std::ostringstream& newLine() { + return m_ossText; + } // Get the shader string produced so far std::string string() const; diff --git a/src/OpenColorIO/ImageDesc.cpp b/src/OpenColorIO/ImageDesc.cpp index 2f045f1597..70e45e58e8 100644 --- a/src/OpenColorIO/ImageDesc.cpp +++ b/src/OpenColorIO/ImageDesc.cpp @@ -249,7 +249,7 @@ struct PackedImageDesc::Impl std::string err("PackedImageDesc Error: Unsupported bit-depth: "); err += BitDepthToString(m_bitDepth); err += "."; - throw Exception(err.c_str()); + throw Exception(err); } } diff --git a/src/OpenColorIO/OCIOYaml.cpp b/src/OpenColorIO/OCIOYaml.cpp index e42cdace6e..07d700550f 100644 --- a/src/OpenColorIO/OCIOYaml.cpp +++ b/src/OpenColorIO/OCIOYaml.cpp @@ -35,7 +35,7 @@ typedef YAML::const_iterator Iterator; // Basic types -inline void load(const YAML::Node& node, bool& x) + void load(const YAML::Node& node, bool& x) { try { @@ -47,11 +47,11 @@ inline void load(const YAML::Node& node, bool& x) os << "At line " << (node.Mark().line + 1) << ", '" << node.Tag() << "' parsing boolean failed " << "with: " << e.what(); - throw Exception(os.str().c_str()); + throw Exception(os); } } -inline void load(const YAML::Node& node, double& x) + void load(const YAML::Node& node, double& x) { try { @@ -63,11 +63,11 @@ inline void load(const YAML::Node& node, double& x) os << "At line " << (node.Mark().line + 1) << ", '" << node.Tag() << "' parsing double failed " << "with: " << e.what(); - throw Exception(os.str().c_str()); + throw Exception(os); } } -inline void load(const YAML::Node& node, std::string& x) + void load(const YAML::Node& node, std::string& x) { try { @@ -79,11 +79,27 @@ inline void load(const YAML::Node& node, std::string& x) os << "At line " << (node.Mark().line + 1) << ", '" << node.Tag() << "' parsing string failed " << "with: " << e.what(); - throw Exception(os.str().c_str()); + throw Exception(os); } } -inline void load(const YAML::Node & node, StringUtils::StringVec & x) + const std::string load_str(const YAML::Node& node) + { + try + { + return node.as(); + } + catch (const std::exception& e) + { + std::ostringstream os; + os << "At line " << (node.Mark().line + 1) + << ", '" << node.Tag() << "' parsing string failed " + << "with: " << e.what(); + throw Exception(os); + } + } + + void load(const YAML::Node & node, StringUtils::StringVec & x) { try { @@ -95,11 +111,11 @@ inline void load(const YAML::Node & node, StringUtils::StringVec & x) os << "At line " << (node.Mark().line + 1) << ", '" << node.Tag() << "' parsing StringVec failed " << "with: " << e.what(); - throw Exception(os.str().c_str()); + throw Exception(os); } } -inline void load(const YAML::Node & node, std::vector & x) + void load(const YAML::Node & node, std::vector & x) { try { @@ -111,11 +127,11 @@ inline void load(const YAML::Node & node, std::vector & x) os << "At line " << (node.Mark().line + 1) << ", '" << node.Tag() << "' parsing vector failed " << "with: " << e.what(); - throw Exception(os.str().c_str()); + throw Exception(os); } } -inline void load(const YAML::Node& node, std::vector& x) + void load(const YAML::Node& node, std::vector& x) { try { @@ -127,62 +143,62 @@ inline void load(const YAML::Node& node, std::vector& x) os << "At line " << (node.Mark().line + 1) << ", '" << node.Tag() << "' parsing vector failed " << "with: " << e.what(); - throw Exception(os.str().c_str()); + throw Exception(os); } } // Enums -inline void load(const YAML::Node& node, BitDepth& depth) + void load(const YAML::Node& node, BitDepth& depth) { std::string str; load(node, str); depth = BitDepthFromString(str.c_str()); } -inline void save(YAML::Emitter& out, BitDepth depth) -{ - out << BitDepthToString(depth); -} +// void save(YAML::Emitter& out, BitDepth depth) +// { +// out << BitDepthToString(depth); +// } -inline void load(const YAML::Node& node, Allocation& alloc) + void load(const YAML::Node& node, Allocation& alloc) { std::string str; load(node, str); alloc = AllocationFromString(str.c_str()); } -inline void save(YAML::Emitter& out, Allocation alloc) -{ - out << AllocationToString(alloc); -} +// void save(YAML::Emitter& out, Allocation alloc) +// { +// out << AllocationToString(alloc); +// } -inline void load(const YAML::Node& node, TransformDirection& dir) + void load(const YAML::Node& node, TransformDirection& dir) { std::string str; load(node, str); dir = TransformDirectionFromString(str.c_str()); } -inline void save(YAML::Emitter& out, TransformDirection dir) -{ - out << TransformDirectionToString(dir); -} +// void save(YAML::Emitter& out, TransformDirection dir) +// { +// out << TransformDirectionToString(dir); +// } -inline void load(const YAML::Node& node, Interpolation& interp) + void load(const YAML::Node& node, Interpolation& interp) { std::string str; load(node, str); interp = InterpolationFromString(str.c_str()); } -inline void save(YAML::Emitter& out, Interpolation interp) -{ - out << InterpolationToString(interp); -} +// void save(YAML::Emitter& out, Interpolation interp) +// { +// out << InterpolationToString(interp); +// } -inline void loadDescription(const YAML::Node& node, std::string& x) + void loadDescription(const YAML::Node& node, std::string& x) { load(node, x); if (!x.empty()) @@ -206,32 +222,32 @@ inline void loadDescription(const YAML::Node& node, std::string& x) // double quotes the backslash is generally not interpreted as an escape character in YAML. } -inline void saveDescription(YAML::Emitter & out, const char * desc) -{ - if (desc && *desc) - { - // Remove trailing newlines so that only one is saved because they won't be read back. - std::string descStr{ desc }; - { - auto last = descStr.back(); - while (last == '\n' && descStr.length()) - { - descStr.pop_back(); - last = descStr.back(); - } - } - - out << YAML::Key << "description" << YAML::Value; - if (descStr.find_first_of('\n') != std::string::npos) - { - out << YAML::Literal; - } - out << descStr; - } -} +// void saveDescription(YAML::Emitter & out, const char * desc) +// { +// if (desc && *desc) +// { +// // Remove trailing newlines so that only one is saved because they won't be read back. +// std::string descStr{ desc }; +// { +// auto last = descStr.back(); +// while (last == '\n' && descStr.length()) +// { +// descStr.pop_back(); +// last = descStr.back(); +// } +// } +// +// out << YAML::Key << "description" << YAML::Value; +// if (descStr.find_first_of('\n') != std::string::npos) +// { +// out << YAML::Literal; +// } +// out << descStr; +// } +// } // -inline void LogUnknownKeyWarning(const YAML::Node & node, + void LogUnknownKeyWarning(const YAML::Node & node, const YAML::Node & key) { std::string keyName; @@ -244,7 +260,7 @@ inline void LogUnknownKeyWarning(const YAML::Node & node, LogWarning(os.str()); } -inline void LogUnknownKeyWarning(const std::string & name, + void LogUnknownKeyWarning(const std::string & name, const YAML::Node & tag) { std::string key; @@ -255,7 +271,19 @@ inline void LogUnknownKeyWarning(const std::string & name, LogWarning(os.str()); } -inline void throwError(const YAML::Node & node, + void throwError(const YAML::Node& node, + const char* msg) + { + std::ostringstream os; + os << "At line " << (node.Mark().line + 1) + << ", '" << node.Tag() << "' parsing failed: " + << msg; + + throw Exception(os); + } + + + void throwError(const YAML::Node & node, const std::string & msg) { std::ostringstream os; @@ -263,12 +291,24 @@ inline void throwError(const YAML::Node & node, << ", '" << node.Tag() << "' parsing failed: " << msg; - throw Exception(os.str().c_str()); + throw Exception(os); } -inline void throwValueError(const std::string & nodeName, + void throwError(const YAML::Node& node, + const std::ostringstream& msg) + { + std::ostringstream os; + os << "At line " << (node.Mark().line + 1) + << ", '" << node.Tag() << "' parsing failed: " + << msg.str(); + + throw Exception(os); + } + + + void throwValueError(const std::string & nodeName, const YAML::Node & key, - const std::string & msg) + const std::string& msg) { std::string keyName; load(key, keyName); @@ -278,11 +318,42 @@ inline void throwValueError(const std::string & nodeName, << ", the value parsing of the key '" << keyName << "' from '" << nodeName << "' failed: " << msg; - throw Exception(os.str().c_str()); + throw Exception(os); } -inline void throwValueError(const YAML::Node & key, - const std::string & msg) + void throwValueError(const std::string& nodeName, + const YAML::Node& key, + const std::ostringstream& msg) + { + std::string keyName; + load(key, keyName); + + std::ostringstream os; + os << "At line " << (key.Mark().line + 1) + << ", the value parsing of the key '" << keyName + << "' from '" << nodeName << "' failed: " << msg.str(); + + throw Exception(os); + } + + +void throwValueError(const std::string& nodeName, + const YAML::Node& key, + const char* msg) + { + std::string keyName; + load(key, keyName); + + std::ostringstream os; + os << "At line " << (key.Mark().line + 1) + << ", the value parsing of the key '" << keyName + << "' from '" << nodeName << "' failed: " << msg; + + throw Exception(os); + } + + void throwValueError(const YAML::Node & key, + const std::string& msg) { std::string keyName; load(key, keyName); @@ -292,12 +363,41 @@ inline void throwValueError(const YAML::Node & key, << ", the value parsing of the key '" << keyName << "' failed: " << msg; - throw Exception(os.str().c_str()); + throw Exception(os); } + void throwValueError(const YAML::Node& key, + const char* msg) + { + std::string keyName; + load(key, keyName); + + std::ostringstream os; + os << "At line " << (key.Mark().line + 1) + << ", the value parsing of the key '" << keyName + << "' failed: " << msg; + + throw Exception(os); + } + + void throwValueError(const YAML::Node& key, + const std::ostringstream& msg) + { + std::string keyName; + load(key, keyName); + + std::ostringstream os; + os << "At line " << (key.Mark().line + 1) + << ", the value parsing of the key '" << keyName + << "' failed: " << msg.str(); + + throw Exception(os); + } + + // Duplicate Checker -inline void CheckDuplicates(const YAML::Node & node) + void CheckDuplicates(const YAML::Node & node) { std::unordered_set keyset; @@ -314,14 +414,14 @@ inline void CheckDuplicates(const YAML::Node & node) std::ostringstream os; os << "Key-value pair with key '" << key; os << "' specified more than once. "; - throwValueError(node.Tag(), iter->first, os.str()); + throwValueError(node.Tag(), iter->first, os); } } } // View -inline void load(const YAML::Node& node, View& v) + void load(const YAML::Node& node, View& v) { if(node.Tag() != "View") return; @@ -333,40 +433,41 @@ inline void load(const YAML::Node& node, View& v) for (Iterator iter = node.begin(); iter != node.end(); ++iter) { + const auto& iter_second = iter->second; const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if(key == "name") { - load(iter->second, v.m_name); + load(iter_second, v.m_name); } else if (key == "view_transform") { expectingDisplayCS = true; - load(iter->second, v.m_viewTransform); + load(iter_second, v.m_viewTransform); } else if(key == "colorspace") { expectingSceneCS = true; - load(iter->second, v.m_colorspace); + load(iter_second, v.m_colorspace); } else if (key == "display_colorspace") { expectingDisplayCS = true; - load(iter->second, v.m_colorspace); + load(iter_second, v.m_colorspace); } else if(key == "looks" || key == "look") { - load(iter->second, v.m_looks); + load(iter_second, v.m_looks); } else if (key == "rule") { - load(iter->second, v.m_rule); + load(iter_second, v.m_rule); } else if (key == "description") { - load(iter->second, v.m_description); + load(iter_second, v.m_description); } else { @@ -382,74 +483,74 @@ inline void load(const YAML::Node& node, View& v) std::ostringstream os; os << "View '" << v.m_name << "' must specify colorspace or view_transform and display_colorspace."; - throwError(node, os.str().c_str()); + throwError(node, os); } if(v.m_colorspace.empty()) { std::ostringstream os; os << "View '" << v.m_name << "' does not specify colorspace."; - throwError(node, os.str().c_str()); + throwError(node, os); } } -inline void save(YAML::Emitter& out, const View & view) -{ - out << YAML::VerbatimTag("View"); - out << YAML::Flow; - out << YAML::BeginMap; - out << YAML::Key << "name" << YAML::Value << view.m_name; - if (view.m_viewTransform.empty()) - { - out << YAML::Key << "colorspace" << YAML::Value << view.m_colorspace; - } - else - { - out << YAML::Key << "view_transform" << YAML::Value << view.m_viewTransform; - out << YAML::Key << "display_colorspace" << YAML::Value << view.m_colorspace; - } - if (!view.m_looks.empty()) - { - out << YAML::Key << "looks" << YAML::Value << view.m_looks; - } - if (!view.m_rule.empty()) - { - out << YAML::Key << "rule" << YAML::Value << view.m_rule; - } - saveDescription(out, view.m_description.c_str()); - out << YAML::EndMap; -} +// void save(YAML::Emitter& out, const View & view) +// { +// out << YAML::VerbatimTag("View"); +// out << YAML::Flow; +// out << YAML::BeginMap; +// out << YAML::Key << "name" << YAML::Value << view.m_name; +// if (view.m_viewTransform.empty()) +// { +// out << YAML::Key << "colorspace" << YAML::Value << view.m_colorspace; +// } +// else +// { +// out << YAML::Key << "view_transform" << YAML::Value << view.m_viewTransform; +// out << YAML::Key << "display_colorspace" << YAML::Value << view.m_colorspace; +// } +// if (!view.m_looks.empty()) +// { +// out << YAML::Key << "looks" << YAML::Value << view.m_looks; +// } +// if (!view.m_rule.empty()) +// { +// out << YAML::Key << "rule" << YAML::Value << view.m_rule; +// } +// saveDescription(out, view.m_description.c_str()); +// out << YAML::EndMap; +// } // Common Transform -inline void EmitBaseTransformKeyValues(YAML::Emitter & out, - const ConstTransformRcPtr & t) -{ - switch (t->getDirection()) - { - case TRANSFORM_DIR_FORWARD: - break; - case TRANSFORM_DIR_INVERSE: - out << YAML::Key << "direction"; - out << YAML::Value << YAML::Flow; - save(out, t->getDirection()); - break; - } -} - -inline void EmitTransformName(YAML::Emitter & out, - const FormatMetadata & metadata) -{ - const FormatMetadataImpl & data = dynamic_cast(metadata); - const std::string & name = data.getName(); - if (!name.empty()) - { - out << YAML::Key << "name" << YAML::Value << name; - } -} +// void EmitBaseTransformKeyValues(YAML::Emitter & out, +// const ConstTransformRcPtr & t) +// { +// switch (t->getDirection()) +// { +// case TRANSFORM_DIR_FORWARD: +// break; +// case TRANSFORM_DIR_INVERSE: +// out << YAML::Key << "direction"; +// out << YAML::Value << YAML::Flow; +// save(out, t->getDirection()); +// break; +// } +// } +// +// void EmitTransformName(YAML::Emitter & out, +// const FormatMetadata & metadata) +// { +// const FormatMetadataImpl & data = dynamic_cast(metadata); +// const std::string & name = data.getName(); +// if (!name.empty()) +// { +// out << YAML::Key << "name" << YAML::Value << name; +// } +// } // AllocationTransform -inline void load(const YAML::Node& node, AllocationTransformRcPtr& t) + void load(const YAML::Node& node, AllocationTransformRcPtr& t) { t = AllocationTransform::Create(); @@ -458,19 +559,20 @@ inline void load(const YAML::Node& node, AllocationTransformRcPtr& t) for (Iterator iter = node.begin(); iter != node.end(); ++iter) { const std::string & key = iter->first.as(); + const auto& iter_second = iter->second; - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if(key == "allocation") { Allocation val; - load(iter->second, val); + load(iter_second, val); t->setAllocation(val); } else if(key == "vars") { std::vector val; - load(iter->second, val); + load(iter_second, val); if(!val.empty()) { t->setVars(static_cast(val.size()), &val[0]); @@ -479,7 +581,7 @@ inline void load(const YAML::Node& node, AllocationTransformRcPtr& t) else if(key == "direction") { TransformDirection val; - load(iter->second, val); + load(iter_second, val); t->setDirection(val); } else @@ -489,30 +591,30 @@ inline void load(const YAML::Node& node, AllocationTransformRcPtr& t) } } -inline void save(YAML::Emitter& out, ConstAllocationTransformRcPtr t) -{ - out << YAML::VerbatimTag("AllocationTransform"); - out << YAML::Flow << YAML::BeginMap; - - out << YAML::Key << "allocation"; - out << YAML::Value << YAML::Flow; - save(out, t->getAllocation()); - - if(t->getNumVars() > 0) - { - std::vector vars(t->getNumVars()); - t->getVars(&vars[0]); - out << YAML::Key << "vars"; - out << YAML::Flow << YAML::Value << vars; - } - - EmitBaseTransformKeyValues(out, t); - out << YAML::EndMap; -} +// void save(YAML::Emitter& out, ConstAllocationTransformRcPtr t) +// { +// out << YAML::VerbatimTag("AllocationTransform"); +// out << YAML::Flow << YAML::BeginMap; +// +// out << YAML::Key << "allocation"; +// out << YAML::Value << YAML::Flow; +// save(out, t->getAllocation()); +// +// if(t->getNumVars() > 0) +// { +// std::vector vars(t->getNumVars()); +// t->getVars(&vars[0]); +// out << YAML::Key << "vars"; +// out << YAML::Flow << YAML::Value << vars; +// } +// +// EmitBaseTransformKeyValues(out, t); +// out << YAML::EndMap; +// } // BuiltinTransform -inline void load(const YAML::Node & node, BuiltinTransformRcPtr & t) + void load(const YAML::Node & node, BuiltinTransformRcPtr & t) { t = BuiltinTransform::Create(); @@ -520,20 +622,22 @@ inline void load(const YAML::Node & node, BuiltinTransformRcPtr & t) for (Iterator iter = node.begin(); iter != node.end(); ++iter) { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "style") { std::string transformStyle; - load(iter->second, transformStyle); + load(iter_second, transformStyle); t->setStyle(transformStyle.c_str()); } else if (key == "direction") { TransformDirection dir = TRANSFORM_DIR_FORWARD; - load(iter->second, dir); + load(iter_second, dir); t->setDirection(dir); } else @@ -543,23 +647,23 @@ inline void load(const YAML::Node & node, BuiltinTransformRcPtr & t) } } -inline void save(YAML::Emitter & out, const ConstBuiltinTransformRcPtr & t) -{ - out << YAML::VerbatimTag("BuiltinTransform"); - out << YAML::Flow << YAML::BeginMap; - - out << YAML::Key << "style"; - out << YAML::Value << YAML::Flow << t->getStyle(); - - EmitBaseTransformKeyValues(out, t); - - out << YAML::EndMap; -} +// void save(YAML::Emitter & out, const ConstBuiltinTransformRcPtr & t) +// { +// out << YAML::VerbatimTag("BuiltinTransform"); +// out << YAML::Flow << YAML::BeginMap; +// +// out << YAML::Key << "style"; +// out << YAML::Value << YAML::Flow << t->getStyle(); +// +// EmitBaseTransformKeyValues(out, t); +// +// out << YAML::EndMap; +// } #if OCIO_LUT_SUPPORT // CDLTransform -inline void load(const YAML::Node& node, CDLTransformRcPtr& t) + void load(const YAML::Node& node, CDLTransformRcPtr& t) { t = CDLTransform::Create(); @@ -569,69 +673,69 @@ inline void load(const YAML::Node& node, CDLTransformRcPtr& t) { const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "slope") { std::vector floatvecval; - load(iter->second, floatvecval); + load(iter_second, floatvecval); if(floatvecval.size() != 3) { std::ostringstream os; os << "'slope' values must be 3 "; os << "floats. Found '" << floatvecval.size() << "'."; - throwValueError(node.Tag(), iter->first, os.str()); + throwValueError(node.Tag(), iter->first, os); } t->setSlope(&floatvecval[0]); } else if (key == "offset") { std::vector floatvecval; - load(iter->second, floatvecval); + load(iter_second, floatvecval); if(floatvecval.size() != 3) { std::ostringstream os; os << "'offset' values must be 3 "; os << "floats. Found '" << floatvecval.size() << "'."; - throwValueError(node.Tag(), iter->first, os.str()); + throwValueError(node.Tag(), iter->first, os); } t->setOffset(&floatvecval[0]); } else if (key == "power") { std::vector floatvecval; - load(iter->second, floatvecval); + load(iter_second, floatvecval); if(floatvecval.size() != 3) { std::ostringstream os; os << "'power' values must be 3 "; os << "floats. Found '" << floatvecval.size() << "'."; - throwValueError(node.Tag(), iter->first, os.str()); + throwValueError(node.Tag(), iter->first, os); } t->setPower(&floatvecval[0]); } else if (key == "saturation" || key == "sat") { double val = 0.0f; - load(iter->second, val); + load(iter_second, val); t->setSat(val); } else if (key == "style") { std::string style; - load(iter->second, style); + load(iter_second, style); t->setStyle(CDLStyleFromString(style.c_str())); } else if (key == "direction") { TransformDirection val; - load(iter->second, val); + load(iter_second, val); t->setDirection(val); } else if (key == "name") { std::string name; - load(iter->second, name); + load(iter_second, name); t->getFormatMetadata().setName(name.c_str()); } else @@ -641,7 +745,7 @@ inline void load(const YAML::Node& node, CDLTransformRcPtr& t) } } -inline void save(YAML::Emitter& out, ConstCDLTransformRcPtr t, unsigned int majorVersion) + void save(YAML::Emitter& out, ConstCDLTransformRcPtr t, unsigned int majorVersion) { out << YAML::VerbatimTag("CDLTransform"); out << YAML::Flow << YAML::BeginMap; @@ -692,7 +796,7 @@ inline void save(YAML::Emitter& out, ConstCDLTransformRcPtr t, unsigned int majo // ColorSpaceTransform -inline void load(const YAML::Node& node, ColorSpaceTransformRcPtr& t) + void load(const YAML::Node& node, ColorSpaceTransformRcPtr& t) { t = ColorSpaceTransform::Create(); @@ -700,32 +804,34 @@ inline void load(const YAML::Node& node, ColorSpaceTransformRcPtr& t) for (Iterator iter = node.begin(); iter != node.end(); ++iter) { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if(key == "src") { std::string stringval; - load(iter->second, stringval); + load(iter_second, stringval); t->setSrc(stringval.c_str()); } else if(key == "dst") { std::string stringval; - load(iter->second, stringval); + load(iter_second, stringval); t->setDst(stringval.c_str()); } else if(key == "direction") { TransformDirection val; - load(iter->second, val); + load(iter_second, val); t->setDirection(val); } else if(key == "data_bypass") { bool val; - load(iter->second, val); + load(iter_second, val); t->setDataBypass(val); } else @@ -735,69 +841,71 @@ inline void load(const YAML::Node& node, ColorSpaceTransformRcPtr& t) } } -inline void save(YAML::Emitter& out, ConstColorSpaceTransformRcPtr t) -{ - out << YAML::VerbatimTag("ColorSpaceTransform"); - out << YAML::Flow << YAML::BeginMap; - out << YAML::Key << "src" << YAML::Value << t->getSrc(); - out << YAML::Key << "dst" << YAML::Value << t->getDst(); - const bool bypass = t->getDataBypass(); - if (!bypass) - { - // NB: Will log a warning if read by a v1 library. - out << YAML::Key << "data_bypass" << YAML::Value << bypass; - } - - EmitBaseTransformKeyValues(out, t); - out << YAML::EndMap; -} +// void save(YAML::Emitter& out, ConstColorSpaceTransformRcPtr t) +// { +// out << YAML::VerbatimTag("ColorSpaceTransform"); +// out << YAML::Flow << YAML::BeginMap; +// out << YAML::Key << "src" << YAML::Value << t->getSrc(); +// out << YAML::Key << "dst" << YAML::Value << t->getDst(); +// const bool bypass = t->getDataBypass(); +// if (!bypass) +// { +// // NB: Will log a warning if read by a v1 library. +// out << YAML::Key << "data_bypass" << YAML::Value << bypass; +// } +// +// EmitBaseTransformKeyValues(out, t); +// out << YAML::EndMap; +// } // DisplayViewTransform -inline void load(const YAML::Node& node, DisplayViewTransformRcPtr& t) + void load(const YAML::Node& node, DisplayViewTransformRcPtr& t) { t = DisplayViewTransform::Create(); for (Iterator iter = node.begin(); iter != node.end(); ++iter) { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "src") { std::string stringval; - load(iter->second, stringval); + load(iter_second, stringval); t->setSrc(stringval.c_str()); } else if (key == "display") { std::string stringval; - load(iter->second, stringval); + load(iter_second, stringval); t->setDisplay(stringval.c_str()); } else if (key == "view") { std::string stringval; - load(iter->second, stringval); + load(iter_second, stringval); t->setView(stringval.c_str()); } else if (key == "direction") { TransformDirection val; - load(iter->second, val); + load(iter_second, val); t->setDirection(val); } else if (key == "looks_bypass") { bool boolval{ true }; - load(iter->second, boolval); + load(iter_second, boolval); t->setLooksBypass(boolval); } else if (key == "data_bypass") { bool boolval{ true }; - load(iter->second, boolval); + load(iter_second, boolval); t->setDataBypass(boolval); } else @@ -807,31 +915,31 @@ inline void load(const YAML::Node& node, DisplayViewTransformRcPtr& t) } } -inline void save(YAML::Emitter& out, ConstDisplayViewTransformRcPtr t) -{ - out << YAML::VerbatimTag("DisplayViewTransform"); - out << YAML::Flow << YAML::BeginMap; - out << YAML::Key << "src" << YAML::Value << t->getSrc(); - out << YAML::Key << "display" << YAML::Value << t->getDisplay(); - out << YAML::Key << "view" << YAML::Value << t->getView(); - const bool looksBypass = t->getLooksBypass(); - if (looksBypass) - { - out << YAML::Key << "looks_bypass" << YAML::Value << looksBypass; - } - const bool dataBypass = t->getDataBypass(); - if (!dataBypass) - { - out << YAML::Key << "data_bypass" << YAML::Value << dataBypass; - } - - EmitBaseTransformKeyValues(out, t); - out << YAML::EndMap; -} +// void save(YAML::Emitter& out, ConstDisplayViewTransformRcPtr t) +// { +// out << YAML::VerbatimTag("DisplayViewTransform"); +// out << YAML::Flow << YAML::BeginMap; +// out << YAML::Key << "src" << YAML::Value << t->getSrc(); +// out << YAML::Key << "display" << YAML::Value << t->getDisplay(); +// out << YAML::Key << "view" << YAML::Value << t->getView(); +// const bool looksBypass = t->getLooksBypass(); +// if (looksBypass) +// { +// out << YAML::Key << "looks_bypass" << YAML::Value << looksBypass; +// } +// const bool dataBypass = t->getDataBypass(); +// if (!dataBypass) +// { +// out << YAML::Key << "data_bypass" << YAML::Value << dataBypass; +// } +// +// EmitBaseTransformKeyValues(out, t); +// out << YAML::EndMap; +// } // ExponentTransform -inline void load(const YAML::Node& node, ExponentTransformRcPtr& t) + void load(const YAML::Node& node, ExponentTransformRcPtr& t) { t = ExponentTransform::Create(); @@ -839,22 +947,24 @@ inline void load(const YAML::Node& node, ExponentTransformRcPtr& t) for (Iterator iter = node.begin(); iter != node.end(); ++iter) { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "value") { std::vector val; - if (iter->second.Type() == YAML::NodeType::Sequence) + if (iter_second.Type() == YAML::NodeType::Sequence) { - load(iter->second, val); + load(iter_second, val); } else { // If a single value is supplied... double singleVal; - load(iter->second, singleVal); + load(iter_second, singleVal); val.resize(4, singleVal); val[3] = 1.0; } @@ -863,7 +973,7 @@ inline void load(const YAML::Node& node, ExponentTransformRcPtr& t) std::ostringstream os; os << "'value' values must be 4 "; os << "floats. Found '" << val.size() << "'."; - throwValueError(node.Tag(), iter->first, os.str()); + throwValueError(node.Tag(), iter->first, os); } const double v[4] = { val[0], val[1], val[2], val[3] }; t->setValue(v); @@ -871,19 +981,19 @@ inline void load(const YAML::Node& node, ExponentTransformRcPtr& t) else if (key == "style") { std::string style; - load(iter->second, style); + load(iter_second, style); t->setNegativeStyle(NegativeStyleFromString(style.c_str())); } else if(key == "direction") { TransformDirection val; - load(iter->second, val); + load(iter_second, val); t->setDirection(val); } else if(key == "name") { std::string name; - load(iter->second, name); + load(iter_second, name); t->getFormatMetadata().setName(name.c_str()); } else @@ -893,46 +1003,46 @@ inline void load(const YAML::Node& node, ExponentTransformRcPtr& t) } } -inline void save(YAML::Emitter& out, ConstExponentTransformRcPtr t, unsigned int majorVersion) -{ - out << YAML::VerbatimTag("ExponentTransform"); - out << YAML::Flow << YAML::BeginMap; - - if (majorVersion >= 2) - { - EmitTransformName(out, t->getFormatMetadata()); - } - - double value[4]; - t->getValue(value); - if (majorVersion >= 2 && value[0] == value[1] && value[0] == value[2] && value[3] == 1.) - { - out << YAML::Key << "value" << YAML::Value << value[0]; - } - else - { - std::vector v; - v.assign(value, value + 4); - - out << YAML::Key << "value"; - out << YAML::Value << YAML::Flow << v; - } - - auto style = t->getNegativeStyle(); - if (style != NEGATIVE_CLAMP) - { - // NB: Will log a warning if read by a v1 library. - out << YAML::Key << "style"; - out << YAML::Value << YAML::Flow << NegativeStyleToString(style); - } - EmitBaseTransformKeyValues(out, t); - - out << YAML::EndMap; -} +// void save(YAML::Emitter& out, ConstExponentTransformRcPtr t, unsigned int majorVersion) +// { +// out << YAML::VerbatimTag("ExponentTransform"); +// out << YAML::Flow << YAML::BeginMap; +// +// if (majorVersion >= 2) +// { +// EmitTransformName(out, t->getFormatMetadata()); +// } +// +// double value[4]; +// t->getValue(value); +// if (majorVersion >= 2 && value[0] == value[1] && value[0] == value[2] && value[3] == 1.) +// { +// out << YAML::Key << "value" << YAML::Value << value[0]; +// } +// else +// { +// std::vector v; +// v.assign(value, value + 4); +// +// out << YAML::Key << "value"; +// out << YAML::Value << YAML::Flow << v; +// } +// +// auto style = t->getNegativeStyle(); +// if (style != NEGATIVE_CLAMP) +// { +// // NB: Will log a warning if read by a v1 library. +// out << YAML::Key << "style"; +// out << YAML::Value << YAML::Flow << NegativeStyleToString(style); +// } +// EmitBaseTransformKeyValues(out, t); +// +// out << YAML::EndMap; +// } // ExponentWithLinear -inline void load(const YAML::Node& node, ExponentWithLinearTransformRcPtr& t) + void load(const YAML::Node& node, ExponentWithLinearTransformRcPtr& t) { t = ExponentWithLinearTransform::Create(); @@ -952,22 +1062,24 @@ inline void load(const YAML::Node& node, ExponentWithLinearTransformRcPtr& t) for (Iterator iter = node.begin(); iter != node.end(); ++iter) { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "gamma") { std::vector val; - if (iter->second.Type() == YAML::NodeType::Sequence) + if (iter_second.Type() == YAML::NodeType::Sequence) { - load(iter->second, val); + load(iter_second, val); } else { // If a single value is supplied... double singleVal; - load(iter->second, singleVal); + load(iter_second, singleVal); val.resize(4, singleVal); val[3] = 1.0; } @@ -978,7 +1090,7 @@ inline void load(const YAML::Node& node, ExponentWithLinearTransformRcPtr& t) << "gamma field must be 4 floats. Found '" << val.size() << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } const double v[4] = { val[0], val[1], val[2], val[3] }; t->setGamma(v); @@ -987,15 +1099,15 @@ inline void load(const YAML::Node& node, ExponentWithLinearTransformRcPtr& t) else if(key == "offset") { std::vector val; - if (iter->second.Type() == YAML::NodeType::Sequence) + if (iter_second.Type() == YAML::NodeType::Sequence) { - load(iter->second, val); + load(iter_second, val); } else { // If a single value is supplied... double singleVal; - load(iter->second, singleVal); + load(iter_second, singleVal); val.resize(4, singleVal); val[3] = 0.0; } @@ -1006,7 +1118,7 @@ inline void load(const YAML::Node& node, ExponentWithLinearTransformRcPtr& t) << "offset field must be 4 floats. Found '" << val.size() << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } const double v[4] = { val[0], val[1], val[2], val[3] }; t->setOffset(v); @@ -1015,19 +1127,19 @@ inline void load(const YAML::Node& node, ExponentWithLinearTransformRcPtr& t) else if (key == "style") { std::string style; - load(iter->second, style); + load(iter_second, style); t->setNegativeStyle(NegativeStyleFromString(style.c_str())); } else if(key == "direction") { TransformDirection val; - load(iter->second, val); + load(iter_second, val); t->setDirection(val); } else if(key == "name") { std::string name; - load(iter->second, name); + load(iter_second, name); t->getFormatMetadata().setName(name.c_str()); } else @@ -1052,63 +1164,63 @@ inline void load(const YAML::Node& node, ExponentWithLinearTransformRcPtr& t) e += "offset field is missing"; } - throw Exception(e.c_str()); + throw Exception(e); } } -inline void save(YAML::Emitter& out, ConstExponentWithLinearTransformRcPtr t) -{ - out << YAML::VerbatimTag("ExponentWithLinearTransform"); - out << YAML::Flow << YAML::BeginMap; - - EmitTransformName(out, t->getFormatMetadata()); - - std::vector v; - - double gamma[4]; - t->getGamma(gamma); - if (gamma[0] == gamma[1] && gamma[0] == gamma[2] && gamma[3] == 1.) - { - out << YAML::Key << "gamma" << YAML::Value << gamma[0]; - } - else - { - v.assign(gamma, gamma + 4); - - out << YAML::Key << "gamma"; - out << YAML::Value << YAML::Flow << v; - } - - double offset[4]; - t->getOffset(offset); - - if (offset[0] == offset[1] && offset[0] == offset[2] && offset[3] == 0.) - { - out << YAML::Key << "offset" << YAML::Value << offset[0]; - } - else - { - v.assign(offset, offset + 4); - - out << YAML::Key << "offset"; - out << YAML::Value << YAML::Flow << v; - } - - // Only save style if not default - auto style = t->getNegativeStyle(); - if (style != NEGATIVE_LINEAR) - { - out << YAML::Key << "style"; - out << YAML::Value << YAML::Flow << NegativeStyleToString(style); - } - - EmitBaseTransformKeyValues(out, t); - out << YAML::EndMap; -} +// void save(YAML::Emitter& out, ConstExponentWithLinearTransformRcPtr t) +// { +// out << YAML::VerbatimTag("ExponentWithLinearTransform"); +// out << YAML::Flow << YAML::BeginMap; +// +// EmitTransformName(out, t->getFormatMetadata()); +// +// std::vector v; +// +// double gamma[4]; +// t->getGamma(gamma); +// if (gamma[0] == gamma[1] && gamma[0] == gamma[2] && gamma[3] == 1.) +// { +// out << YAML::Key << "gamma" << YAML::Value << gamma[0]; +// } +// else +// { +// v.assign(gamma, gamma + 4); +// +// out << YAML::Key << "gamma"; +// out << YAML::Value << YAML::Flow << v; +// } +// +// double offset[4]; +// t->getOffset(offset); +// +// if (offset[0] == offset[1] && offset[0] == offset[2] && offset[3] == 0.) +// { +// out << YAML::Key << "offset" << YAML::Value << offset[0]; +// } +// else +// { +// v.assign(offset, offset + 4); +// +// out << YAML::Key << "offset"; +// out << YAML::Value << YAML::Flow << v; +// } +// +// // Only save style if not default +// auto style = t->getNegativeStyle(); +// if (style != NEGATIVE_LINEAR) +// { +// out << YAML::Key << "style"; +// out << YAML::Value << YAML::Flow << NegativeStyleToString(style); +// } +// +// EmitBaseTransformKeyValues(out, t); +// out << YAML::EndMap; +// } // ExposureContrastTransform -inline void load(const YAML::Node& node, ExposureContrastTransformRcPtr& t) + void load(const YAML::Node& node, ExposureContrastTransformRcPtr& t) { t = ExposureContrastTransform::Create(); @@ -1119,66 +1231,68 @@ inline void load(const YAML::Node& node, ExposureContrastTransformRcPtr& t) bool dynGamma = true; for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "exposure") { double param; - load(iter->second, param); + load(iter_second, param); t->setExposure(param); dynExposure = false; } else if (key == "contrast") { double param; - load(iter->second, param); + load(iter_second, param); t->setContrast(param); dynContrast = false; } else if (key == "gamma") { double param; - load(iter->second, param); + load(iter_second, param); t->setGamma(param); dynGamma = false; } else if (key == "pivot") { double param; - load(iter->second, param); + load(iter_second, param); t->setPivot(param); } else if (key == "log_exposure_step") { double param; - load(iter->second, param); + load(iter_second, param); t->setLogExposureStep(param); } else if (key == "log_midway_gray") { double param; - load(iter->second, param); + load(iter_second, param); t->setLogMidGray(param); } else if (key == "style") { std::string style; - load(iter->second, style); + load(iter_second, style); t->setStyle(ExposureContrastStyleFromString(style.c_str())); } else if (key == "direction") { TransformDirection val; - load(iter->second, val); + load(iter_second, val); t->setDirection(val); } else if (key == "name") { std::string name; - load(iter->second, name); + load(iter_second, name); t->getFormatMetadata().setName(name.c_str()); } else @@ -1202,57 +1316,57 @@ inline void load(const YAML::Node& node, ExposureContrastTransformRcPtr& t) } } -inline void save(YAML::Emitter& out, ConstExposureContrastTransformRcPtr t) -{ - out << YAML::VerbatimTag("ExposureContrastTransform"); - out << YAML::Flow << YAML::BeginMap; - - EmitTransformName(out, t->getFormatMetadata()); - - out << YAML::Key << "style"; - out << YAML::Value << YAML::Flow << ExposureContrastStyleToString(t->getStyle()); - - // Do not save dynamic values. - - if (!t->isExposureDynamic()) - { - out << YAML::Key << "exposure" << YAML::Value << YAML::Flow << t->getExposure(); - } - if (!t->isContrastDynamic()) - { - out << YAML::Key << "contrast" << YAML::Value << YAML::Flow << t->getContrast(); - } - if (!t->isGammaDynamic()) - { - out << YAML::Key << "gamma" << YAML::Value << YAML::Flow << t->getGamma(); - } - - out << YAML::Key << "pivot"; - out << YAML::Value << YAML::Flow << t->getPivot(); - - const auto les = t->getLogExposureStep(); - if (les != ExposureContrastOpData::LOGEXPOSURESTEP_DEFAULT) - { - out << YAML::Key << "log_exposure_step"; - out << YAML::Value << YAML::Flow << les; - } - - const auto lmg = t->getLogMidGray(); - if (lmg != ExposureContrastOpData::LOGMIDGRAY_DEFAULT) - { - out << YAML::Key << "log_midway_gray"; - out << YAML::Value << YAML::Flow << lmg; - } - - EmitBaseTransformKeyValues(out, t); - out << YAML::EndMap; -} +// void save(YAML::Emitter& out, ConstExposureContrastTransformRcPtr t) +// { +// out << YAML::VerbatimTag("ExposureContrastTransform"); +// out << YAML::Flow << YAML::BeginMap; +// +// EmitTransformName(out, t->getFormatMetadata()); +// +// out << YAML::Key << "style"; +// out << YAML::Value << YAML::Flow << ExposureContrastStyleToString(t->getStyle()); +// +// // Do not save dynamic values. +// +// if (!t->isExposureDynamic()) +// { +// out << YAML::Key << "exposure" << YAML::Value << YAML::Flow << t->getExposure(); +// } +// if (!t->isContrastDynamic()) +// { +// out << YAML::Key << "contrast" << YAML::Value << YAML::Flow << t->getContrast(); +// } +// if (!t->isGammaDynamic()) +// { +// out << YAML::Key << "gamma" << YAML::Value << YAML::Flow << t->getGamma(); +// } +// +// out << YAML::Key << "pivot"; +// out << YAML::Value << YAML::Flow << t->getPivot(); +// +// const auto les = t->getLogExposureStep(); +// if (les != ExposureContrastOpData::LOGEXPOSURESTEP_DEFAULT) +// { +// out << YAML::Key << "log_exposure_step"; +// out << YAML::Value << YAML::Flow << les; +// } +// +// const auto lmg = t->getLogMidGray(); +// if (lmg != ExposureContrastOpData::LOGMIDGRAY_DEFAULT) +// { +// out << YAML::Key << "log_midway_gray"; +// out << YAML::Value << YAML::Flow << lmg; +// } +// +// EmitBaseTransformKeyValues(out, t); +// out << YAML::EndMap; +// } #if OCIO_LUT_SUPPORT // FileTransform -inline void load(const YAML::Node& node, FileTransformRcPtr& t) + void load(const YAML::Node& node, FileTransformRcPtr& t) { t = FileTransform::Create(); @@ -1264,33 +1378,33 @@ inline void load(const YAML::Node& node, FileTransformRcPtr& t) { const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "src") { - load(iter->second, stringval); + load(iter_second, stringval); t->setSrc(stringval.c_str()); } else if (key == "cccid") { - load(iter->second, stringval); + load(iter_second, stringval); t->setCCCId(stringval.c_str()); } else if (key == "cdl_style") { - load(iter->second, stringval); + load(iter_second, stringval); t->setCDLStyle(CDLStyleFromString(stringval.c_str())); } else if (key == "interpolation") { Interpolation val; - load(iter->second, val); + load(iter_second, val); t->setInterpolation(val); } else if (key == "direction") { TransformDirection val; - load(iter->second, val); + load(iter_second, val); t->setDirection(val); } else @@ -1300,7 +1414,7 @@ inline void load(const YAML::Node& node, FileTransformRcPtr& t) } } -inline void save(YAML::Emitter& out, ConstFileTransformRcPtr t, unsigned int majorVersion) + void save(YAML::Emitter& out, ConstFileTransformRcPtr t, unsigned int majorVersion) { out << YAML::VerbatimTag("FileTransform"); out << YAML::Flow << YAML::BeginMap; @@ -1338,7 +1452,7 @@ inline void save(YAML::Emitter& out, ConstFileTransformRcPtr t, unsigned int maj // FixedFunctionTransform -inline void load(const YAML::Node& node, FixedFunctionTransformRcPtr& t) + void load(const YAML::Node& node, FixedFunctionTransformRcPtr& t) { t = FixedFunctionTransform::Create(FIXED_FUNCTION_ACES_RED_MOD_03); @@ -1347,34 +1461,36 @@ inline void load(const YAML::Node& node, FixedFunctionTransformRcPtr& t) bool styleFound{ false }; for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if(key == "params") { std::vector params; - load(iter->second, params); + load(iter_second, params); t->setParams(¶ms[0], params.size()); } else if(key == "style") { std::string style; - load(iter->second, style); + load(iter_second, style); t->setStyle( FixedFunctionStyleFromString(style.c_str()) ); styleFound = true; } else if(key == "direction") { TransformDirection val; - load(iter->second, val); + load(iter_second, val); t->setDirection(val); } else if(key == "name") { std::string name; - load(iter->second, name); + load(iter_second, name); t->getFormatMetadata().setName(name.c_str()); } else @@ -1388,32 +1504,32 @@ inline void load(const YAML::Node& node, FixedFunctionTransformRcPtr& t) } } -inline void save(YAML::Emitter& out, ConstFixedFunctionTransformRcPtr t) -{ - out << YAML::VerbatimTag("FixedFunctionTransform"); - out << YAML::Flow << YAML::BeginMap; - - EmitTransformName(out, t->getFormatMetadata()); - - out << YAML::Key << "style"; - out << YAML::Value << YAML::Flow << FixedFunctionStyleToString(t->getStyle()); - - const size_t numParams = t->getNumParams(); - if(numParams>0) - { - std::vector params(numParams, 0.); - t->getParams(¶ms[0]); - out << YAML::Key << "params"; - out << YAML::Value << YAML::Flow << params; - } - - EmitBaseTransformKeyValues(out, t); - out << YAML::EndMap; -} +// void save(YAML::Emitter& out, ConstFixedFunctionTransformRcPtr t) +// { +// out << YAML::VerbatimTag("FixedFunctionTransform"); +// out << YAML::Flow << YAML::BeginMap; +// +// EmitTransformName(out, t->getFormatMetadata()); +// +// out << YAML::Key << "style"; +// out << YAML::Value << YAML::Flow << FixedFunctionStyleToString(t->getStyle()); +// +// const size_t numParams = t->getNumParams(); +// if(numParams>0) +// { +// std::vector params(numParams, 0.); +// t->getParams(¶ms[0]); +// out << YAML::Key << "params"; +// out << YAML::Value << YAML::Flow << params; +// } +// +// EmitBaseTransformKeyValues(out, t); +// out << YAML::EndMap; +// } // GradingPrimaryTransform -inline void load(const YAML::Node & parent, const YAML::Node & node, GradingRGBM & rgbm) + void load(const YAML::Node & parent, const YAML::Node & node, GradingRGBM & rgbm) { if (node.Type() == YAML::NodeType::Map) { @@ -1421,15 +1537,17 @@ inline void load(const YAML::Node & parent, const YAML::Node & node, GradingRGBM bool masterOK{ false }; for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "rgb") { std::vector vals; - load(iter->second, vals); + load(iter_second, vals); if (vals.size() != 3) { throwError(iter->first, "The RGB value needs to be a 3 doubles."); @@ -1441,7 +1559,7 @@ inline void load(const YAML::Node & parent, const YAML::Node & node, GradingRGBM } else if (key == "master") { - load(iter->second, rgbm.m_master); + load(iter_second, rgbm.m_master); masterOK = true; } else @@ -1460,7 +1578,7 @@ inline void load(const YAML::Node & parent, const YAML::Node & node, GradingRGBM } } -inline void loadPivot(const YAML::Node & parent, const YAML::Node & node, + void loadPivot(const YAML::Node & parent, const YAML::Node & node, double & val, bool & valLoaded, double & blackVal, bool & blackValLoaded, double & whiteVal, bool & whiteValLoaded) @@ -1468,24 +1586,26 @@ inline void loadPivot(const YAML::Node & parent, const YAML::Node & node, if (node.Type() == YAML::NodeType::Map) { for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "contrast") { - load(iter->second, val); + load(iter_second, val); valLoaded = true; } else if (key == "black") { - load(iter->second, blackVal); + load(iter_second, blackVal); blackValLoaded = true; } else if (key == "white") { - load(iter->second, whiteVal); + load(iter_second, whiteVal); whiteValLoaded = true; } else @@ -1505,26 +1625,28 @@ inline void loadPivot(const YAML::Node & parent, const YAML::Node & node, } } -inline void loadClamp(const YAML::Node & parent, const YAML::Node & node, + void loadClamp(const YAML::Node & parent, const YAML::Node & node, double & blackVal, bool & blackValLoaded, double & whiteVal, bool & whiteValLoaded) { if (node.Type() == YAML::NodeType::Map) { for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "black") { - load(iter->second, blackVal); + load(iter_second, blackVal); blackValLoaded = true; } else if (key == "white") { - load(iter->second, whiteVal); + load(iter_second, whiteVal); whiteValLoaded = true; } else @@ -1544,7 +1666,7 @@ inline void loadClamp(const YAML::Node & parent, const YAML::Node & node, } } -inline void load(const YAML::Node & node, GradingPrimaryTransformRcPtr & t) + void load(const YAML::Node & node, GradingPrimaryTransformRcPtr & t) { CheckDuplicates(node); @@ -1565,77 +1687,79 @@ inline void load(const YAML::Node & node, GradingPrimaryTransformRcPtr & t) bool clampWhiteLoaded{ false }; for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "style") { std::string style; - load(iter->second, style); + load(iter_second, style); t->setStyle(GradingStyleFromString(style.c_str())); } else if (key == "direction") { TransformDirection val; - load(iter->second, val); + load(iter_second, val); t->setDirection(val); } else if (key == "brightness") { brightnessLoaded = true; - load(iter->first, iter->second, values.m_brightness); + load(iter->first, iter_second, values.m_brightness); } else if (key == "contrast") { contrastLoaded = true; - load(iter->first, iter->second, values.m_contrast); + load(iter->first, iter_second, values.m_contrast); } else if (key == "gamma") { gammaLoaded = true; - load(iter->first, iter->second, values.m_gamma); + load(iter->first, iter_second, values.m_gamma); } else if (key == "offset") { offsetLoaded = true; - load(iter->first, iter->second, values.m_offset); + load(iter->first, iter_second, values.m_offset); } else if (key == "exposure") { exposureLoaded = true; - load(iter->first, iter->second, values.m_exposure); + load(iter->first, iter_second, values.m_exposure); } else if (key == "lift") { liftLoaded = true; - load(iter->first, iter->second, values.m_lift); + load(iter->first, iter_second, values.m_lift); } else if (key == "gain") { gainLoaded = true; - load(iter->first, iter->second, values.m_gain); + load(iter->first, iter_second, values.m_gain); } else if (key == "pivot") { - loadPivot(iter->first, iter->second, values.m_pivot, pivotLoaded, + loadPivot(iter->first, iter_second, values.m_pivot, pivotLoaded, values.m_pivotBlack, pivotBlackLoaded, values.m_pivotWhite, pivotWhiteLoaded); } else if (key == "saturation") { saturationLoaded = true; - load(iter->second, values.m_saturation); + load(iter_second, values.m_saturation); } else if (key == "clamp") { - loadClamp(iter->first, iter->second, values.m_clampBlack, clampBlackLoaded, + loadClamp(iter->first, iter_second, values.m_clampBlack, clampBlackLoaded, values.m_clampWhite, clampWhiteLoaded); } else if (key == "name") { std::string name; - load(iter->second, name); + load(iter_second, name); t->getFormatMetadata().setName(name.c_str()); } else @@ -1701,141 +1825,143 @@ inline void load(const YAML::Node & node, GradingPrimaryTransformRcPtr & t) t->setValue(valuesSet); } -inline void save(YAML::Emitter & out, const char * paramName, const GradingRGBM & rgbm, - const GradingRGBM & defaultRgbm) -{ - if (rgbm != defaultRgbm) - { - std::vector vals(3); - vals[0] = rgbm.m_red; - vals[1] = rgbm.m_green; - vals[2] = rgbm.m_blue; - out << YAML::Key << paramName; - out << YAML::Value << YAML::Flow << YAML::BeginMap; - out << YAML::Key << "rgb" << YAML::Value << YAML::Flow << vals; - out << YAML::Key << "master"; - out << YAML::Value << YAML::Flow << rgbm.m_master; - out << YAML::EndMap; - } -} - -inline void save(YAML::Emitter & out, const char * paramName, double val, double defaultVal) -{ - if (val != defaultVal) - { - out << YAML::Key << paramName << YAML::Value << YAML::Flow << val; - } -} - -inline void savePivot(YAML::Emitter & out, double val, bool saveContrast, - double blackVal, double defaultBlackVal, - double whiteVal, double defaultWhiteVal) -{ - if (saveContrast || blackVal != defaultBlackVal || whiteVal != defaultWhiteVal) - { - out << YAML::Key << "pivot"; - out << YAML::Value << YAML::Flow << YAML::BeginMap; - if (saveContrast) - { - out << YAML::Key << "contrast" << YAML::Value << YAML::Flow << val; - } - save(out, "black", blackVal, defaultBlackVal); - save(out, "white", whiteVal, defaultWhiteVal); - out << YAML::EndMap; - } -} - -inline void saveClamp(YAML::Emitter & out, - double blackVal, double defaultBlackVal, - double whiteVal, double defaultWhiteVal) -{ - if (blackVal != defaultBlackVal || whiteVal != defaultWhiteVal) - { - out << YAML::Key << "clamp"; - out << YAML::Value << YAML::Flow << YAML::BeginMap; - save(out, "black", blackVal, defaultBlackVal); - save(out, "white", whiteVal, defaultWhiteVal); - out << YAML::EndMap; - } -} - -inline void save(YAML::Emitter & out, ConstGradingPrimaryTransformRcPtr t) -{ - out << YAML::VerbatimTag("GradingPrimaryTransform"); - - const auto style = t->getStyle(); - const auto & vals = t->getValue(); - const GradingPrimary defaultVals{ style }; - - if (vals == defaultVals) out << YAML::Flow; - out << YAML::BeginMap; - - EmitTransformName(out, t->getFormatMetadata()); - - out << YAML::Key << "style"; - out << YAML::Value << YAML::Flow << GradingStyleToString(style); - switch (style) - { - case GRADING_LOG: - { - save(out, "brightness", vals.m_brightness, defaultVals.m_brightness); - save(out, "contrast", vals.m_contrast, defaultVals.m_contrast); - save(out, "gamma", vals.m_gamma, defaultVals.m_gamma); - save(out, "saturation", vals.m_saturation, defaultVals.m_saturation); - const bool forcePivot = (vals.m_contrast != defaultVals.m_contrast) || - (vals.m_pivot != defaultVals.m_pivot); - savePivot(out, vals.m_pivot, forcePivot, - vals.m_pivotBlack, defaultVals.m_pivotBlack, - vals.m_pivotWhite, defaultVals.m_pivotWhite); - break; - } - case GRADING_LIN: - { - save(out, "offset", vals.m_offset, defaultVals.m_offset); - save(out, "exposure", vals.m_exposure, defaultVals.m_exposure); - save(out, "contrast", vals.m_contrast, defaultVals.m_contrast); - save(out, "saturation", vals.m_saturation, defaultVals.m_saturation); - const bool forcePivot = (vals.m_contrast != defaultVals.m_contrast) || - (vals.m_pivot != defaultVals.m_pivot); - savePivot(out, vals.m_pivot, forcePivot, 0., 0., 0., 0.); - break; - } - case GRADING_VIDEO: - { - save(out, "lift", vals.m_lift, defaultVals.m_lift); - save(out, "gamma", vals.m_gamma, defaultVals.m_gamma); - save(out, "gain", vals.m_gain, defaultVals.m_gain); - save(out, "offset", vals.m_offset, defaultVals.m_offset); - save(out, "saturation", vals.m_saturation, defaultVals.m_saturation); - savePivot(out, 0., false, vals.m_pivotBlack, defaultVals.m_pivotBlack, - vals.m_pivotWhite, defaultVals.m_pivotWhite); - break; - } - } - saveClamp(out, vals.m_clampBlack, defaultVals.m_clampBlack, - vals.m_clampWhite, defaultVals.m_clampWhite); - - EmitBaseTransformKeyValues(out, t); - out << YAML::EndMap; -} - +// void save(YAML::Emitter & out, const char * paramName, const GradingRGBM & rgbm, +// const GradingRGBM & defaultRgbm) +// { +// if (rgbm != defaultRgbm) +// { +// std::vector vals(3); +// vals[0] = rgbm.m_red; +// vals[1] = rgbm.m_green; +// vals[2] = rgbm.m_blue; +// out << YAML::Key << paramName; +// out << YAML::Value << YAML::Flow << YAML::BeginMap; +// out << YAML::Key << "rgb" << YAML::Value << YAML::Flow << vals; +// out << YAML::Key << "master"; +// out << YAML::Value << YAML::Flow << rgbm.m_master; +// out << YAML::EndMap; +// } +// } + +// void save(YAML::Emitter & out, const char * paramName, double val, double defaultVal) +// { +// if (val != defaultVal) +// { +// out << YAML::Key << paramName << YAML::Value << YAML::Flow << val; +// } +// } + +// void savePivot(YAML::Emitter & out, double val, bool saveContrast, +// double blackVal, double defaultBlackVal, +// double whiteVal, double defaultWhiteVal) +// { +// if (saveContrast || blackVal != defaultBlackVal || whiteVal != defaultWhiteVal) +// { +// out << YAML::Key << "pivot"; +// out << YAML::Value << YAML::Flow << YAML::BeginMap; +// if (saveContrast) +// { +// out << YAML::Key << "contrast" << YAML::Value << YAML::Flow << val; +// } +// save(out, "black", blackVal, defaultBlackVal); +// save(out, "white", whiteVal, defaultWhiteVal); +// out << YAML::EndMap; +// } +// } +// +// void saveClamp(YAML::Emitter & out, +// double blackVal, double defaultBlackVal, +// double whiteVal, double defaultWhiteVal) +// { +// if (blackVal != defaultBlackVal || whiteVal != defaultWhiteVal) +// { +// out << YAML::Key << "clamp"; +// out << YAML::Value << YAML::Flow << YAML::BeginMap; +// save(out, "black", blackVal, defaultBlackVal); +// save(out, "white", whiteVal, defaultWhiteVal); +// out << YAML::EndMap; +// } +// } + +// void save(YAML::Emitter & out, ConstGradingPrimaryTransformRcPtr t) +// { +// out << YAML::VerbatimTag("GradingPrimaryTransform"); +// +// const auto style = t->getStyle(); +// const auto & vals = t->getValue(); +// const GradingPrimary defaultVals{ style }; +// +// if (vals == defaultVals) out << YAML::Flow; +// out << YAML::BeginMap; +// +// EmitTransformName(out, t->getFormatMetadata()); +// +// out << YAML::Key << "style"; +// out << YAML::Value << YAML::Flow << GradingStyleToString(style); +// switch (style) +// { +// case GRADING_LOG: +// { +// save(out, "brightness", vals.m_brightness, defaultVals.m_brightness); +// save(out, "contrast", vals.m_contrast, defaultVals.m_contrast); +// save(out, "gamma", vals.m_gamma, defaultVals.m_gamma); +// save(out, "saturation", vals.m_saturation, defaultVals.m_saturation); +// const bool forcePivot = (vals.m_contrast != defaultVals.m_contrast) || +// (vals.m_pivot != defaultVals.m_pivot); +// savePivot(out, vals.m_pivot, forcePivot, +// vals.m_pivotBlack, defaultVals.m_pivotBlack, +// vals.m_pivotWhite, defaultVals.m_pivotWhite); +// break; +// } +// case GRADING_LIN: +// { +// save(out, "offset", vals.m_offset, defaultVals.m_offset); +// save(out, "exposure", vals.m_exposure, defaultVals.m_exposure); +// save(out, "contrast", vals.m_contrast, defaultVals.m_contrast); +// save(out, "saturation", vals.m_saturation, defaultVals.m_saturation); +// const bool forcePivot = (vals.m_contrast != defaultVals.m_contrast) || +// (vals.m_pivot != defaultVals.m_pivot); +// savePivot(out, vals.m_pivot, forcePivot, 0., 0., 0., 0.); +// break; +// } +// case GRADING_VIDEO: +// { +// save(out, "lift", vals.m_lift, defaultVals.m_lift); +// save(out, "gamma", vals.m_gamma, defaultVals.m_gamma); +// save(out, "gain", vals.m_gain, defaultVals.m_gain); +// save(out, "offset", vals.m_offset, defaultVals.m_offset); +// save(out, "saturation", vals.m_saturation, defaultVals.m_saturation); +// savePivot(out, 0., false, vals.m_pivotBlack, defaultVals.m_pivotBlack, +// vals.m_pivotWhite, defaultVals.m_pivotWhite); +// break; +// } +// } +// saveClamp(out, vals.m_clampBlack, defaultVals.m_clampBlack, +// vals.m_clampWhite, defaultVals.m_clampWhite); +// +// EmitBaseTransformKeyValues(out, t); +// out << YAML::EndMap; +// } +// // GradingRGBCurveTransform -inline void load(const YAML::Node & parent, const YAML::Node & node, GradingBSplineCurveRcPtr & sc) + void load(const YAML::Node & parent, const YAML::Node & node, GradingBSplineCurveRcPtr & sc) { if (node.Type() == YAML::NodeType::Map) { bool cpOK{ false }; for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "control_points") { std::vector vals; - load(iter->second, vals); + load(iter_second, vals); const size_t numVals = vals.size(); if (numVals % 2 != 0) { @@ -1855,7 +1981,7 @@ inline void load(const YAML::Node & parent, const YAML::Node & node, GradingBSpl else if (key == "slopes") { std::vector vals; - load(iter->second, vals); + load(iter_second, vals); const size_t numVals = vals.size(); const size_t numCtPts = sc->getNumControlPoints(); if (numVals != numCtPts) @@ -1885,7 +2011,7 @@ inline void load(const YAML::Node & parent, const YAML::Node & node, GradingBSpl } } -inline void load(const YAML::Node & node, GradingRGBCurveTransformRcPtr & t) + void load(const YAML::Node & node, GradingRGBCurveTransformRcPtr & t) { CheckDuplicates(node); @@ -1897,53 +2023,55 @@ inline void load(const YAML::Node & node, GradingRGBCurveTransformRcPtr & t) GradingBSplineCurveRcPtr master; for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "style") { std::string style; - load(iter->second, style); + load(iter_second, style); t->setStyle(GradingStyleFromString(style.c_str())); } else if (key == "direction") { TransformDirection val; - load(iter->second, val); + load(iter_second, val); t->setDirection(val); } else if (key == "lintolog_bypass") { bool bypass = true; - load(iter->second, bypass); + load(iter_second, bypass); t->setBypassLinToLog(bypass); } else if (key == "red") { red = GradingBSplineCurve::Create(0); - load(iter->first, iter->second, red); + load(iter->first, iter_second, red); } else if (key == "green") { green = GradingBSplineCurve::Create(0); - load(iter->first, iter->second, green); + load(iter->first, iter_second, green); } else if (key == "blue") { blue = GradingBSplineCurve::Create(0); - load(iter->first, iter->second, blue); + load(iter->first, iter_second, blue); } else if (key == "master") { master = GradingBSplineCurve::Create(0); - load(iter->first, iter->second, master); + load(iter->first, iter_second, master); } else if (key == "name") { std::string name; - load(iter->second, name); + load(iter_second, name); t->getFormatMetadata().setName(name.c_str()); } else @@ -1964,84 +2092,84 @@ inline void load(const YAML::Node & node, GradingRGBCurveTransformRcPtr & t) t->setValue(curves); } -inline void save(YAML::Emitter & out, const char * paramName, const ConstGradingBSplineCurveRcPtr & curve) -{ - std::vector ctPts; - const size_t numCtPts = curve->getNumControlPoints(); - for (size_t c = 0; c < numCtPts; ++c) - { - const auto & pt = curve->getControlPoint(c); - ctPts.push_back(pt.m_x); - ctPts.push_back(pt.m_y); - } - out << YAML::Key << paramName; - out << YAML::Flow << YAML::BeginMap; - out << YAML::Key << "control_points" << YAML::Value << ctPts; - if (!curve->slopesAreDefault()) - { - // (Number of slopes is always the same as control points.) - const size_t numSlopes = curve->getNumControlPoints(); - std::vector slopes; - for (size_t i = 0; i < numSlopes; ++i) - { - const float val = curve->getSlope(i); - slopes.push_back(val); - } - out << YAML::Key << "slopes" << YAML::Value << slopes; - } - out << YAML::EndMap; -} +// void save(YAML::Emitter & out, const char * paramName, const ConstGradingBSplineCurveRcPtr & curve) +// { +// std::vector ctPts; +// const size_t numCtPts = curve->getNumControlPoints(); +// for (size_t c = 0; c < numCtPts; ++c) +// { +// const auto & pt = curve->getControlPoint(c); +// ctPts.push_back(pt.m_x); +// ctPts.push_back(pt.m_y); +// } +// out << YAML::Key << paramName; +// out << YAML::Flow << YAML::BeginMap; +// out << YAML::Key << "control_points" << YAML::Value << ctPts; +// if (!curve->slopesAreDefault()) +// { +// // (Number of slopes is always the same as control points.) +// const size_t numSlopes = curve->getNumControlPoints(); +// std::vector slopes; +// for (size_t i = 0; i < numSlopes; ++i) +// { +// const float val = curve->getSlope(i); +// slopes.push_back(val); +// } +// out << YAML::Key << "slopes" << YAML::Value << slopes; +// } +// out << YAML::EndMap; +// } + +// void save(YAML::Emitter & out, ConstGradingRGBCurveTransformRcPtr t) +// { +// const auto & vals = t->getValue(); +// auto & defCurve = t->getStyle() == GRADING_LIN ? GradingRGBCurveImpl::DefaultLin : +// GradingRGBCurveImpl::Default; +// bool useLineBreaks = false; +// for (int c = 0; c < RGB_NUM_CURVES; ++c) +// { +// const auto & curve = vals->getCurve(static_cast(c)); +// if (*curve != defCurve) +// { +// useLineBreaks = true; +// break; +// } +// } +// +// out << YAML::VerbatimTag("GradingRGBCurveTransform"); +// if (!useLineBreaks) out << YAML::Flow; +// out << YAML::BeginMap; +// +// EmitTransformName(out, t->getFormatMetadata()); +// +// const auto style = t->getStyle(); +// out << YAML::Key << "style"; +// out << YAML::Value << YAML::Flow << GradingStyleToString(style); +// +// if (t->getBypassLinToLog()) +// { +// out << YAML::Key << "lintolog_bypass"; +// out << YAML::Value << YAML::Flow << true; +// } +// +// static const std::vector curveNames = { "red", "green", "blue", "master" }; +// for (int c = 0; c < RGB_NUM_CURVES; ++c) +// { +// const auto & curve = vals->getCurve(static_cast(c)); +// if ((*curve != defCurve) || !(curve->slopesAreDefault())) +// { +// save(out, curveNames[c], curve); +// } +// } +// +// EmitBaseTransformKeyValues(out, t); +// out << YAML::EndMap; +// } + +// GradingToneTransform -inline void save(YAML::Emitter & out, ConstGradingRGBCurveTransformRcPtr t) -{ - const auto & vals = t->getValue(); - auto & defCurve = t->getStyle() == GRADING_LIN ? GradingRGBCurveImpl::DefaultLin : - GradingRGBCurveImpl::Default; - bool useLineBreaks = false; - for (int c = 0; c < RGB_NUM_CURVES; ++c) - { - const auto & curve = vals->getCurve(static_cast(c)); - if (*curve != defCurve) - { - useLineBreaks = true; - break; - } - } - - out << YAML::VerbatimTag("GradingRGBCurveTransform"); - if (!useLineBreaks) out << YAML::Flow; - out << YAML::BeginMap; - - EmitTransformName(out, t->getFormatMetadata()); - - const auto style = t->getStyle(); - out << YAML::Key << "style"; - out << YAML::Value << YAML::Flow << GradingStyleToString(style); - - if (t->getBypassLinToLog()) - { - out << YAML::Key << "lintolog_bypass"; - out << YAML::Value << YAML::Flow << true; - } - - static const std::vector curveNames = { "red", "green", "blue", "master" }; - for (int c = 0; c < RGB_NUM_CURVES; ++c) - { - const auto & curve = vals->getCurve(static_cast(c)); - if ((*curve != defCurve) || !(curve->slopesAreDefault())) - { - save(out, curveNames[c], curve); - } - } - - EmitBaseTransformKeyValues(out, t); - out << YAML::EndMap; -} - -// GradingToneTransform - -inline void load(const YAML::Node & parent, const YAML::Node & node, GradingRGBMSW & rgbm, - bool center, bool pivot) + void load(const YAML::Node & parent, const YAML::Node & node, GradingRGBMSW & rgbm, + bool center, bool pivot) { if (node.Type() == YAML::NodeType::Map) { @@ -2051,15 +2179,17 @@ inline void load(const YAML::Node & parent, const YAML::Node & node, GradingRGBM bool widthOK{ false }; for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "rgb") { std::vector vals; - load(iter->second, vals); + load(iter_second, vals); if (vals.size() != 3) { throwError(iter->first, "The RGB value needs to be a 3 doubles."); @@ -2071,17 +2201,17 @@ inline void load(const YAML::Node & parent, const YAML::Node & node, GradingRGBM } else if (key == "master") { - load(iter->second, rgbm.m_master); + load(iter_second, rgbm.m_master); masterOK = true; } else if (key == (center ? "center" : "start")) { - load(iter->second, rgbm.m_start); + load(iter_second, rgbm.m_start); startOK = true; } else if (key == (pivot ? "pivot" : "width")) { - load(iter->second, rgbm.m_width); + load(iter_second, rgbm.m_width); widthOK = true; } else @@ -2095,7 +2225,7 @@ inline void load(const YAML::Node & parent, const YAML::Node & node, GradingRGBM std::ostringstream oss; oss << "Rgb, master, " << (center ? "center" : "start") << ", and " << (pivot ? "pivot" : "width") << " values are required."; - throwValueError(parent, oss.str()); + throwValueError(parent, oss); } } else @@ -2104,7 +2234,7 @@ inline void load(const YAML::Node & parent, const YAML::Node & node, GradingRGBM } } -inline void load(const YAML::Node & node, GradingToneTransformRcPtr & t) + void load(const YAML::Node & node, GradingToneTransformRcPtr & t) { CheckDuplicates(node); @@ -2119,56 +2249,58 @@ inline void load(const YAML::Node & node, GradingToneTransformRcPtr & t) double scontrast = 1.0; for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "style") { std::string style; - load(iter->second, style); + load(iter_second, style); t->setStyle(GradingStyleFromString(style.c_str())); } else if (key == "direction") { TransformDirection val; - load(iter->second, val); + load(iter_second, val); t->setDirection(val); } else if (key == "blacks") { blacksLoaded = true; - load(iter->first, iter->second, blacks, false, false); + load(iter->first, iter_second, blacks, false, false); } else if (key == "shadows") { shadowsLoaded = true; - load(iter->first, iter->second, shadows, false, true); + load(iter->first, iter_second, shadows, false, true); } else if (key == "midtones") { midtonesLoaded = true; - load(iter->first, iter->second, midtones, true, false); + load(iter->first, iter_second, midtones, true, false); } else if (key == "highlights") { highlightsLoaded = true; - load(iter->first, iter->second, highlights, false, true); + load(iter->first, iter_second, highlights, false, true); } else if (key == "whites") { whitesLoaded = true; - load(iter->first, iter->second, whites, false, false); + load(iter->first, iter_second, whites, false, false); } else if (key == "s_contrast") { - load(iter->second, scontrast); + load(iter_second, scontrast); } else if (key == "name") { std::string name; - load(iter->second, name); + load(iter_second, name); t->getFormatMetadata().setName(name.c_str()); } else @@ -2188,72 +2320,74 @@ inline void load(const YAML::Node & node, GradingToneTransformRcPtr & t) t->setValue(values); } -inline void save(YAML::Emitter & out, const char * paramName, const GradingRGBMSW & rgbm, - const GradingRGBMSW & defaultRgbm, bool center, bool pivot) -{ - if (rgbm != defaultRgbm) - { - std::vector vals{ rgbm.m_red, rgbm.m_green, rgbm.m_blue }; - out << YAML::Key << paramName; - out << YAML::Value << YAML::Flow << YAML::BeginMap; - out << YAML::Key << "rgb" << YAML::Value << YAML::Flow << vals; - out << YAML::Key << "master" << YAML::Value << YAML::Flow << rgbm.m_master; - out << YAML::Key << (center ? "center" : "start") << YAML::Value << YAML::Flow - << rgbm.m_start; - out << YAML::Key << (pivot ? "pivot" : "width") << YAML::Value << YAML::Flow - << rgbm.m_width; - out << YAML::EndMap; - } -} - -inline void save(YAML::Emitter & out, ConstGradingToneTransformRcPtr t) -{ - out << YAML::VerbatimTag("GradingToneTransform"); - - const auto style = t->getStyle(); - const auto & vals = t->getValue(); - const GradingTone defaultVals(style); - - if (vals == defaultVals) out << YAML::Flow; - out << YAML::BeginMap; - - EmitTransformName(out, t->getFormatMetadata()); - - out << YAML::Key << "style"; - out << YAML::Value << YAML::Flow << GradingStyleToString(style); - save(out, "blacks", vals.m_blacks, defaultVals.m_blacks, false, false); - save(out, "shadows", vals.m_shadows, defaultVals.m_shadows, false, true); - save(out, "midtones", vals.m_midtones, defaultVals.m_midtones, true, false); - save(out, "highlights", vals.m_highlights, defaultVals.m_highlights, false, true); - save(out, "whites", vals.m_whites, defaultVals.m_whites, false, false); - save(out, "s_contrast", vals.m_scontrast, defaultVals.m_scontrast); - - EmitBaseTransformKeyValues(out, t); - out << YAML::EndMap; -} +// void save(YAML::Emitter & out, const char * paramName, const GradingRGBMSW & rgbm, +// const GradingRGBMSW & defaultRgbm, bool center, bool pivot) +// { +// if (rgbm != defaultRgbm) +// { +// std::vector vals{ rgbm.m_red, rgbm.m_green, rgbm.m_blue }; +// out << YAML::Key << paramName; +// out << YAML::Value << YAML::Flow << YAML::BeginMap; +// out << YAML::Key << "rgb" << YAML::Value << YAML::Flow << vals; +// out << YAML::Key << "master" << YAML::Value << YAML::Flow << rgbm.m_master; +// out << YAML::Key << (center ? "center" : "start") << YAML::Value << YAML::Flow +// << rgbm.m_start; +// out << YAML::Key << (pivot ? "pivot" : "width") << YAML::Value << YAML::Flow +// << rgbm.m_width; +// out << YAML::EndMap; +// } +// } + +// void save(YAML::Emitter & out, ConstGradingToneTransformRcPtr t) +// { +// out << YAML::VerbatimTag("GradingToneTransform"); +// +// const auto style = t->getStyle(); +// const auto & vals = t->getValue(); +// const GradingTone defaultVals(style); +// +// if (vals == defaultVals) out << YAML::Flow; +// out << YAML::BeginMap; +// +// EmitTransformName(out, t->getFormatMetadata()); +// +// out << YAML::Key << "style"; +// out << YAML::Value << YAML::Flow << GradingStyleToString(style); +// save(out, "blacks", vals.m_blacks, defaultVals.m_blacks, false, false); +// save(out, "shadows", vals.m_shadows, defaultVals.m_shadows, false, true); +// save(out, "midtones", vals.m_midtones, defaultVals.m_midtones, true, false); +// save(out, "highlights", vals.m_highlights, defaultVals.m_highlights, false, true); +// save(out, "whites", vals.m_whites, defaultVals.m_whites, false, false); +// save(out, "s_contrast", vals.m_scontrast, defaultVals.m_scontrast); +// +// EmitBaseTransformKeyValues(out, t); +// out << YAML::EndMap; +// } // GroupTransform void load(const YAML::Node& node, TransformRcPtr& t); void save(YAML::Emitter& out, ConstTransformRcPtr t, unsigned int majorVersion); -inline void load(const YAML::Node& node, GroupTransformRcPtr& t) + void load(const YAML::Node& node, GroupTransformRcPtr& t) { t = GroupTransform::Create(); CheckDuplicates(node); for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if(key == "children") { - for (std::size_t i = 0; i < iter->second.size(); i++) + for (std::size_t i = 0; i < iter_second.size(); i++) { - const YAML::Node & val = iter->second[i]; + const YAML::Node & val = iter_second[i]; TransformRcPtr childTransform; load(val, childTransform); @@ -2272,13 +2406,13 @@ inline void load(const YAML::Node& node, GroupTransformRcPtr& t) else if(key == "direction") { TransformDirection val; - load(iter->second, val); + load(iter_second, val); t->setDirection(val); } else if(key == "name") { std::string name; - load(iter->second, name); + load(iter_second, name); t->getFormatMetadata().setName(name.c_str()); } else @@ -2288,33 +2422,33 @@ inline void load(const YAML::Node& node, GroupTransformRcPtr& t) } } -inline void save(YAML::Emitter& out, ConstGroupTransformRcPtr t, unsigned int majorVersion) -{ - out << YAML::VerbatimTag("GroupTransform"); - out << YAML::BeginMap; - - if (majorVersion >= 2) - { - EmitTransformName(out, t->getFormatMetadata()); - } - EmitBaseTransformKeyValues(out, t); - - out << YAML::Key << "children"; - out << YAML::Value; - - out << YAML::BeginSeq; - for(int i = 0; i < t->getNumTransforms(); ++i) - { - save(out, t->getTransform(i), majorVersion); - } - out << YAML::EndSeq; - - out << YAML::EndMap; -} +// void save(YAML::Emitter& out, ConstGroupTransformRcPtr t, unsigned int majorVersion) +// { +// out << YAML::VerbatimTag("GroupTransform"); +// out << YAML::BeginMap; +// +// if (majorVersion >= 2) +// { +// EmitTransformName(out, t->getFormatMetadata()); +// } +// EmitBaseTransformKeyValues(out, t); +// +// out << YAML::Key << "children"; +// out << YAML::Value; +// +// out << YAML::BeginSeq; +// for(int i = 0; i < t->getNumTransforms(); ++i) +// { +// save(out, t->getTransform(i), majorVersion); +// } +// out << YAML::EndSeq; +// +// out << YAML::EndMap; +// } // LogAffineTransform -inline void loadLogParam(const YAML::Node & node, + void loadLogParam(const YAML::Node & node, double(¶m)[3], const std::string & paramName) { @@ -2336,7 +2470,7 @@ inline void loadLogParam(const YAML::Node & node, std::ostringstream os; os << "LogAffine/CameraTransform parse error, " << paramName; os << " value field must have 3 components. Found '" << val.size() << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } param[0] = val[0]; param[1] = val[1]; @@ -2344,7 +2478,7 @@ inline void loadLogParam(const YAML::Node & node, } } -inline void load(const YAML::Node& node, LogAffineTransformRcPtr& t) + void load(const YAML::Node& node, LogAffineTransformRcPtr& t) { t = LogAffineTransform::Create(); @@ -2357,52 +2491,54 @@ inline void load(const YAML::Node& node, LogAffineTransformRcPtr& t) double logOffset[3] = { 0.0, 0.0, 0.0 }; for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "base") { - size_t nb = iter->second.size(); + size_t nb = iter_second.size(); if (nb == 0) { - load(iter->second, base); + load(iter_second, base); } else { std::ostringstream os; os << "LogAffineTransform parse error, base must be a "; os << "single double. Found " << nb << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } } else if (key == "lin_side_offset") { - loadLogParam(iter->second, linOffset, key); + loadLogParam(iter_second, linOffset, key); } else if (key == "lin_side_slope") { - loadLogParam(iter->second, linSlope, key); + loadLogParam(iter_second, linSlope, key); } else if (key == "log_side_offset") { - loadLogParam(iter->second, logOffset, key); + loadLogParam(iter_second, logOffset, key); } else if (key == "log_side_slope") { - loadLogParam(iter->second, logSlope, key); + loadLogParam(iter_second, logSlope, key); } else if(key == "direction") { TransformDirection val; - load(iter->second, val); + load(iter_second, val); t->setDirection(val); } else if(key == "name") { std::string name; - load(iter->second, name); + load(iter_second, name); t->getFormatMetadata().setName(name.c_str()); } else @@ -2417,60 +2553,60 @@ inline void load(const YAML::Node& node, LogAffineTransformRcPtr& t) t->setLogSideOffsetValue(logOffset); } -inline void saveLogParam(YAML::Emitter& out, const double(¶m)[3], - double defaultVal, const char * paramName) -{ - // (See test in Config_test.cpp that verifies double precision is preserved.) - if (param[0] == param[1] && param[0] == param[2]) - { - // Set defaultVal to NaN if there is no default value. It will always write param, - // otherwise default params are not saved. - if (param[0] != defaultVal) - { - out << YAML::Key << paramName << YAML::Value << param[0]; - } - } - else - { - std::vector vals; - vals.assign(param, param + 3); - out << YAML::Key << paramName << YAML::Value << vals; - } -} - -inline void save(YAML::Emitter& out, ConstLogAffineTransformRcPtr t) -{ - out << YAML::VerbatimTag("LogAffineTransform"); - out << YAML::Flow << YAML::BeginMap; - - EmitTransformName(out, t->getFormatMetadata()); - - double logSlope[3] = { 1.0, 1.0, 1.0 }; - double linSlope[3] = { 1.0, 1.0, 1.0 }; - double linOffset[3] = { 0.0, 0.0, 0.0 }; - double logOffset[3] = { 0.0, 0.0, 0.0 }; - t->getLogSideSlopeValue(logSlope); - t->getLogSideOffsetValue(logOffset); - t->getLinSideSlopeValue(linSlope); - t->getLinSideOffsetValue(linOffset); - - const double baseVal = t->getBase(); - if (baseVal != 2.0) - { - out << YAML::Key << "base" << YAML::Value << baseVal; - } - saveLogParam(out, logSlope, 1.0, "log_side_slope"); - saveLogParam(out, logOffset, 0.0, "log_side_offset"); - saveLogParam(out, linSlope, 1.0, "lin_side_slope"); - saveLogParam(out, linOffset, 0.0, "lin_side_offset"); - - EmitBaseTransformKeyValues(out, t); - out << YAML::EndMap; -} +// void saveLogParam(YAML::Emitter& out, const double(¶m)[3], +// double defaultVal, const char * paramName) +// { +// // (See test in Config_test.cpp that verifies double precision is preserved.) +// if (param[0] == param[1] && param[0] == param[2]) +// { +// // Set defaultVal to NaN if there is no default value. It will always write param, +// // otherwise default params are not saved. +// if (param[0] != defaultVal) +// { +// out << YAML::Key << paramName << YAML::Value << param[0]; +// } +// } +// else +// { +// std::vector vals; +// vals.assign(param, param + 3); +// out << YAML::Key << paramName << YAML::Value << vals; +// } +// } + +// void save(YAML::Emitter& out, ConstLogAffineTransformRcPtr t) +// { +// out << YAML::VerbatimTag("LogAffineTransform"); +// out << YAML::Flow << YAML::BeginMap; +// +// EmitTransformName(out, t->getFormatMetadata()); +// +// double logSlope[3] = { 1.0, 1.0, 1.0 }; +// double linSlope[3] = { 1.0, 1.0, 1.0 }; +// double linOffset[3] = { 0.0, 0.0, 0.0 }; +// double logOffset[3] = { 0.0, 0.0, 0.0 }; +// t->getLogSideSlopeValue(logSlope); +// t->getLogSideOffsetValue(logOffset); +// t->getLinSideSlopeValue(linSlope); +// t->getLinSideOffsetValue(linOffset); +// +// const double baseVal = t->getBase(); +// if (baseVal != 2.0) +// { +// out << YAML::Key << "base" << YAML::Value << baseVal; +// } +// saveLogParam(out, logSlope, 1.0, "log_side_slope"); +// saveLogParam(out, logOffset, 0.0, "log_side_offset"); +// saveLogParam(out, linSlope, 1.0, "lin_side_slope"); +// saveLogParam(out, linOffset, 0.0, "lin_side_offset"); +// +// EmitBaseTransformKeyValues(out, t); +// out << YAML::EndMap; +// } // LogCameraTransform -inline void load(const YAML::Node & node, LogCameraTransformRcPtr & t) + void load(const YAML::Node & node, LogCameraTransformRcPtr & t) { double linBreak[3] = { 0.0, 0.0, 0.0 }; t = LogCameraTransform::Create(linBreak); @@ -2487,62 +2623,64 @@ inline void load(const YAML::Node & node, LogCameraTransformRcPtr & t) bool linearSlopeFound = false; for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "base") { - size_t nb = iter->second.size(); + size_t nb = iter_second.size(); if (nb == 0) { - load(iter->second, base); + load(iter_second, base); } else { std::ostringstream os; os << "LogCameraTransform parse error, base must be a "; os << "single double. Found " << nb << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } } else if (key == "lin_side_offset") { - loadLogParam(iter->second, linOffset, key); + loadLogParam(iter_second, linOffset, key); } else if (key == "lin_side_slope") { - loadLogParam(iter->second, linSlope, key); + loadLogParam(iter_second, linSlope, key); } else if (key == "log_side_offset") { - loadLogParam(iter->second, logOffset, key); + loadLogParam(iter_second, logOffset, key); } else if (key == "log_side_slope") { - loadLogParam(iter->second, logSlope, key); + loadLogParam(iter_second, logSlope, key); } else if (key == "lin_side_break") { linBreakFound = true; - loadLogParam(iter->second, linBreak, key); + loadLogParam(iter_second, linBreak, key); } else if (key == "linear_slope") { linearSlopeFound = true; - loadLogParam(iter->second, linearSlope, key); + loadLogParam(iter_second, linearSlope, key); } else if (key == "direction") { TransformDirection val; - load(iter->second, val); + load(iter_second, val); t->setDirection(val); } else if (key == "name") { std::string name; - load(iter->second, name); + load(iter_second, name); t->getFormatMetadata().setName(name.c_str()); } else @@ -2566,87 +2704,93 @@ inline void load(const YAML::Node & node, LogCameraTransformRcPtr & t) } } -inline void save(YAML::Emitter& out, ConstLogCameraTransformRcPtr t) -{ - out << YAML::VerbatimTag("LogCameraTransform"); - out << YAML::Flow << YAML::BeginMap; - - EmitTransformName(out, t->getFormatMetadata()); - - double logSlope[3] = { 1.0, 1.0, 1.0 }; - double linSlope[3] = { 1.0, 1.0, 1.0 }; - double linOffset[3] = { 0.0, 0.0, 0.0 }; - double logOffset[3] = { 0.0, 0.0, 0.0 }; - double linBreak[3] = { 0.0, 0.0, 0.0 }; - double linearSlope[3] = { 1.0, 1.0, 1.0 }; - t->getLogSideSlopeValue(logSlope); - t->getLogSideOffsetValue(logOffset); - t->getLinSideSlopeValue(linSlope); - t->getLinSideOffsetValue(linOffset); - t->getLinSideBreakValue(linBreak); - const bool hasLinearSlope = t->getLinearSlopeValue(linearSlope); - - const double baseVal = t->getBase(); - if (baseVal != 2.0) - { - out << YAML::Key << "base" << YAML::Value << baseVal; - } - saveLogParam(out, logSlope, 1.0, "log_side_slope"); - saveLogParam(out, logOffset, 0.0, "log_side_offset"); - saveLogParam(out, linSlope, 1.0, "lin_side_slope"); - saveLogParam(out, linOffset, 0.0, "lin_side_offset"); - saveLogParam(out, linBreak, std::numeric_limits::quiet_NaN(), "lin_side_break"); - if (hasLinearSlope) - { - saveLogParam(out, linearSlope, std::numeric_limits::quiet_NaN(), "linear_slope"); - } - - EmitBaseTransformKeyValues(out, t); - out << YAML::EndMap; -} +// void save(YAML::Emitter& out, ConstLogCameraTransformRcPtr t) +// { +// out << YAML::VerbatimTag("LogCameraTransform"); +// out << YAML::Flow << YAML::BeginMap; +// +// EmitTransformName(out, t->getFormatMetadata()); +// +// double logSlope[3] = { 1.0, 1.0, 1.0 }; +// double linSlope[3] = { 1.0, 1.0, 1.0 }; +// double linOffset[3] = { 0.0, 0.0, 0.0 }; +// double logOffset[3] = { 0.0, 0.0, 0.0 }; +// double linBreak[3] = { 0.0, 0.0, 0.0 }; +// double linearSlope[3] = { 1.0, 1.0, 1.0 }; +// t->getLogSideSlopeValue(logSlope); +// t->getLogSideOffsetValue(logOffset); +// t->getLinSideSlopeValue(linSlope); +// t->getLinSideOffsetValue(linOffset); +// t->getLinSideBreakValue(linBreak); +// const bool hasLinearSlope = t->getLinearSlopeValue(linearSlope); +// +// const double baseVal = t->getBase(); +// if (baseVal != 2.0) +// { +// out << YAML::Key << "base" << YAML::Value << baseVal; +// } +// saveLogParam(out, logSlope, 1.0, "log_side_slope"); +// saveLogParam(out, logOffset, 0.0, "log_side_offset"); +// saveLogParam(out, linSlope, 1.0, "lin_side_slope"); +// saveLogParam(out, linOffset, 0.0, "lin_side_offset"); +// saveLogParam(out, linBreak, std::numeric_limits::quiet_NaN(), "lin_side_break"); +// if (hasLinearSlope) +// { +// saveLogParam(out, linearSlope, std::numeric_limits::quiet_NaN(), "linear_slope"); +// } +// +// EmitBaseTransformKeyValues(out, t); +// out << YAML::EndMap; +// } // LogTransform -inline void load(const YAML::Node& node, LogTransformRcPtr& t) + void load(const YAML::Node& node, LogTransformRcPtr& t) { t = LogTransform::Create(); + auto tp = t.get(); CheckDuplicates(node); for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "base") { double base = 2.0; - size_t nb = iter->second.size(); + size_t nb = iter_second.size(); if (nb == 0) { - load(iter->second, base); + load(iter_second, base); } else { std::ostringstream os; os << "LogTransform parse error, base must be a "; os << " single double. Found " << nb << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } t->setBase(base); } else if (key == "direction") { TransformDirection val; - load(iter->second, val); + load(iter_second, val); t->setDirection(val); } else if (key == "name") { - std::string name; - load(iter->second, name); - t->getFormatMetadata().setName(name.c_str()); +// std::string name; +// load(iter_second, name); +// t->getFormatMetadata().setName(name.c_str()); + + tp->getFormatMetadata().setName(load_str(iter_second)); + } else { @@ -2655,61 +2799,63 @@ inline void load(const YAML::Node& node, LogTransformRcPtr& t) } } -inline void save(YAML::Emitter& out, ConstLogTransformRcPtr t, unsigned int majorVersion) -{ - out << YAML::VerbatimTag("LogTransform"); - out << YAML::Flow << YAML::BeginMap; - - if (majorVersion >= 2) - { - EmitTransformName(out, t->getFormatMetadata()); - } - - const double baseVal = t->getBase(); - if (baseVal != 2.0 || majorVersion < 2) - { - out << YAML::Key << "base" << YAML::Value << baseVal; - } - EmitBaseTransformKeyValues(out, t); - out << YAML::EndMap; -} +// void save(YAML::Emitter& out, ConstLogTransformRcPtr t, unsigned int majorVersion) +// { +// out << YAML::VerbatimTag("LogTransform"); +// out << YAML::Flow << YAML::BeginMap; +// +// if (majorVersion >= 2) +// { +// EmitTransformName(out, t->getFormatMetadata()); +// } +// +// const double baseVal = t->getBase(); +// if (baseVal != 2.0 || majorVersion < 2) +// { +// out << YAML::Key << "base" << YAML::Value << baseVal; +// } +// EmitBaseTransformKeyValues(out, t); +// out << YAML::EndMap; +// } // LookTransform -inline void load(const YAML::Node& node, LookTransformRcPtr& t) + void load(const YAML::Node& node, LookTransformRcPtr& t) { t = LookTransform::Create(); CheckDuplicates(node); for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if(key == "src") { std::string stringval; - load(iter->second, stringval); + load(iter_second, stringval); t->setSrc(stringval.c_str()); } else if(key == "dst") { std::string stringval; - load(iter->second, stringval); + load(iter_second, stringval); t->setDst(stringval.c_str()); } else if(key == "looks") { std::string stringval; - load(iter->second, stringval); + load(iter_second, stringval); t->setLooks(stringval.c_str()); } else if(key == "direction") { TransformDirection val; - load(iter->second, val); + load(iter_second, val); t->setDirection(val); } else @@ -2719,67 +2865,69 @@ inline void load(const YAML::Node& node, LookTransformRcPtr& t) } } -inline void save(YAML::Emitter& out, ConstLookTransformRcPtr t) -{ - out << YAML::VerbatimTag("LookTransform"); - out << YAML::Flow << YAML::BeginMap; - out << YAML::Key << "src" << YAML::Value << t->getSrc(); - out << YAML::Key << "dst" << YAML::Value << t->getDst(); - out << YAML::Key << "looks" << YAML::Value << t->getLooks(); - EmitBaseTransformKeyValues(out, t); - out << YAML::EndMap; -} +// void save(YAML::Emitter& out, ConstLookTransformRcPtr t) +// { +// out << YAML::VerbatimTag("LookTransform"); +// out << YAML::Flow << YAML::BeginMap; +// out << YAML::Key << "src" << YAML::Value << t->getSrc(); +// out << YAML::Key << "dst" << YAML::Value << t->getDst(); +// out << YAML::Key << "looks" << YAML::Value << t->getLooks(); +// EmitBaseTransformKeyValues(out, t); +// out << YAML::EndMap; +// } // MatrixTransform -inline void load(const YAML::Node& node, MatrixTransformRcPtr& t) + void load(const YAML::Node& node, MatrixTransformRcPtr& t) { t = MatrixTransform::Create(); CheckDuplicates(node); for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if(key == "matrix") { std::vector val; - load(iter->second, val); + load(iter_second, val); if(val.size() != 16) { std::ostringstream os; os << "'matrix' values must be 16 "; os << "numbers. Found '" << val.size() << "'."; - throwValueError(node.Tag(), iter->first, os.str()); + throwValueError(node.Tag(), iter->first, os); } t->setMatrix(&val[0]); } else if(key == "offset") { std::vector val; - load(iter->second, val); + load(iter_second, val); if(val.size() != 4) { std::ostringstream os; os << "'offset' values must be 4 "; os << "numbers. Found '" << val.size() << "'."; - throwValueError(node.Tag(), iter->first, os.str()); + throwValueError(node.Tag(), iter->first, os); } t->setOffset(&val[0]); } else if(key == "direction") { TransformDirection val; - load(iter->second, val); + load(iter_second, val); t->setDirection(val); } else if(key == "name") { std::string name; - load(iter->second, name); + load(iter_second, name); t->getFormatMetadata().setName(name.c_str()); } else @@ -2789,49 +2937,51 @@ inline void load(const YAML::Node& node, MatrixTransformRcPtr& t) } } -inline void save(YAML::Emitter& out, ConstMatrixTransformRcPtr t, unsigned int majorVersion) -{ - out << YAML::VerbatimTag("MatrixTransform"); - out << YAML::Flow << YAML::BeginMap; - - if (majorVersion >= 2) - { - EmitTransformName(out, t->getFormatMetadata()); - } - - std::vector matrix(16, 0.0); - t->getMatrix(&matrix[0]); - if(!IsM44Identity(&matrix[0])) - { - out << YAML::Key << "matrix"; - out << YAML::Value << YAML::Flow << matrix; - } - - std::vector offset(4, 0.0); - t->getOffset(&offset[0]); - if(!IsVecEqualToZero(&offset[0],4)) - { - out << YAML::Key << "offset"; - out << YAML::Value << YAML::Flow << offset; - } - - EmitBaseTransformKeyValues(out, t); - out << YAML::EndMap; -} +// void save(YAML::Emitter& out, ConstMatrixTransformRcPtr t, unsigned int majorVersion) +// { +// out << YAML::VerbatimTag("MatrixTransform"); +// out << YAML::Flow << YAML::BeginMap; +// +// if (majorVersion >= 2) +// { +// EmitTransformName(out, t->getFormatMetadata()); +// } +// +// std::vector matrix(16, 0.0); +// t->getMatrix(&matrix[0]); +// if(!IsM44Identity(&matrix[0])) +// { +// out << YAML::Key << "matrix"; +// out << YAML::Value << YAML::Flow << matrix; +// } +// +// std::vector offset(4, 0.0); +// t->getOffset(&offset[0]); +// if(!IsVecEqualToZero(&offset[0],4)) +// { +// out << YAML::Key << "offset"; +// out << YAML::Value << YAML::Flow << offset; +// } +// +// EmitBaseTransformKeyValues(out, t); +// out << YAML::EndMap; +// } // RangeTransform -inline void load(const YAML::Node& node, RangeTransformRcPtr& t) + void load(const YAML::Node& node, RangeTransformRcPtr& t) { t = RangeTransform::Create(); CheckDuplicates(node); for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; double val = 0.0; @@ -2840,40 +2990,40 @@ inline void load(const YAML::Node& node, RangeTransformRcPtr& t) // are only there once. if(key == "min_in_value") { - load(iter->second, val); + load(iter_second, val); t->setMinInValue(val); } else if(key == "max_in_value") { - load(iter->second, val); + load(iter_second, val); t->setMaxInValue(val); } else if(key == "min_out_value") { - load(iter->second, val); + load(iter_second, val); t->setMinOutValue(val); } else if(key == "max_out_value") { - load(iter->second, val); + load(iter_second, val); t->setMaxOutValue(val); } else if(key == "style") { std::string style; - load(iter->second, style); + load(iter_second, style); t->setStyle(RangeStyleFromString(style.c_str())); } else if(key == "direction") { TransformDirection dir; - load(iter->second, dir); + load(iter_second, dir); t->setDirection(dir); } else if(key == "name") { std::string name; - load(iter->second, name); + load(iter_second, name); t->getFormatMetadata().setName(name.c_str()); } else @@ -2883,49 +3033,56 @@ inline void load(const YAML::Node& node, RangeTransformRcPtr& t) } } -inline void save(YAML::Emitter& out, ConstRangeTransformRcPtr t) -{ - out << YAML::VerbatimTag("RangeTransform"); - out << YAML::Flow << YAML::BeginMap; - - EmitTransformName(out, t->getFormatMetadata()); - - if(t->hasMinInValue()) - { - out << YAML::Key << "min_in_value"; - out << YAML::Value << YAML::Flow << t->getMinInValue(); - } - - if(t->hasMaxInValue()) - { - out << YAML::Key << "max_in_value"; - out << YAML::Value << YAML::Flow << t->getMaxInValue(); - } - - if(t->hasMinOutValue()) - { - out << YAML::Key << "min_out_value"; - out << YAML::Value << YAML::Flow << t->getMinOutValue(); - } - - if(t->hasMaxOutValue()) - { - out << YAML::Key << "max_out_value"; - out << YAML::Value << YAML::Flow << t->getMaxOutValue(); - } - - if(t->getStyle()!=RANGE_CLAMP) - { - out << YAML::Key << "style"; - out << YAML::Value << YAML::Flow << RangeStyleToString(t->getStyle()); - } - - EmitBaseTransformKeyValues(out, t); - out << YAML::EndMap; -} +// void save(YAML::Emitter& out, ConstRangeTransformRcPtr t) +// { +// out << YAML::VerbatimTag("RangeTransform"); +// out << YAML::Flow << YAML::BeginMap; +// +// EmitTransformName(out, t->getFormatMetadata()); +// +// if(t->hasMinInValue()) +// { +// out << YAML::Key << "min_in_value"; +// out << YAML::Value << YAML::Flow << t->getMinInValue(); +// } +// +// if(t->hasMaxInValue()) +// { +// out << YAML::Key << "max_in_value"; +// out << YAML::Value << YAML::Flow << t->getMaxInValue(); +// } +// +// if(t->hasMinOutValue()) +// { +// out << YAML::Key << "min_out_value"; +// out << YAML::Value << YAML::Flow << t->getMinOutValue(); +// } +// +// if(t->hasMaxOutValue()) +// { +// out << YAML::Key << "max_out_value"; +// out << YAML::Value << YAML::Flow << t->getMaxOutValue(); +// } +// +// if(t->getStyle()!=RANGE_CLAMP) +// { +// out << YAML::Key << "style"; +// out << YAML::Value << YAML::Flow << RangeStyleToString(t->getStyle()); +// } +// +// EmitBaseTransformKeyValues(out, t); +// out << YAML::EndMap; +// } // Transform +TransformRcPtr load_transform(const YAML::Node& node) + { + TransformRcPtr t; + load(node, t); + return t; + } + void load(const YAML::Node& node, TransformRcPtr& t) { if(node.Type() != YAML::NodeType::Map) @@ -2934,7 +3091,7 @@ void load(const YAML::Node& node, TransformRcPtr& t) os << "Unsupported Transform type encountered: (" << node.Type() << ") in OCIO profile. " << "Only Mapping types supported."; - throwError(node, os.str()); + throwError(node, os); } std::string type = node.Tag(); @@ -3079,83 +3236,83 @@ void load(const YAML::Node& node, TransformRcPtr& t) // t = EmptyTransformRcPtr(new EmptyTransform(), &deleter); std::ostringstream os; os << "Unsupported transform type !<" << type << "> in OCIO profile. "; - throwError(node, os.str()); + throwError(node, os); } } -void save(YAML::Emitter& out, ConstTransformRcPtr t, unsigned int majorVersion) -{ - if(ConstAllocationTransformRcPtr Allocation_tran = \ - DynamicPtrCast(t)) - save(out, Allocation_tran); - else if (ConstBuiltinTransformRcPtr builtin_tran = \ - DynamicPtrCast(t)) - save(out, builtin_tran); -#if OCIO_LUT_SUPPORT - else if(ConstCDLTransformRcPtr CDL_tran = \ - DynamicPtrCast(t)) - save(out, CDL_tran, majorVersion); -#endif //OCIO_LUT_SUPPORT - else if(ConstColorSpaceTransformRcPtr ColorSpace_tran = \ - DynamicPtrCast(t)) - save(out, ColorSpace_tran); - else if (ConstDisplayViewTransformRcPtr Display_tran = \ - DynamicPtrCast(t)) - save(out, Display_tran); - else if(ConstExponentTransformRcPtr Exponent_tran = \ - DynamicPtrCast(t)) - save(out, Exponent_tran, majorVersion); - else if (ConstExponentWithLinearTransformRcPtr ExpLinear_tran = \ - DynamicPtrCast(t)) - save(out, ExpLinear_tran); -#if OCIO_LUT_SUPPORT - else if(ConstFileTransformRcPtr File_tran = \ - DynamicPtrCast(t)) - save(out, File_tran, majorVersion); -#endif OCIO_LUT_SUPPORT - else if (ConstExposureContrastTransformRcPtr File_tran = \ - DynamicPtrCast(t)) - save(out, File_tran); - else if(ConstFixedFunctionTransformRcPtr Func_tran = \ - DynamicPtrCast(t)) - save(out, Func_tran); - else if (ConstGradingPrimaryTransformRcPtr GP_tran = \ - DynamicPtrCast(t)) - save(out, GP_tran); - else if (ConstGradingRGBCurveTransformRcPtr GC_tran = \ - DynamicPtrCast(t)) - save(out, GC_tran); - else if (ConstGradingToneTransformRcPtr GT_tran = \ - DynamicPtrCast(t)) - save(out, GT_tran); - else if(ConstGroupTransformRcPtr Group_tran = \ - DynamicPtrCast(t)) - save(out, Group_tran, majorVersion); - else if(ConstLogAffineTransformRcPtr Log_tran = \ - DynamicPtrCast(t)) - save(out, Log_tran); - else if (ConstLogCameraTransformRcPtr Log_tran = \ - DynamicPtrCast(t)) - save(out, Log_tran); - else if(ConstLogTransformRcPtr Log_tran = \ - DynamicPtrCast(t)) - save(out, Log_tran, majorVersion); - else if(ConstLookTransformRcPtr Look_tran = \ - DynamicPtrCast(t)) - save(out, Look_tran); - else if(ConstMatrixTransformRcPtr Matrix_tran = \ - DynamicPtrCast(t)) - save(out, Matrix_tran, majorVersion); - else if(ConstRangeTransformRcPtr Range_tran = \ - DynamicPtrCast(t)) - save(out, Range_tran); - else - throw Exception("Unsupported Transform() type for serialization."); -} +// void save(YAML::Emitter& out, ConstTransformRcPtr t, unsigned int majorVersion) +// { +// if(ConstAllocationTransformRcPtr Allocation_tran = \ +// DynamicPtrCast(t)) +// save(out, Allocation_tran); +// else if (ConstBuiltinTransformRcPtr builtin_tran = \ +// DynamicPtrCast(t)) +// save(out, builtin_tran); +// #if OCIO_LUT_SUPPORT +// else if(ConstCDLTransformRcPtr CDL_tran = \ +// DynamicPtrCast(t)) +// save(out, CDL_tran, majorVersion); +// #endif //OCIO_LUT_SUPPORT +// else if(ConstColorSpaceTransformRcPtr ColorSpace_tran = \ +// DynamicPtrCast(t)) +// save(out, ColorSpace_tran); +// else if (ConstDisplayViewTransformRcPtr Display_tran = \ +// DynamicPtrCast(t)) +// save(out, Display_tran); +// else if(ConstExponentTransformRcPtr Exponent_tran = \ +// DynamicPtrCast(t)) +// save(out, Exponent_tran, majorVersion); +// else if (ConstExponentWithLinearTransformRcPtr ExpLinear_tran = \ +// DynamicPtrCast(t)) +// save(out, ExpLinear_tran); +// #if OCIO_LUT_SUPPORT +// else if(ConstFileTransformRcPtr File_tran = \ +// DynamicPtrCast(t)) +// save(out, File_tran, majorVersion); +// #endif OCIO_LUT_SUPPORT +// else if (ConstExposureContrastTransformRcPtr File_tran = \ +// DynamicPtrCast(t)) +// save(out, File_tran); +// else if(ConstFixedFunctionTransformRcPtr Func_tran = \ +// DynamicPtrCast(t)) +// save(out, Func_tran); +// else if (ConstGradingPrimaryTransformRcPtr GP_tran = \ +// DynamicPtrCast(t)) +// save(out, GP_tran); +// else if (ConstGradingRGBCurveTransformRcPtr GC_tran = \ +// DynamicPtrCast(t)) +// save(out, GC_tran); +// else if (ConstGradingToneTransformRcPtr GT_tran = \ +// DynamicPtrCast(t)) +// save(out, GT_tran); +// else if(ConstGroupTransformRcPtr Group_tran = \ +// DynamicPtrCast(t)) +// save(out, Group_tran, majorVersion); +// else if(ConstLogAffineTransformRcPtr Log_tran = \ +// DynamicPtrCast(t)) +// save(out, Log_tran); +// else if (ConstLogCameraTransformRcPtr Log_tran = \ +// DynamicPtrCast(t)) +// save(out, Log_tran); +// else if(ConstLogTransformRcPtr Log_tran = \ +// DynamicPtrCast(t)) +// save(out, Log_tran, majorVersion); +// else if(ConstLookTransformRcPtr Look_tran = \ +// DynamicPtrCast(t)) +// save(out, Look_tran); +// else if(ConstMatrixTransformRcPtr Matrix_tran = \ +// DynamicPtrCast(t)) +// save(out, Matrix_tran, majorVersion); +// else if(ConstRangeTransformRcPtr Range_tran = \ +// DynamicPtrCast(t)) +// save(out, Range_tran); +// else +// throw Exception("Unsupported Transform() type for serialization."); +// } // ColorSpace -inline void load(const YAML::Node& node, ColorSpaceRcPtr& cs, unsigned int majorVersion) + void load(const YAML::Node& node, ColorSpaceRcPtr& cs_sp, unsigned int majorVersion) { if(node.Tag() != "ColorSpace") return; // not a ! tag @@ -3164,7 +3321,7 @@ inline void load(const YAML::Node& node, ColorSpaceRcPtr& cs, unsigned int major { std::ostringstream os; os << "The '!' content needs to be a map."; - throwError(node, os.str()); + throwError(node, os); } CheckDuplicates(node); @@ -3172,21 +3329,25 @@ inline void load(const YAML::Node& node, ColorSpaceRcPtr& cs, unsigned int major std::string stringval; bool boolval; + auto cs = cs_sp.get(); + for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if(key == "name") { - load(iter->second, stringval); + load(iter_second, stringval); cs->setName(stringval.c_str()); } else if (key == "aliases") { StringUtils::StringVec aliases; - load(iter->second, aliases); + load(iter_second, aliases); for (const auto & alias : aliases) { cs->addAlias(alias.c_str()); @@ -3194,34 +3355,34 @@ inline void load(const YAML::Node& node, ColorSpaceRcPtr& cs, unsigned int major } else if(key == "description") { - loadDescription(iter->second, stringval); + loadDescription(iter_second, stringval); cs->setDescription(stringval.c_str()); } else if(key == "family") { - load(iter->second, stringval); + load(iter_second, stringval); cs->setFamily(stringval.c_str()); } else if(key == "equalitygroup") { - load(iter->second, stringval); + load(iter_second, stringval); cs->setEqualityGroup(stringval.c_str()); } else if(key == "bitdepth") { BitDepth ret; - load(iter->second, ret); + load(iter_second, ret); cs->setBitDepth(ret); } else if(key == "isdata") { - load(iter->second, boolval); + load(iter_second, boolval); cs->setIsData(boolval); } else if(key == "categories") { StringUtils::StringVec categories; - load(iter->second, categories); + load(iter_second, categories); for(auto name : categories) { cs->addCategory(name.c_str()); @@ -3229,19 +3390,19 @@ inline void load(const YAML::Node& node, ColorSpaceRcPtr& cs, unsigned int major } else if (key == "encoding") { - load(iter->second, stringval); + load(iter_second, stringval); cs->setEncoding(stringval.c_str()); } else if(key == "allocation") { Allocation val; - load(iter->second, val); + load(iter_second, val); cs->setAllocation(val); } else if(key == "allocationvars") { std::vector val; - load(iter->second, val); + load(iter_second, val); if(!val.empty()) cs->setAllocationVars(static_cast(val.size()), &val[0]); } @@ -3253,7 +3414,7 @@ inline void load(const YAML::Node& node, ColorSpaceRcPtr& cs, unsigned int major "display color space."); } TransformRcPtr val; - load(iter->second, val); + load(iter_second, val); cs->setTransform(val, COLORSPACE_DIR_TO_REFERENCE); } else if (key == "to_display_reference") @@ -3263,9 +3424,12 @@ inline void load(const YAML::Node& node, ColorSpaceRcPtr& cs, unsigned int major throwError(node, "'to_display_reference' cannot be used for a " "non-display color space."); } - TransformRcPtr val; - load(iter->second, val); - cs->setTransform(val, COLORSPACE_DIR_TO_REFERENCE); +// TransformRcPtr val; +// load(iter->second, val); +// cs->setTransform(val, COLORSPACE_DIR_TO_REFERENCE); + + cs->setTransform(load_transform(iter_second), COLORSPACE_DIR_TO_REFERENCE); + } else if(key == "from_reference" || (majorVersion >= 2 && key == "from_scene_reference")) { @@ -3275,7 +3439,7 @@ inline void load(const YAML::Node& node, ColorSpaceRcPtr& cs, unsigned int major "a display color space."); } TransformRcPtr val; - load(iter->second, val); + load(iter_second, val); cs->setTransform(val, COLORSPACE_DIR_FROM_REFERENCE); } else if (key == "from_display_reference") @@ -3285,9 +3449,11 @@ inline void load(const YAML::Node& node, ColorSpaceRcPtr& cs, unsigned int major throwError(node, "'from_display_reference' cannot be used for a " "non-display color space."); } - TransformRcPtr val; - load(iter->second, val); - cs->setTransform(val, COLORSPACE_DIR_FROM_REFERENCE); +// TransformRcPtr val; +// load(iter_second, val); +// cs->setTransform(val, COLORSPACE_DIR_FROM_REFERENCE); + cs->setTransform(load_transform(iter_second), COLORSPACE_DIR_FROM_REFERENCE); + } else { @@ -3296,84 +3462,84 @@ inline void load(const YAML::Node& node, ColorSpaceRcPtr& cs, unsigned int major } } -inline void save(YAML::Emitter& out, ConstColorSpaceRcPtr cs, unsigned int majorVersion) -{ - out << YAML::VerbatimTag("ColorSpace"); - out << YAML::BeginMap; - - out << YAML::Key << "name" << YAML::Value << cs->getName(); - const size_t numAliases = cs->getNumAliases(); - if (majorVersion >= 2 && numAliases) - { - out << YAML::Key << "aliases"; - StringUtils::StringVec aliases; - for (size_t aidx = 0; aidx < numAliases; ++aidx) - { - aliases.push_back(cs->getAlias(aidx)); - } - out << YAML::Flow << YAML::Value << aliases; - } - out << YAML::Key << "family" << YAML::Value << cs->getFamily(); - out << YAML::Key << "equalitygroup" << YAML::Value << cs->getEqualityGroup(); - out << YAML::Key << "bitdepth" << YAML::Value; - save(out, cs->getBitDepth()); - saveDescription(out, cs->getDescription()); - out << YAML::Key << "isdata" << YAML::Value << cs->isData(); - - if(cs->getNumCategories() > 0) - { - StringUtils::StringVec categories; - for(int idx=0; idxgetNumCategories(); ++idx) - { - categories.push_back(cs->getCategory(idx)); - } - out << YAML::Key << "categories"; - out << YAML::Flow << YAML::Value << categories; - } - - const std::string is{ cs->getEncoding() }; - if (!is.empty()) - { - out << YAML::Key << "encoding"; - out << YAML::Value << is; - } - - out << YAML::Key << "allocation" << YAML::Value; - save(out, cs->getAllocation()); - if(cs->getAllocationNumVars() > 0) - { - std::vector allocationvars(cs->getAllocationNumVars()); - cs->getAllocationVars(&allocationvars[0]); - out << YAML::Key << "allocationvars"; - out << YAML::Flow << YAML::Value << allocationvars; - } - - const auto isDisplay = (cs->getReferenceSpaceType() == REFERENCE_SPACE_DISPLAY); - ConstTransformRcPtr toref = cs->getTransform(COLORSPACE_DIR_TO_REFERENCE); - if(toref) - { - out << YAML::Key << (isDisplay ? "to_display_reference" : - (majorVersion < 2) ? "to_reference" : - "to_scene_reference") << YAML::Value; - save(out, toref, majorVersion); - } - - ConstTransformRcPtr fromref = cs->getTransform(COLORSPACE_DIR_FROM_REFERENCE); - if(fromref) - { - out << YAML::Key << (isDisplay ? "from_display_reference" : - (majorVersion < 2) ? "from_reference" : - "from_scene_reference") << YAML::Value; - save(out, fromref, majorVersion); - } - - out << YAML::EndMap; - out << YAML::Newline; -} +// void save(YAML::Emitter& out, ConstColorSpaceRcPtr cs, unsigned int majorVersion) +// { +// out << YAML::VerbatimTag("ColorSpace"); +// out << YAML::BeginMap; +// +// out << YAML::Key << "name" << YAML::Value << cs->getName(); +// const size_t numAliases = cs->getNumAliases(); +// if (majorVersion >= 2 && numAliases) +// { +// out << YAML::Key << "aliases"; +// StringUtils::StringVec aliases; +// for (size_t aidx = 0; aidx < numAliases; ++aidx) +// { +// aliases.push_back(cs->getAlias(aidx)); +// } +// out << YAML::Flow << YAML::Value << aliases; +// } +// out << YAML::Key << "family" << YAML::Value << cs->getFamily(); +// out << YAML::Key << "equalitygroup" << YAML::Value << cs->getEqualityGroup(); +// out << YAML::Key << "bitdepth" << YAML::Value; +// save(out, cs->getBitDepth()); +// saveDescription(out, cs->getDescription()); +// out << YAML::Key << "isdata" << YAML::Value << cs->isData(); +// +// if(cs->getNumCategories() > 0) +// { +// StringUtils::StringVec categories; +// for(int idx=0; idxgetNumCategories(); ++idx) +// { +// categories.push_back(cs->getCategory(idx)); +// } +// out << YAML::Key << "categories"; +// out << YAML::Flow << YAML::Value << categories; +// } +// +// const std::string is{ cs->getEncoding() }; +// if (!is.empty()) +// { +// out << YAML::Key << "encoding"; +// out << YAML::Value << is; +// } +// +// out << YAML::Key << "allocation" << YAML::Value; +// save(out, cs->getAllocation()); +// if(cs->getAllocationNumVars() > 0) +// { +// std::vector allocationvars(cs->getAllocationNumVars()); +// cs->getAllocationVars(&allocationvars[0]); +// out << YAML::Key << "allocationvars"; +// out << YAML::Flow << YAML::Value << allocationvars; +// } +// +// const auto isDisplay = (cs->getReferenceSpaceType() == REFERENCE_SPACE_DISPLAY); +// ConstTransformRcPtr toref = cs->getTransform(COLORSPACE_DIR_TO_REFERENCE); +// if(toref) +// { +// out << YAML::Key << (isDisplay ? "to_display_reference" : +// (majorVersion < 2) ? "to_reference" : +// "to_scene_reference") << YAML::Value; +// save(out, toref, majorVersion); +// } +// +// ConstTransformRcPtr fromref = cs->getTransform(COLORSPACE_DIR_FROM_REFERENCE); +// if(fromref) +// { +// out << YAML::Key << (isDisplay ? "from_display_reference" : +// (majorVersion < 2) ? "from_reference" : +// "from_scene_reference") << YAML::Value; +// save(out, fromref, majorVersion); +// } +// +// out << YAML::EndMap; +// out << YAML::Newline; +// } // Look -inline void load(const YAML::Node& node, LookRcPtr& look) + void load(const YAML::Node& node, LookRcPtr& look) { if(node.Tag() != "Look") return; @@ -3381,39 +3547,41 @@ inline void load(const YAML::Node& node, LookRcPtr& look) CheckDuplicates(node); for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if(key == "name") { std::string stringval; - load(iter->second, stringval); + load(iter_second, stringval); look->setName(stringval.c_str()); } else if(key == "process_space") { std::string stringval; - load(iter->second, stringval); + load(iter_second, stringval); look->setProcessSpace(stringval.c_str()); } else if(key == "transform") { TransformRcPtr val; - load(iter->second, val); + load(iter_second, val); look->setTransform(val); } else if(key == "inverse_transform") { TransformRcPtr val; - load(iter->second, val); + load(iter_second, val); look->setInverseTransform(val); } else if(key == "description") { std::string stringval; - loadDescription(iter->second, stringval); + loadDescription(iter_second, stringval); look->setDescription(stringval.c_str()); } else @@ -3423,35 +3591,35 @@ inline void load(const YAML::Node& node, LookRcPtr& look) } } -inline void save(YAML::Emitter& out, ConstLookRcPtr look, unsigned int majorVersion) -{ - out << YAML::VerbatimTag("Look"); - out << YAML::BeginMap; - out << YAML::Key << "name" << YAML::Value << look->getName(); - out << YAML::Key << "process_space" << YAML::Value << look->getProcessSpace(); - saveDescription(out, look->getDescription()); - - if(look->getTransform()) - { - out << YAML::Key << "transform"; - out << YAML::Value; - save(out, look->getTransform(), majorVersion); - } - - if(look->getInverseTransform()) - { - out << YAML::Key << "inverse_transform"; - out << YAML::Value; - save(out, look->getInverseTransform(), majorVersion); - } - - out << YAML::EndMap; - out << YAML::Newline; -} +// void save(YAML::Emitter& out, ConstLookRcPtr look, unsigned int majorVersion) +// { +// out << YAML::VerbatimTag("Look"); +// out << YAML::BeginMap; +// out << YAML::Key << "name" << YAML::Value << look->getName(); +// out << YAML::Key << "process_space" << YAML::Value << look->getProcessSpace(); +// saveDescription(out, look->getDescription()); +// +// if(look->getTransform()) +// { +// out << YAML::Key << "transform"; +// out << YAML::Value; +// save(out, look->getTransform(), majorVersion); +// } +// +// if(look->getInverseTransform()) +// { +// out << YAML::Key << "inverse_transform"; +// out << YAML::Value; +// save(out, look->getInverseTransform(), majorVersion); +// } +// +// out << YAML::EndMap; +// out << YAML::Newline; +// } // View transform -inline ReferenceSpaceType peekViewTransformReferenceSpace(const YAML::Node & node) + ReferenceSpaceType peekViewTransformReferenceSpace(const YAML::Node & node) { if (node.Type() != YAML::NodeType::Map) { @@ -3462,10 +3630,12 @@ inline ReferenceSpaceType peekViewTransformReferenceSpace(const YAML::Node & nod bool isDisplay = false; for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "to_scene_reference") { @@ -3498,7 +3668,7 @@ inline ReferenceSpaceType peekViewTransformReferenceSpace(const YAML::Node & nod return isDisplay ? REFERENCE_SPACE_DISPLAY : REFERENCE_SPACE_SCENE; } -inline void load(const YAML::Node & node, ViewTransformRcPtr & vt) + void load(const YAML::Node & node, ViewTransformRcPtr & vt) { if (node.Tag() != "ViewTransform") { @@ -3509,39 +3679,41 @@ inline void load(const YAML::Node & node, ViewTransformRcPtr & vt) { std::ostringstream os; os << "The '!' content needs to be a map."; - throwError(node, os.str()); + throwError(node, os); } CheckDuplicates(node); for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "name") { std::string stringval; - load(iter->second, stringval); + load(iter_second, stringval); vt->setName(stringval.c_str()); } else if (key == "description") { std::string stringval; - loadDescription(iter->second, stringval); + loadDescription(iter_second, stringval); vt->setDescription(stringval.c_str()); } else if (key == "family") { std::string stringval; - load(iter->second, stringval); + load(iter_second, stringval); vt->setFamily(stringval.c_str()); } else if (key == "categories") { StringUtils::StringVec categories; - load(iter->second, categories); + load(iter_second, categories); for (auto name : categories) { vt->addCategory(name.c_str()); @@ -3550,25 +3722,25 @@ inline void load(const YAML::Node & node, ViewTransformRcPtr & vt) else if (key == "to_scene_reference") { TransformRcPtr val; - load(iter->second, val); + load(iter_second, val); vt->setTransform(val, VIEWTRANSFORM_DIR_TO_REFERENCE); } else if (key == "to_display_reference") { TransformRcPtr val; - load(iter->second, val); + load(iter_second, val); vt->setTransform(val, VIEWTRANSFORM_DIR_TO_REFERENCE); } else if (key == "from_scene_reference") { TransformRcPtr val; - load(iter->second, val); + load(iter_second, val); vt->setTransform(val, VIEWTRANSFORM_DIR_FROM_REFERENCE); } else if (key == "from_display_reference") { TransformRcPtr val; - load(iter->second, val); + load(iter_second, val); vt->setTransform(val, VIEWTRANSFORM_DIR_FROM_REFERENCE); } else @@ -3578,52 +3750,52 @@ inline void load(const YAML::Node & node, ViewTransformRcPtr & vt) } } -inline void save(YAML::Emitter & out, ConstViewTransformRcPtr & vt, unsigned int majorVersion) -{ - out << YAML::VerbatimTag("ViewTransform"); - out << YAML::BeginMap; - - out << YAML::Key << "name" << YAML::Value << vt->getName(); - const char * family = vt->getFamily(); - if (family && *family) - { - out << YAML::Key << "family" << YAML::Value << family; - } - saveDescription(out, vt->getDescription()); - - if (vt->getNumCategories() > 0) - { - StringUtils::StringVec categories; - for (int idx = 0; idx < vt->getNumCategories(); ++idx) - { - categories.push_back(vt->getCategory(idx)); - } - out << YAML::Key << "categories"; - out << YAML::Flow << YAML::Value << categories; - } - - const auto isDisplay = (vt->getReferenceSpaceType() == REFERENCE_SPACE_DISPLAY); - ConstTransformRcPtr toref = vt->getTransform(VIEWTRANSFORM_DIR_TO_REFERENCE); - if (toref) - { - out << YAML::Key << (isDisplay ? "to_display_reference" : "to_scene_reference") << YAML::Value; - save(out, toref, majorVersion); - } - - ConstTransformRcPtr fromref = vt->getTransform(VIEWTRANSFORM_DIR_FROM_REFERENCE); - if (fromref) - { - out << YAML::Key << (isDisplay ? "from_display_reference" : "from_scene_reference") << YAML::Value; - save(out, fromref, majorVersion); - } - - out << YAML::EndMap; - out << YAML::Newline; -} +// void save(YAML::Emitter & out, ConstViewTransformRcPtr & vt, unsigned int majorVersion) +// { +// out << YAML::VerbatimTag("ViewTransform"); +// out << YAML::BeginMap; +// +// out << YAML::Key << "name" << YAML::Value << vt->getName(); +// const char * family = vt->getFamily(); +// if (family && *family) +// { +// out << YAML::Key << "family" << YAML::Value << family; +// } +// saveDescription(out, vt->getDescription()); +// +// if (vt->getNumCategories() > 0) +// { +// StringUtils::StringVec categories; +// for (int idx = 0; idx < vt->getNumCategories(); ++idx) +// { +// categories.push_back(vt->getCategory(idx)); +// } +// out << YAML::Key << "categories"; +// out << YAML::Flow << YAML::Value << categories; +// } +// +// const auto isDisplay = (vt->getReferenceSpaceType() == REFERENCE_SPACE_DISPLAY); +// ConstTransformRcPtr toref = vt->getTransform(VIEWTRANSFORM_DIR_TO_REFERENCE); +// if (toref) +// { +// out << YAML::Key << (isDisplay ? "to_display_reference" : "to_scene_reference") << YAML::Value; +// save(out, toref, majorVersion); +// } +// +// ConstTransformRcPtr fromref = vt->getTransform(VIEWTRANSFORM_DIR_FROM_REFERENCE); +// if (fromref) +// { +// out << YAML::Key << (isDisplay ? "from_display_reference" : "from_scene_reference") << YAML::Value; +// save(out, fromref, majorVersion); +// } +// +// out << YAML::EndMap; +// out << YAML::Newline; +// } // NamedTransform -inline void load(const YAML::Node & node, NamedTransformRcPtr & nt) + void load(const YAML::Node & node, NamedTransformRcPtr & nt) { if (node.Tag() != "NamedTransform") { @@ -3634,7 +3806,7 @@ inline void load(const YAML::Node & node, NamedTransformRcPtr & nt) { std::ostringstream os; os << "The '!' content needs to be a map."; - throwError(node, os.str()); + throwError(node, os); } CheckDuplicates(node); @@ -3642,20 +3814,22 @@ inline void load(const YAML::Node & node, NamedTransformRcPtr & nt) std::string stringval; for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == "name") { - load(iter->second, stringval); + load(iter_second, stringval); nt->setName(stringval.c_str()); } else if (key == "aliases") { StringUtils::StringVec aliases; - load(iter->second, aliases); + load(iter_second, aliases); for (const auto & alias : aliases) { nt->addAlias(alias.c_str()); @@ -3663,18 +3837,18 @@ inline void load(const YAML::Node & node, NamedTransformRcPtr & nt) } else if (key == "description") { - load(iter->second, stringval); + load(iter_second, stringval); nt->setDescription(stringval.c_str()); } else if (key == "family") { - load(iter->second, stringval); + load(iter_second, stringval); nt->setFamily(stringval.c_str()); } else if (key == "categories") { StringUtils::StringVec categories; - load(iter->second, categories); + load(iter_second, categories); for (auto name : categories) { nt->addCategory(name.c_str()); @@ -3682,19 +3856,19 @@ inline void load(const YAML::Node & node, NamedTransformRcPtr & nt) } else if (key == "encoding") { - load(iter->second, stringval); + load(iter_second, stringval); nt->setEncoding(stringval.c_str()); } else if (key == "transform") { TransformRcPtr val; - load(iter->second, val); + load(iter_second, val); nt->setTransform(val, TRANSFORM_DIR_FORWARD); } else if (key == "inverse_transform") { TransformRcPtr val; - load(iter->second, val); + load(iter_second, val); nt->setTransform(val, TRANSFORM_DIR_INVERSE); } else @@ -3704,67 +3878,67 @@ inline void load(const YAML::Node & node, NamedTransformRcPtr & nt) } } -inline void save(YAML::Emitter & out, ConstNamedTransformRcPtr & nt, unsigned int majorVersion) -{ - out << YAML::VerbatimTag("NamedTransform"); - out << YAML::BeginMap; - - out << YAML::Key << "name" << YAML::Value << nt->getName(); - - const size_t numAliases = nt->getNumAliases(); - if (majorVersion >= 2 && numAliases) - { - out << YAML::Key << "aliases"; - StringUtils::StringVec aliases; - for (size_t aidx = 0; aidx < numAliases; ++aidx) - { - aliases.push_back(nt->getAlias(aidx)); - } - out << YAML::Flow << YAML::Value << aliases; - } - - saveDescription(out, nt->getDescription()); - - const char * family = nt->getFamily(); - if (family && *family) - { - out << YAML::Key << "family" << YAML::Value << family; - } - - if (nt->getNumCategories() > 0) - { - StringUtils::StringVec categories; - for (int idx = 0; idx < nt->getNumCategories(); ++idx) - { - categories.push_back(nt->getCategory(idx)); - } - out << YAML::Key << "categories"; - out << YAML::Flow << YAML::Value << categories; - } - - const char * encoding = nt->getEncoding(); - if (encoding && *encoding) - { - out << YAML::Key << "encoding" << YAML::Value << encoding; - } - - ConstTransformRcPtr transform = nt->getTransform(TRANSFORM_DIR_FORWARD); - if (transform) - { - out << YAML::Key << "transform" << YAML::Value; - save(out, transform, majorVersion); - } - - transform = nt->getTransform(TRANSFORM_DIR_INVERSE); - if (transform) - { - out << YAML::Key << "inverse_transform" << YAML::Value; - save(out, transform, majorVersion); - } - - out << YAML::EndMap; - out << YAML::Newline; -} +// void save(YAML::Emitter & out, ConstNamedTransformRcPtr & nt, unsigned int majorVersion) +// { +// out << YAML::VerbatimTag("NamedTransform"); +// out << YAML::BeginMap; +// +// out << YAML::Key << "name" << YAML::Value << nt->getName(); +// +// const size_t numAliases = nt->getNumAliases(); +// if (majorVersion >= 2 && numAliases) +// { +// out << YAML::Key << "aliases"; +// StringUtils::StringVec aliases; +// for (size_t aidx = 0; aidx < numAliases; ++aidx) +// { +// aliases.push_back(nt->getAlias(aidx)); +// } +// out << YAML::Flow << YAML::Value << aliases; +// } +// +// saveDescription(out, nt->getDescription()); +// +// const char * family = nt->getFamily(); +// if (family && *family) +// { +// out << YAML::Key << "family" << YAML::Value << family; +// } +// +// if (nt->getNumCategories() > 0) +// { +// StringUtils::StringVec categories; +// for (int idx = 0; idx < nt->getNumCategories(); ++idx) +// { +// categories.push_back(nt->getCategory(idx)); +// } +// out << YAML::Key << "categories"; +// out << YAML::Flow << YAML::Value << categories; +// } +// +// const char * encoding = nt->getEncoding(); +// if (encoding && *encoding) +// { +// out << YAML::Key << "encoding" << YAML::Value << encoding; +// } +// +// ConstTransformRcPtr transform = nt->getTransform(TRANSFORM_DIR_FORWARD); +// if (transform) +// { +// out << YAML::Key << "transform" << YAML::Value; +// save(out, transform, majorVersion); +// } +// +// transform = nt->getTransform(TRANSFORM_DIR_INVERSE); +// if (transform) +// { +// out << YAML::Key << "inverse_transform" << YAML::Value; +// save(out, transform, majorVersion); +// } +// +// out << YAML::EndMap; +// out << YAML::Newline; +// } // File rules @@ -3773,14 +3947,16 @@ struct CustomKeysLoader StringUtils::StringVec m_keyVals; }; -inline void loadCustomKeys(const YAML::Node& node, CustomKeysLoader & ck) + void loadCustomKeys(const YAML::Node& node, CustomKeysLoader & ck) { if (node.Type() == YAML::NodeType::Map) { for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - const std::string & val = iter->second.as(); + const std::string & val = iter_second.as(); ck.m_keyVals.push_back(key); ck.m_keyVals.push_back(val); @@ -3792,7 +3968,7 @@ inline void loadCustomKeys(const YAML::Node& node, CustomKeysLoader & ck) } } -inline void load(const YAML::Node & node, FileRulesRcPtr & fr, bool & defaultRuleFound) + void load(const YAML::Node & node, FileRulesRcPtr & fr, bool & defaultRuleFound) { if (node.Tag() != "Rule") return; @@ -3804,40 +3980,42 @@ inline void load(const YAML::Node & node, FileRulesRcPtr & fr, bool & defaultRul StringUtils::StringVec keyVals; for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == FileRuleUtils::Name) { - load(iter->second, stringval); + load(iter_second, stringval); name = stringval; } else if (key == FileRuleUtils::ColorSpace) { - load(iter->second, stringval); + load(iter_second, stringval); colorspace = stringval; } else if (key == FileRuleUtils::Pattern) { - load(iter->second, stringval); + load(iter_second, stringval); pattern = stringval; } else if (key == FileRuleUtils::Extension) { - load(iter->second, stringval); + load(iter_second, stringval); extension = stringval; } else if (key == FileRuleUtils::Regex) { - load(iter->second, stringval); + load(iter_second, stringval); regex = stringval; } else if (key == FileRuleUtils::CustomKey) { CustomKeysLoader kv; - loadCustomKeys(iter->second, kv); + loadCustomKeys(iter_second, kv); keyVals = kv.m_keyVals; } else @@ -3856,7 +4034,7 @@ inline void load(const YAML::Node & node, FileRulesRcPtr & fr, bool & defaultRul std::ostringstream oss; oss << "'" << FileRules::DefaultRuleName << "' " << "rule can't use pattern, extension or regex."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } if (colorspace.empty()) @@ -3864,7 +4042,7 @@ inline void load(const YAML::Node & node, FileRulesRcPtr & fr, bool & defaultRul std::ostringstream oss; oss << "'" << FileRules::DefaultRuleName << "' " << "rule cannot have an empty color space name."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } defaultRuleFound = true; @@ -3877,7 +4055,7 @@ inline void load(const YAML::Node & node, FileRulesRcPtr & fr, bool & defaultRul std::ostringstream oss; oss << "'" << FileRules::FilePathSearchRuleName << "' " << "rule can't use pattern, extension or regex."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } fr->insertPathSearchRule(pos); } @@ -3888,14 +4066,14 @@ inline void load(const YAML::Node & node, FileRulesRcPtr & fr, bool & defaultRul std::ostringstream oss; oss << "File rule '" << name << "' can't use regex '" << regex << "' and " << "pattern & extension '" << pattern << "' '" << extension << "'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } if (colorspace.empty()) { std::ostringstream oss; oss << "File rule '" << name << "' cannot have an empty color space name."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } if (regex.empty()) @@ -3918,56 +4096,56 @@ inline void load(const YAML::Node & node, FileRulesRcPtr & fr, bool & defaultRul { std::ostringstream os; os << "File rules: " << ex.what(); - throwError(node, os.str().c_str()); + throwError(node, os); } } -inline void save(YAML::Emitter & out, ConstFileRulesRcPtr & fr, size_t position) -{ - out << YAML::VerbatimTag("Rule"); - out << YAML::Flow; - out << YAML::BeginMap; - out << YAML::Key << FileRuleUtils::Name << YAML::Value << fr->getName(position); - const char * cs{ fr->getColorSpace(position) }; - if (cs && *cs) - { - out << YAML::Key << FileRuleUtils::ColorSpace << YAML::Value << std::string(cs); - } - const char * regex{ fr->getRegex(position) }; - if (regex && *regex) - { - out << YAML::Key << FileRuleUtils::Regex << YAML::Value << std::string(regex); - } - const char * pattern{ fr->getPattern(position) }; - if (pattern && *pattern) - { - out << YAML::Key << FileRuleUtils::Pattern << YAML::Value << std::string(pattern); - } - const char * extension{ fr->getExtension(position) }; - if (extension && *extension) - { - out << YAML::Key << FileRuleUtils::Extension << YAML::Value << std::string(extension); - } - const auto numKeys = fr->getNumCustomKeys(position); - if (numKeys) - { - out << YAML::Key << FileRuleUtils::CustomKey; - out << YAML::Value; - out << YAML::BeginMap; - - for (size_t i = 0; i < numKeys; ++i) - { - out << YAML::Key << fr->getCustomKeyName(position, i) - << YAML::Value << fr->getCustomKeyValue(position, i); - } - out << YAML::EndMap; - } - out << YAML::EndMap; -} +// void save(YAML::Emitter & out, ConstFileRulesRcPtr & fr, size_t position) +// { +// out << YAML::VerbatimTag("Rule"); +// out << YAML::Flow; +// out << YAML::BeginMap; +// out << YAML::Key << FileRuleUtils::Name << YAML::Value << fr->getName(position); +// const char * cs{ fr->getColorSpace(position) }; +// if (cs && *cs) +// { +// out << YAML::Key << FileRuleUtils::ColorSpace << YAML::Value << std::string(cs); +// } +// const char * regex{ fr->getRegex(position) }; +// if (regex && *regex) +// { +// out << YAML::Key << FileRuleUtils::Regex << YAML::Value << std::string(regex); +// } +// const char * pattern{ fr->getPattern(position) }; +// if (pattern && *pattern) +// { +// out << YAML::Key << FileRuleUtils::Pattern << YAML::Value << std::string(pattern); +// } +// const char * extension{ fr->getExtension(position) }; +// if (extension && *extension) +// { +// out << YAML::Key << FileRuleUtils::Extension << YAML::Value << std::string(extension); +// } +// const auto numKeys = fr->getNumCustomKeys(position); +// if (numKeys) +// { +// out << YAML::Key << FileRuleUtils::CustomKey; +// out << YAML::Value; +// out << YAML::BeginMap; +// +// for (size_t i = 0; i < numKeys; ++i) +// { +// out << YAML::Key << fr->getCustomKeyName(position, i) +// << YAML::Value << fr->getCustomKeyValue(position, i); +// } +// out << YAML::EndMap; +// } +// out << YAML::EndMap; +// } // Viewing rules -inline void load(const YAML::Node & node, ViewingRulesRcPtr & vr) + void load(const YAML::Node & node, ViewingRulesRcPtr & vr) { if (node.Tag() != "Rule") return; @@ -3978,46 +4156,48 @@ inline void load(const YAML::Node & node, ViewingRulesRcPtr & vr) StringUtils::StringVec keyVals; for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if (key == ViewingRuleUtils::Name) { - load(iter->second, stringval); + load(iter_second, stringval); name = stringval; } else if (key == ViewingRuleUtils::ColorSpaces) { - if (iter->second.Type() == YAML::NodeType::Sequence) + if (iter_second.Type() == YAML::NodeType::Sequence) { - load(iter->second, colorspaces); + load(iter_second, colorspaces); } else { // If a single value is supplied... - load(iter->second, stringval); + load(iter_second, stringval); colorspaces.emplace_back(stringval); } } else if (key == ViewingRuleUtils::Encodings) { - if (iter->second.Type() == YAML::NodeType::Sequence) + if (iter_second.Type() == YAML::NodeType::Sequence) { - load(iter->second, encodings); + load(iter_second, encodings); } else { // If a single value is supplied... - load(iter->second, stringval); + load(iter_second, stringval); encodings.emplace_back(stringval); } } else if (key == ViewingRuleUtils::CustomKey) { CustomKeysLoader kv; - loadCustomKeys(iter->second, kv); + loadCustomKeys(iter_second, kv); keyVals = kv.m_keyVals; } else @@ -4050,69 +4230,69 @@ inline void load(const YAML::Node & node, ViewingRulesRcPtr & vr) { std::ostringstream os; os << "File rules: " << ex.what(); - throwError(node, os.str().c_str()); + throwError(node, os); } } -inline void save(YAML::Emitter & out, ConstViewingRulesRcPtr & vr, size_t position) -{ - out << YAML::VerbatimTag("Rule"); - out << YAML::Flow; - out << YAML::BeginMap; - out << YAML::Key << ViewingRuleUtils::Name << YAML::Value << vr->getName(position); - const size_t numcs = vr->getNumColorSpaces(position); - if (numcs == 1) - { - out << YAML::Key << ViewingRuleUtils::ColorSpaces; - out << YAML::Value << vr->getColorSpace(position, 0); - } - else if (numcs > 1) - { - StringUtils::StringVec colorspaces; - for (size_t i = 0; i < numcs; ++i) - { - colorspaces.emplace_back(vr->getColorSpace(position, i)); - } - out << YAML::Key << ViewingRuleUtils::ColorSpaces; - out << YAML::Value << YAML::Flow << colorspaces; - } - const size_t numenc = vr->getNumEncodings(position); - if (numenc == 1) - { - out << YAML::Key << ViewingRuleUtils::Encodings; - out << YAML::Value << vr->getEncoding(position, 0); - } - else if (numenc > 1) - { - StringUtils::StringVec encodings; - for (size_t i = 0; i < numenc; ++i) - { - encodings.emplace_back(vr->getEncoding(position, i)); - } - out << YAML::Key << ViewingRuleUtils::Encodings; - out << YAML::Value << YAML::Flow << encodings; - } - const auto numKeys = vr->getNumCustomKeys(position); - if (numKeys) - { - out << YAML::Key << ViewingRuleUtils::CustomKey; - out << YAML::Value; - out << YAML::BeginMap; - - for (size_t i = 0; i < numKeys; ++i) - { - out << YAML::Key << vr->getCustomKeyName(position, i) - << YAML::Value << vr->getCustomKeyValue(position, i); - } - out << YAML::EndMap; - } - out << YAML::EndMap; -} +// void save(YAML::Emitter & out, ConstViewingRulesRcPtr & vr, size_t position) +// { +// out << YAML::VerbatimTag("Rule"); +// out << YAML::Flow; +// out << YAML::BeginMap; +// out << YAML::Key << ViewingRuleUtils::Name << YAML::Value << vr->getName(position); +// const size_t numcs = vr->getNumColorSpaces(position); +// if (numcs == 1) +// { +// out << YAML::Key << ViewingRuleUtils::ColorSpaces; +// out << YAML::Value << vr->getColorSpace(position, 0); +// } +// else if (numcs > 1) +// { +// StringUtils::StringVec colorspaces; +// for (size_t i = 0; i < numcs; ++i) +// { +// colorspaces.emplace_back(vr->getColorSpace(position, i)); +// } +// out << YAML::Key << ViewingRuleUtils::ColorSpaces; +// out << YAML::Value << YAML::Flow << colorspaces; +// } +// const size_t numenc = vr->getNumEncodings(position); +// if (numenc == 1) +// { +// out << YAML::Key << ViewingRuleUtils::Encodings; +// out << YAML::Value << vr->getEncoding(position, 0); +// } +// else if (numenc > 1) +// { +// StringUtils::StringVec encodings; +// for (size_t i = 0; i < numenc; ++i) +// { +// encodings.emplace_back(vr->getEncoding(position, i)); +// } +// out << YAML::Key << ViewingRuleUtils::Encodings; +// out << YAML::Value << YAML::Flow << encodings; +// } +// const auto numKeys = vr->getNumCustomKeys(position); +// if (numKeys) +// { +// out << YAML::Key << ViewingRuleUtils::CustomKey; +// out << YAML::Value; +// out << YAML::BeginMap; +// +// for (size_t i = 0; i < numKeys; ++i) +// { +// out << YAML::Key << vr->getCustomKeyName(position, i) +// << YAML::Value << vr->getCustomKeyValue(position, i); +// } +// out << YAML::EndMap; +// } +// out << YAML::EndMap; +// } // Config -inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filename) + void load(const YAML::Node& node, ConfigRcPtr & config, const char* filename) { // check profile version @@ -4156,7 +4336,7 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen << (version.empty() ? "" : version) << "."; - throwError(node, os.str()); + throwError(node, os); } try @@ -4181,7 +4361,7 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen os << "is not able to load that config version."; os << std::endl << ex.what(); - throw Exception(os.str().c_str()); + throw Exception(os); } bool fileRulesFound = false; @@ -4195,21 +4375,23 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen EnvironmentMode mode = ENV_ENVIRONMENT_LOAD_ALL; for (Iterator iter = node.begin(); iter != node.end(); ++iter) - { + { + const auto& iter_second = iter->second; + const std::string & key = iter->first.as(); - if (iter->second.IsNull() || !iter->second.IsDefined()) continue; + if (iter_second.IsNull() || !iter_second.IsDefined()) continue; if(key == "ocio_profile_version") { } // Already handled above. else if(key == "environment") { mode = ENV_ENVIRONMENT_LOAD_PREDEFINED; - if(iter->second.Type() != YAML::NodeType::Map) + if(iter_second.Type() != YAML::NodeType::Map) { throwValueError(node.Tag(), iter->first, "The value type of key 'environment' needs to be a map."); } - for (Iterator it = iter->second.begin(); it != iter->second.end(); ++it) + for (Iterator it = iter_second.begin(); it != iter_second.end(); ++it) { const std::string & k = it->first.as(); const std::string & v = it->second.as(); @@ -4218,15 +4400,15 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen } else if(key == "search_path" || key == "resource_path") { - if (iter->second.size() == 0) + if (iter_second.size() == 0) { - load(iter->second, stringval); + load(iter_second, stringval); config->setSearchPath(stringval.c_str()); } else { StringUtils::StringVec paths; - load(iter->second, paths); + load(iter_second, paths); for (const auto & path : paths) { config->addSearchPath(path.c_str()); @@ -4235,12 +4417,12 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen } else if(key == "strictparsing") { - load(iter->second, boolval); + load(iter_second, boolval); config->setStrictParsingEnabled(boolval); } else if (key == "name") { - loadDescription(iter->second, stringval); + loadDescription(iter_second, stringval); config->setName(stringval.c_str()); } else if (key=="family_separator") @@ -4252,42 +4434,42 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen throwError(iter->first, "Config v1 can't have 'family_separator'."); } - load(iter->second, stringval); + load(iter_second, stringval); if(stringval.size()!=1) { std::ostringstream os; os << "'family_separator' value must be a single character."; os << " Found '" << stringval << "'."; - throwValueError(node.Tag(), iter->first, os.str()); + throwValueError(node.Tag(), iter->first, os); } config->setFamilySeparator(stringval[0]); } else if(key == "description") { - loadDescription(iter->second, stringval); + loadDescription(iter_second, stringval); config->setDescription(stringval.c_str()); } else if(key == "luma") { std::vector val; - load(iter->second, val); + load(iter_second, val); if(val.size() != 3) { std::ostringstream os; os << "'luma' values must be 3 "; os << "floats. Found '" << val.size() << "'."; - throwValueError(node.Tag(), iter->first, os.str()); + throwValueError(node.Tag(), iter->first, os); } config->setDefaultLumaCoefs(&val[0]); } else if(key == "roles") { - if(iter->second.Type() != YAML::NodeType::Map) + if(iter_second.Type() != YAML::NodeType::Map) { throwValueError(node.Tag(), iter->first, "The value type of the key 'roles' needs to be a map."); } - for (Iterator it = iter->second.begin(); it != iter->second.end(); ++it) + for (Iterator it = iter_second.begin(); it != iter_second.end(); ++it) { const std::string & k = it->first.as(); const std::string & v = it->second.as(); @@ -4303,20 +4485,20 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen throwError(iter->first, "Config v1 can't use 'file_rules'"); } - if (iter->second.Type() != YAML::NodeType::Sequence) + if (iter_second.Type() != YAML::NodeType::Sequence) { - throwError(iter->second, "The 'file_rules' field needs to be a (- !) list."); + throwError(iter_second, "The 'file_rules' field needs to be a (- !) list."); } - for (std::size_t i = 0; i < iter->second.size(); i++) + for (std::size_t i = 0; i < iter_second.size(); i++) { - const YAML::Node & val = iter->second[i]; + const YAML::Node & val = iter_second[i]; if (val.Tag() == "Rule") { if (defaultFileRuleFound) { - throwError(iter->second, "The 'file_rules' Default rule has to be " + throwError(iter_second, "The 'file_rules' Default rule has to be " "the last rule."); } load(val, fileRules, defaultFileRuleFound); @@ -4338,16 +4520,16 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen } else if (key == "viewing_rules") { - if (iter->second.Type() != YAML::NodeType::Sequence) + if (iter_second.Type() != YAML::NodeType::Sequence) { - throwError(iter->second, "The 'viewing_rules' field needs to be a (- !) list."); + throwError(iter_second, "The 'viewing_rules' field needs to be a (- !) list."); } auto viewingRules = ViewingRules::Create(); - for (std::size_t i = 0; i < iter->second.size(); i++) + for (std::size_t i = 0; i < iter_second.size(); i++) { - const YAML::Node & val = iter->second[i]; + const YAML::Node & val = iter_second[i]; if (val.Tag() == "Rule") { @@ -4366,14 +4548,14 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen } else if (key == "shared_views") { - if (iter->second.Type() != YAML::NodeType::Sequence) + if (iter_second.Type() != YAML::NodeType::Sequence) { throwValueError(node.Tag(), iter->first, "The view list is a sequence."); } - for (std::size_t i = 0; i < iter->second.size(); i++) + for (std::size_t i = 0; i < iter_second.size(); i++) { - const YAML::Node & val = iter->second[i]; + const YAML::Node & val = iter_second[i]; View view; load(val, view); @@ -4385,12 +4567,12 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen } else if (key == "displays") { - if(iter->second.Type() != YAML::NodeType::Map) + if(iter_second.Type() != YAML::NodeType::Map) { throwValueError(node.Tag(), iter->first, "The value type of the key 'displays' needs to be a map."); } - for (Iterator it = iter->second.begin(); it != iter->second.end(); ++it) + for (Iterator it = iter_second.begin(); it != iter_second.end(); ++it) { const std::string & display = it->first.as(); @@ -4426,14 +4608,14 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen } else if (key == "virtual_display") { - if (iter->second.Type() != YAML::NodeType::Sequence) + if (iter_second.Type() != YAML::NodeType::Sequence) { throwValueError(node.Tag(), iter->first, "The view list is a sequence."); } - for (std::size_t i = 0; i < iter->second.size(); i++) + for (std::size_t i = 0; i < iter_second.size(); i++) { - const YAML::Node & val = iter->second[i]; + const YAML::Node & val = iter_second[i]; if (val.Tag() == "View") { @@ -4467,34 +4649,34 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen else if(key == "active_displays") { StringUtils::StringVec display; - load(iter->second, display); + load(iter_second, display); std::string displays = JoinStringEnvStyle(display); config->setActiveDisplays(displays.c_str()); } else if(key == "active_views") { StringUtils::StringVec view; - load(iter->second, view); + load(iter_second, view); std::string views = JoinStringEnvStyle(view); config->setActiveViews(views.c_str()); } else if(key == "inactive_colorspaces") { StringUtils::StringVec inactiveCSs; - load(iter->second, inactiveCSs); + load(iter_second, inactiveCSs); const std::string inactivecCSsStr = JoinStringEnvStyle(inactiveCSs); config->setInactiveColorSpaces(inactivecCSsStr.c_str()); } else if(key == "colorspaces") { - if (iter->second.Type() != YAML::NodeType::Sequence) + if (iter_second.Type() != YAML::NodeType::Sequence) { - throwError(iter->second, "'colorspaces' field needs to be a (- !) list."); + throwError(iter_second, "'colorspaces' field needs to be a (- !) list."); } - for (std::size_t i = 0; i < iter->second.size(); i++) + for (std::size_t i = 0; i < iter_second.size(); i++) { - const YAML::Node & val = iter->second[i]; + const YAML::Node & val = iter_second[i]; if(val.Tag() == "ColorSpace") { @@ -4506,7 +4688,7 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen { std::ostringstream os; os << "Colorspace with name '" << cs->getName() << "' already defined."; - throwError(iter->second, os.str()); + throwError(iter_second, os); } } config->addColorSpace(cs); @@ -4523,14 +4705,14 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen } else if (key == "display_colorspaces") { - if (iter->second.Type() != YAML::NodeType::Sequence) + if (iter_second.Type() != YAML::NodeType::Sequence) { - throwError(iter->second, "'display_colorspaces' field needs to be a (- !) list."); + throwError(iter_second, "'display_colorspaces' field needs to be a (- !) list."); } - for (std::size_t i = 0; i < iter->second.size(); i++) + for (std::size_t i = 0; i < iter_second.size(); i++) { - const YAML::Node & val = iter->second[i]; + const YAML::Node & val = iter_second[i]; if (val.Tag() == "ColorSpace") { @@ -4542,7 +4724,7 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen { std::ostringstream os; os << "Colorspace with name '" << cs->getName() << "' already defined."; - throwError(iter->second, os.str()); + throwError(iter_second, os); } } config->addColorSpace(cs); @@ -4559,14 +4741,14 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen } else if (key == "looks") { - if (iter->second.Type() != YAML::NodeType::Sequence) + if (iter_second.Type() != YAML::NodeType::Sequence) { - throwError(iter->second, "'looks' field needs to be a (- !) list."); + throwError(iter_second, "'looks' field needs to be a (- !) list."); } - for (std::size_t i = 0; i < iter->second.size(); i++) + for (std::size_t i = 0; i < iter_second.size(); i++) { - const YAML::Node & val = iter->second[i]; + const YAML::Node & val = iter_second[i]; if(val.Tag() == "Look") { @@ -4586,14 +4768,14 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen } else if (key == "view_transforms") { - if (iter->second.Type() != YAML::NodeType::Sequence) + if (iter_second.Type() != YAML::NodeType::Sequence) { - throwError(iter->second, "'view_transforms' field needs to be a (- !) list."); + throwError(iter_second, "'view_transforms' field needs to be a (- !) list."); } - for (std::size_t i = 0; i < iter->second.size(); i++) + for (std::size_t i = 0; i < iter_second.size(); i++) { - const YAML::Node & val = iter->second[i]; + const YAML::Node & val = iter_second[i]; if (val.Tag() == "ViewTransform") { @@ -4614,20 +4796,20 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen } else if (key == "default_view_transform") { - load(iter->second, stringval); + load(iter_second, stringval); config->setDefaultViewTransformName(stringval.c_str()); } else if (key == "named_transforms") { - if (iter->second.Type() != YAML::NodeType::Sequence) + if (iter_second.Type() != YAML::NodeType::Sequence) { - throwError(iter->second, + throwError(iter_second, "'named_transforms' field needs to be a (- !) list."); } - for (std::size_t i = 0; i < iter->second.size(); i++) + for (std::size_t i = 0; i < iter_second.size(); i++) { - const YAML::Node & val = iter->second[i]; + const YAML::Node & val = iter_second[i]; if (val.Tag() == "NamedTransform") { @@ -4641,7 +4823,7 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen std::ostringstream oss; oss << "NamedTransform: There is already one NamedTransform named: '"; oss << std::string(nt->getName()) << "'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } // Will throw if name is empty. @@ -4737,380 +4919,380 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen } } -inline void save(YAML::Emitter & out, const Config & config) -{ - std::stringstream ss; - const unsigned configMajorVersion = config.getMajorVersion(); - ss << configMajorVersion; - if(config.getMinorVersion()!=0) - { - ss << "." << config.getMinorVersion(); - } - - out << YAML::Block; - out << YAML::BeginMap; - out << YAML::Key << "ocio_profile_version" << YAML::Value << ss.str(); - out << YAML::Newline; - out << YAML::Newline; - - if (configMajorVersion >= 2 || config.getNumEnvironmentVars() > 0) - { - // For v2 configs, write the environment section, even if empty. - out << YAML::Key << "environment"; - out << YAML::Value << YAML::BeginMap; - for(int i = 0; i < config.getNumEnvironmentVars(); ++i) - { - const char* name = config.getEnvironmentVarNameByIndex(i); - out << YAML::Key << name; - out << YAML::Value << config.getEnvironmentVarDefault(name); - } - out << YAML::EndMap; - out << YAML::Newline; - } - - if (configMajorVersion < 2) - { - // Save search paths as a single string. - out << YAML::Key << "search_path" << YAML::Value << config.getSearchPath(); - } - else - { - StringUtils::StringVec searchPaths; - const int numSP = config.getNumSearchPaths(); - for (int i = 0; i < config.getNumSearchPaths(); ++i) - { - searchPaths.emplace_back(config.getSearchPath(i)); - } - - if (numSP == 0) - { - out << YAML::Key << "search_path" << YAML::Value << ""; - } - else if (numSP == 1) - { - out << YAML::Key << "search_path" << YAML::Value << searchPaths[0]; - } - else - { - out << YAML::Key << "search_path" << YAML::Value << searchPaths; - } - } - out << YAML::Key << "strictparsing" << YAML::Value << config.isStrictParsingEnabled(); - - if (configMajorVersion >= 2) - { - const char familySeparator = config.getFamilySeparator(); - if (familySeparator != '/') - { - out << YAML::Key << "family_separator" << YAML::Value << familySeparator; - } - } - - std::vector luma(3, 0.f); - config.getDefaultLumaCoefs(&luma[0]); - out << YAML::Key << "luma" << YAML::Value << YAML::Flow << luma; - - if (configMajorVersion >= 2) - { - const std::string name{ config.getName() }; - if (!name.empty()) - { - out << YAML::Key << "name" << YAML::Value << name; - } - } - saveDescription(out, config.getDescription()); - - // Roles - out << YAML::Newline; - out << YAML::Newline; - out << YAML::Key << "roles"; - out << YAML::Value << YAML::BeginMap; - for(int i = 0; i < config.getNumRoles(); ++i) - { - const char* role = config.getRoleName(i); - if(role && *role) - { - ConstColorSpaceRcPtr colorspace = config.getColorSpace(role); - if(colorspace) - { - out << YAML::Key << role; - out << YAML::Value << config.getColorSpace(role)->getName(); - } - else - { - std::ostringstream os; - os << "Colorspace associated to the role '" << role << "', does not exist."; - throw Exception(os.str().c_str()); - } - } - } - out << YAML::EndMap; - out << YAML::Newline; - - // File rules - if (configMajorVersion >= 2) - { - auto rules = config.getFileRules(); - out << YAML::Newline; - out << YAML::Key << "file_rules"; - out << YAML::Value << YAML::BeginSeq; - for (size_t i = 0; i < rules->getNumEntries(); ++i) - { - save(out, rules, i); - } - out << YAML::EndSeq; - out << YAML::Newline; - } - - // Viewing rules - if (configMajorVersion >= 2) - { - auto rules = config.getViewingRules(); - const auto numRules = rules->getNumEntries(); - if (numRules) - { - out << YAML::Newline; - out << YAML::Key << "viewing_rules"; - out << YAML::Value << YAML::BeginSeq; - for (size_t i = 0; i < numRules; ++i) - { - save(out, rules, i); - } - out << YAML::EndSeq; - out << YAML::Newline; - } - } - - // Shared views - const int numSharedViews = config.getNumViews(VIEW_SHARED, nullptr); - if (numSharedViews) - { - out << YAML::Newline; - out << YAML::Key << "shared_views"; - out << YAML::Value << YAML::BeginSeq; - for (int v = 0; v < numSharedViews; ++v) - { - const char * name = config.getView(VIEW_SHARED, nullptr, v); - const View dview{ name, - config.getDisplayViewTransformName(nullptr, name), - config.getDisplayViewColorSpaceName(nullptr, name), - config.getDisplayViewLooks(nullptr, name), - config.getDisplayViewRule(nullptr, name), - config.getDisplayViewDescription(nullptr, name) }; - save(out, dview); - } - out << YAML::EndSeq; - out << YAML::Newline; - } - - // Displays. - out << YAML::Newline; - out << YAML::Key << "displays"; - out << YAML::Value << YAML::BeginMap; - // All displays are saved (not just active ones). - for(int i = 0; i < config.getNumDisplaysAll(); ++i) - { - // Do not save displays instantiated from a virtual display. - if (!config.isDisplayTemporary(i)) - { - const char * display = config.getDisplayAll(i); - - out << YAML::Key << display; - out << YAML::Value << YAML::BeginSeq; - for(int v = 0; v < config.getNumViews(VIEW_DISPLAY_DEFINED, display); ++v) - { - const char * name = config.getView(VIEW_DISPLAY_DEFINED, display, v); - const View dview{ name, - config.getDisplayViewTransformName(display, name), - config.getDisplayViewColorSpaceName(display, name), - config.getDisplayViewLooks(display, name), - config.getDisplayViewRule(display, name), - config.getDisplayViewDescription(display, name) }; - save(out, dview); - } - - StringUtils::StringVec sharedViews; - for (int v = 0; v < config.getNumViews(VIEW_SHARED, display); ++v) - { - sharedViews.push_back(config.getView(VIEW_SHARED, display, v)); - } - if (!sharedViews.empty()) - { - out << YAML::VerbatimTag("Views"); - out << YAML::Flow << sharedViews; - } - out << YAML::EndSeq; - } - } - out << YAML::EndMap; - - // Virtual Display. - const int numVirtualDisplayViews - = config.getVirtualDisplayNumViews(VIEW_DISPLAY_DEFINED) - + config.getVirtualDisplayNumViews(VIEW_SHARED); - - if (configMajorVersion >= 2 && numVirtualDisplayViews > 0) - { - out << YAML::Newline; - out << YAML::Newline; - out << YAML::Key << "virtual_display"; - out << YAML::Value << YAML::BeginSeq; - - for(int idx = 0; idx < config.getVirtualDisplayNumViews(VIEW_DISPLAY_DEFINED); ++idx) - { - const char * viewName = config.getVirtualDisplayView(VIEW_DISPLAY_DEFINED, idx); - const View view{ viewName, - config.getVirtualDisplayViewTransformName(viewName), - config.getVirtualDisplayViewColorSpaceName(viewName), - config.getVirtualDisplayViewLooks(viewName), - config.getVirtualDisplayViewRule(viewName), - config.getVirtualDisplayViewDescription(viewName) }; - save(out, view); - } - - StringUtils::StringVec sharedViews; - for (int idx = 0; idx < config.getVirtualDisplayNumViews(VIEW_SHARED); ++idx) - { - sharedViews.push_back(config.getVirtualDisplayView(VIEW_SHARED, idx)); - } - if (!sharedViews.empty()) - { - out << YAML::VerbatimTag("Views"); - out << YAML::Flow << sharedViews; - } - - out << YAML::EndSeq; - } - - out << YAML::Newline; - out << YAML::Newline; - out << YAML::Key << "active_displays"; - StringUtils::StringVec active_displays; - if(config.getActiveDisplays() != NULL && strlen(config.getActiveDisplays()) > 0) - active_displays = SplitStringEnvStyle(config.getActiveDisplays()); - out << YAML::Value << YAML::Flow << active_displays; - out << YAML::Key << "active_views"; - StringUtils::StringVec active_views; - if(config.getActiveViews() != NULL && strlen(config.getActiveViews()) > 0) - active_views = SplitStringEnvStyle(config.getActiveViews()); - out << YAML::Value << YAML::Flow << active_views; - - const std::string inactiveCSs = config.getInactiveColorSpaces(); - if (!inactiveCSs.empty()) - { - const StringUtils::StringVec inactive_colorspaces{ SplitStringEnvStyle(inactiveCSs) }; - out << YAML::Key << "inactive_colorspaces"; - out << YAML::Value << YAML::Flow << inactive_colorspaces; - } - - out << YAML::Newline; - - // Looks - if(config.getNumLooks() > 0) - { - out << YAML::Newline; - out << YAML::Key << "looks"; - out << YAML::Value << YAML::BeginSeq; - for(int i = 0; i < config.getNumLooks(); ++i) - { - const char* name = config.getLookNameByIndex(i); - save(out, config.getLook(name), configMajorVersion); - } - out << YAML::EndSeq; - out << YAML::Newline; - } - - // View transforms. - const std::string defVT{ config.getDefaultViewTransformName() }; - if (!defVT.empty()) - { - out << YAML::Newline; - out << YAML::Key << "default_view_transform" << YAML::Value << defVT; - out << YAML::Newline; - } - const int numVT = config.getNumViewTransforms(); - if (numVT > 0) - { - out << YAML::Newline; - out << YAML::Key << "view_transforms"; - out << YAML::Value << YAML::BeginSeq; - for (int i = 0; i < numVT; ++i) - { - auto name = config.getViewTransformNameByIndex(i); - auto vt = config.getViewTransform(name); - save(out, vt, configMajorVersion); - } - out << YAML::EndSeq; - } - - std::vector sceneCS; - std::vector displayCS; - for (int i = 0; i < config.getNumColorSpaces(SEARCH_REFERENCE_SPACE_ALL, COLORSPACE_ALL); ++i) - { - const char * name - = config.getColorSpaceNameByIndex(SEARCH_REFERENCE_SPACE_ALL, COLORSPACE_ALL, i); - - auto cs = config.getColorSpace(name); - if (cs->getReferenceSpaceType() == REFERENCE_SPACE_DISPLAY) - { - // Display color spaces instantiated from a virtual display must not be saved. - // Check them using their name as they have the same name as the display. - - const int idx = config.getDisplayAllByName(name); - if (idx==-1 || !config.isDisplayTemporary(idx)) - { - displayCS.push_back(cs); - } - } - else - { - sceneCS.push_back(cs); - } - } - - // Display ColorSpaces - if (!displayCS.empty()) - { - out << YAML::Newline; - out << YAML::Key << "display_colorspaces"; - out << YAML::Value << YAML::BeginSeq; - for (const auto & cs : displayCS) - { - save(out, cs, configMajorVersion); - } - out << YAML::EndSeq; - } - - // ColorSpaces - { - out << YAML::Newline; - out << YAML::Key << "colorspaces"; - out << YAML::Value << YAML::BeginSeq; - for (const auto & cs : sceneCS) - { - save(out, cs, configMajorVersion); - } - out << YAML::EndSeq; - } - - // Named transforms. - const int numNT = config.getNumNamedTransforms(NAMEDTRANSFORM_ALL); - if (numNT > 0) - { - out << YAML::Newline; - out << YAML::Key << "named_transforms"; - out << YAML::Value << YAML::BeginSeq; - for (int i = 0; i < numNT; ++i) - { - auto name = config.getNamedTransformNameByIndex(NAMEDTRANSFORM_ALL, i); - auto nt = config.getNamedTransform(name); - save(out, nt, configMajorVersion); - } - out << YAML::EndSeq; - } - - out << YAML::EndMap; -} +// void save(YAML::Emitter & out, const Config & config) +// { +// std::stringstream ss; +// const unsigned configMajorVersion = config.getMajorVersion(); +// ss << configMajorVersion; +// if(config.getMinorVersion()!=0) +// { +// ss << "." << config.getMinorVersion(); +// } +// +// out << YAML::Block; +// out << YAML::BeginMap; +// out << YAML::Key << "ocio_profile_version" << YAML::Value << ss.str(); +// out << YAML::Newline; +// out << YAML::Newline; +// +// if (configMajorVersion >= 2 || config.getNumEnvironmentVars() > 0) +// { +// // For v2 configs, write the environment section, even if empty. +// out << YAML::Key << "environment"; +// out << YAML::Value << YAML::BeginMap; +// for(int i = 0; i < config.getNumEnvironmentVars(); ++i) +// { +// const char* name = config.getEnvironmentVarNameByIndex(i); +// out << YAML::Key << name; +// out << YAML::Value << config.getEnvironmentVarDefault(name); +// } +// out << YAML::EndMap; +// out << YAML::Newline; +// } +// +// if (configMajorVersion < 2) +// { +// // Save search paths as a single string. +// out << YAML::Key << "search_path" << YAML::Value << config.getSearchPath(); +// } +// else +// { +// StringUtils::StringVec searchPaths; +// const int numSP = config.getNumSearchPaths(); +// for (int i = 0; i < config.getNumSearchPaths(); ++i) +// { +// searchPaths.emplace_back(config.getSearchPath(i)); +// } +// +// if (numSP == 0) +// { +// out << YAML::Key << "search_path" << YAML::Value << ""; +// } +// else if (numSP == 1) +// { +// out << YAML::Key << "search_path" << YAML::Value << searchPaths[0]; +// } +// else +// { +// out << YAML::Key << "search_path" << YAML::Value << searchPaths; +// } +// } +// out << YAML::Key << "strictparsing" << YAML::Value << config.isStrictParsingEnabled(); +// +// if (configMajorVersion >= 2) +// { +// const char familySeparator = config.getFamilySeparator(); +// if (familySeparator != '/') +// { +// out << YAML::Key << "family_separator" << YAML::Value << familySeparator; +// } +// } +// +// std::vector luma(3, 0.f); +// config.getDefaultLumaCoefs(&luma[0]); +// out << YAML::Key << "luma" << YAML::Value << YAML::Flow << luma; +// +// if (configMajorVersion >= 2) +// { +// const std::string name{ config.getName() }; +// if (!name.empty()) +// { +// out << YAML::Key << "name" << YAML::Value << name; +// } +// } +// saveDescription(out, config.getDescription()); +// +// // Roles +// out << YAML::Newline; +// out << YAML::Newline; +// out << YAML::Key << "roles"; +// out << YAML::Value << YAML::BeginMap; +// for(int i = 0; i < config.getNumRoles(); ++i) +// { +// const char* role = config.getRoleName(i); +// if(role && *role) +// { +// ConstColorSpaceRcPtr colorspace = config.getColorSpace(role); +// if(colorspace) +// { +// out << YAML::Key << role; +// out << YAML::Value << config.getColorSpace(role)->getName(); +// } +// else +// { +// std::ostringstream os; +// os << "Colorspace associated to the role '" << role << "', does not exist."; +// throw Exception(os); +// } +// } +// } +// out << YAML::EndMap; +// out << YAML::Newline; +// +// // File rules +// if (configMajorVersion >= 2) +// { +// auto rules = config.getFileRules(); +// out << YAML::Newline; +// out << YAML::Key << "file_rules"; +// out << YAML::Value << YAML::BeginSeq; +// for (size_t i = 0; i < rules->getNumEntries(); ++i) +// { +// save(out, rules, i); +// } +// out << YAML::EndSeq; +// out << YAML::Newline; +// } +// +// // Viewing rules +// if (configMajorVersion >= 2) +// { +// auto rules = config.getViewingRules(); +// const auto numRules = rules->getNumEntries(); +// if (numRules) +// { +// out << YAML::Newline; +// out << YAML::Key << "viewing_rules"; +// out << YAML::Value << YAML::BeginSeq; +// for (size_t i = 0; i < numRules; ++i) +// { +// save(out, rules, i); +// } +// out << YAML::EndSeq; +// out << YAML::Newline; +// } +// } +// +// // Shared views +// const int numSharedViews = config.getNumViews(VIEW_SHARED, nullptr); +// if (numSharedViews) +// { +// out << YAML::Newline; +// out << YAML::Key << "shared_views"; +// out << YAML::Value << YAML::BeginSeq; +// for (int v = 0; v < numSharedViews; ++v) +// { +// const char * name = config.getView(VIEW_SHARED, nullptr, v); +// const View dview{ name, +// config.getDisplayViewTransformName(nullptr, name), +// config.getDisplayViewColorSpaceName(nullptr, name), +// config.getDisplayViewLooks(nullptr, name), +// config.getDisplayViewRule(nullptr, name), +// config.getDisplayViewDescription(nullptr, name) }; +// save(out, dview); +// } +// out << YAML::EndSeq; +// out << YAML::Newline; +// } +// +// // Displays. +// out << YAML::Newline; +// out << YAML::Key << "displays"; +// out << YAML::Value << YAML::BeginMap; +// // All displays are saved (not just active ones). +// for(int i = 0; i < config.getNumDisplaysAll(); ++i) +// { +// // Do not save displays instantiated from a virtual display. +// if (!config.isDisplayTemporary(i)) +// { +// const char * display = config.getDisplayAll(i); +// +// out << YAML::Key << display; +// out << YAML::Value << YAML::BeginSeq; +// for(int v = 0; v < config.getNumViews(VIEW_DISPLAY_DEFINED, display); ++v) +// { +// const char * name = config.getView(VIEW_DISPLAY_DEFINED, display, v); +// const View dview{ name, +// config.getDisplayViewTransformName(display, name), +// config.getDisplayViewColorSpaceName(display, name), +// config.getDisplayViewLooks(display, name), +// config.getDisplayViewRule(display, name), +// config.getDisplayViewDescription(display, name) }; +// save(out, dview); +// } +// +// StringUtils::StringVec sharedViews; +// for (int v = 0; v < config.getNumViews(VIEW_SHARED, display); ++v) +// { +// sharedViews.push_back(config.getView(VIEW_SHARED, display, v)); +// } +// if (!sharedViews.empty()) +// { +// out << YAML::VerbatimTag("Views"); +// out << YAML::Flow << sharedViews; +// } +// out << YAML::EndSeq; +// } +// } +// out << YAML::EndMap; +// +// // Virtual Display. +// const int numVirtualDisplayViews +// = config.getVirtualDisplayNumViews(VIEW_DISPLAY_DEFINED) +// + config.getVirtualDisplayNumViews(VIEW_SHARED); +// +// if (configMajorVersion >= 2 && numVirtualDisplayViews > 0) +// { +// out << YAML::Newline; +// out << YAML::Newline; +// out << YAML::Key << "virtual_display"; +// out << YAML::Value << YAML::BeginSeq; +// +// for(int idx = 0; idx < config.getVirtualDisplayNumViews(VIEW_DISPLAY_DEFINED); ++idx) +// { +// const char * viewName = config.getVirtualDisplayView(VIEW_DISPLAY_DEFINED, idx); +// const View view{ viewName, +// config.getVirtualDisplayViewTransformName(viewName), +// config.getVirtualDisplayViewColorSpaceName(viewName), +// config.getVirtualDisplayViewLooks(viewName), +// config.getVirtualDisplayViewRule(viewName), +// config.getVirtualDisplayViewDescription(viewName) }; +// save(out, view); +// } +// +// StringUtils::StringVec sharedViews; +// for (int idx = 0; idx < config.getVirtualDisplayNumViews(VIEW_SHARED); ++idx) +// { +// sharedViews.push_back(config.getVirtualDisplayView(VIEW_SHARED, idx)); +// } +// if (!sharedViews.empty()) +// { +// out << YAML::VerbatimTag("Views"); +// out << YAML::Flow << sharedViews; +// } +// +// out << YAML::EndSeq; +// } +// +// out << YAML::Newline; +// out << YAML::Newline; +// out << YAML::Key << "active_displays"; +// StringUtils::StringVec active_displays; +// if(config.getActiveDisplays() != NULL && strlen(config.getActiveDisplays()) > 0) +// active_displays = SplitStringEnvStyle(config.getActiveDisplays()); +// out << YAML::Value << YAML::Flow << active_displays; +// out << YAML::Key << "active_views"; +// StringUtils::StringVec active_views; +// if(config.getActiveViews() != NULL && strlen(config.getActiveViews()) > 0) +// active_views = SplitStringEnvStyle(config.getActiveViews()); +// out << YAML::Value << YAML::Flow << active_views; +// +// const std::string inactiveCSs = config.getInactiveColorSpaces(); +// if (!inactiveCSs.empty()) +// { +// const StringUtils::StringVec inactive_colorspaces{ SplitStringEnvStyle(inactiveCSs) }; +// out << YAML::Key << "inactive_colorspaces"; +// out << YAML::Value << YAML::Flow << inactive_colorspaces; +// } +// +// out << YAML::Newline; +// +// // Looks +// if(config.getNumLooks() > 0) +// { +// out << YAML::Newline; +// out << YAML::Key << "looks"; +// out << YAML::Value << YAML::BeginSeq; +// for(int i = 0; i < config.getNumLooks(); ++i) +// { +// const char* name = config.getLookNameByIndex(i); +// save(out, config.getLook(name), configMajorVersion); +// } +// out << YAML::EndSeq; +// out << YAML::Newline; +// } +// +// // View transforms. +// const std::string defVT{ config.getDefaultViewTransformName() }; +// if (!defVT.empty()) +// { +// out << YAML::Newline; +// out << YAML::Key << "default_view_transform" << YAML::Value << defVT; +// out << YAML::Newline; +// } +// const int numVT = config.getNumViewTransforms(); +// if (numVT > 0) +// { +// out << YAML::Newline; +// out << YAML::Key << "view_transforms"; +// out << YAML::Value << YAML::BeginSeq; +// for (int i = 0; i < numVT; ++i) +// { +// auto name = config.getViewTransformNameByIndex(i); +// auto vt = config.getViewTransform(name); +// save(out, vt, configMajorVersion); +// } +// out << YAML::EndSeq; +// } +// +// std::vector sceneCS; +// std::vector displayCS; +// for (int i = 0; i < config.getNumColorSpaces(SEARCH_REFERENCE_SPACE_ALL, COLORSPACE_ALL); ++i) +// { +// const char * name +// = config.getColorSpaceNameByIndex(SEARCH_REFERENCE_SPACE_ALL, COLORSPACE_ALL, i); +// +// auto cs = config.getColorSpace(name); +// if (cs->getReferenceSpaceType() == REFERENCE_SPACE_DISPLAY) +// { +// // Display color spaces instantiated from a virtual display must not be saved. +// // Check them using their name as they have the same name as the display. +// +// const int idx = config.getDisplayAllByName(name); +// if (idx==-1 || !config.isDisplayTemporary(idx)) +// { +// displayCS.push_back(cs); +// } +// } +// else +// { +// sceneCS.push_back(cs); +// } +// } +// +// // Display ColorSpaces +// if (!displayCS.empty()) +// { +// out << YAML::Newline; +// out << YAML::Key << "display_colorspaces"; +// out << YAML::Value << YAML::BeginSeq; +// for (const auto & cs : displayCS) +// { +// save(out, cs, configMajorVersion); +// } +// out << YAML::EndSeq; +// } +// +// // ColorSpaces +// { +// out << YAML::Newline; +// out << YAML::Key << "colorspaces"; +// out << YAML::Value << YAML::BeginSeq; +// for (const auto & cs : sceneCS) +// { +// save(out, cs, configMajorVersion); +// } +// out << YAML::EndSeq; +// } +// +// // Named transforms. +// const int numNT = config.getNumNamedTransforms(NAMEDTRANSFORM_ALL); +// if (numNT > 0) +// { +// out << YAML::Newline; +// out << YAML::Key << "named_transforms"; +// out << YAML::Value << YAML::BeginSeq; +// for (int i = 0; i < numNT; ++i) +// { +// auto name = config.getNamedTransformNameByIndex(NAMEDTRANSFORM_ALL, i); +// auto nt = config.getNamedTransform(name); +// save(out, nt, configMajorVersion); +// } +// out << YAML::EndSeq; +// } +// +// out << YAML::EndMap; +// } } @@ -5133,17 +5315,17 @@ void OCIOYaml::Read(std::istream & istream, ConfigRcPtr & config, const char * f os << "'" << filename << "' "; } os << "failed. " << e.what(); - throw Exception(os.str().c_str()); + throw Exception(os); } } void OCIOYaml::Write(std::ostream & ostream, const Config & config) { - YAML::Emitter out; - out.SetDoublePrecision(std::numeric_limits::digits10); - out.SetFloatPrecision(7); - save(out, config); - ostream << out.c_str(); +// YAML::Emitter out; +// out.SetDoublePrecision(std::numeric_limits::digits10); +// out.SetFloatPrecision(7); +// save(out, config); +// ostream << out.c_str(); } } // namespace OCIO_NAMESPACE diff --git a/src/OpenColorIO/OCIOZArchive.cpp b/src/OpenColorIO/OCIOZArchive.cpp index 768f9e6d19..a7e16cbbe8 100644 --- a/src/OpenColorIO/OCIOZArchive.cpp +++ b/src/OpenColorIO/OCIOZArchive.cpp @@ -194,7 +194,7 @@ void addSupportedFiles(void * archiver, const char * path, const char * configWo std::ostringstream os; os << "Could not write LUT file " << absPath << " to in-memory archive."; - throw Exception(os.str().c_str()); + throw Exception(os); } } } @@ -218,7 +218,7 @@ void archiveConfig(std::ostream & ostream, const Config & config, const char * c { std::ostringstream os; os << "Config is not archivable."; - throw Exception(os.str().c_str()); + throw Exception(os); } // Initialize. @@ -292,7 +292,7 @@ void archiveConfig(std::ostream & ostream, const Config & config, const char * c { std::ostringstream os; os << "Could not write config to in-memory archive."; - throw Exception(os.str().c_str()); + throw Exception(os); } // Close the entry. mz_zip_writer_entry_close(archiver); @@ -301,7 +301,7 @@ void archiveConfig(std::ostream & ostream, const Config & config, const char * c { std::ostringstream os; os << "Could not prepare an entry for writing."; - throw Exception(os.str().c_str()); + throw Exception(os); } /////////////////////// @@ -358,7 +358,7 @@ void ExtractOCIOZArchive(const char * archivePath, const char * destination) { std::ostringstream os; os << "Could not open " << archivePath << " for reading."; - throw Exception(os.str().c_str()); + throw Exception(os); } else { @@ -369,13 +369,13 @@ void ExtractOCIOZArchive(const char * archivePath, const char * destination) // The archive has no files. std::ostringstream os; os << "No files in archive."; - throw Exception(os.str().c_str()); + throw Exception(os); } else if (err != MZ_OK) { std::ostringstream os; os << "Could not extract: " << archivePath; - throw Exception(os.str().c_str()); + throw Exception(os); } } @@ -384,7 +384,7 @@ void ExtractOCIOZArchive(const char * archivePath, const char * destination) { std::ostringstream os; os << "Could not close " << archivePath << " after reading."; - throw Exception(os.str().c_str()); + throw Exception(os); } // Clean up. @@ -482,7 +482,7 @@ std::vector getFileStringFromArchiveFile(const std::string & filepath, std::ostringstream os; os << "Could not open " << archivePath.c_str() << " in order to get the file: " << filepath; - throw Exception(os.str().c_str()); + throw Exception(os); } else { @@ -545,7 +545,7 @@ void getEntriesMappingFromArchiveFile(const std::string & archivePath, { std::ostringstream os; os << "Could not open " << archivePath.c_str() << " in order to get the entries."; - throw Exception(os.str().c_str()); + throw Exception(os); } else { diff --git a/src/OpenColorIO/Op.cpp b/src/OpenColorIO/Op.cpp index 532581aae0..460809c26b 100755 --- a/src/OpenColorIO/Op.cpp +++ b/src/OpenColorIO/Op.cpp @@ -149,7 +149,7 @@ void Op::combineWith(OpRcPtrVec & /*ops*/, ConstOpRcPtr & /*secondOp*/) const std::ostringstream os; os << "Op: " << getInfo() << " cannot be combined. "; os << "A type-specific combining function is not defined."; - throw Exception(os.str().c_str()); + throw Exception(os); } void Op::validate() const @@ -193,7 +193,7 @@ OpRcPtr Op::getIdentityReplacement() const std::ostringstream oss; oss << "Unexpected type in getIdentityReplacement. Expecting Matrix or Range, got :" << std::string(GetTypeName(opData->getType())) << "."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } return ops[0]; } diff --git a/src/OpenColorIO/ParseUtils.cpp b/src/OpenColorIO/ParseUtils.cpp index eaeefc00e4..c7fd0e910a 100644 --- a/src/OpenColorIO/ParseUtils.cpp +++ b/src/OpenColorIO/ParseUtils.cpp @@ -84,7 +84,7 @@ std::string ConvertXmlTokenToSpecialChar(const std::string & str) { std::ostringstream oss; oss << "Unknown XML tag:" << std::string(&(*it)); - throw Exception(oss.str().c_str()); + throw Exception(oss); } break; } @@ -147,7 +147,7 @@ TransformDirection TransformDirectionFromString(const char * s) std::ostringstream oss; oss << "Unrecognized transform direction: '" << p << "'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } TransformDirection CombineTransformDirections(TransformDirection d1, TransformDirection d2) @@ -290,7 +290,7 @@ GpuLanguage GpuLanguageFromString(const char * s) std::ostringstream oss; oss << "Unsupported GPU shader language: '" << p << "'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } const char * EnvironmentModeToString(EnvironmentMode mode) @@ -326,7 +326,7 @@ CDLStyle CDLStyleFromString(const char * style) std::ostringstream oss; oss << "Wrong CDL style: '" << p << "'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } const char * RangeStyleToString(RangeStyle style) @@ -346,7 +346,7 @@ RangeStyle RangeStyleFromString(const char * style) std::ostringstream oss; oss << "Wrong Range style '" << p << "'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } const char * FixedFunctionStyleToString(FixedFunctionStyle style) @@ -395,7 +395,7 @@ FixedFunctionStyle FixedFunctionStyleFromString(const char * style) // Default style is meaningless. std::stringstream ss; ss << "Unknown Fixed FunctionOp style: '" << p << "'."; - throw Exception(ss.str().c_str()); + throw Exception(ss); } namespace @@ -430,7 +430,7 @@ GradingStyle GradingStyleFromString(const char * style) // Default style is meaningless. std::stringstream ss; ss << "Unknown grading style: '" << p << "'."; - throw Exception(ss.str().c_str()); + throw Exception(ss); } namespace @@ -465,7 +465,7 @@ ExposureContrastStyle ExposureContrastStyleFromString(const char * style) // Default style is meaningless. std::stringstream ss; ss << "Unknown exposure contrast style: '" << p << "'."; - throw Exception(ss.str().c_str()); + throw Exception(ss); } @@ -502,7 +502,7 @@ NegativeStyle NegativeStyleFromString(const char * style) std::stringstream ss; ss << "Unknown exponent style: '" << p << "'."; - throw Exception(ss.str().c_str()); + throw Exception(ss); } // Define variables declared in OpenColorTypes.h. diff --git a/src/OpenColorIO/SystemMonitor.cpp b/src/OpenColorIO/SystemMonitor.cpp index 8ee5e915e5..8fa68a15bd 100644 --- a/src/OpenColorIO/SystemMonitor.cpp +++ b/src/OpenColorIO/SystemMonitor.cpp @@ -86,7 +86,7 @@ const char * SystemMonitorsImpl::getMonitorName(size_t index) const std::ostringstream oss; oss << "Invalid index for the monitor name " << index << " where the number of monitors is " << m_monitors.size() << "."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } return m_monitors[index].m_monitorName.c_str(); @@ -99,7 +99,7 @@ const char * SystemMonitorsImpl::getProfileFilepath(size_t index) const std::ostringstream oss; oss << "Invalid index for the monitor name " << index << " where the number of monitors is " << m_monitors.size() << "."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } return m_monitors[index].m_ICCFilepath.c_str(); @@ -117,7 +117,7 @@ std::string SystemMonitorsImpl::GetICCProfileFromMonitorName(const char * monito std::ostringstream oss; oss << "The monitor name '" << monitorName << "' does not exist."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } // namespace OCIO_NAMESPACE diff --git a/src/OpenColorIO/Transform.cpp b/src/OpenColorIO/Transform.cpp index 2c5f64033a..31d9cce3a4 100755 --- a/src/OpenColorIO/Transform.cpp +++ b/src/OpenColorIO/Transform.cpp @@ -34,7 +34,7 @@ void Transform::validate() const std::string err(typeid(*this).name()); err += ": invalid direction."; - throw Exception(err.c_str()); + throw Exception(err); } } @@ -170,7 +170,7 @@ void BuildOps(OpRcPtrVec & ops, error << "Unknown transform type for creation: " << typeid(transform).name(); - throw Exception(error.str().c_str()); + throw Exception(error); } } @@ -300,7 +300,7 @@ std::ostream& operator<< (std::ostream & os, const Transform & transform) error << "Unknown transform type for serialization: " << typeid(transform).name(); - throw Exception(error.str().c_str()); + throw Exception(error); } @@ -378,7 +378,7 @@ void CreateTransform(GroupTransformRcPtr & group, ConstOpRcPtr & op) error << "CreateTransform from op. Missing implementation for: " << typeid(op).name(); - throw Exception(error.str().c_str()); + throw Exception(error); } } diff --git a/src/OpenColorIO/ViewingRules.cpp b/src/OpenColorIO/ViewingRules.cpp index be780c94e1..75446214b0 100644 --- a/src/OpenColorIO/ViewingRules.cpp +++ b/src/OpenColorIO/ViewingRules.cpp @@ -80,7 +80,7 @@ class ViewingRule os << "The rule '" << m_name << "' "; os << "refers to color space '" << std::string(csname); os << "' which is not defined."; - throw Exception(os.str().c_str()); + throw Exception(os); } } const int numEnc = m_encodings.getNumTokens(); @@ -101,14 +101,14 @@ class ViewingRule std::ostringstream os; os << "The rule '" << m_name << "' "; os << "must have either a color space or an encoding."; - throw Exception(os.str().c_str()); + throw Exception(os); } else if (numCS != 0 && numEnc != 0) { std::ostringstream os; os << "The rule '" << m_name << "' "; os << "cannot refer to both a color space and an encoding."; - throw Exception(os.str().c_str()); + throw Exception(os); } } @@ -173,7 +173,7 @@ void ViewingRules::Impl::validatePosition(size_t ruleIndex) const std::ostringstream oss; oss << "Viewing rules: rule index '" << ruleIndex << "' invalid." << " There are only '" << numRules << "' rules."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } @@ -192,7 +192,7 @@ void ViewingRules::Impl::validateNewRule(const char * name) const { std::ostringstream oss; oss << "Viewing rules: A rule named '" << name << "' already exists."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } @@ -224,7 +224,7 @@ size_t ViewingRules::getIndexForRule(const char * ruleName) const std::ostringstream oss; oss << "Viewing rules: rule name '" << ruleName << "' not found."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } const char * ViewingRules::getName(size_t ruleIndex) const @@ -249,7 +249,7 @@ const char * ViewingRules::getColorSpace(size_t ruleIndex, size_t colorSpaceInde oss << "Viewing rules: rule '" << std::string(m_impl->m_rules[ruleIndex]->getName()) << "' at index '" << ruleIndex << "': colorspace index '" << colorSpaceIndex << "' is invalid. There are only '" << numCS << "' colorspaces."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } return m_impl->m_rules[ruleIndex]->m_colorSpaces.getToken(static_cast(colorSpaceIndex)); } @@ -262,7 +262,7 @@ void ViewingRules::addColorSpace(size_t ruleIndex, const char * colorSpace) std::ostringstream oss; oss << "Viewing rules: rule '" << std::string(m_impl->m_rules[ruleIndex]->getName()) << "' at index '" << ruleIndex << "': colorspace should have a non-empty name."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } if (m_impl->m_rules[ruleIndex]->m_encodings.getNumTokens() != 0) { @@ -270,7 +270,7 @@ void ViewingRules::addColorSpace(size_t ruleIndex, const char * colorSpace) oss << "Viewing rules: rule '" << std::string(m_impl->m_rules[ruleIndex]->getName()) << "' at index '" << ruleIndex << "': colorspace can't be added if there are encodings."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } m_impl->m_rules[ruleIndex]->m_colorSpaces.addToken(colorSpace); } @@ -297,7 +297,7 @@ const char * ViewingRules::getEncoding(size_t ruleIndex, size_t encodingIndex) c oss << "Viewing rules: rule '" << std::string(m_impl->m_rules[ruleIndex]->getName()) << "' at index '" << ruleIndex << "': encoding index '" << encodingIndex << "' is invalid. There are only '" << numEnc << "' encodings."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } return m_impl->m_rules[ruleIndex]->m_encodings.getToken(static_cast(encodingIndex)); } @@ -310,7 +310,7 @@ void ViewingRules::addEncoding(size_t ruleIndex, const char * encoding) std::ostringstream oss; oss << "Viewing rules: rule '" << std::string(m_impl->m_rules[ruleIndex]->getName()) << "' at index '" << ruleIndex << "': encoding should have a non-empty name."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } if (m_impl->m_rules[ruleIndex]->m_colorSpaces.getNumTokens() != 0) { @@ -318,7 +318,7 @@ void ViewingRules::addEncoding(size_t ruleIndex, const char * encoding) oss << "Viewing rules: rule '" << std::string(m_impl->m_rules[ruleIndex]->getName()) << "' at index '" << ruleIndex << "': encoding can't be added if there are colorspaces."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } m_impl->m_rules[ruleIndex]->m_encodings.addToken(encoding); } @@ -347,7 +347,7 @@ const char * ViewingRules::getCustomKeyName(size_t ruleIndex, size_t key) const std::ostringstream oss; oss << "Viewing rules: rule named '" << std::string(m_impl->m_rules[ruleIndex]->getName()) << "' error: " << e.what(); - throw Exception(oss.str().c_str()); + throw Exception(oss); } } @@ -363,7 +363,7 @@ const char * ViewingRules::getCustomKeyValue(size_t ruleIndex, size_t key) const std::ostringstream oss; oss << "Viewing rules: rule named '" << std::string(m_impl->m_rules[ruleIndex]->getName()) << "' error: " << e.what(); - throw Exception(oss.str().c_str()); + throw Exception(oss); } } @@ -379,7 +379,7 @@ void ViewingRules::setCustomKey(size_t ruleIndex, const char * key, const char * std::ostringstream oss; oss << "Viewing rules: rule named '" << std::string(m_impl->m_rules[ruleIndex]->getName()) << "' error: " << e.what(); - throw Exception(oss.str().c_str()); + throw Exception(oss); } } diff --git a/src/OpenColorIO/apphelpers/ColorSpaceHelpers.cpp b/src/OpenColorIO/apphelpers/ColorSpaceHelpers.cpp index a75fbef192..893708a293 100644 --- a/src/OpenColorIO/apphelpers/ColorSpaceHelpers.cpp +++ b/src/OpenColorIO/apphelpers/ColorSpaceHelpers.cpp @@ -564,7 +564,7 @@ void ColorSpaceMenuHelperImpl::refresh() { std::ostringstream oss; oss << "Element '" << name << "' is neither a color space not a named transform."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } } @@ -745,7 +745,7 @@ void AddColorSpace(ConfigRcPtr & config, errMsg += colorSpace->getName(); errMsg += "' already exists."; - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } // Step 1 - Create the color transformation. @@ -762,7 +762,7 @@ void AddColorSpace(ConfigRcPtr & config, errMsg += connectionColorSpaceName; errMsg += "' does not exist."; - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } ConstTransformRcPtr tr = connectionCS->getTransform(COLORSPACE_DIR_TO_REFERENCE); diff --git a/src/OpenColorIO/apphelpers/DisplayViewHelpers.cpp b/src/OpenColorIO/apphelpers/DisplayViewHelpers.cpp index b1ebd48285..e808244365 100644 --- a/src/OpenColorIO/apphelpers/DisplayViewHelpers.cpp +++ b/src/OpenColorIO/apphelpers/DisplayViewHelpers.cpp @@ -169,7 +169,7 @@ void AddActiveDisplayView(ConfigRcPtr & config, const char * displayName, const << OCIO_ACTIVE_DISPLAYS_ENVVAR << "' controls the active list."; - throw Exception(err.str().c_str()); + throw Exception(err); } } else @@ -207,7 +207,7 @@ void AddActiveDisplayView(ConfigRcPtr & config, const char * displayName, const << OCIO_ACTIVE_VIEWS_ENVVAR << "' controls the active list."; - throw Exception(err.str().c_str()); + throw Exception(err); } } else @@ -250,7 +250,7 @@ void RemoveActiveDisplayView(ConfigRcPtr & config, const char * displayName, con << OCIO_ACTIVE_DISPLAYS_ENVVAR << "' controls the active list."; - throw Exception(err.str().c_str()); + throw Exception(err); } } else @@ -305,7 +305,7 @@ void RemoveActiveDisplayView(ConfigRcPtr & config, const char * displayName, con << OCIO_ACTIVE_VIEWS_ENVVAR << "' controls the active list."; - throw Exception(err.str().c_str()); + throw Exception(err); } } else @@ -410,7 +410,7 @@ void AddDisplayView(ConfigRcPtr & config, errMsg += connectionColorSpaceName; errMsg += "' does not exist."; - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } ConstTransformRcPtr tr = connectionCS->getTransform(COLORSPACE_DIR_FROM_REFERENCE); @@ -473,7 +473,7 @@ void AddDisplayView(ConfigRcPtr & config, errMsg += colorSpace->getName(); errMsg += "' already exists."; - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } // Add categories if any. @@ -513,7 +513,7 @@ void RemoveDisplayView(ConfigRcPtr & config, const char * displayName, const cha errMsg += "' and '"; errMsg += viewName; errMsg += "'."; - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } // Step 1 - Remove the (display, view) pair. diff --git a/src/OpenColorIO/apphelpers/LegacyViewingPipeline.cpp b/src/OpenColorIO/apphelpers/LegacyViewingPipeline.cpp index 71fe1941fd..41cb0780a5 100644 --- a/src/OpenColorIO/apphelpers/LegacyViewingPipeline.cpp +++ b/src/OpenColorIO/apphelpers/LegacyViewingPipeline.cpp @@ -168,7 +168,7 @@ void LegacyViewingPipelineImpl::validate() const std::ostringstream oss; oss << "LegacyViewingPipeline is not valid: " << e.what(); - throw Exception(oss.str().c_str()); + throw Exception(oss); } } @@ -202,7 +202,7 @@ ConstProcessorRcPtr LegacyViewingPipelineImpl::getProcessor(const ConstConfigRcP { os << "Cannot find inputColorSpace, named '" << inputColorSpaceName << "'."; } - throw Exception(os.str().c_str()); + throw Exception(os); } const std::string display = m_displayViewTransform->getDisplay(); @@ -273,7 +273,7 @@ ConstProcessorRcPtr LegacyViewingPipelineImpl::getProcessor(const ConstConfigRcP os << "DisplayViewTransform error:"; os << " LinearCC requires '" << std::string(ROLE_SCENE_LINEAR); os << "' role to be defined."; - throw Exception(os.str().c_str()); + throw Exception(os); } if (!skipColorSpaceConversions) @@ -303,7 +303,7 @@ ConstProcessorRcPtr LegacyViewingPipelineImpl::getProcessor(const ConstConfigRcP os << "DisplayViewTransform error:"; os << " ColorTimingCC requires '" << std::string(ROLE_COLOR_TIMING); os << "' role to be defined."; - throw Exception(os.str().c_str()); + throw Exception(os); } if (!skipColorSpaceConversions) diff --git a/src/OpenColorIO/apphelpers/MixingHelpers.cpp b/src/OpenColorIO/apphelpers/MixingHelpers.cpp index 9f6fa1e396..fe1f63d22f 100644 --- a/src/OpenColorIO/apphelpers/MixingHelpers.cpp +++ b/src/OpenColorIO/apphelpers/MixingHelpers.cpp @@ -182,7 +182,7 @@ const char * MixingColorSpaceManagerImpl::getMixingSpaceUIName(size_t idx) const ss << "Invalid mixing space index " << idx << " where size is " << m_mixingSpaces.size() << "."; - throw Exception(ss.str().c_str()); + throw Exception(ss); } size_t MixingColorSpaceManagerImpl::getSelectedMixingSpaceIdx() const noexcept @@ -197,7 +197,7 @@ void MixingColorSpaceManagerImpl::setSelectedMixingSpaceIdx(size_t idx) std::stringstream ss; ss << "Invalid idx for the mixing space index " << idx << " where size is " << m_mixingSpaces.size() << "."; - throw Exception(ss.str().c_str()); + throw Exception(ss); } m_selectedMixingSpaceIdx = idx; @@ -216,7 +216,7 @@ void MixingColorSpaceManagerImpl::setSelectedMixingSpace(const char * mixingSpac std::stringstream ss; ss << "Invalid mixing space name: '" << mixingSpace << "'."; - throw Exception(ss.str().c_str()); + throw Exception(ss); } bool MixingColorSpaceManagerImpl::isPerceptuallyUniform() const noexcept @@ -246,7 +246,7 @@ const char * MixingColorSpaceManagerImpl::getMixingEncodingName(size_t idx) cons ss << "Invalid mixing encoding index " << idx << " where size is " << m_mixingEncodings.size() << "."; - throw Exception(ss.str().c_str()); + throw Exception(ss); } size_t MixingColorSpaceManagerImpl::getSelectedMixingEncodingIdx() const noexcept @@ -261,7 +261,7 @@ void MixingColorSpaceManagerImpl::setSelectedMixingEncodingIdx(size_t idx) std::stringstream ss; ss << "Invalid idx for the mixing encoding index " << idx << " where size is " << m_mixingEncodings.size() << "."; - throw Exception(ss.str().c_str()); + throw Exception(ss); } m_selectedMixingEncodingIdx = idx; @@ -280,7 +280,7 @@ void MixingColorSpaceManagerImpl::setSelectedMixingEncoding(const char * mixingE std::stringstream ss; ss << "Invalid mixing encoding: '" << mixingEncoding << "'."; - throw Exception(ss.str().c_str()); + throw Exception(ss); } // Get a processor to convert from the working/rendering space to the mixing space diff --git a/src/OpenColorIO/builtinconfigs/BuiltinConfigRegistry.cpp b/src/OpenColorIO/builtinconfigs/BuiltinConfigRegistry.cpp index 5bc4631765..9ebc25a2dc 100644 --- a/src/OpenColorIO/builtinconfigs/BuiltinConfigRegistry.cpp +++ b/src/OpenColorIO/builtinconfigs/BuiltinConfigRegistry.cpp @@ -157,7 +157,7 @@ const char * BuiltinConfigRegistryImpl::getBuiltinConfigByName(const char * conf std::ostringstream os; os << "Could not find '" << configName << "' in the built-in configurations."; - throw Exception(os.str().c_str()); + throw Exception(os); } bool BuiltinConfigRegistryImpl::isBuiltinConfigRecommended(size_t configIndex) const diff --git a/src/OpenColorIO/fileformats/FileFormat3DL.cpp b/src/OpenColorIO/fileformats/FileFormat3DL.cpp index 362a2c981d..fc71b5057a 100755 --- a/src/OpenColorIO/fileformats/FileFormat3DL.cpp +++ b/src/OpenColorIO/fileformats/FileFormat3DL.cpp @@ -279,7 +279,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "Not expecting a line starting with \"<\"."; os << "Line (" << lineNumber << "): '"; os << lineBuffer << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } } @@ -311,7 +311,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "Appears to contain more than 1 shaper LUT."; os << "Line (" << lineNumber << "): '"; os << lineBuffer << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } } // If we've found 3 ints, add it to our 3D LUT. @@ -333,7 +333,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "Invalid line with less than 3 values."; os << "Line (" << lineNumber << "): '"; os << lineBuffer << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } } } @@ -343,7 +343,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, std::ostringstream os; os << "Error parsing .3dl file. "; os << "Does not appear to contain a valid shaper LUT or a 3D LUT."; - throw Exception(os.str().c_str()); + throw Exception(os); } LocalCachedFileRcPtr cachedFile = LocalCachedFileRcPtr(new LocalCachedFile()); @@ -378,7 +378,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "file, but instead a related format that shares a similar "; os << "structure."; - throw Exception(os.str().c_str()); + throw Exception(os); } int shaperbitdepth = GetLikelyLutBitDepth(shapermax); @@ -389,7 +389,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "The maximum shaper LUT value, " << shapermax; os << ", does not correspond to any likely bit depth. "; os << "Please confirm source file is valid."; - throw Exception(os.str().c_str()); + throw Exception(os); } out1DBD = GetOCIOBitdepth(shaperbitdepth); @@ -400,7 +400,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "Error parsing .3dl file. "; os << "The shaper LUT bit depth is not known. "; os << "Please confirm source file is valid."; - throw Exception(os.str().c_str()); + throw Exception(os); } if (!IsIdentity(rawshaper, out1DBD)) @@ -440,7 +440,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "file, but instead a related format that shares a similar "; os << "structure."; - throw Exception(os.str().c_str()); + throw Exception(os); } int lut3dbitdepth = GetLikelyLutBitDepth(lut3dmax); @@ -451,7 +451,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "The maximum 3D LUT value, " << lut3dmax; os << ", does not correspond to any likely bit depth. "; os << "Please confirm source file is valid."; - throw Exception(os.str().c_str()); + throw Exception(os); } // Interpret the int array as a 3D LUT @@ -515,7 +515,7 @@ void LocalFileFormat::bake(const Baker & baker, std::ostringstream os; os << "Unknown 3dl format name, '"; os << formatName << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } ConstConfigRcPtr config = baker.getConfig(); @@ -594,7 +594,7 @@ LocalFileFormat::buildFileOps(OpRcPtrVec & ops, { std::ostringstream os; os << "Cannot build .3dl Op. Invalid cache type."; - throw Exception(os.str().c_str()); + throw Exception(os); } const auto newDir = CombineTransformDirections(dir, fileTransform.getDirection()); diff --git a/src/OpenColorIO/fileformats/FileFormatCC.cpp b/src/OpenColorIO/fileformats/FileFormatCC.cpp index a4854ca419..891de1cf8a 100755 --- a/src/OpenColorIO/fileformats/FileFormatCC.cpp +++ b/src/OpenColorIO/fileformats/FileFormatCC.cpp @@ -98,13 +98,13 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "Error parsing .cc file. "; os << "Does not appear to contain a valid ASC CDL XML:"; os << e.what(); - throw Exception(os.str().c_str()); + throw Exception(os); } if (!parser.isCC()) { std::ostringstream os; os << "File '" << fileName << "' is not a .cc file."; - throw Exception(os.str().c_str()); + throw Exception(os); } return cachedFile; @@ -145,7 +145,7 @@ LocalFileFormat::buildFileOps(OpRcPtrVec & ops, { std::ostringstream os; os << "Cannot build .cc Op. Invalid cache type."; - throw Exception(os.str().c_str()); + throw Exception(os); } const auto newDir = CombineTransformDirections(dir, fileTransform.getDirection()); diff --git a/src/OpenColorIO/fileformats/FileFormatCCC.cpp b/src/OpenColorIO/fileformats/FileFormatCCC.cpp index 44746d5408..82ed107f5a 100755 --- a/src/OpenColorIO/fileformats/FileFormatCCC.cpp +++ b/src/OpenColorIO/fileformats/FileFormatCCC.cpp @@ -116,7 +116,7 @@ void LocalFileFormat::write(const ConstConfigRcPtr & /*config*/, { std::ostringstream os; os << "Write to " << formatName << ": there should be at least one CDL."; - throw Exception(os.str().c_str()); + throw Exception(os); } for (int i = 0; i < numCDL; ++i) { @@ -125,7 +125,7 @@ void LocalFileFormat::write(const ConstConfigRcPtr & /*config*/, { std::ostringstream os; os << "Write to " << formatName << ": only CDL can be written."; - throw Exception(os.str().c_str()); + throw Exception(os); } } @@ -170,7 +170,7 @@ void LocalFileFormat::buildFileOps(OpRcPtrVec & ops, { std::ostringstream os; os << "Cannot build .ccc Op. Invalid cache type."; - throw Exception(os.str().c_str()); + throw Exception(os); } const auto newDir = CombineTransformDirections(dir, fileTransform.getDirection()); diff --git a/src/OpenColorIO/fileformats/FileFormatCDL.cpp b/src/OpenColorIO/fileformats/FileFormatCDL.cpp index d592459a98..f702978d2e 100755 --- a/src/OpenColorIO/fileformats/FileFormatCDL.cpp +++ b/src/OpenColorIO/fileformats/FileFormatCDL.cpp @@ -139,7 +139,7 @@ void LocalFileFormat::write(const ConstConfigRcPtr & /*config*/, { std::ostringstream os; os << "Write to " << formatName << ": there should be at least one CDL."; - throw Exception(os.str().c_str()); + throw Exception(os); } for (int i = 0; i < numCDL; ++i) { @@ -148,7 +148,7 @@ void LocalFileFormat::write(const ConstConfigRcPtr & /*config*/, { std::ostringstream os; os << "Write to " << formatName << ": only CDL can be written."; - throw Exception(os.str().c_str()); + throw Exception(os); } } @@ -199,7 +199,7 @@ LocalFileFormat::buildFileOps(OpRcPtrVec & ops, { std::ostringstream os; os << "Cannot build .cdl Op. Invalid cache type."; - throw Exception(os.str().c_str()); + throw Exception(os); } const auto newDir = CombineTransformDirections(dir, fileTransform.getDirection()); diff --git a/src/OpenColorIO/fileformats/FileFormatCSP.cpp b/src/OpenColorIO/fileformats/FileFormatCSP.cpp index 9c421dcec6..ce1f6eb4a1 100755 --- a/src/OpenColorIO/fileformats/FileFormatCSP.cpp +++ b/src/OpenColorIO/fileformats/FileFormatCSP.cpp @@ -376,7 +376,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, std::ostringstream os; os << "File " << fileName; os << ": file stream empty when trying to read csp LUT."; - throw Exception(os.str().c_str()); + throw Exception(os); } if (!startswithU(line, "CSPLUTV100")) @@ -384,7 +384,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, std::ostringstream os; os << "File " << fileName << " doesn't seem to be a csp LUT, "; os << "expected 'CSPLUTV100'. First line: '" << line << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } // Next line tells us if we are reading a 1D or 3D LUT. @@ -394,7 +394,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, std::ostringstream os; os << "Unsupported CSP LUT type. Require 1D or 3D. "; os << "Found, '" << line << "' in " << fileName << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } std::string csptype = line; @@ -433,7 +433,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, std::ostringstream os; os << "Prelut does not specify valid dimension size on channel '"; os << c << ": '" << line << "' in " << fileName << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } if(cpoints>=2) @@ -454,7 +454,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "Expected: " << cpoints << "."; os << "Found: " << inputparts.size() << ", " << outputparts.size() << "."; os << " In " << fileName << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } if(!StringVecToFloatVec(prelut_in[c], inputparts) || @@ -463,7 +463,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, std::ostringstream os; os << "Prelut data is malformed, cannot convert to float array."; os << " In " << fileName << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } useprelut[c] = (!VecsEqualWithRelError(&(prelut_in[c][0]), static_cast(prelut_in[c].size()), @@ -497,7 +497,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "A csp 1D LUT with invalid number of entries ("; os << points1D << "): " << line << " ."; os << " In " << fileName << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } lut1d_ptr = std::make_shared(points1D); @@ -524,7 +524,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "must contain three numbers. Line: '"; os << line << "'. File: "; os << fileName << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } // Store each channel. @@ -551,7 +551,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "Malformed 3D csp in LUT file, couldn't read cube size. '"; os << line << "'. In file: "; os << fileName << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } // TODO: Support nonuniform cube sizes. @@ -562,7 +562,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "A csp 3D LUT with nonuniform cube sizes is not supported ("; os << cubeSize[0] << ", " << cubeSize[1] << ", " << cubeSize[2]; os << "): " << line << " ."; - throw Exception(os.str().c_str()); + throw Exception(os); } if (lutSize <= 0) @@ -570,7 +570,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, std::ostringstream os; os << "A csp 3D LUT with invalid cube size ("; os << lutSize << "): " << line << "' in " << fileName << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } lut3d_ptr = std::make_shared(lutSize); @@ -606,7 +606,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, std::ostringstream os; os << "Malformed 3D csp LUT, couldn't read cube row ("; os << i << "): " << line << "' in " << fileName << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } lutArray[arrayIdx + 0] = floatArray[0]; @@ -859,7 +859,7 @@ LocalFileFormat::buildFileOps(OpRcPtrVec & ops, { std::ostringstream os; os << "Cannot build CSP Op. Invalid cache type."; - throw Exception(os.str().c_str()); + throw Exception(os); } const auto newDir = CombineTransformDirections(dir, fileTransform.getDirection()); diff --git a/src/OpenColorIO/fileformats/FileFormatCTF.cpp b/src/OpenColorIO/fileformats/FileFormatCTF.cpp index 9f1ef3478a..95e840c117 100644 --- a/src/OpenColorIO/fileformats/FileFormatCTF.cpp +++ b/src/OpenColorIO/fileformats/FileFormatCTF.cpp @@ -332,7 +332,7 @@ class XMLParserHelper os << m_fileName.c_str() << "). "; os << "Error is: " << error.c_str(); os << ". At line (" << m_lineNumber << ")"; - throw Exception(os.str().c_str()); + throw Exception(os); } // Determines if the element name is supported in the current context. @@ -1181,7 +1181,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, { std::ostringstream oss; oss << "Parsing error: '" << filePath << "' is not a CTF/CLF file."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } XMLParserHelper parser(filePath); @@ -1341,7 +1341,7 @@ void LocalFileFormat::bake(const Baker & baker, std::ostringstream os; os << "Unknown CLF/CTF file format name, '"; os << formatName << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } // @@ -1549,7 +1549,7 @@ void LocalFileFormat::write(const ConstConfigRcPtr & config, // Neither a clf nor a ctf. std::ostringstream os; os << "Error: CLF/CTF writer does not also write format " << formatName << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } OpRcPtrVec ops; diff --git a/src/OpenColorIO/fileformats/FileFormatDiscreet1DL.cpp b/src/OpenColorIO/fileformats/FileFormatDiscreet1DL.cpp index dbf4e79084..921cc01c5c 100755 --- a/src/OpenColorIO/fileformats/FileFormatDiscreet1DL.cpp +++ b/src/OpenColorIO/fileformats/FileFormatDiscreet1DL.cpp @@ -696,7 +696,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << " At line (" << errline << "): '"; os << errorLine << "'."; } - throw Exception(os.str().c_str()); + throw Exception(os); } const BitDepth inputBD = Lut1dUtils::GetBitDepth(discreetLut1d->srcBitDepth); @@ -750,7 +750,7 @@ LocalFileFormat::buildFileOps(OpRcPtrVec & ops, { std::ostringstream os; os << "Cannot build .lut Op. Invalid cache type."; - throw Exception(os.str().c_str()); + throw Exception(os); } const auto newDir = CombineTransformDirections(dir, fileTransform.getDirection()); diff --git a/src/OpenColorIO/fileformats/FileFormatHDL.cpp b/src/OpenColorIO/fileformats/FileFormatHDL.cpp index 8a9d979a1c..466ad04957 100755 --- a/src/OpenColorIO/fileformats/FileFormatHDL.cpp +++ b/src/OpenColorIO/fileformats/FileFormatHDL.cpp @@ -97,7 +97,7 @@ findHeaderItem(StringToStringVecMap& headers, { std::ostringstream os; os << "'" << key << "' line not found"; - throw Exception(os.str().c_str()); + throw Exception(os); } // Error if incorrect number of values is found @@ -117,7 +117,7 @@ findHeaderItem(StringToStringVecMap& headers, os << "between " << min_vals << " and " << max_vals; } - throw Exception(os.str().c_str()); + throw Exception(os); } return iter->second; @@ -174,7 +174,7 @@ readLuts(std::istream& istream, os << "Malformed LUT - Unknown word '"; os << word << "' after LUT name '"; os << nextword << "'"; - throw Exception(os.str().c_str()); + throw Exception(os); } } } @@ -200,7 +200,7 @@ readLuts(std::istream& istream, std::ostringstream os; os << "Invalid float value in " << lutname; os << " LUT, '" << word << "'"; - throw Exception(os.str().c_str()); + throw Exception(os); } } else @@ -208,7 +208,7 @@ readLuts(std::istream& istream, std::ostringstream os; os << "Unexpected word, possibly a value outside"; os <<" a LUT {} block. Word was '" << word << "'"; - throw Exception(os.str().c_str()); + throw Exception(os); } } @@ -353,7 +353,7 @@ LocalFileFormat::read(std::istream & istream, std::ostringstream os; os << "Invalid float value(s) on 'From' line, '"; os << value[0] << "' and '" << value[1] << "'"; - throw Exception(os.str().c_str()); + throw Exception(os); } cachedFile->from_min = from_min; cachedFile->from_max = from_max; @@ -373,7 +373,7 @@ LocalFileFormat::read(std::istream & istream, std::ostringstream os; os << "Invalid float value(s) on 'To' line, '"; os << value[0] << "' and '" << value[1] << "'"; - throw Exception(os.str().c_str()); + throw Exception(os); } cachedFile->to_min = to_min; cachedFile->to_max = to_max; @@ -392,7 +392,7 @@ LocalFileFormat::read(std::istream & istream, std::ostringstream os; os << "Invalid float value on 'Black' line, '"; os << value[0] << "'"; - throw Exception(os.str().c_str()); + throw Exception(os); } cachedFile->hdlblack = black; } @@ -407,7 +407,7 @@ LocalFileFormat::read(std::istream & istream, std::ostringstream os; os << "Invalid float value on 'White' line, '"; os << value[0] << "'"; - throw Exception(os.str().c_str()); + throw Exception(os); } cachedFile->hdlwhite = white; } @@ -421,7 +421,7 @@ LocalFileFormat::read(std::istream & istream, { std::ostringstream os; os << "Unsupported Houdini LUT type: '" << ltype << "'"; - throw Exception(os.str().c_str()); + throw Exception(os); } } @@ -444,7 +444,7 @@ LocalFileFormat::read(std::istream & istream, std::ostringstream os; os << "Invalid integer on 'Length' line: "; os << "'" << value[0] << "'"; - throw Exception(os.str().c_str()); + throw Exception(os); } lut_sizes.push_back(tmpsize); } @@ -488,7 +488,7 @@ LocalFileFormat::read(std::istream & istream, { std::ostringstream os; os << "3D+1D LUT should contain Pre{} LUT section"; - throw Exception(os.str().c_str()); + throw Exception(os); } if(size_prelut != static_cast(lut_iter->second.size())) @@ -496,7 +496,7 @@ LocalFileFormat::read(std::istream & istream, std::ostringstream os; os << "Pre{} LUT was " << lut_iter->second.size(); os << " values long, expected " << size_prelut << " values"; - throw Exception(os.str().c_str()); + throw Exception(os); } cachedFile->setLUT1D(lut_iter->second, interp); @@ -513,7 +513,7 @@ LocalFileFormat::read(std::istream & istream, { std::ostringstream os; os << "3D LUT section not found"; - throw Exception(os.str().c_str()); + throw Exception(os); } int size_3d_cubed = size_3d * size_3d * size_3d; @@ -529,7 +529,7 @@ LocalFileFormat::read(std::istream & istream, os << "(" << foundlines << " lines), "; os << "expected " << (size_3d_cubed*3) << " values "; os << "(" << size_3d_cubed << " lines)"; - throw Exception(os.str().c_str()); + throw Exception(os); } lut3d_ptr->setArrayFromRedFastestOrder(lut_iter->second); @@ -546,7 +546,7 @@ LocalFileFormat::read(std::istream & istream, { std::ostringstream os; os << "3D+1D LUT should contain Pre{} LUT section"; - throw Exception(os.str().c_str()); + throw Exception(os); } if(size_1d != static_cast(lut_iter->second.size())) @@ -554,7 +554,7 @@ LocalFileFormat::read(std::istream & istream, std::ostringstream os; os << "RGB{} LUT was " << lut_iter->second.size(); os << " values long, expected " << size_1d << " values"; - throw Exception(os.str().c_str()); + throw Exception(os); } cachedFile->setLUT1D(lut_iter->second, interp); @@ -573,7 +573,7 @@ void LocalFileFormat::bake(const Baker & baker, std::ostringstream os; os << "Unknown hdl format name, '"; os << formatName << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } // setup the floating point precision @@ -814,7 +814,7 @@ LocalFileFormat::buildFileOps(OpRcPtrVec & ops, { std::ostringstream os; os << "Cannot build Houdini Op. Invalid cache type."; - throw Exception(os.str().c_str()); + throw Exception(os); } const auto newDir = CombineTransformDirections(dir, fileTransform.getDirection()); diff --git a/src/OpenColorIO/fileformats/FileFormatICC.cpp b/src/OpenColorIO/fileformats/FileFormatICC.cpp index 5633fb77f7..57d53432e2 100755 --- a/src/OpenColorIO/fileformats/FileFormatICC.cpp +++ b/src/OpenColorIO/fileformats/FileFormatICC.cpp @@ -126,7 +126,7 @@ void LocalFileFormat::ThrowErrorMessage(const std::string & error, os << "). "; os << error; - throw Exception(os.str().c_str()); + throw Exception(os); } LocalCachedFileRcPtr LocalFileFormat::ReadInfo(std::istream & istream, @@ -756,7 +756,7 @@ LocalFileFormat::buildFileOps(OpRcPtrVec & ops, { std::ostringstream os; os << "Cannot build Op. Invalid cache type."; - throw Exception(os.str().c_str()); + throw Exception(os); } const auto newDir = CombineTransformDirections(dir, fileTransform.getDirection()); @@ -893,7 +893,7 @@ std::string GetProfileDescriptionFromICCProfile(const char * ICCProfileFilepath) os << "The specified file '"; os << ICCProfileFilepath << "' could not be opened. "; os << "Please confirm the file exists with appropriate read permissions."; - throw Exception(os.str().c_str()); + throw Exception(os); } SampleICC::IccContent icc; diff --git a/src/OpenColorIO/fileformats/FileFormatIridasCube.cpp b/src/OpenColorIO/fileformats/FileFormatIridasCube.cpp index ec0d7ab835..8566581885 100755 --- a/src/OpenColorIO/fileformats/FileFormatIridasCube.cpp +++ b/src/OpenColorIO/fileformats/FileFormatIridasCube.cpp @@ -137,7 +137,7 @@ void LocalFileFormat::ThrowErrorMessage(const std::string & error, } os << error; - throw Exception(os.str().c_str()); + throw Exception(os); } void LocalFileFormat::getFormatInfo(FormatInfoVec & formatInfoVec) const @@ -454,7 +454,7 @@ void LocalFileFormat::bake(const Baker & baker, std::ostringstream os; os << "Unknown cube format name, '"; os << formatName << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } ConstConfigRcPtr config = baker.getConfig(); @@ -510,7 +510,7 @@ LocalFileFormat::buildFileOps(OpRcPtrVec & ops, { std::ostringstream os; os << "Cannot build Iridas .cube Op. Invalid cache type."; - throw Exception(os.str().c_str()); + throw Exception(os); } const auto newDir = CombineTransformDirections(dir, fileTransform.getDirection()); diff --git a/src/OpenColorIO/fileformats/FileFormatIridasItx.cpp b/src/OpenColorIO/fileformats/FileFormatIridasItx.cpp index 75af1b315e..477e2a29fa 100755 --- a/src/OpenColorIO/fileformats/FileFormatIridasItx.cpp +++ b/src/OpenColorIO/fileformats/FileFormatIridasItx.cpp @@ -108,7 +108,7 @@ void LocalFileFormat::ThrowErrorMessage(const std::string & error, } os << error; - throw Exception(os.str().c_str()); + throw Exception(os); } void LocalFileFormat::getFormatInfo(FormatInfoVec & formatInfoVec) const @@ -242,7 +242,7 @@ void LocalFileFormat::bake(const Baker & baker, std::ostringstream os; os << "Unknown 3dl format name, '"; os << formatName << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } ConstConfigRcPtr config = baker.getConfig(); @@ -299,7 +299,7 @@ LocalFileFormat::buildFileOps(OpRcPtrVec & ops, { std::ostringstream os; os << "Cannot build Iridas .itx Op. Invalid cache type."; - throw Exception(os.str().c_str()); + throw Exception(os); } const auto newDir = CombineTransformDirections(dir, fileTransform.getDirection()); diff --git a/src/OpenColorIO/fileformats/FileFormatIridasLook.cpp b/src/OpenColorIO/fileformats/FileFormatIridasLook.cpp index d22ea8712c..3d3842f4e0 100755 --- a/src/OpenColorIO/fileformats/FileFormatIridasLook.cpp +++ b/src/OpenColorIO/fileformats/FileFormatIridasLook.cpp @@ -201,7 +201,7 @@ class XMLParserHelper os << m_fileName.c_str() << "). "; os << "Number of characters in 'data' must be multiple of 8. "; os << m_lutString.size() << " elements found."; - throw Exception(os.str().c_str()); + throw Exception(os); } lutSize = m_lutSize; @@ -219,7 +219,7 @@ class XMLParserHelper os << m_fileName.c_str() << "). "; os << "Non-hex characters found in 'data' block "; os << "at index '" << (8 * i) << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } lut.push_back(fval); } @@ -231,7 +231,7 @@ class XMLParserHelper os << m_fileName.c_str() << "). "; os << "Incorrect number of lut3d entries. "; os << "Found " << lut.size() << " values, expected " << expactedVectorSize << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } } @@ -245,7 +245,7 @@ class XMLParserHelper os << m_fileName.c_str() << "). "; os << "Error is: " << error.c_str(); os << ". At line (" << m_lineNumber << ")"; - throw Exception(os.str().c_str()); + throw Exception(os); } // Start the parsing of one element @@ -557,7 +557,7 @@ LocalFileFormat::buildFileOps(OpRcPtrVec & ops, { std::ostringstream os; os << "Cannot build Iridas .look Op. Invalid cache type."; - throw Exception(os.str().c_str()); + throw Exception(os); } const auto newDir = CombineTransformDirections(dir, fileTransform.getDirection()); diff --git a/src/OpenColorIO/fileformats/FileFormatPandora.cpp b/src/OpenColorIO/fileformats/FileFormatPandora.cpp index 387d515435..50a7b4ce30 100755 --- a/src/OpenColorIO/fileformats/FileFormatPandora.cpp +++ b/src/OpenColorIO/fileformats/FileFormatPandora.cpp @@ -78,7 +78,7 @@ void LocalFileFormat::ThrowErrorMessage(const std::string & error, } os << error; - throw Exception(os.str().c_str()); + throw Exception(os); } void LocalFileFormat::getFormatInfo(FormatInfoVec & formatInfoVec) const @@ -288,7 +288,7 @@ LocalFileFormat::buildFileOps(OpRcPtrVec & ops, { std::ostringstream os; os << "Cannot build Pandora LUT. Invalid cache type."; - throw Exception(os.str().c_str()); + throw Exception(os); } const auto newDir = CombineTransformDirections(dir, fileTransform.getDirection()); diff --git a/src/OpenColorIO/fileformats/FileFormatResolveCube.cpp b/src/OpenColorIO/fileformats/FileFormatResolveCube.cpp index 580bb70b50..6c2704db16 100755 --- a/src/OpenColorIO/fileformats/FileFormatResolveCube.cpp +++ b/src/OpenColorIO/fileformats/FileFormatResolveCube.cpp @@ -243,7 +243,7 @@ void LocalFileFormat::ThrowErrorMessage(const std::string & error, } os << error; - throw Exception(os.str().c_str()); + throw Exception(os); } void LocalFileFormat::getFormatInfo(FormatInfoVec & formatInfoVec) const @@ -510,7 +510,7 @@ void LocalFileFormat::bake(const Baker & baker, std::ostringstream os; os << "Unknown cube format name, '"; os << formatName << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } // @@ -732,7 +732,7 @@ LocalFileFormat::buildFileOps(OpRcPtrVec & ops, { std::ostringstream os; os << "Cannot build Resolve .cube Op. Invalid cache type."; - throw Exception(os.str().c_str()); + throw Exception(os); } const auto newDir = CombineTransformDirections(dir, fileTransform.getDirection()); diff --git a/src/OpenColorIO/fileformats/FileFormatSpi1D.cpp b/src/OpenColorIO/fileformats/FileFormatSpi1D.cpp index 4d360a540b..e7b2f81b4f 100755 --- a/src/OpenColorIO/fileformats/FileFormatSpi1D.cpp +++ b/src/OpenColorIO/fileformats/FileFormatSpi1D.cpp @@ -322,7 +322,7 @@ void LocalFileFormat::bake(const Baker & baker, std::ostringstream os; os << "Unknown spi format name, '"; os << formatName << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } // @@ -401,7 +401,7 @@ void LocalFileFormat::buildFileOps(OpRcPtrVec & ops, { std::ostringstream os; os << "Cannot build Spi1D Op. Invalid cache type."; - throw Exception(os.str().c_str()); + throw Exception(os); } const auto newDir = CombineTransformDirections(dir, fileTransform.getDirection()); @@ -452,7 +452,7 @@ void LocalFileFormat::ThrowErrorMessage(const std::string & error, os << " (" << lineContent << ")"; } - throw Exception(os.str().c_str()); + throw Exception(os); } } diff --git a/src/OpenColorIO/fileformats/FileFormatSpi3D.cpp b/src/OpenColorIO/fileformats/FileFormatSpi3D.cpp index c846bb0e3c..02838a97a3 100755 --- a/src/OpenColorIO/fileformats/FileFormatSpi3D.cpp +++ b/src/OpenColorIO/fileformats/FileFormatSpi3D.cpp @@ -98,7 +98,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "). "; os << "LUT does not appear to be valid spilut format. "; os << "Expected 'SPILUT'. Found: '" << lineBuffer << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } // TODO: Assert 2nd line is 3 3 @@ -115,7 +115,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "). "; os << "Error while reading LUT size. Found: '"; os << lineBuffer << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } // TODO: Support nonuniformly sized LUTs. @@ -127,7 +127,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "). "; os << "LUT size should be the same for all components. Found: '"; os << lineBuffer << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } Lut3DOpDataRcPtr lut3d = std::make_shared((unsigned long)rSize); @@ -183,7 +183,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "A color value is specified ("; os << redValueS << " " << greenValueS << " " << blueValueS; os << ") that cannot be parsed as a floating-point triplet."; - throw Exception(os.str().c_str()); + throw Exception(os); } bool invalidIndex = false; @@ -214,7 +214,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "A LUT entry is specified ("; os << rIndex << " " << gIndex << " " << bIndex; os << ") that falls outside of the cube."; - throw Exception(os.str().c_str()); + throw Exception(os); } lutArray[index+0] = redValue; @@ -235,7 +235,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "A LUT entry is specified multiple times ("; os << rIndex << " " << gIndex << " " << bIndex; os << ")."; - throw Exception(os.str().c_str()); + throw Exception(os); } } } @@ -248,7 +248,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << fileName; os << "). "; os << "Not enough entries found."; - throw Exception(os.str().c_str()); + throw Exception(os); } LocalCachedFileRcPtr cachedFile = LocalCachedFileRcPtr(new LocalCachedFile()); @@ -268,7 +268,7 @@ void LocalFileFormat::bake(const Baker & baker, std::ostringstream os; os << "Unknown spi format name, '"; os << formatName << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } ConstConfigRcPtr config = baker.getConfig(); @@ -315,7 +315,7 @@ void LocalFileFormat::buildFileOps(OpRcPtrVec & ops, { std::ostringstream os; os << "Cannot build Spi3D Op. Invalid cache type."; - throw Exception(os.str().c_str()); + throw Exception(os); } const auto newDir = CombineTransformDirections(dir, fileTransform.getDirection()); diff --git a/src/OpenColorIO/fileformats/FileFormatSpiMtx.cpp b/src/OpenColorIO/fileformats/FileFormatSpiMtx.cpp index 2e096091db..a691372051 100755 --- a/src/OpenColorIO/fileformats/FileFormatSpiMtx.cpp +++ b/src/OpenColorIO/fileformats/FileFormatSpiMtx.cpp @@ -94,7 +94,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << fileName << "). "; os << "File must contain 12 float entries. "; os << lineParts.size() << " found."; - throw Exception(os.str().c_str()); + throw Exception(os); } // Turn the parts into floats @@ -105,7 +105,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "Error parsing .spimtx file ("; os << fileName << "). "; os << "File must contain all float entries. "; - throw Exception(os.str().c_str()); + throw Exception(os); } @@ -153,7 +153,7 @@ void LocalFileFormat::buildFileOps(OpRcPtrVec & ops, { std::ostringstream os; os << "Cannot build SpiMtx Ops. Invalid cache type."; - throw Exception(os.str().c_str()); + throw Exception(os); } const auto newDir = CombineTransformDirections(dir, fileTransform.getDirection()); diff --git a/src/OpenColorIO/fileformats/FileFormatTruelight.cpp b/src/OpenColorIO/fileformats/FileFormatTruelight.cpp index a3529ba4ed..e462ee37db 100755 --- a/src/OpenColorIO/fileformats/FileFormatTruelight.cpp +++ b/src/OpenColorIO/fileformats/FileFormatTruelight.cpp @@ -148,7 +148,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "Only equal grid size LUTs are supported. Found "; os << "grid size: " << size3d[0] << " x "; os << size3d[1] << " x " << size3d[2] << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } raw3d.reserve(3*size3d[0]*size3d[1]*size3d[2]); @@ -212,7 +212,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "Parse error in Truelight .cub LUT. "; os << "Incorrect number of lut1d entries. "; os << "Found " << raw1d.size()/3 << ", expected " << size1d << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } if(size3d[0]*size3d[1]*size3d[2] != static_cast(raw3d.size()/3)) @@ -221,7 +221,7 @@ CachedFileRcPtr LocalFileFormat::read(std::istream & istream, os << "Parse error in Truelight .cub LUT. "; os << "Incorrect number of 3D LUT entries. "; os << "Found " << raw3d.size()/3 << ", expected " << size3d[0]*size3d[1]*size3d[2] << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } @@ -351,7 +351,7 @@ LocalFileFormat::buildFileOps(OpRcPtrVec & ops, { std::ostringstream os; os << "Cannot build Truelight .cub Op. Invalid cache type."; - throw Exception(os.str().c_str()); + throw Exception(os); } const auto newDir = CombineTransformDirections(dir, fileTransform.getDirection()); diff --git a/src/OpenColorIO/fileformats/FileFormatVF.cpp b/src/OpenColorIO/fileformats/FileFormatVF.cpp index c2fdb94761..19cc1bbe92 100755 --- a/src/OpenColorIO/fileformats/FileFormatVF.cpp +++ b/src/OpenColorIO/fileformats/FileFormatVF.cpp @@ -79,7 +79,7 @@ void LocalFileFormat::ThrowErrorMessage(const std::string & error, } os << error; - throw Exception(os.str().c_str()); + throw Exception(os); } void LocalFileFormat::getFormatInfo(FormatInfoVec & formatInfoVec) const @@ -267,7 +267,7 @@ LocalFileFormat::buildFileOps(OpRcPtrVec & ops, { std::ostringstream os; os << "Cannot build .vf Op. Invalid cache type."; - throw Exception(os.str().c_str()); + throw Exception(os); } const auto newDir = CombineTransformDirections(dir, fileTransform.getDirection()); diff --git a/src/OpenColorIO/fileformats/FormatMetadata.cpp b/src/OpenColorIO/fileformats/FormatMetadata.cpp index 8b5fe1cfad..1d2bb214bd 100644 --- a/src/OpenColorIO/fileformats/FormatMetadata.cpp +++ b/src/OpenColorIO/fileformats/FormatMetadata.cpp @@ -399,6 +399,12 @@ void FormatMetadataImpl::setName(const char * name) noexcept addAttribute(attrib); } +void FormatMetadataImpl::setName(const std::string& name) noexcept +{ + addAttribute(Attribute(METADATA_NAME, name)); +} + + const char * FormatMetadataImpl::getID() const noexcept { return getAttributeValueString(METADATA_ID).c_str(); diff --git a/src/OpenColorIO/fileformats/FormatMetadata.h b/src/OpenColorIO/fileformats/FormatMetadata.h index 35c8cb2e01..387ab4ddcd 100644 --- a/src/OpenColorIO/fileformats/FormatMetadata.h +++ b/src/OpenColorIO/fileformats/FormatMetadata.h @@ -96,6 +96,8 @@ class FormatMetadataImpl : public FormatMetadata const char * getName() const noexcept override; void setName(const char * name) noexcept override; + void setName(const std::string& name) noexcept override; + const char * getID() const noexcept override; void setID(const char * id) noexcept override; diff --git a/src/OpenColorIO/fileformats/cdl/CDLParser.cpp b/src/OpenColorIO/fileformats/cdl/CDLParser.cpp index 72239299b3..c3900532e9 100644 --- a/src/OpenColorIO/fileformats/cdl/CDLParser.cpp +++ b/src/OpenColorIO/fileformats/cdl/CDLParser.cpp @@ -238,7 +238,7 @@ void CDLParser::Impl::throwMessage(const std::string & error) const os << m_fileName.c_str() << "). "; os << "Error is: " << error.c_str(); os << ". At line (" << m_lineNumber << ")"; - throw Exception(os.str().c_str()); + throw Exception(os); } void CDLParser::Impl::parse(const std::string & buffer, bool lastLine) @@ -988,7 +988,7 @@ void CDLParser::getCDLTransforms(CDLTransformMap & transformMap, os << "Error loading ccc xml. "; os << "Duplicate elements with '" << id << "' found. "; os << "If id is specified, it must be unique."; - throw Exception(os.str().c_str()); + throw Exception(os); } transformMap[id] = pTransform; diff --git a/src/OpenColorIO/fileformats/ctf/CTFReaderHelper.cpp b/src/OpenColorIO/fileformats/ctf/CTFReaderHelper.cpp index 00d39c3889..2f1003d5d0 100644 --- a/src/OpenColorIO/fileformats/ctf/CTFReaderHelper.cpp +++ b/src/OpenColorIO/fileformats/ctf/CTFReaderHelper.cpp @@ -607,7 +607,7 @@ void GetNextIndexPair(const char *s, size_t len, size_t& pos, float& num1, float std::ostringstream oss; oss << "GetNextIndexPair: First number of a pair is the end of the string '" << TruncateString(s, len) << "'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } // Extract a number at pos. @@ -763,7 +763,7 @@ void validateInfoElementVersion(const char * versionAttr, std::ostringstream oss; oss << "CTF reader. Invalid Info element version attribute: "; oss << versionValue << " ."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } // Always compare with 'ints' so we do not include minor versions @@ -775,7 +775,7 @@ void validateInfoElementVersion(const char * versionAttr, std::ostringstream oss; oss << "CTF reader. Unsupported Info element version attribute: "; oss << versionValue << " ."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } } @@ -2671,7 +2671,7 @@ RGBCurveType GetRGBCurveType(const std::string & name) } std::ostringstream err; err << "Invalid curve name '" << name << "'."; - throw Exception(err.str().c_str()); + throw Exception(err); } } @@ -4426,7 +4426,7 @@ void CTFReaderMatrixElt::endArray(unsigned int position) arg << "Expected " << array.getLength() << "x" << array.getLength(); arg << " Array values, found " << position; - throw Exception(arg.str().c_str()); + throw Exception(arg); } // Array parsing is done. @@ -4478,7 +4478,7 @@ void CTFReaderMatrixElt::convert_1_2_to_Latest() arg << "MatrixElt: Expecting array dimension to be 3 or 4. Got: "; arg << array.getLength() << "."; - throw Exception(arg.str().c_str()); + throw Exception(arg); } } } diff --git a/src/OpenColorIO/fileformats/ctf/CTFReaderUtils.cpp b/src/OpenColorIO/fileformats/ctf/CTFReaderUtils.cpp index ffd73cbd43..551bc97ce8 100644 --- a/src/OpenColorIO/fileformats/ctf/CTFReaderUtils.cpp +++ b/src/OpenColorIO/fileformats/ctf/CTFReaderUtils.cpp @@ -29,7 +29,7 @@ Interpolation GetInterpolation1D(const char * str) std::ostringstream oss; oss << "1D LUT interpolation not recongnized: '" << str << "'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } throw Exception("1D LUT missing interpolation value."); @@ -71,7 +71,7 @@ Interpolation GetInterpolation3D(const char * str) std::ostringstream oss; oss << "3D LUT interpolation not recongnized: '" << str << "'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } throw Exception("3D LUT missing interpolation value."); @@ -148,7 +148,7 @@ void ConvertStringToGradingStyleAndDir(const char * str, std::ostringstream os; os << "Unknown grading style: '" << str << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } return; } @@ -171,6 +171,6 @@ const char * ConvertGradingStyleAndDirToString(GradingStyle style, TransformDire std::ostringstream os; os << "Unknown grading style: " << style; - throw Exception(os.str().c_str()); + throw Exception(os); } } // namespace OCIO_NAMESPACE diff --git a/src/OpenColorIO/fileformats/ctf/CTFTransform.cpp b/src/OpenColorIO/fileformats/ctf/CTFTransform.cpp index 662ef67756..f3f5d62167 100644 --- a/src/OpenColorIO/fileformats/ctf/CTFTransform.cpp +++ b/src/OpenColorIO/fileformats/ctf/CTFTransform.cpp @@ -75,7 +75,7 @@ void CTFVersion::ReadVersion(const std::string & versionString, CTFVersion & ver os << versionString; os << "' is not a valid version. "; os << "Expecting MAJOR[.MINOR[.REVISION]] "; - throw Exception(os.str().c_str()); + throw Exception(os); } versionOut.m_major = 0; @@ -745,7 +745,7 @@ BitDepth GetValidatedFileBitDepth(BitDepth bd, OpData::Type type) std::ostringstream oss; oss << "Op " << typeName << ". Bit-depth: " << bd << " is not supported for writing to CLF/CTF."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } void OpWriter::getAttributes(XmlFormatter::Attributes & attributes) const @@ -2477,7 +2477,7 @@ void ThrowWriteOp(const std::string & type) std::ostringstream oss; oss << "Transform uses the '" << type << "' op which cannot be written " "as CLF. Use CTF format or Bake the transform."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } BitDepth GetInputFileBD(ConstOpDataRcPtr op) diff --git a/src/OpenColorIO/fileformats/ctf/IndexMapping.cpp b/src/OpenColorIO/fileformats/ctf/IndexMapping.cpp index 4b116963d3..52c3c6ae48 100644 --- a/src/OpenColorIO/fileformats/ctf/IndexMapping.cpp +++ b/src/OpenColorIO/fileformats/ctf/IndexMapping.cpp @@ -49,7 +49,7 @@ void IndexMapping::validateIndex(size_t index) const oss << "IndexMapping: Index "; oss << index << " is invalid. Should be less than "; oss << m_indices[0].size() << "."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } diff --git a/src/OpenColorIO/fileformats/xmlutils/XMLReaderHelper.cpp b/src/OpenColorIO/fileformats/xmlutils/XMLReaderHelper.cpp index 124f463cf1..4251e2ad0e 100644 --- a/src/OpenColorIO/fileformats/xmlutils/XMLReaderHelper.cpp +++ b/src/OpenColorIO/fileformats/xmlutils/XMLReaderHelper.cpp @@ -47,7 +47,7 @@ void XmlReaderElement::throwMessage(const std::string & error) const std::ostringstream os; os << "At line " << getXmlLineNumber() << ": "; os << error.c_str(); - throw Exception(os.str().c_str()); + throw Exception(os); } void XmlReaderElement::logParameterWarning(const char * param) const diff --git a/src/OpenColorIO/fileformats/xmlutils/XMLReaderUtils.h b/src/OpenColorIO/fileformats/xmlutils/XMLReaderUtils.h index 317a3da828..86e0fe6423 100644 --- a/src/OpenColorIO/fileformats/xmlutils/XMLReaderUtils.h +++ b/src/OpenColorIO/fileformats/xmlutils/XMLReaderUtils.h @@ -179,7 +179,7 @@ void ParseNumber(const char * str, size_t startPos, size_t endPos, T & value) << parsedStr << "' can not be parsed to numbers in '" << TruncateString(fullStr.c_str(), endPos, 100) << "'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } else if (!IsValid(value, val)) { @@ -190,7 +190,7 @@ void ParseNumber(const char * str, size_t startPos, size_t endPos, T & value) << parsedStr << "' are illegal in '" << TruncateString(fullStr.c_str(), endPos, 100) << "'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } else if (result.ptr != str + endPos) { @@ -202,7 +202,7 @@ void ParseNumber(const char * str, size_t startPos, size_t endPos, T & value) << parsedStr << "' number is followed by unexpected characters in '" << TruncateString(fullStr.c_str(), endPos, 100) << "'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } diff --git a/src/OpenColorIO/ops/OpArray.h b/src/OpenColorIO/ops/OpArray.h index 4a7b0b72ff..c6f37b6566 100644 --- a/src/OpenColorIO/ops/OpArray.h +++ b/src/OpenColorIO/ops/OpArray.h @@ -175,7 +175,7 @@ template class ArrayT : public ArrayBase std::ostringstream os; os << "Array contains: " << m_data.size() << " values, "; os << "but " << getNumValues() << " are expected."; - throw Exception(os.str().c_str()); + throw Exception(os); } } diff --git a/src/OpenColorIO/ops/cdl/CDLOpData.cpp b/src/OpenColorIO/ops/cdl/CDLOpData.cpp index fa214be887..6491de2ed2 100644 --- a/src/OpenColorIO/ops/cdl/CDLOpData.cpp +++ b/src/OpenColorIO/ops/cdl/CDLOpData.cpp @@ -102,7 +102,7 @@ CDLOpData::Style CDLOpData::ConvertStyle(CDLStyle style, TransformDirection dir) std::stringstream ss("Unknown CDL transform style: "); ss << style; - throw Exception(ss.str().c_str()); + throw Exception(ss); } // Convert internal OpData style to Transform style. @@ -121,7 +121,7 @@ CDLStyle CDLOpData::ConvertStyle(CDLOpData::Style style) std::stringstream ss("Unknown CDL style: "); ss << style; - throw Exception(ss.str().c_str()); + throw Exception(ss); } CDLOpData::CDLOpData() @@ -231,7 +231,7 @@ void validateGreaterEqual(const char * name, oss << "' " << value; oss << " should be greater than "; oss << threshold << "."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } @@ -248,7 +248,7 @@ void validateGreaterThan(const char * name, oss << "' " << value; oss << " should be greater than "; oss << threshold << "."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } diff --git a/src/OpenColorIO/ops/exposurecontrast/ExposureContrastOpData.cpp b/src/OpenColorIO/ops/exposurecontrast/ExposureContrastOpData.cpp index 4197b7dde4..730f1288a7 100644 --- a/src/OpenColorIO/ops/exposurecontrast/ExposureContrastOpData.cpp +++ b/src/OpenColorIO/ops/exposurecontrast/ExposureContrastOpData.cpp @@ -60,7 +60,7 @@ ExposureContrastOpData::Style ExposureContrastOpData::ConvertStringToStyle(const std::ostringstream os; os << "Unknown exposure contrast style: '" << str << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } throw Exception("Missing exposure contrast style."); } @@ -127,7 +127,7 @@ ExposureContrastOpData::Style ExposureContrastOpData::ConvertStyle(ExposureContr std::stringstream ss("Unknown ExposureContrast transform style: "); ss << style; - throw Exception(ss.str().c_str()); + throw Exception(ss); } // Convert internal OpData style to Transform style. @@ -151,7 +151,7 @@ ExposureContrastStyle ExposureContrastOpData::ConvertStyle(ExposureContrastOpDat std::stringstream ss("Unknown ExposureContrast style: "); ss << style; - throw Exception(ss.str().c_str()); + throw Exception(ss); } ExposureContrastOpData::ExposureContrastOpData() diff --git a/src/OpenColorIO/ops/fixedfunction/FixedFunctionOpData.cpp b/src/OpenColorIO/ops/fixedfunction/FixedFunctionOpData.cpp index c7007fd16c..057fcd873d 100644 --- a/src/OpenColorIO/ops/fixedfunction/FixedFunctionOpData.cpp +++ b/src/OpenColorIO/ops/fixedfunction/FixedFunctionOpData.cpp @@ -99,7 +99,7 @@ const char * FixedFunctionOpData::ConvertStyleToString(Style style, bool detaile std::stringstream ss("Unknown FixedFunction style: "); ss << style; - throw Exception(ss.str().c_str()); + throw Exception(ss); } // Convert CTF attribute string into OpData style enum. @@ -201,7 +201,7 @@ FixedFunctionOpData::Style FixedFunctionOpData::GetStyle(const char * name) std::string st("Unknown FixedFunction style: "); st += name; - throw Exception(st.c_str()); + throw Exception(st); } // Combine the Transform style and direction into the internal OpData style. @@ -275,7 +275,7 @@ FixedFunctionOpData::Style FixedFunctionOpData::ConvertStyle(FixedFunctionStyle std::stringstream ss("Unknown FixedFunction transform style: "); ss << style; - throw Exception(ss.str().c_str()); + throw Exception(ss); } // Convert internal OpData style to Transform style. @@ -331,7 +331,7 @@ FixedFunctionStyle FixedFunctionOpData::ConvertStyle(FixedFunctionOpData::Style std::stringstream ss("Unknown FixedFunction style: "); ss << style; - throw Exception(ss.str().c_str()); + throw Exception(ss); } FixedFunctionOpData::FixedFunctionOpData(Style style) @@ -370,7 +370,7 @@ void FixedFunctionOpData::validate() const ss << "The style '" << ConvertStyleToString(m_style, true) << "' must have seven parameters but " << m_params.size() << " found."; - throw Exception(ss.str().c_str()); + throw Exception(ss); } const double lim_cyan = m_params[0]; @@ -387,7 +387,7 @@ void FixedFunctionOpData::validate() const { std::stringstream ss; ss << "Parameter " << val << " (" << name << ") is outside valid range [" << low << "," << high << "]"; - throw Exception(ss.str().c_str()); + throw Exception(ss); } }; @@ -417,7 +417,7 @@ void FixedFunctionOpData::validate() const ss << "The style '" << ConvertStyleToString(m_style, true) << "' must have one parameter but " << m_params.size() << " found."; - throw Exception(ss.str().c_str()); + throw Exception(ss); } const double p = m_params[0]; @@ -428,13 +428,13 @@ void FixedFunctionOpData::validate() const { std::stringstream ss; ss << "Parameter " << p << " is less than lower bound " << low_bound; - throw Exception(ss.str().c_str()); + throw Exception(ss); } else if (p > hi_bound) { std::stringstream ss; ss << "Parameter " << p << " is greater than upper bound " << hi_bound; - throw Exception(ss.str().c_str()); + throw Exception(ss); } } else @@ -445,7 +445,7 @@ void FixedFunctionOpData::validate() const ss << "The style '" << ConvertStyleToString(m_style, true) << "' must have zero parameters but " << m_params.size() << " found."; - throw Exception(ss.str().c_str()); + throw Exception(ss); } } } diff --git a/src/OpenColorIO/ops/gamma/GammaOpData.cpp b/src/OpenColorIO/ops/gamma/GammaOpData.cpp index 482a5b79d7..06212779ee 100644 --- a/src/OpenColorIO/ops/gamma/GammaOpData.cpp +++ b/src/OpenColorIO/ops/gamma/GammaOpData.cpp @@ -111,7 +111,7 @@ GammaOpData::Style GammaOpData::ConvertStringToStyle(const char * str) std::ostringstream os; os << "Unknown gamma style: '" << str << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } throw Exception("Missing gamma style."); @@ -146,7 +146,7 @@ const char * GammaOpData::ConvertStyleToString(Style style) std::stringstream ss("Unknown Gamma style: "); ss << style; - throw Exception(ss.str().c_str()); + throw Exception(ss); } NegativeStyle GammaOpData::ConvertStyle(Style style) @@ -172,7 +172,7 @@ NegativeStyle GammaOpData::ConvertStyle(Style style) std::stringstream ss("Unknown Gamma style: "); ss << style; - throw Exception(ss.str().c_str()); + throw Exception(ss); } GammaOpData::Style GammaOpData::ConvertStyleBasic(NegativeStyle negStyle, TransformDirection dir) @@ -205,7 +205,7 @@ GammaOpData::Style GammaOpData::ConvertStyleBasic(NegativeStyle negStyle, Transf std::stringstream ss("Unknown negative extrapolation style: "); ss << negStyle; - throw Exception(ss.str().c_str()); + throw Exception(ss); } GammaOpData::Style GammaOpData::ConvertStyleMonCurve(NegativeStyle negStyle, TransformDirection dir) @@ -238,7 +238,7 @@ GammaOpData::Style GammaOpData::ConvertStyleMonCurve(NegativeStyle negStyle, Tra std::stringstream ss("Unknown negative extrapolation style: "); ss << negStyle; - throw Exception(ss.str().c_str()); + throw Exception(ss); } GammaOpData::GammaOpData() @@ -378,13 +378,13 @@ void validateParams(const GammaOpData::Params & p, { std::stringstream ss; ss << "Parameter " << p[i] << " is less than lower bound " << lowBounds[i]; - throw Exception(ss.str().c_str()); + throw Exception(ss); } if (p[i] > highBounds[i]) { std::stringstream ss; ss << "Parameter " << p[i] << " is greater than upper bound " << highBounds[i]; - throw Exception(ss.str().c_str()); + throw Exception(ss); } } } diff --git a/src/OpenColorIO/ops/gradingprimary/GradingPrimary.cpp b/src/OpenColorIO/ops/gradingprimary/GradingPrimary.cpp index 788640b7f7..1b840b4539 100644 --- a/src/OpenColorIO/ops/gradingprimary/GradingPrimary.cpp +++ b/src/OpenColorIO/ops/gradingprimary/GradingPrimary.cpp @@ -75,7 +75,7 @@ void GradingPrimary::validate(GradingStyle style) const std::ostringstream oss; oss << "GradingPrimary gamma '" << m_gamma << "' are below lower bound (" << GradingPrimaryLowerBound << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } if (style == GRADING_LIN && @@ -87,7 +87,7 @@ void GradingPrimary::validate(GradingStyle style) const std::ostringstream oss; oss << "GradingPrimary contrast '" << m_contrast << "' are below lower bound (" << GradingPrimaryLowerBound << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } if ((m_pivotWhite - m_pivotBlack) < GradingPrimaryMin) diff --git a/src/OpenColorIO/ops/gradingrgbcurve/GradingBSplineCurve.cpp b/src/OpenColorIO/ops/gradingrgbcurve/GradingBSplineCurve.cpp index 72c656725a..c85c9c4e54 100644 --- a/src/OpenColorIO/ops/gradingrgbcurve/GradingBSplineCurve.cpp +++ b/src/OpenColorIO/ops/gradingrgbcurve/GradingBSplineCurve.cpp @@ -71,7 +71,7 @@ void GradingBSplineCurveImpl::validateIndex(size_t index) const { std::ostringstream oss; oss << "There are '"<< numPoints << "' control points. '" << index << "' is invalid."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } @@ -134,7 +134,7 @@ void GradingBSplineCurveImpl::validate() const std::ostringstream oss; oss << "Control point at index " << i << " has a x coordinate '" << x << "' that is "; oss << "less from previous control point x cooordinate '" << lastX << "'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } lastX = x; } diff --git a/src/OpenColorIO/ops/gradingrgbcurve/GradingRGBCurve.cpp b/src/OpenColorIO/ops/gradingrgbcurve/GradingRGBCurve.cpp index 196988a8e7..12b7162acd 100644 --- a/src/OpenColorIO/ops/gradingrgbcurve/GradingRGBCurve.cpp +++ b/src/OpenColorIO/ops/gradingrgbcurve/GradingRGBCurve.cpp @@ -102,7 +102,7 @@ void GradingRGBCurveImpl::validate() const std::ostringstream oss; oss << "GradingRGBCurve validation failed for '" << CurveType(c) << "' curve " << "with: " << e.what(); - throw Exception(oss.str().c_str()); + throw Exception(oss); } } } diff --git a/src/OpenColorIO/ops/gradingtone/GradingTone.cpp b/src/OpenColorIO/ops/gradingtone/GradingTone.cpp index 932b0a6d14..c5dc380d13 100644 --- a/src/OpenColorIO/ops/gradingtone/GradingTone.cpp +++ b/src/OpenColorIO/ops/gradingtone/GradingTone.cpp @@ -72,14 +72,14 @@ void GradingTone::validate() const { std::ostringstream oss; oss << "GradingTone blacks '" << bd << "' are below lower bound (" << MinBMW << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } if (bd.m_width < MinWSCTol) { std::ostringstream oss; oss << "GradingTone blacks width '" << bd.m_width << "' is below lower bound (" << MinWSC << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } if (bd.m_red > MaxBMWTol || bd.m_green > MaxBMWTol || @@ -88,7 +88,7 @@ void GradingTone::validate() const { std::ostringstream oss; oss << "GradingTone blacks '" << bd << "' are above upper bound (" << MaxBMW << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } { @@ -102,14 +102,14 @@ void GradingTone::validate() const std::ostringstream oss; oss << "GradingTone midtones '" << midtones << "' are below lower bound (" << MinBMW << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } if (midtones.m_width < MinWSCTol) { std::ostringstream oss; oss << "GradingTone midtones width '" << midtones.m_width << "' is below lower bound (" << MinWSC << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } if (midtones.m_red > MaxBMWTol || midtones.m_green > MaxBMWTol || @@ -119,7 +119,7 @@ void GradingTone::validate() const std::ostringstream oss; oss << "GradingTone midtones '" << midtones << "' are above upper bound (" << MaxBMW << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } { @@ -133,14 +133,14 @@ void GradingTone::validate() const std::ostringstream oss; oss << "GradingTone whites '" << dw << "' are below lower bound (" << MinBMW << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } if (dw.m_width < MinWSCTol) { std::ostringstream oss; oss << "GradingTone whites width '" << dw.m_width << "' is below lower bound (" << MinWSC << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } if (dw.m_red > MaxBMWTol || dw.m_green > MaxBMWTol || @@ -150,7 +150,7 @@ void GradingTone::validate() const std::ostringstream oss; oss << "GradingTone white '" << dw << "' are above upper bound (" << MaxBMW << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } { @@ -164,7 +164,7 @@ void GradingTone::validate() const std::ostringstream oss; oss << "GradingTone shadows '" << shadows << "' are below lower bound (" << MinSH << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } // Check that pivot is not overlapping start. if (shadows.m_start < shadows.m_width + MinWSCTol) @@ -172,7 +172,7 @@ void GradingTone::validate() const std::ostringstream oss; oss << "GradingTone shadows start '" << shadows.m_start << "' is less than pivot ('" << shadows.m_width << "' + " << MinWSC << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } if (shadows.m_red > MaxSHTol || shadows.m_green > MaxSHTol || @@ -182,7 +182,7 @@ void GradingTone::validate() const std::ostringstream oss; oss << "GradingTone shadows '" << shadows << "' are above upper bound (" << MaxSH << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } { @@ -196,7 +196,7 @@ void GradingTone::validate() const std::ostringstream oss; oss << "GradingTone highlights '" << hl << "' are below lower bound (" << MinSH << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } // Check that pivot is not overlapping start. if (hl.m_start > hl.m_width - MinWSCTol) @@ -204,7 +204,7 @@ void GradingTone::validate() const std::ostringstream oss; oss << "GradingTone highlights start '" << hl.m_start << "' is greater than pivot ('" << hl.m_width << "' - " << MinWSC << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } if (hl.m_red > MaxSHTol || hl.m_green > MaxSHTol || @@ -214,7 +214,7 @@ void GradingTone::validate() const std::ostringstream oss; oss << "GradingTone highlights '" << hl << "' are above upper bound (" << MaxSH << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } { @@ -223,14 +223,14 @@ void GradingTone::validate() const std::ostringstream oss; oss << "GradingTone s-contrast '" << m_scontrast << "' is below lower bound (" << MinWSC << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } if (m_scontrast > MaxSCTol) { std::ostringstream oss; oss << "GradingTone s-contrast '" << m_scontrast << "' is above upper bound (" << MaxSC << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } } diff --git a/src/OpenColorIO/ops/log/LogOpData.cpp b/src/OpenColorIO/ops/log/LogOpData.cpp index ec0589479b..fdaa1f03ed 100644 --- a/src/OpenColorIO/ops/log/LogOpData.cpp +++ b/src/OpenColorIO/ops/log/LogOpData.cpp @@ -48,7 +48,7 @@ void ValidateParams(const LogOpData::Params & params, TransformDirection /* dire oss << "Log: Invalid linear side slope value '"; oss << params[LIN_SIDE_SLOPE]; oss << "', linear side slope cannot be 0."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } if (IsScalarEqualToZero(params[LOG_SIDE_SLOPE])) { @@ -56,7 +56,7 @@ void ValidateParams(const LogOpData::Params & params, TransformDirection /* dire oss << "Log: Invalid log side slope value '"; oss << params[LOG_SIDE_SLOPE]; oss << "', log side slope cannot be 0."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } } @@ -217,7 +217,7 @@ void LogOpData::validate() const oss << "Log: Invalid base value '"; oss << m_base; oss << "', base cannot be 1."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } else if (m_base <= 0.0) { @@ -225,7 +225,7 @@ void LogOpData::validate() const oss << "Log: Invalid base value '"; oss << m_base; oss << "', base must be greater than 0."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } diff --git a/src/OpenColorIO/ops/log/LogUtils.cpp b/src/OpenColorIO/ops/log/LogUtils.cpp index 77548acfe6..7f3a0f72aa 100644 --- a/src/OpenColorIO/ops/log/LogUtils.cpp +++ b/src/OpenColorIO/ops/log/LogUtils.cpp @@ -55,7 +55,7 @@ LogStyle ConvertStringToStyle(const char * str) { std::stringstream ss("Unknown Log style: '"); ss << str << "'."; - throw Exception(ss.str().c_str()); + throw Exception(ss); } } @@ -87,7 +87,7 @@ const char * ConvertStyleToString(LogStyle style) std::stringstream ss("Unknown Log style: "); ss << style; - throw Exception(ss.str().c_str()); + throw Exception(ss); } @@ -143,7 +143,7 @@ void ValidateLegacyParams(const CTFParams::Params & ctfParams) oss << "Log: Invalid gamma value '"; oss << gamma; oss << "', gamma should be greater than 0.01."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } // refWhite > refBlack. @@ -153,7 +153,7 @@ void ValidateLegacyParams(const CTFParams::Params & ctfParams) oss << "Log: Invalid refWhite '" << refWhite; oss << "' and refBlack '" << refBlack; oss << "', refWhite should be greater than refBlack."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } // highlight > shadow. @@ -163,7 +163,7 @@ void ValidateLegacyParams(const CTFParams::Params & ctfParams) oss << "Log: Invalid highlight '" << highlight; oss << "' and shadow '" << shadow; oss << "', highlight should be greater than shadow."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } diff --git a/src/OpenColorIO/ops/lut1d/Lut1DOpData.cpp b/src/OpenColorIO/ops/lut1d/Lut1DOpData.cpp index 6bc0634950..ad1fb5b85d 100644 --- a/src/OpenColorIO/ops/lut1d/Lut1DOpData.cpp +++ b/src/OpenColorIO/ops/lut1d/Lut1DOpData.cpp @@ -97,7 +97,7 @@ void Lut1DOpData::Lut3by1DArray::resize(unsigned long length, unsigned long numC std::ostringstream oss; oss << "LUT 1D: Length '" << length << "' must not be greater than 1024x1024 (1048576)."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } Array::resize(length, numColorComponents); } @@ -405,7 +405,7 @@ void Lut1DOpData::validate() const oss << "1D LUT does not support interpolation algorithm: "; oss << InterpolationToString(getInterpolation()); oss << "."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } try @@ -418,7 +418,7 @@ void Lut1DOpData::validate() const oss << "1D LUT content array issue: "; oss << e.what(); - throw Exception(oss.str().c_str()); + throw Exception(oss); } // If isHalfDomain is set, we need to make sure we have 65536 entries. @@ -432,7 +432,7 @@ void Lut1DOpData::validate() const oss << HALF_DOMAIN_REQUIRED_ENTRIES; oss << " required for halfDomain 1D LUT."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } @@ -462,7 +462,7 @@ unsigned long Lut1DOpData::GetLutIdealSize(BitDepth incomingBitDepth) { std::string err("Bit-depth is not supported: "); err += BitDepthToString(incomingBitDepth); - throw Exception(err.c_str()); + throw Exception(err); } } diff --git a/src/OpenColorIO/ops/lut3d/Lut3DOp.cpp b/src/OpenColorIO/ops/lut3d/Lut3DOp.cpp index 8e0c8b965a..c4c08f2e93 100644 --- a/src/OpenColorIO/ops/lut3d/Lut3DOp.cpp +++ b/src/OpenColorIO/ops/lut3d/Lut3DOp.cpp @@ -70,7 +70,7 @@ int Get3DLutEdgeLenFromNumPixels(int numPixels) os << numPixels << " element(s) does not correspond to a "; os << "unform cube edge length. (nearest edge length is "; os << dim << ")."; - throw Exception(os.str().c_str()); + throw Exception(os); } return dim; diff --git a/src/OpenColorIO/ops/lut3d/Lut3DOpData.cpp b/src/OpenColorIO/ops/lut3d/Lut3DOpData.cpp index 3f530cbc13..bce556f558 100644 --- a/src/OpenColorIO/ops/lut3d/Lut3DOpData.cpp +++ b/src/OpenColorIO/ops/lut3d/Lut3DOpData.cpp @@ -203,7 +203,7 @@ void Lut3DOpData::Lut3DArray::resize(unsigned long length, unsigned long numColo std::ostringstream oss; oss << "LUT 3D: Grid size '" << length << "' must not be greater than '" << maxSupportedLength << "'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } Array::resize(length, numColorComponents); } @@ -322,7 +322,7 @@ void Lut3DOpData::setArrayFromRedFastestOrder(const std::vector & lut) std::ostringstream oss; oss << "Lut3D length '" << lutSize << " * " << lutSize << " * " << lutSize << " * 3"; oss << "' does not match the vector size '"<< lut.size() <<"'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } for (unsigned long b = 0; b < lutSize; ++b) @@ -370,7 +370,7 @@ void Lut3DOpData::validate() const oss << "Lut3D does not support interpolation algorithm: "; oss << InterpolationToString(getInterpolation()); oss << "."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } try @@ -383,7 +383,7 @@ void Lut3DOpData::validate() const oss << "Lut3D content array issue: "; oss << e.what(); - throw Exception(oss.str().c_str()); + throw Exception(oss); } if (getArray().getNumColorComponents() != 3) @@ -398,7 +398,7 @@ void Lut3DOpData::validate() const oss << "Lut3D length: " << getArray().getLength(); oss << " is not supported. "; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } diff --git a/src/OpenColorIO/ops/matrix/MatrixOpData.cpp b/src/OpenColorIO/ops/matrix/MatrixOpData.cpp index 9750b154eb..fb2f12f222 100644 --- a/src/OpenColorIO/ops/matrix/MatrixOpData.cpp +++ b/src/OpenColorIO/ops/matrix/MatrixOpData.cpp @@ -492,7 +492,7 @@ void MatrixOpData::validate() const oss << "Matrix array content issue: "; oss << e.what(); - throw Exception(oss.str().c_str()); + throw Exception(oss); } if (m_direction == TRANSFORM_DIR_INVERSE) { @@ -633,7 +633,7 @@ double MatrixOpData::getOffsetValue(unsigned long index) const oss << index; oss << "'. "; - throw Exception(oss.str().c_str()); + throw Exception(oss); } return m_offsets[index]; @@ -652,7 +652,7 @@ void MatrixOpData::setOffsetValue(unsigned long index, double value) oss << index; oss << "'. "; - throw Exception(oss.str().c_str()); + throw Exception(oss); } m_offsets[index] = value; diff --git a/src/OpenColorIO/ops/noop/NoOps.cpp b/src/OpenColorIO/ops/noop/NoOps.cpp index 0fa00b4b49..8c66ce9dab 100644 --- a/src/OpenColorIO/ops/noop/NoOps.cpp +++ b/src/OpenColorIO/ops/noop/NoOps.cpp @@ -262,7 +262,7 @@ void PartitionGPUOps(OpRcPtrVec & gpuPreOps, error << "gpuLut3DOpStartIndex: " << gpuLut3DOpStartIndex << " "; error << "gpuLut3DOpEndIndex: " << gpuLut3DOpEndIndex << " "; error << "cpuOps.size: " << ops.size(); - throw Exception(error.str().c_str()); + throw Exception(error); } // If the specified location defines an allocation, use it. diff --git a/src/OpenColorIO/transforms/AllocationTransform.cpp b/src/OpenColorIO/transforms/AllocationTransform.cpp index eeca74431d..864e726528 100755 --- a/src/OpenColorIO/transforms/AllocationTransform.cpp +++ b/src/OpenColorIO/transforms/AllocationTransform.cpp @@ -92,7 +92,7 @@ void AllocationTransform::validate() const { std::string errMsg("AllocationTransform validation failed: "); errMsg += ex.what(); - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } if (getImpl()->m_allocation == ALLOCATION_UNIFORM) diff --git a/src/OpenColorIO/transforms/BuiltinTransform.cpp b/src/OpenColorIO/transforms/BuiltinTransform.cpp index 1f3f4d8e79..393bfe0655 100644 --- a/src/OpenColorIO/transforms/BuiltinTransform.cpp +++ b/src/OpenColorIO/transforms/BuiltinTransform.cpp @@ -74,7 +74,7 @@ void BuiltinTransformImpl::setStyle(const char * style) std::ostringstream oss; oss << "BuiltinTransform: invalid built-in transform style '" << style << "'."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } diff --git a/src/OpenColorIO/transforms/CDLTransform.cpp b/src/OpenColorIO/transforms/CDLTransform.cpp index 588c9215f7..4b9ba475f7 100755 --- a/src/OpenColorIO/transforms/CDLTransform.cpp +++ b/src/OpenColorIO/transforms/CDLTransform.cpp @@ -81,7 +81,7 @@ CDLTransformRcPtr GetCDL(GroupTransformRcPtr & group, const std::string & cdlId) std::ostringstream os; os << "The specified CDL Id/Index '" << cdlId; os << "' could not be loaded from the file."; - throw Exception(os.str().c_str()); + throw Exception(os); } CDLTransformRcPtr CDLTransform::CreateFromFile(const char * src, const char * cdlId_) @@ -151,7 +151,7 @@ void CDLTransformImpl::validate() const { std::string errMsg("CDLTransform validation failed: "); errMsg += ex.what(); - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } } diff --git a/src/OpenColorIO/transforms/ColorSpaceTransform.cpp b/src/OpenColorIO/transforms/ColorSpaceTransform.cpp index 2039ea66bd..68dce6b066 100755 --- a/src/OpenColorIO/transforms/ColorSpaceTransform.cpp +++ b/src/OpenColorIO/transforms/ColorSpaceTransform.cpp @@ -91,7 +91,7 @@ void ColorSpaceTransform::validate() const { std::string errMsg("ColorSpaceTransform validation failed: "); errMsg += ex.what(); - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } if (getImpl()->m_src.empty()) @@ -158,7 +158,7 @@ void ThrowMissingCS(const char * cs) { std::ostringstream os; os << "Color space '" << cs << "' could not be found."; - throw Exception(os.str().c_str()); + throw Exception(os); } } diff --git a/src/OpenColorIO/transforms/DisplayViewTransform.cpp b/src/OpenColorIO/transforms/DisplayViewTransform.cpp index 629008cf3b..d38c7ec725 100644 --- a/src/OpenColorIO/transforms/DisplayViewTransform.cpp +++ b/src/OpenColorIO/transforms/DisplayViewTransform.cpp @@ -82,7 +82,7 @@ void DisplayViewTransform::validate() const { std::string errMsg("DisplayViewTransform validation failed: "); errMsg += ex.what(); - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } if (getImpl()->m_src.empty()) @@ -210,7 +210,7 @@ void BuildSourceToDisplay(OpRcPtrVec & ops, std::ostringstream os; os << "View transform named '" << viewTransform->getName(); os << "' needs either a transform from or to reference."; - throw Exception(os.str().c_str()); + throw Exception(os); } // Convert from the display-referred reference space to the displayCS. @@ -248,7 +248,7 @@ void BuildDisplayToSource(OpRcPtrVec & ops, std::ostringstream os; os << "View transform named '" << viewTransform->getName(); os << "' needs either a transform from or to reference."; - throw Exception(os.str().c_str()); + throw Exception(os); } // If necessary, convert from the type of reference space used by the view transform to the @@ -320,7 +320,7 @@ void BuildDisplayOps(OpRcPtrVec & ops, { os << " Cannot find source color space named '" << srcColorSpaceName << "'."; } - throw Exception(os.str().c_str()); + throw Exception(os); } const std::string display = displayViewTransform.getDisplay(); @@ -329,7 +329,7 @@ void BuildDisplayOps(OpRcPtrVec & ops, std::ostringstream os; os << "DisplayViewTransform error."; os << " Display '" << display << "' not found."; - throw Exception(os.str().c_str()); + throw Exception(os); } const std::string view = displayViewTransform.getView(); @@ -350,7 +350,7 @@ void BuildDisplayOps(OpRcPtrVec & ops, std::ostringstream os; os << "DisplayViewTransform error. The view transform '"; os << viewTransformName << "' is neither a view transform nor a named transform."; - throw Exception(os.str().c_str()); + throw Exception(os); } } } @@ -385,7 +385,7 @@ void BuildDisplayOps(OpRcPtrVec & ops, std::ostringstream os; os << "DisplayViewTransform error." << " The display '"; os << display << "' does not have view '" << view << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } // Note: If there is a view transform, the display color space isn't allowed to be a @@ -396,7 +396,7 @@ void BuildDisplayOps(OpRcPtrVec & ops, os << "DisplayViewTransform error." << " The view '"; os << view << "' refers to a display color space '"; os << displayColorSpaceName << "' that can't be found."; - throw Exception(os.str().c_str()); + throw Exception(os); } // At this point, there is no view transform, so displayColorSpaceName is typically @@ -410,7 +410,7 @@ void BuildDisplayOps(OpRcPtrVec & ops, os << "DisplayViewTransform error."; os << " Cannot find color space or named transform with name '"; os << displayColorSpaceName << "'."; - throw Exception(os.str().c_str()); + throw Exception(os); } } diff --git a/src/OpenColorIO/transforms/ExponentTransform.cpp b/src/OpenColorIO/transforms/ExponentTransform.cpp index 719c9b44dc..76423a7f98 100755 --- a/src/OpenColorIO/transforms/ExponentTransform.cpp +++ b/src/OpenColorIO/transforms/ExponentTransform.cpp @@ -48,7 +48,7 @@ void ExponentTransformImpl::validate() const { std::string errMsg("ExponentTransform validation failed: "); errMsg += ex.what(); - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } } diff --git a/src/OpenColorIO/transforms/ExponentWithLinearTransform.cpp b/src/OpenColorIO/transforms/ExponentWithLinearTransform.cpp index 53c4ca480b..0b329c6910 100644 --- a/src/OpenColorIO/transforms/ExponentWithLinearTransform.cpp +++ b/src/OpenColorIO/transforms/ExponentWithLinearTransform.cpp @@ -68,7 +68,7 @@ void ExponentWithLinearTransformImpl::validate() const { std::string errMsg("ExponentWithLinearTransform validation failed: "); errMsg += ex.what(); - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } } diff --git a/src/OpenColorIO/transforms/ExposureContrastTransform.cpp b/src/OpenColorIO/transforms/ExposureContrastTransform.cpp index 49b8bbb316..052a49f50d 100644 --- a/src/OpenColorIO/transforms/ExposureContrastTransform.cpp +++ b/src/OpenColorIO/transforms/ExposureContrastTransform.cpp @@ -47,7 +47,7 @@ void ExposureContrastTransformImpl::validate() const { std::string errMsg("ExposureContrastTransform validation failed: "); errMsg += ex.what(); - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } } diff --git a/src/OpenColorIO/transforms/FileTransform.cpp b/src/OpenColorIO/transforms/FileTransform.cpp index 2bba078272..2cadd9c0b6 100755 --- a/src/OpenColorIO/transforms/FileTransform.cpp +++ b/src/OpenColorIO/transforms/FileTransform.cpp @@ -94,7 +94,7 @@ void FileTransform::validate() const { std::string errMsg("FileTransform validation failed: "); errMsg += ex.what(); - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } if (getImpl()->m_src.empty()) @@ -389,7 +389,7 @@ void FormatRegistry::registerFileFormat(FileFormat* format) std::ostringstream os; os << "FileFormat Registry error. "; os << "A file format did not provide the required format info."; - throw Exception(os.str().c_str()); + throw Exception(os); } for(unsigned int i=0; iread(filestream, filepath, interp); @@ -725,7 +725,7 @@ void LoadFileUncached(FileFormat * & returnFormat, os << "Please confirm the file exists with "; os << "appropriate read"; os << " permissions."; - throw Exception(os.str().c_str()); + throw Exception(os); } cachedFile = altFormat->read(filestream, filepath, interp); @@ -791,7 +791,7 @@ void LoadFileUncached(FileFormat * & returnFormat, os << primaryErrorText; } - throw Exception(os.str().c_str()); + throw Exception(os); } // We mutex both the main map and each item individually, so that @@ -881,7 +881,7 @@ void GetCachedFileAndFormat(FileFormat * & format, if (result->error) { - throw Exception(result->exceptionText.c_str()); + throw Exception(result->exceptionText); } else { @@ -895,7 +895,7 @@ void GetCachedFileAndFormat(FileFormat * & format, os << "The specified file load "; os << filepath << " appeared to succeed, but no format "; os << "was returned."; - throw Exception(os.str().c_str()); + throw Exception(os); } if (!cachedFile.get()) @@ -904,7 +904,7 @@ void GetCachedFileAndFormat(FileFormat * & format, os << "The specified file load "; os << filepath << " appeared to succeed, but no cachedFile "; os << "was returned."; - throw Exception(os.str().c_str()); + throw Exception(os); } } @@ -924,7 +924,7 @@ void BuildFileTransformOps(OpRcPtrVec & ops, { std::ostringstream os; os << "The transform file has not been specified."; - throw Exception(os.str().c_str()); + throw Exception(os); } std::string filepath = context->resolveFileLocation(src.c_str()); @@ -946,7 +946,7 @@ void BuildFileTransformOps(OpRcPtrVec & ops, os << "Reference to: " << filepath; os << " is creating a recursion."; - throw Exception(os.str().c_str()); + throw Exception(os); } } } @@ -986,7 +986,7 @@ void BuildFileTransformOps(OpRcPtrVec & ops, err << "The transform file: " << filepath; err << " failed while building ops with this error: "; err << e.what(); - throw Exception(err.str().c_str()); + throw Exception(err); } } diff --git a/src/OpenColorIO/transforms/FixedFunctionTransform.cpp b/src/OpenColorIO/transforms/FixedFunctionTransform.cpp index 1449e09dba..6a9125b0e3 100644 --- a/src/OpenColorIO/transforms/FixedFunctionTransform.cpp +++ b/src/OpenColorIO/transforms/FixedFunctionTransform.cpp @@ -87,7 +87,7 @@ void FixedFunctionTransformImpl::validate() const { std::string errMsg("FixedFunctionTransform validation failed: "); errMsg += ex.what(); - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } } diff --git a/src/OpenColorIO/transforms/GradingPrimaryTransform.cpp b/src/OpenColorIO/transforms/GradingPrimaryTransform.cpp index c013866c92..1e83288d84 100644 --- a/src/OpenColorIO/transforms/GradingPrimaryTransform.cpp +++ b/src/OpenColorIO/transforms/GradingPrimaryTransform.cpp @@ -54,7 +54,7 @@ void GradingPrimaryTransformImpl::validate() const { std::string errMsg("GradingPrimaryTransform validation failed: "); errMsg += ex.what(); - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } } diff --git a/src/OpenColorIO/transforms/GradingRGBCurveTransform.cpp b/src/OpenColorIO/transforms/GradingRGBCurveTransform.cpp index 77ace5ad4f..8cfbd92885 100644 --- a/src/OpenColorIO/transforms/GradingRGBCurveTransform.cpp +++ b/src/OpenColorIO/transforms/GradingRGBCurveTransform.cpp @@ -53,7 +53,7 @@ void GradingRGBCurveTransformImpl::validate() const { std::string errMsg("GradingRGBCurveTransform validation failed: "); errMsg += ex.what(); - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } } diff --git a/src/OpenColorIO/transforms/GradingToneTransform.cpp b/src/OpenColorIO/transforms/GradingToneTransform.cpp index 5031612d9a..b19ac8d6c6 100644 --- a/src/OpenColorIO/transforms/GradingToneTransform.cpp +++ b/src/OpenColorIO/transforms/GradingToneTransform.cpp @@ -54,7 +54,7 @@ void GradingToneTransformImpl::validate() const { std::string errMsg("GradingToneTransform validation failed: "); errMsg += ex.what(); - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } } diff --git a/src/OpenColorIO/transforms/GroupTransform.cpp b/src/OpenColorIO/transforms/GroupTransform.cpp index e2bb62a10f..56ad453efd 100755 --- a/src/OpenColorIO/transforms/GroupTransform.cpp +++ b/src/OpenColorIO/transforms/GroupTransform.cpp @@ -63,7 +63,7 @@ void GroupTransformImpl::validate() const { std::string errMsg("GroupTransform validation failed: "); errMsg += ex.what(); - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } for(const auto & val : m_vec) @@ -83,7 +83,7 @@ ConstTransformRcPtr GroupTransformImpl::getTransform(int index) const { std::ostringstream os; os << "Invalid transform index " << index << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } return m_vec[index]; @@ -95,7 +95,7 @@ TransformRcPtr & GroupTransformImpl::getTransform(int index) { std::ostringstream os; os << "Invalid transform index " << index << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } return m_vec[index]; @@ -123,7 +123,7 @@ void GroupTransformImpl::write(const ConstConfigRcPtr & config, std::ostringstream err; err << "The format named '" << formatName; err << "' could not be found. "; - throw Exception(err.str().c_str()); + throw Exception(err); } try @@ -135,7 +135,7 @@ void GroupTransformImpl::write(const ConstConfigRcPtr & config, std::ostringstream err; err << "Error writing format '" << formatName << "': "; err << e.what(); - throw Exception(err.str().c_str()); + throw Exception(err); } } diff --git a/src/OpenColorIO/transforms/LogAffineTransform.cpp b/src/OpenColorIO/transforms/LogAffineTransform.cpp index d54de42d85..98e31962f6 100644 --- a/src/OpenColorIO/transforms/LogAffineTransform.cpp +++ b/src/OpenColorIO/transforms/LogAffineTransform.cpp @@ -55,7 +55,7 @@ void LogAffineTransformImpl::validate() const { std::string errMsg("LogAffineTransform validation failed: "); errMsg += ex.what(); - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } } diff --git a/src/OpenColorIO/transforms/LogCameraTransform.cpp b/src/OpenColorIO/transforms/LogCameraTransform.cpp index ee7cb7276a..9d341d616f 100644 --- a/src/OpenColorIO/transforms/LogCameraTransform.cpp +++ b/src/OpenColorIO/transforms/LogCameraTransform.cpp @@ -62,7 +62,7 @@ void LogCameraTransformImpl::validate() const { std::string errMsg("LogCameraTransform validation failed: "); errMsg += ex.what(); - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } } diff --git a/src/OpenColorIO/transforms/LogTransform.cpp b/src/OpenColorIO/transforms/LogTransform.cpp index ad6d13d159..840760c18a 100755 --- a/src/OpenColorIO/transforms/LogTransform.cpp +++ b/src/OpenColorIO/transforms/LogTransform.cpp @@ -54,7 +54,7 @@ void LogTransformImpl::validate() const { std::string errMsg("LogTransform validation failed: "); errMsg += ex.what(); - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } } diff --git a/src/OpenColorIO/transforms/LookTransform.cpp b/src/OpenColorIO/transforms/LookTransform.cpp index 8d41ba6280..18e464d88a 100755 --- a/src/OpenColorIO/transforms/LookTransform.cpp +++ b/src/OpenColorIO/transforms/LookTransform.cpp @@ -92,7 +92,7 @@ void LookTransform::validate() const { std::string errMsg("LookTransform validation failed: "); errMsg += ex.what(); - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } if (getImpl()->m_src.empty()) @@ -237,7 +237,7 @@ void RunLookTokens(OpRcPtrVec & ops, // [in/out] os << ")."; } - throw Exception(os.str().c_str()); + throw Exception(os); } OpRcPtrVec tmpOps; @@ -280,7 +280,7 @@ void RunLookTokens(OpRcPtrVec & ops, // [in/out] os << "The specified look, '" << lookTokens[i].name; os << "', requires processing in the ColorSpace, '"; os << look->getProcessSpace() << "' which is not defined."; - throw Exception(os.str().c_str()); + throw Exception(os); } if (!currentColorSpace) @@ -319,7 +319,7 @@ void BuildLookOps(OpRcPtrVec & ops, os << "BuildLookOps error."; os << "The specified lookTransform specifies a src colorspace, '"; os << lookTransform.getSrc() << "', which is not defined."; - throw Exception(os.str().c_str()); + throw Exception(os); } ConstColorSpaceRcPtr dst = config.getColorSpace(lookTransform.getDst()); @@ -329,7 +329,7 @@ void BuildLookOps(OpRcPtrVec & ops, os << "BuildLookOps error."; os << "The specified lookTransform specifies a dst colorspace, '"; os << lookTransform.getDst() << "', which is not defined."; - throw Exception(os.str().c_str()); + throw Exception(os); } LookParseResult looks; diff --git a/src/OpenColorIO/transforms/Lut1DTransform.cpp b/src/OpenColorIO/transforms/Lut1DTransform.cpp index 1b3bf089e1..e8476b4783 100644 --- a/src/OpenColorIO/transforms/Lut1DTransform.cpp +++ b/src/OpenColorIO/transforms/Lut1DTransform.cpp @@ -71,7 +71,7 @@ void Lut1DTransformImpl::validate() const std::ostringstream oss; oss << "Lut1DTransform validation failed: "; oss << ex.what(); - throw Exception(oss.str().c_str()); + throw Exception(oss); } } @@ -118,7 +118,7 @@ void CheckLUT1DIndex(const char * function, unsigned long index, unsigned long s oss << "Lut1DTransform " << function << ": index ("; oss << index << ") should be less than the length ("; oss << size << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } } diff --git a/src/OpenColorIO/transforms/Lut3DTransform.cpp b/src/OpenColorIO/transforms/Lut3DTransform.cpp index 26f9eac1d2..b0c0df134f 100644 --- a/src/OpenColorIO/transforms/Lut3DTransform.cpp +++ b/src/OpenColorIO/transforms/Lut3DTransform.cpp @@ -67,7 +67,7 @@ void Lut3DTransformImpl::validate() const { std::string errMsg("Lut3DTransform validation failed: "); errMsg += ex.what(); - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } } @@ -123,7 +123,7 @@ void CheckLUT3DIndex(const char * function, oss << "Lut3DTransform " << function << ": " << component << " index ("; oss << index << ") should be less than the grid size ("; oss << size << ")."; - throw Exception(oss.str().c_str()); + throw Exception(oss); } } } diff --git a/src/OpenColorIO/transforms/MatrixTransform.cpp b/src/OpenColorIO/transforms/MatrixTransform.cpp index d9991bd4e3..1282c1d68e 100755 --- a/src/OpenColorIO/transforms/MatrixTransform.cpp +++ b/src/OpenColorIO/transforms/MatrixTransform.cpp @@ -48,7 +48,7 @@ void MatrixTransformImpl::validate() const { std::string errMsg("MatrixTransform validation failed: "); errMsg += ex.what(); - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } } @@ -179,7 +179,7 @@ void MatrixTransform::Fit(double * m44, double * offset4, os << "Max value equals min value '"; os << oldmax4[i] << "' in channel index "; os << i << "."; - throw Exception(os.str().c_str()); + throw Exception(os); } if(m44) m44[5*i] = (newmax4[i]-newmin4[i]) / denom; diff --git a/src/OpenColorIO/transforms/RangeTransform.cpp b/src/OpenColorIO/transforms/RangeTransform.cpp index 745cb20e37..c4a0c90015 100644 --- a/src/OpenColorIO/transforms/RangeTransform.cpp +++ b/src/OpenColorIO/transforms/RangeTransform.cpp @@ -68,7 +68,7 @@ void RangeTransformImpl::validate() const { std::string errMsg("RangeTransform validation failed: "); errMsg += ex.what(); - throw Exception(errMsg.c_str()); + throw Exception(errMsg); } } diff --git a/src/apps/ociolutimage/main.cpp b/src/apps/ociolutimage/main.cpp index c34831ce43..73eae732cc 100644 --- a/src/apps/ociolutimage/main.cpp +++ b/src/apps/ociolutimage/main.cpp @@ -80,7 +80,7 @@ void Generate(int cubesize, int maxwidth, std::ostringstream os; os << "You must specify an OCIO configuration "; os << "(either with --config or $OCIO)."; - throw OCIO::Exception(os.str().c_str()); + throw OCIO::Exception(os); } OCIO::ConstCPUProcessorRcPtr processor = @@ -112,7 +112,7 @@ void Extract(int cubesize, int maxwidth, os << "Image does not have expected dimensions. "; os << "Expected " << width << "x" << height << ", "; os << "Found " << img.getWidth() << "x" << img.getHeight(); - throw OCIO::Exception(os.str().c_str()); + throw OCIO::Exception(os); } if (img.getNumChannels() != 3) @@ -287,7 +287,7 @@ void WriteLut3D(const std::string & filename, const float* lutdata, int edgeLen) os << "Only .spi3d writing is currently supported. "; os << "As a work around, please write a .spi3d file, and then use "; os << "ociobakelut for transcoding."; - throw OCIO::Exception(os.str().c_str()); + throw OCIO::Exception(os); } std::ofstream output; @@ -296,7 +296,7 @@ void WriteLut3D(const std::string & filename, const float* lutdata, int edgeLen) { std::ostringstream os; os << "Error opening " << filename << " for writing."; - throw OCIO::Exception(os.str().c_str()); + throw OCIO::Exception(os); } output << "SPILUT 1.0\n"; diff --git a/src/apps/ociomakeclf/main.cpp b/src/apps/ociomakeclf/main.cpp index b79c771328..d4a74e648f 100644 --- a/src/apps/ociomakeclf/main.cpp +++ b/src/apps/ociomakeclf/main.cpp @@ -73,7 +73,7 @@ void CreateOutputLutFile(const std::string & outLutFilepath, OCIO::ConstGroupTra << outLutFilepath << "'." << std::endl; - throw OCIO::Exception(oss.str().c_str()); + throw OCIO::Exception(oss); } } diff --git a/src/apps/ocioperf/main.cpp b/src/apps/ocioperf/main.cpp index a3af75a587..e3833387c4 100644 --- a/src/apps/ocioperf/main.cpp +++ b/src/apps/ocioperf/main.cpp @@ -440,7 +440,7 @@ int main(int argc, const char **argv) { std::string err("Unsupported bit-depth: "); err += str; - throw OCIO::Exception(err.c_str()); + throw OCIO::Exception(err); } return bd; diff --git a/src/bindings/java/JNIUtil.cpp b/src/bindings/java/JNIUtil.cpp index eae5fbe2a2..2a0e53f94d 100644 --- a/src/bindings/java/JNIUtil.cpp +++ b/src/bindings/java/JNIUtil.cpp @@ -23,14 +23,14 @@ float* GetJFloatBuffer(JNIEnv * env, jobject buffer, int32_t len) { std::ostringstream err; err << "the FloatBuffer object is not 'direct' it needs to be created "; err << "from a ByteBuffer.allocateDirect(..).asFloatBuffer() call."; - throw Exception(err.str().c_str()); + throw Exception(err); } if(env->GetDirectBufferCapacity(buffer) != len) { std::ostringstream err; err << "the FloatBuffer object is not allocated correctly it needs to "; err << "of size " << len << " but is "; err << env->GetDirectBufferCapacity(buffer) << "."; - throw Exception(err.str().c_str()); + throw Exception(err); } return (float*)env->GetDirectBufferAddress(buffer); } diff --git a/src/bindings/python/PyUtils.cpp b/src/bindings/python/PyUtils.cpp index 23be750685..5c9a8fdec4 100644 --- a/src/bindings/python/PyUtils.cpp +++ b/src/bindings/python/PyUtils.cpp @@ -79,7 +79,7 @@ py::dtype bitDepthToDtype(BitDepth bitDepth) default: err = "Error: Unsupported bit-depth: "; err += BitDepthToString(bitDepth); - throw Exception(err.c_str()); + throw Exception(err); } return py::dtype(name); @@ -106,7 +106,7 @@ py::ssize_t bitDepthToBytes(BitDepth bitDepth) default: err = "Error: Unsupported bit-depth: "; err += BitDepthToString(bitDepth); - throw Exception(err.c_str()); + throw Exception(err); } } diff --git a/src/libutils/imageioapphelpers/imageio.cpp b/src/libutils/imageioapphelpers/imageio.cpp index b1701f8909..8f317eb936 100644 --- a/src/libutils/imageioapphelpers/imageio.cpp +++ b/src/libutils/imageioapphelpers/imageio.cpp @@ -29,7 +29,7 @@ std::vector GetChannelNames(const ChannelOrdering & chanOrder) { std::stringstream ss; ss << "Error: Unsupported channel ordering: " << chanOrder; - throw Exception(ss.str().c_str()); + throw Exception(ss); } } } @@ -49,7 +49,7 @@ size_t GetNumChannels(const ChannelOrdering & chanOrder) { std::stringstream ss; ss << "Error: Unsupported channel ordering: " << chanOrder; - throw Exception(ss.str().c_str()); + throw Exception(ss); } } } @@ -75,7 +75,7 @@ unsigned GetChannelSizeInBytes(BitDepth bitdepth) { std::stringstream ss; ss << "Error: Unsupported bitdepth: " << BitDepthToString(bitdepth); - throw Exception(ss.str().c_str()); + throw Exception(ss); } } } diff --git a/src/libutils/imageioapphelpers/imageio_exr.cpp b/src/libutils/imageioapphelpers/imageio_exr.cpp index a53f9c745c..4511ba2bd6 100644 --- a/src/libutils/imageioapphelpers/imageio_exr.cpp +++ b/src/libutils/imageioapphelpers/imageio_exr.cpp @@ -34,7 +34,7 @@ BitDepth BitDepthFromPixelType(Imf::PixelType type) { std::stringstream ss; ss << "Error: Unsupported pixel type: " << type; - throw Exception(ss.str().c_str()); + throw Exception(ss); } } } @@ -56,7 +56,7 @@ Imf::PixelType BitDepthToPixelType(BitDepth bitdepth) { std::stringstream ss; ss << "Error: Unsupported bitdepth: " << BitDepthToString(bitdepth); - throw Exception(ss.str().c_str()); + throw Exception(ss); } } } diff --git a/src/libutils/imageioapphelpers/imageio_oiio.cpp b/src/libutils/imageioapphelpers/imageio_oiio.cpp index 9505af6ee6..a4af20735b 100644 --- a/src/libutils/imageioapphelpers/imageio_oiio.cpp +++ b/src/libutils/imageioapphelpers/imageio_oiio.cpp @@ -37,7 +37,7 @@ BitDepth BitDepthFromTypeDesc(OIIO::TypeDesc type) { std::stringstream ss; ss << "Error: Unsupported type desc: " << type; - throw Exception(ss.str().c_str()); + throw Exception(ss); } } } @@ -59,7 +59,7 @@ OIIO::TypeDesc BitDepthToTypeDesc(BitDepth bitdepth) { std::stringstream ss; ss << "Error: Unsupported bitdepth: " << BitDepthToString(bitdepth); - throw Exception(ss.str().c_str()); + throw Exception(ss); } } } @@ -249,7 +249,7 @@ class ImageIO::Impl { std::stringstream ss; ss << "Error: Could not read image: " << m_buffer.geterror(); - throw Exception(ss.str().c_str()); + throw Exception(); } } @@ -261,7 +261,7 @@ class ImageIO::Impl { std::stringstream ss; ss << "Error: Could not write image: " << m_buffer.geterror(); - throw Exception(ss.str().c_str()); + throw Exception(); } } diff --git a/src/libutils/oglapphelpers/glsl.cpp b/src/libutils/oglapphelpers/glsl.cpp index 16709fa3e7..794bcfbd40 100644 --- a/src/libutils/oglapphelpers/glsl.cpp +++ b/src/libutils/oglapphelpers/glsl.cpp @@ -53,7 +53,7 @@ void CheckStatus() std::string error; if (GetGLError(error)) { - throw Exception(error.c_str()); + throw Exception(error); } } @@ -173,7 +173,7 @@ GLuint CompileShaderText(GLenum shaderType, const char * text) err += "\n"; err += text; - throw Exception(err.c_str()); + throw Exception(err); } return shader; @@ -204,7 +204,7 @@ void LinkShaders(GLuint program, GLuint fragShader) std::string err("Shader link error:\n"); err += log; - throw Exception(err.c_str()); + throw Exception(err); } } } @@ -229,7 +229,7 @@ void OpenGLBuilder::Uniform::setUp(unsigned program) std::string err("Shader parameter "); err += m_name; err += " not found: "; - throw Exception(err.c_str()); + throw Exception(err); } } diff --git a/tests/cpu/MathUtils_tests.cpp b/tests/cpu/MathUtils_tests.cpp index fda8c82b50..ffce1b3a3f 100644 --- a/tests/cpu/MathUtils_tests.cpp +++ b/tests/cpu/MathUtils_tests.cpp @@ -247,7 +247,7 @@ OCIO_ADD_TEST(MathUtils, mxb_invert) #define KEEP_DENORMS false #define COMPRESS_DENORMS true -#define TEST_CHECK_MESSAGE(a, msg) if(!(a)) throw OCIO::Exception(msg.c_str()) +#define TEST_CHECK_MESSAGE(a, msg) if(!(a)) throw OCIO::Exception(msg) namespace diff --git a/tests/cpu/UnitTestUtils.cpp b/tests/cpu/UnitTestUtils.cpp index f298db0f3e..8037ecc432 100644 --- a/tests/cpu/UnitTestUtils.cpp +++ b/tests/cpu/UnitTestUtils.cpp @@ -90,7 +90,7 @@ std::string CreateTemporaryDirectory(const std::string & name) std::ostringstream error; error << "Could not create a temporary directory." << " Make sure that the directory do " << "not already exist or sufficient permissions are set"; - throw Exception(error.str().c_str()); + throw Exception(error); } return directory; diff --git a/tests/gpu/GPUUnitTest.cpp b/tests/gpu/GPUUnitTest.cpp index c6c1bd0715..330c0fab8c 100644 --- a/tests/gpu/GPUUnitTest.cpp +++ b/tests/gpu/GPUUnitTest.cpp @@ -500,7 +500,7 @@ namespace << gpuImage[4 * pixelIdx + 0] << ", " << gpuImage[4 * pixelIdx + 1] << ", " << gpuImage[4 * pixelIdx + 2] << ", " << gpuImage[4 * pixelIdx + 3] << "}\n"; } - throw OCIO::Exception(err.str().c_str()); + throw OCIO::Exception(err); } else {