Files Classes Functions Hierarchy
#include <streamconversion.h>
Static Public Member Functions | |
| static void | forward (string &os, istream &is) |
| Convert a stream to a string of ascii digits. | |
| static void | reverse (ostream &os, string const &in) |
| Convert a string of ascii digits to a stream. | |
Definition at line 14 of file streamconversion.h.
| void asciitodig::forward | ( | string & | os, | |
| istream & | is | |||
| ) | [static] |
Convert a stream to a string of ascii digits.
Definition at line 13 of file streamconversion.cpp.
Referenced by rsatest::test01().
00014 { 00015 char ch; 00016 uint w; 00017 is.unsetf(ios::skipws); 00018 while (is.eof()==false) 00019 { 00020 is >> ch; 00021 if (is.eof()) 00022 break; 00023 w = (uint)ch; 00024 00025 stringstream ss; 00026 if (w==0) 00027 ss << "000"; 00028 else 00029 if (w<10) 00030 ss << "00" << w; 00031 else 00032 if (w<100) 00033 ss << "0" << w; 00034 else 00035 ss << w; 00036 00037 os += ss.str(); 00038 } 00039 }
| void asciitodig::reverse | ( | ostream & | os, | |
| string const & | in | |||
| ) | [static] |
Convert a string of ascii digits to a stream.
Definition at line 42 of file streamconversion.cpp.
Referenced by rsatest::test01().
00046 { 00047 assert((in.size()%3)==0); 00048 uintc n = in.size()/3; 00049 00050 string s; 00051 char c; 00052 uint x; 00053 for (uint k=0; k<n; ++k) 00054 { 00055 s = in.substr(3*k,3); 00056 stringstream ss(s.c_str()); 00057 ss >> x; 00058 c = (char)x; 00059 os << c; 00060 } 00061 }
1.5.8