#include #include #include #include #include #include using namespace std; typedef vector vch; struct command{ enum cmd_type { block=0xBB, symbol=0xAA, str=0xFF }; cmd_type cmd; union { unsigned long n1; char c; vch * v; }; unsigned long n2; command(cmd_type cc, unsigned long a1): cmd(cc), n1(a1) {} command(cmd_type cc, char a1): cmd(cc), c(a1) {} command(cmd_type cc, vch* a1): cmd(cc), v(a1) {} command(cmd_type cc): cmd(cc) {} command(cmd_type cc, unsigned long a1, unsigned long a2): cmd(cc), n1(a1), n2(a2) {} }; typedef vector vcm; class vch_holder{ vcm * p; vector vchs; vch_holder(vch_holder&); public: vch * getvch(){ vch * p = new vch; vchs.push_back(p); return p; } ~vch_holder(){ while( !vchs.empty() ){ delete vchs.back(); vchs.pop_back(); } } vch_holder(vcm& c): p(&c){} }; unsigned long load(ifstream & is, vch & v); bool loaddlo(ifstream &is, vcm & v, vch_holder& h); void getdlo(vch & f1, vch & f2, vcm & d); void procdlo(vcm & d, vch_holder & vh, vch & file); void savedlo(ofstream & of, vcm & d); // imia, razmer, bsumma void dlomake(vch& out, vcm& d, vch *in); void save(ofstream& of, const vch& file); bool read_int(istream &i, unsigned long & x); bool read_string(istream &i, string & s); void print_bar(long x, long max){ if ( x>max ) x=max; if ( x<0 ) x=0; const long bar_size = 50; int bar = int( (float)x/max*50 ); static int oldbar = -1; if( oldbar == bar ) return; oldbar = bar; cout<<'\r'; long i; for( i=0; i>=7; }while(x); r.back() &= 0x7F; return r; } vch getb7(ifstream & i){ vch r; char c; while(1){ i.get(c); if( !i ) break; r.push_back(c); if( !(c & 0x80) ) break; } return r; } void savedlo(ofstream & of, vcm & d){ for(vcm::iterator i=d.begin(); i!=d.end(); ++i ) switch( (*i).cmd ){ case command::block: of<size()) ); save(of,*(*i).v); break; default: cout<<"Bad dlo"<push_back(c); } v.push_back( command(command::str,p) ); } break; default: cout<<"c: "<size() < (*i).n2 ){ cout<<"out of bound (dlo does not match " "input file) [size:"<size()<< ", ref:"<<(*i).n2<<"]"< > mcv; for( i=0; i mat; vector mat2; mainloop: print_bar(c2,size2); if( c2==size2 ) return; ulong c2fix = c2; mat = mcv[f2[c2]]; if( mat.empty() ){ d.push_back( command(command::symbol,f2[c2]) ); c2++; goto mainloop; } matloop: mat2.clear(); c2++; if( c2 != size2 ) for( i=0; i