tylerliu | 01d63ca | 2020-10-06 16:29:23 -0700 | [diff] [blame] | 1 | // |
| 2 | // Created by Tyler on 10/6/20. |
| 3 | // |
| 4 | |
| 5 | #include "assignment-param.hpp" |
| 6 | |
| 7 | namespace ndn { |
| 8 | namespace ndncert { |
| 9 | |
tylerliu | 01d63ca | 2020-10-06 16:29:23 -0700 | [diff] [blame] | 10 | NDNCERT_REGISTER_FUNCFACTORY(AssignmentParam, "param"); |
| 11 | |
Zhiyi Zhang | 8683ec9 | 2020-10-07 18:18:35 -0700 | [diff] [blame^] | 12 | AssignmentParam::AssignmentParam(const std::string& format) |
| 13 | : NameAssignmentFuncFactory("param", format) |
| 14 | {} |
| 15 | |
| 16 | std::vector<PartialName> |
| 17 | AssignmentParam::assignName(const std::vector<std::tuple<std::string, std::string>>& params) |
tylerliu | 01d63ca | 2020-10-06 16:29:23 -0700 | [diff] [blame] | 18 | { |
Zhiyi Zhang | 8683ec9 | 2020-10-07 18:18:35 -0700 | [diff] [blame^] | 19 | std::vector<PartialName> resultList; |
| 20 | Name result; |
| 21 | for (const auto& item : m_nameFormat) { |
| 22 | auto it = std::find_if(params.begin(), params.end(), |
| 23 | [&](const std::tuple<std::string, std::string>& e) { return std::get<0>(e) == item; }); |
| 24 | if (it != params.end()) { |
| 25 | result.append(std::get<1>(*it)); |
tylerliu | 01d63ca | 2020-10-06 16:29:23 -0700 | [diff] [blame] | 26 | } |
Zhiyi Zhang | 8683ec9 | 2020-10-07 18:18:35 -0700 | [diff] [blame^] | 27 | else { |
| 28 | return resultList; |
tylerliu | 01d63ca | 2020-10-06 16:29:23 -0700 | [diff] [blame] | 29 | } |
Zhiyi Zhang | 8683ec9 | 2020-10-07 18:18:35 -0700 | [diff] [blame^] | 30 | } |
| 31 | resultList.push_back(std::move(result)); |
| 32 | return resultList; |
tylerliu | 01d63ca | 2020-10-06 16:29:23 -0700 | [diff] [blame] | 33 | } |
| 34 | |
Zhiyi Zhang | 8683ec9 | 2020-10-07 18:18:35 -0700 | [diff] [blame^] | 35 | } // namespace ndncert |
| 36 | } // namespace ndn |