MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / SplitStringEnvStyle

Function SplitStringEnvStyle

src/OpenColorIO/ParseUtils.cpp:749–808  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

747}
748
749StringUtils::StringVec SplitStringEnvStyle(const std::string & str)
750{
751 const std::string s = StringUtils::Trim(str);
752 if( s.size() == 0 )
753 {
754 // Look parsing always wants a result, even if an empty string.
755 return { "" };
756 }
757
758 StringUtils::StringVec outputvec;
759 auto foundComma = s.find_first_of(",");
760 auto foundColon = s.find_first_of(":");
761
762 if( foundComma != std::string::npos ||
763 foundColon != std::string::npos )
764 {
765 int currentPos = 0;
766 while( s.size() > 0 &&
767 currentPos <= (int)s.size() )
768 {
769 int nameEndPos = FindEndOfName( s,
770 currentPos,
771 foundComma != std::string::npos ? ',' : ':' );
772 if(nameEndPos > currentPos)
773 {
774 outputvec.push_back(s.substr(currentPos, nameEndPos - currentPos));
775 currentPos = nameEndPos + 1;
776 }
777 else
778 {
779 outputvec.push_back("");
780 currentPos += 1;
781 }
782 }
783 }
784 else
785 {
786 // If there is no comma or colon, consider the string as a single element.
787 outputvec.push_back(s);
788 }
789
790 for ( auto & val : outputvec )
791 {
792 const std::string trimmedValue = StringUtils::Trim(val);
793
794 // If the trimmed value is surrounded by quotes, remove them.
795 if( trimmedValue.size() > 1 &&
796 trimmedValue[0] == '"' &&
797 trimmedValue[trimmedValue.size() - 1] == '"' )
798 {
799 val = trimmedValue.substr(1, trimmedValue.size() - 2);
800 }
801 else
802 {
803 val = trimmedValue;
804 }
805 }
806

Callers 7

saveFunction · 0.85
LookParse.cppFile · 0.85
ImplMethod · 0.85
setActiveDisplaysMethod · 0.85
setActiveViewsMethod · 0.85
saveFunction · 0.85
OCIO_ADD_TESTFunction · 0.85

Calls 4

FindEndOfNameFunction · 0.85
TrimFunction · 0.50
sizeMethod · 0.45
push_backMethod · 0.45

Tested by 1

OCIO_ADD_TESTFunction · 0.68