Bitstream Interpretation Library (BIL)  0.1
DeviceNameUtil.cpp
Go to the documentation of this file.
1 
6 #include <cstdlib>
7 #include <cstring>
9 
10 using namespace bil;
11 
12 
13 std::string bil::removePackageAndSpeed(const char* deviceName)
14 {
15  // get length until beginning of package name
16  const char* sPtr = strstr(deviceName, "ff");
17  size_t len;
18  if (0 != sPtr) len = sPtr - deviceName;
19  else len = strlen(deviceName);
20 
21  // return string until package name
22  return std::string(deviceName, len);
23 }
24 
25 
26 std::string bil::removeSpeed(const char* deviceName)
27 {
28  // get length until beginning of speed grade
29  const char* sPtr = strchr(deviceName, '-');
30  size_t len;
31  if (0 != sPtr) len = sPtr - deviceName;
32  else len = strlen(deviceName);
33 
34  // return string until package name
35  return std::string(deviceName, len);
36 }