@@ -36,26 +36,27 @@ CommandLine& CommandLine::operator=(const CommandLine& from) = default;
36
36
37
37
CommandLine& CommandLine::operator =(CommandLine&& from) = default ;
38
38
39
- bool CommandLine::HasOption (StringView name, size_t * index) const {
40
- auto it = option_index_.find (name.ToString ());
39
+ bool CommandLine::HasOption (std::string_view name, size_t * index) const {
40
+ auto it = option_index_.find (name.data ());
41
41
if (it == option_index_.end ())
42
42
return false ;
43
43
if (index)
44
44
*index = it->second ;
45
45
return true ;
46
46
}
47
47
48
- bool CommandLine::GetOptionValue (StringView name, std::string* value) const {
48
+ bool CommandLine::GetOptionValue (std::string_view name,
49
+ std::string* value) const {
49
50
size_t index;
50
51
if (!HasOption (name, &index))
51
52
return false ;
52
53
*value = options_[index].value ;
53
54
return true ;
54
55
}
55
56
56
- std::vector<fml::StringView > CommandLine::GetOptionValues (
57
- StringView name) const {
58
- std::vector<fml::StringView > ret;
57
+ std::vector<std::string_view > CommandLine::GetOptionValues (
58
+ std::string_view name) const {
59
+ std::vector<std::string_view > ret;
59
60
for (const auto & option : options_) {
60
61
if (option.name == name)
61
62
ret.push_back (option.value );
@@ -64,11 +65,11 @@ std::vector<fml::StringView> CommandLine::GetOptionValues(
64
65
}
65
66
66
67
std::string CommandLine::GetOptionValueWithDefault (
67
- StringView name,
68
- StringView default_value) const {
68
+ std::string_view name,
69
+ std::string_view default_value) const {
69
70
size_t index;
70
71
if (!HasOption (name, &index))
71
- return default_value.ToString () ;
72
+ return { default_value.data (), default_value. size ()} ;
72
73
return options_[index].value ;
73
74
}
74
75
0 commit comments