MCPcopy Create free account
hub / github.com/apple/foundationdb / parseOptionValues

Function parseOptionValues

fdbclient/MultiVersionTransaction.actor.cpp:2825–2862  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2823}
2824
2825std::vector<std::string> parseOptionValues(std::string valueStr) {
2826 std::string specialCharacters = "\\";
2827 specialCharacters += ENV_VAR_PATH_SEPARATOR;
2828
2829 std::vector<std::string> values;
2830
2831 size_t index = 0;
2832 size_t nextIndex = 0;
2833 std::stringstream ss;
2834 while (true) {
2835 nextIndex = valueStr.find_first_of(specialCharacters, index);
2836 char c = nextIndex == valueStr.npos ? ENV_VAR_PATH_SEPARATOR : valueStr[nextIndex];
2837
2838 if (c == '\\') {
2839 if (valueStr.size() == nextIndex + 1 || specialCharacters.find(valueStr[nextIndex + 1]) == valueStr.npos) {
2840 throw invalid_option_value();
2841 }
2842
2843 ss << valueStr.substr(index, nextIndex - index);
2844 ss << valueStr[nextIndex + 1];
2845
2846 index = nextIndex + 2;
2847 } else if (c == ENV_VAR_PATH_SEPARATOR) {
2848 ss << valueStr.substr(index, nextIndex - index);
2849 values.push_back(ss.str());
2850 ss.str(std::string());
2851
2852 if (nextIndex == valueStr.npos) {
2853 break;
2854 }
2855 index = nextIndex + 1;
2856 } else {
2857 ASSERT(false);
2858 }
2859 }
2860
2861 return values;
2862}
2863
2864// This function sets all environment variable options which have not been set previously by a call to this function.
2865// If an option has multiple values and setting one of those values failed with an error, then only those options

Calls 5

substrMethod · 0.80
sizeMethod · 0.45
findMethod · 0.45
push_backMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected