MCPcopy Create free account
hub / github.com/Kitware/CMake / ExpandExpression

Method ExpandExpression

Source/cmWindowsRegistry.cxx:721–769  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

719}
720
721cm::optional<std::vector<std::string>> cmWindowsRegistry::ExpandExpression(
722 cm::string_view expression, View view, cm::string_view separator)
723{
724#if defined(_WIN32) && !defined(__CYGWIN__)
725 static std::string NOTFOUND{ "/REGISTRY-NOTFOUND" };
726
727 this->LastError.clear();
728
729 // compute list of registry views
730 auto views = this->ComputeViews(view);
731 std::vector<std::string> result;
732
733 for (auto v : views) {
734 ExpressionParser parser(expression);
735
736 while (parser.Find()) {
737 try {
738 auto handler =
739 KeyHandler::OpenKey(parser.GetRootKey(), parser.GetSubKey(), v);
740 auto data = handler.ReadValue(parser.GetValueName(),
741 this->SupportedTypes, separator);
742 parser.Replace(data);
743 } catch (registry_error const& e) {
744 this->LastError = e.what();
745 parser.Replace(NOTFOUND);
746 continue;
747 }
748 }
749 result.emplace_back(parser.GetExpression());
750 if (expression == parser.GetExpression()) {
751 // there no substitutions, so can ignore other views
752 break;
753 }
754 }
755
756 return result;
757#else
758 (void)view;
759 (void)separator;
760
761 ExpressionParser parser(expression);
762 if (parser.Find()) {
763 // expression holds unsupported registry access
764 // so the expression cannot be used on this platform
765 return cm::nullopt;
766 }
767 return std::vector<std::string>{ std::string{ expression } };
768#endif
769}

Callers 1

AddUserPathMethod · 0.80

Calls 10

ComputeViewsMethod · 0.95
GetRootKeyMethod · 0.80
GetSubKeyMethod · 0.80
GetValueNameMethod · 0.80
emplace_backMethod · 0.80
clearMethod · 0.45
FindMethod · 0.45
ReadValueMethod · 0.45
ReplaceMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected