name-helper.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
23 #ifndef NLSR_NAME_HELPER_HPP
24 #define NLSR_NAME_HELPER_HPP
25 
26 #include <boost/algorithm/string.hpp>
27 #include <boost/algorithm/string/regex_find_format.hpp>
28 #include <boost/regex.hpp>
29 #include <boost/cstdint.hpp>
30 #include <ndn-cxx/name-component.hpp>
31 #include <ndn-cxx/name.hpp>
32 
33 namespace nlsr {
34 namespace util {
35 
43 inline static int32_t
44 getNameComponentPosition(const ndn::Name& name, const std::string& searchString)
45 {
46  ndn::name::Component component(searchString);
47  size_t nameSize = name.size();
48  for (uint32_t i = 0; i < nameSize; i++) {
49  if (component == name[i]) {
50  return (int32_t)i;
51  }
52  }
53  return -1;
54 }
55 
56 } // namespace util
57 
58 } // namespace nlsr
59 
60 #endif //NLSR_NAME_HELPER_HPP
static int32_t getNameComponentPosition(const ndn::Name &name, const std::string &searchString)
search a name component in ndn::Name and return the position of the component
Definition: name-helper.hpp:44
Copyright (c) 2014-2017, The University of Memphis, Regents of the University of California, Arizona Board of Regents.