Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 41 additions & 40 deletions .github/workflows/ci_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ jobs:
strategy:
fail-fast: true
matrix:
build: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
# build: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
build: [1, 2, 4, 5, 7, 8, 10, 11, 12]
include:
# -------------------------------------------------------------------
# VFX CY2026 (Python 3.13)
Expand Down Expand Up @@ -108,19 +109,19 @@ jobs:
# -------------------------------------------------------------------
# VFX CY2025 (Python 3.11)
# -------------------------------------------------------------------
- build: 9
build-type: Debug
build-shared: 'ON'
build-docs: 'OFF'
build-openfx: 'ON'
use-simd: 'ON'
use-oiio: 'ON'
cxx-standard: 20
cxx-compiler: clang++
cc-compiler: clang
compiler-desc: Clang
vfx-cy: 2025
install-ext-packages: MISSING
# - build: 9
# build-type: Debug
# build-shared: 'ON'
# build-docs: 'OFF'
# build-openfx: 'ON'
# use-simd: 'ON'
# use-oiio: 'ON'
# cxx-standard: 20
# cxx-compiler: clang++
# cc-compiler: clang
# compiler-desc: Clang
# vfx-cy: 2025
# install-ext-packages: MISSING
- build: 8
build-type: Release
build-shared: 'ON'
Expand Down Expand Up @@ -150,19 +151,19 @@ jobs:
# -------------------------------------------------------------------
# VFX CY2024 (Python 3.11)
# -------------------------------------------------------------------
- build: 6
build-type: Debug
build-shared: 'ON'
build-docs: 'OFF'
build-openfx: 'ON'
use-simd: 'ON'
use-oiio: 'ON'
cxx-standard: 20
cxx-compiler: clang++
cc-compiler: clang
compiler-desc: Clang
vfx-cy: 2024
install-ext-packages: MISSING
# - build: 6
# build-type: Debug
# build-shared: 'ON'
# build-docs: 'OFF'
# build-openfx: 'ON'
# use-simd: 'ON'
# use-oiio: 'ON'
# cxx-standard: 20
# cxx-compiler: clang++
# cc-compiler: clang
# compiler-desc: Clang
# vfx-cy: 2024
# install-ext-packages: MISSING
- build: 5
build-type: Release
build-shared: 'ON'
Expand Down Expand Up @@ -192,19 +193,19 @@ jobs:
# -------------------------------------------------------------------
# VFX CY2023 (Python 3.10)
# -------------------------------------------------------------------
- build: 3
build-type: Debug
build-shared: 'ON'
build-docs: 'OFF'
build-openfx: 'ON'
use-simd: 'ON'
use-oiio: 'ON'
cxx-standard: 20
cxx-compiler: clang++
cc-compiler: clang
compiler-desc: Clang
vfx-cy: 2023
install-ext-packages: MISSING
# - build: 3
# build-type: Debug
# build-shared: 'ON'
# build-docs: 'OFF'
# build-openfx: 'ON'
# use-simd: 'ON'
# use-oiio: 'ON'
# cxx-standard: 20
# cxx-compiler: clang++
# cc-compiler: clang
# compiler-desc: Clang
# vfx-cy: 2023
# install-ext-packages: MISSING
- build: 2
build-type: Release
build-shared: 'ON'
Expand Down
5 changes: 3 additions & 2 deletions src/OpenColorIO/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2561,7 +2561,8 @@ const char * Config::getInactiveColorSpaces() const
bool Config::isInactiveColorSpace(const char * colorspace) const noexcept
{
StringUtils::StringVec svec;
pystring::split(getImpl()->m_inactiveColorSpaceNamesConf.c_str(), svec, ", ");
svec = StringUtils::Split(getImpl()->m_inactiveColorSpaceNamesConf.c_str(), ',');
StringUtils::Trim(svec);

for (size_t i = 0; i < svec.size(); i++)
{
Expand Down Expand Up @@ -6026,7 +6027,7 @@ bool Config::isArchivable() const
// 1) Path may not be absolute.
pystring::os::path::isabs(normPath) ||
// 2) Path may not start with double dot ".." (going above working directory).
pystring::startswith(normPath, "..") ||
StringUtils::StartsWith(normPath, "..") ||
// 3) A context variable may not be located at the start of the path.
(ContainsContextVariables(path) &&
(StringUtils::Find(path, "$") == 0 ||
Expand Down
2 changes: 1 addition & 1 deletion src/OpenColorIO/OCIOZArchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void addSupportedFiles(void * archiver, const char * path, const char * configWo
std::string root, ext;
pystring::os::path::splitext(root, ext, std::string(entry->d_name));
// Strip leading dot character in order to get the extension name only.
ext = pystring::lstrip(ext, ".");
ext = StringUtils::LeftTrim(ext, '.');

// Check if the extension is supported. Using logic from LoadFileUncached().
FormatRegistry & formatRegistry = FormatRegistry::GetInstance();
Expand Down
5 changes: 2 additions & 3 deletions src/OpenColorIO/Op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include <cstring>
#include <sstream>

#include <pystring.h>

#include <OpenColorIO/OpenColorIO.h>

#include "Logging.h"
Expand All @@ -23,6 +21,7 @@
#include "ops/lut1d/Lut1DOp.h"
#include "ops/lut3d/Lut3DOp.h"
#include "ops/range/RangeOp.h"
#include "utils/StringUtils.h"

namespace OCIO_NAMESPACE
{
Expand Down Expand Up @@ -478,7 +477,7 @@ std::string SerializeOpVec(const OpRcPtrVec & ops, int indent)
{
const OpRcPtr & op = ops[idx];

oss << pystring::mul(" ", indent);
oss << StringUtils::Multiply(" ", indent);
oss << "Op " << idx << ": " << *op << " ";
oss << op->getCacheID();

Expand Down
2 changes: 1 addition & 1 deletion src/OpenColorIO/fileformats/FileFormatIridasLook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ class XMLParserHelper
if (pImpl->m_size)
{
std::string size_raw = std::string(s, len);
std::string size_clean = pystring::strip(size_raw, "'\" "); // strip quotes and space
std::string size_clean = StringUtils::Trim(size_raw, "'\" "); // strip quotes and space

long int size_3d{};

Expand Down
2 changes: 1 addition & 1 deletion src/OpenColorIO/transforms/FileTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ void LoadFileUncached(FileFormat * & returnFormat,
std::string root, extension;
pystring::os::path::splitext(root, extension, filepath);
// remove the leading '.'
extension = pystring::replace(extension,".","",1);
extension = StringUtils::Replace(extension, ".", "", 1);

FormatRegistry & formatRegistry = FormatRegistry::GetInstance();

Expand Down
76 changes: 62 additions & 14 deletions src/utils/StringUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ inline bool StartsWith(const std::string& str, char prefix)
}

// Starting from the left, trim the character.
inline std::string LeftTrim(std::string str, const std::string & prefix)
{
size_t first_good_char = str.find_first_not_of(prefix);
if (first_good_char == std::string::npos) { return str; }
str.erase(0, first_good_char);
return str;
}

inline std::string LeftTrim(std::string str, char c)
{
const auto it = std::find_if(str.begin(), str.end(), [&c](char ch) { return c!=ch; });
Expand All @@ -126,6 +134,14 @@ inline std::string LeftTrim(std::string str)
}

// Starting from the right, trim the character.
inline std::string RightTrim(std::string str, const std::string & suffix)
{
size_t last_good_char = str.find_last_not_of(suffix);
if (last_good_char == std::string::npos) { return str; }
str.erase(last_good_char + 1);
return str;
}

inline std::string RightTrim(std::string str, char c)
{
const auto it = std::find_if(str.rbegin(), str.rend(), [&c](char ch) { return c!=ch; });
Expand All @@ -149,6 +165,11 @@ inline std::string Trim(std::string str, char c)
}

// From the left and right, trim all the space characters i.e. space, tabulation, etc.
inline std::string Trim(std::string str, const std::string & chars)
{
return LeftTrim(RightTrim(str, chars), chars);
}

inline std::string Trim(std::string str)
{
return LeftTrim(RightTrim(str));
Expand Down Expand Up @@ -249,39 +270,54 @@ inline std::string::size_type ReverseFind(const std::string & subject, const std
return subject.rfind(search);
}

// In place replace the 'search' substring by the 'replace' string in 'str'.
inline bool ReplaceInPlace(std::string & subject, const std::string & search, const std::string & replace)
// In place replace the 'search' substring by the 'replace' string in 'subject'. Limited by 'count'.
inline bool ReplaceInPlace(std::string & subject, const std::string & search, const std::string & replace, int count)
{
if (search.empty()) return false;

bool changed = false;

size_t pos = 0;
size_t pos = 0;
int iter = 0;
while ((pos = subject.find(search, pos)) != std::string::npos)
{
if ( count > -1 && iter >= count ) { break; }
subject.replace(pos, search.length(), replace);
pos += replace.length();
changed = true;
++iter;
}

return changed;
}

// Replace the 'search' substring by the 'replace' string in 'str'.
inline std::string Replace(const std::string & subject, const std::string & search, const std::string & replace)
// In place replace the 'search' substring by the 'replace' string in 'subject'.
inline bool ReplaceInPlace(std::string & subject, const std::string & search, const std::string & replace)
{
return ReplaceInPlace(subject, search, replace, -1);
}

// Replace the 'search' substring by the 'replace' string in 'subject'. Limited by 'count'.
inline std::string Replace(const std::string & subject, const std::string & search, const std::string & replace, int count)
{
std::string str{subject};
ReplaceInPlace(str, search, replace);
ReplaceInPlace(str, search, replace, count);
return str;
}

// Replace the 'search' substring by the 'replace' string in 'subject'.
inline std::string Replace(const std::string & subject, const std::string & search, const std::string & replace)
{
return Replace(subject, search, replace, -1);
}

// Check if the 'entry' is in the 'list' using a case insensitive comparison.
inline bool Contain(const StringVec & list, const std::string & entry)
{
const auto it = std::find_if(list.begin(), list.end(),
[entry](const std::string & ent)
{
return Compare(ent.c_str(), entry.c_str());
const auto it = std::find_if(list.begin(), list.end(),
[entry](const std::string & ent)
{
return Compare(ent.c_str(), entry.c_str());
});
return it!=list.end();
}
Expand All @@ -290,10 +326,10 @@ inline bool Contain(const StringVec & list, const std::string & entry)
// It returns true if found.
inline bool Remove(StringVec & list, const std::string & entry)
{
const auto it = std::find_if(list.begin(), list.end(),
[entry](const std::string & ent)
{
return Compare(ent.c_str(), entry.c_str());
const auto it = std::find_if(list.begin(), list.end(),
[entry](const std::string & ent)
{
return Compare(ent.c_str(), entry.c_str());
});
if (it!=list.end())
{
Expand All @@ -304,6 +340,18 @@ inline bool Remove(StringVec & list, const std::string & entry)
return false;
}

// Repeat the 'str' by the 'n' value.
inline std::string Multiply(const std::string & str, int n)
{
// Early exits
if (n <= 0) return "";
if (n == 1) return str;

std::ostringstream os;
for(int i = 0; i < n; ++i) { os << str; }
return os.str();
}

} // namespace StringUtils

#endif // INCLUDED_STRINGUTILS_H
Loading