blob: 56da4360d7da27bba0fded6f35a933e53c94eb5d [file] [log] [blame]
tylerliu01d63ca2020-10-06 16:29:23 -07001//
2// Created by Tyler on 10/6/20.
3//
4
5#include "assignment-param.hpp"
6
7namespace ndn {
8namespace ndncert {
9
tylerliu01d63ca2020-10-06 16:29:23 -070010NDNCERT_REGISTER_FUNCFACTORY(AssignmentParam, "param");
11
Zhiyi Zhang8683ec92020-10-07 18:18:35 -070012AssignmentParam::AssignmentParam(const std::string& format)
13 : NameAssignmentFuncFactory("param", format)
14{}
15
16std::vector<PartialName>
17AssignmentParam::assignName(const std::vector<std::tuple<std::string, std::string>>& params)
tylerliu01d63ca2020-10-06 16:29:23 -070018{
Zhiyi Zhang8683ec92020-10-07 18:18:35 -070019 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));
tylerliu01d63ca2020-10-06 16:29:23 -070026 }
Zhiyi Zhang8683ec92020-10-07 18:18:35 -070027 else {
28 return resultList;
tylerliu01d63ca2020-10-06 16:29:23 -070029 }
Zhiyi Zhang8683ec92020-10-07 18:18:35 -070030 }
31 resultList.push_back(std::move(result));
32 return resultList;
tylerliu01d63ca2020-10-06 16:29:23 -070033}
34
Zhiyi Zhang8683ec92020-10-07 18:18:35 -070035} // namespace ndncert
36} // namespace ndn