blob: 90b3eca8732bd33f10aae21be6efa23b4b7cc745 [file] [log] [blame]
akmhoque31d1d4b2014-05-05 22:08:14 -05001#ifndef NLSR_NAME_HELPER_HPP
2#define NLSR_NAME_HELPER_HPP
3
akmhoque157b0a42014-05-13 00:26:37 -05004#include <boost/algorithm/string.hpp>
5#include <boost/algorithm/string/regex_find_format.hpp>
6#include <boost/regex.hpp>
akmhoque31d1d4b2014-05-05 22:08:14 -05007#include <boost/cstdint.hpp>
8#include <ndn-cxx/name-component.hpp>
9#include <ndn-cxx/name.hpp>
10
11namespace nlsr {
12namespace util {
13/**
14 * @brief search a name component in ndn::Name and return the position of the component
15 * @param name where to search the searchString
16 * @param searchString, the string to search in name
17 * @retrun int32_t -1 if searchString not found else return the position
18 * starting from 0
19 */
20
21inline static int32_t
22getNameComponentPosition(const ndn::Name& name, const std::string& searchString)
23{
24 ndn::name::Component component(searchString);
25 size_t nameSize = name.size();
akmhoque157b0a42014-05-13 00:26:37 -050026 for (uint32_t i = 0; i < nameSize; i++) {
27 if (component == name[i]) {
akmhoque31d1d4b2014-05-05 22:08:14 -050028 return (int32_t)i;
29 }
30 }
31 return -1;
32}
33
34} //namespace util
35
36} // namespace nlsr
37
38#endif //NLSR_NAME_HELPER_HPP