58SCAN_Name::SCAN_Name(std::string_view algo_spec) : m_orig_algo_spec(algo_spec), m_alg_name(), m_args(), m_mode_info() {
59 if(algo_spec.empty()) {
60 throw Invalid_Argument(
"Expected algorithm name, got empty string");
63 std::vector<std::pair<size_t, std::string>>
name;
65 std::pair<size_t, std::string> accum = std::make_pair(level,
"");
67 const std::string decoding_error =
"Bad SCAN name '" + m_orig_algo_spec +
"': ";
69 for(
char c : algo_spec) {
70 if(c ==
'/' || c ==
',' || c ==
'(' || c ==
')') {
75 throw Decoding_Error(decoding_error +
"Mismatched parens");
80 if(c ==
'/' && level > 0) {
81 accum.second.push_back(c);
83 if(!accum.second.empty()) {
84 name.push_back(accum);
86 accum = std::make_pair(level,
"");
89 accum.second.push_back(c);
93 if(!accum.second.empty()) {
94 name.push_back(accum);
98 throw Decoding_Error(decoding_error +
"Missing close paren");
102 throw Decoding_Error(decoding_error +
"Empty name");
105 m_alg_name =
name[0].second;
107 bool in_modes =
false;
109 for(
size_t i = 1; i !=
name.size(); ++i) {
110 if(name[i].first == 0) {
111 m_mode_info.push_back(make_arg(name, i));
113 }
else if(
name[i].first == 1 && !in_modes) {
114 m_args.push_back(make_arg(name, i));