8#include <botan/scan_name.h>
9#include <botan/parsing.h>
10#include <botan/exceptn.h>
16std::string make_arg(
const std::vector<std::pair<size_t, std::string>>&
name,
size_t start)
18 std::string output =
name[start].second;
19 size_t level =
name[start].first;
21 size_t paren_depth = 0;
23 for(
size_t i = start + 1; i !=
name.size(); ++i)
25 if(
name[i].first <=
name[start].first)
28 if(
name[i].first > level)
30 output +=
"(" +
name[i].second;
33 else if(
name[i].first < level)
35 for (
size_t j =
name[i].first; j < level; j++) {
39 output +=
"," +
name[i].second;
43 if(output[output.size() - 1] !=
'(')
45 output +=
name[i].second;
48 level =
name[i].first;
51 for(
size_t i = 0; i != paren_depth; ++i)
63SCAN_Name::SCAN_Name(std::string algo_spec) : m_orig_algo_spec(algo_spec), m_alg_name(), m_args(), m_mode_info()
65 if(algo_spec.size() == 0)
68 std::vector<std::pair<size_t, std::string>>
name;
70 std::pair<size_t, std::string> accum = std::make_pair(level,
"");
72 const std::string decoding_error =
"Bad SCAN name '" + algo_spec +
"': ";
74 for(
size_t i = 0; i != algo_spec.size(); ++i)
76 char c = algo_spec[i];
78 if(c ==
'/' || c ==
',' || c ==
'(' || c ==
')')
89 if(c ==
'/' && level > 0)
90 accum.second.push_back(c);
93 if(accum.second !=
"")
94 name.push_back(accum);
95 accum = std::make_pair(level,
"");
99 accum.second.push_back(c);
102 if(accum.second !=
"")
103 name.push_back(accum);
111 m_alg_name =
name[0].second;
113 bool in_modes =
false;
115 for(
size_t i = 1; i !=
name.size(); ++i)
117 if(
name[i].first == 0)
119 m_mode_info.push_back(make_arg(
name, i));
122 else if(
name[i].first == 1 && !in_modes)
123 m_args.push_back(make_arg(
name, i));
131 " out of range for '" +
to_string() +
"'");
std::string arg(size_t i) const
const std::string & to_string() const
SCAN_Name(const char *algo_spec)
size_t arg_as_integer(size_t i, size_t def_value) const
std::string to_string(const BER_Object &obj)
uint32_t to_u32bit(const std::string &str)