- Timestamp:
- Jun 19, 2007, 11:53:16 PM (16 years ago)
- Location:
- trunk/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/utility.cc
r313 r373 79 79 80 80 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 81 93 std::string htrim(std::string str) 82 94 { -
trunk/lib/utility.h
r371 r373 63 63 /// 64 64 std::string getenv(const std::string& var); 65 66 /// 67 /// If @a width is set, size is forced to length @a width. This 68 /// implies, e.g., that hex(15,2) and hex(17,1) return "0F" and "1", 69 /// respectively. 70 /// 71 /// @return x in hexadecimal base 72 /// 73 std::string hex(int x, u_int width=0); 65 74 66 75 ///
Note: See TracChangeset
for help on using the changeset viewer.