/* * Base64 encode data * * without parameters reads data from standard input and writes encoded data to standard output * with 1 parameter reads data from the file given and writes encoded data to standard output * with 2 parameters reads data from the file in the 1st argument and writes encoded data to the file in the 2nd argument * */ #include #include #include using namespace std; using namespace xstream; int main(int argc, char* argv[]){ const size_t len = 4*1024; char buf[len]; istream* readfrom; ostream* writeto; try{ if(1rdbuf()); ostream b64(&b64sb); //raise exceptions b64.exceptions(ios::badbit); while(readfrom->good()){ readfrom->read(buf,len); b64.write(buf,readfrom->gcount()); } b64.flush(); } catch(exception& e){ cerr<<"Error: "<