Changeset 373 for trunk/lib/utility.cc


Ignore:
Timestamp:
Jun 19, 2007, 11:53:16 PM (14 years ago)
Author:
Peter Johansson
Message:

adding function transforming decimal int to hexadecimal refs #200

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/utility.cc

    r313 r373  
    7979
    8080
     81  std::string hex(int x, u_int width)
     82  {
     83    std::stringstream ss;
     84    ss << std::hex << x;
     85    if (!width)
     86      return ss.str();
     87    if (ss.str().size()<width)
     88      return std::string(width-ss.str().size(), '0') + ss.str();
     89    return ss.str().substr(0, width);
     90  }
     91
     92
    8193  std::string htrim(std::string str)
    8294  {
Note: See TracChangeset for help on using the changeset viewer.