Bitstream Interpretation Library (BIL)  0.1
NameSplit.cpp
Go to the documentation of this file.
1 
6 #include <cstdlib>
7 #include <cstring>
9 
10 using namespace bil;
11 
12 
13 bool bil::extractPosition(const char* name, unsigned& x, unsigned& y)
14 {
15  // scan for last occurrence of underscore
16  name = strrchr(name, '_');
17 
18  // read X coordinate
19  if (0 == name) return false;
20  if ('X' != *(++name)) return false;
21  x = strtol(++name, const_cast<char**>(&name), 10);
22 
23  // read Y coordinate
24  if (0 == name) return false;
25  if ('Y' != *(name++)) return false;
26  y = strtol(name, const_cast<char**>(&name), 10);
27 
28  // test for string end
29  return ((0 != name) && (0 == *name));
30 }