Bitstream Interpretation Library (BIL)  0.1
V5FrameAddressString.cpp
Go to the documentation of this file.
1 
6 #include <cstdio>
9 
10 using namespace bil;
11 
12 static char sBuf[64];
13 const char* const LOWERHALF_STR = "LOWERHALF";
14 const char* const UPPERHALF_STR = "UPPERHALF";
15 
16 
17 std::string bil::toRawAddressString(const V5FrameAddress& address)
18 {
19  // format raw address
20  sprintf(sBuf, "0x%.8x", address.rawAddress());
21  // return composed string
22  return std::string(sBuf);
23 }
24 
25 
26 std::string bil::toExpandedString(const V5FrameAddress& address)
27 {
28  // convert upper/lower flag
29  char c = address.lowerHalf() ? '1' : '0';
30  // format all address parts into one string
31  sprintf(sBuf, "%u %c %u %u %u", address.block(), c, address.rowIndex(),
32  address.columnIndex(), address.frameIndex());
33  // return composed string
34  return std::string(sBuf);
35 }
36 
37 
38 std::string bil::toSymbolicString(const V5FrameAddress& address)
39 {
40  // convert block
41  V5CfgBlock::block_t block = address.block();
42  const char* blockName = V5CfgBlock::toString(block);
43  // convert upper/lower flag
44  const char* upperFlagName = address.lowerHalf() ? LOWERHALF_STR : UPPERHALF_STR;
45  // format all address parts into one string
46  if (0 == blockName)
47  sprintf(sBuf, "%u %s %u %u %u", block, upperFlagName,
48  address.rowIndex(), address.columnIndex(), address.frameIndex());
49  else
50  sprintf(sBuf, "%s %s %u %u %u", blockName, upperFlagName,
51  address.rowIndex(), address.columnIndex(), address.frameIndex());
52  // return composed string
53  return std::string(sBuf);
54 }