Diferente pentru parsare-fisier-iesire intre reviziile #1 si #2

Nu exista diferente intre titluri.

Diferente intre continut:

Acesta este un cod demonstrativ pentru parsarea fişierului de ieşire folosind metoda obiectuală:
== code(cpp) |
class OutputPrinter
{
public:
    OutputPrinter () {}
    OutputPrinter (char *file_name) {output_file = fopen (file_name, "w"); memset (sir, 0, sizeof (sir));}
    OutputPrinter &operator << (int val)
    {
        int cif[15];
        cif[0] = 0;
        if (val == 0) cif[0] = 1, cif[1] = 0;
        while (val) cif[++cif[0]] = val % 10, val /= 10;
        for (int i=cif[0]; i>=1; i--)
            sir[pos ++] = cif[i] + '0';
        if (pos >= max_l) CheckFinish ();
        return *this;
    }
    OutputPrinter &operator << (char c)
    {
        sir[pos ++] = c;
        if (pos >= max_l) CheckFinish ();
        return *this;
    }
    OutputPrinter &operator << (char *str)
    {
        while (*str)
        {
            sir[pos ++] = *str, str ++;
            if (pos >= max_l) CheckFinish ();
        }
        return *this;
    }
    ~OutputPrinter () {fprintf (output_file, "%s", sir);}
#include <stdio.h>
 
class OutParser {
private:
    FILE *output_file;
    static const int max_l = 50000;
    int pos = 0;
    char sir[max_l + 20];
    void CheckFinish () {fprintf (output_file, "%s", sir), pos = 0, memset (sir, 0, sizeof (sir));}
	FILE *fout;
	char *buff;
	int sp;
 
	void write_ch(char ch) {
		if (sp == 4096) {
			fwrite(buff, 1, 4906, fout);
			sp = 0;
			buff[sp] = ch;
		} else {
			buff[sp++] = ch;
		}
	}
 
 
public:
	OutParser(const char* name) {
		fout = fopen(name, "w");
		buff = new char[4096]();
		sp = 0;
	}
	~OutParser() {
		fwrite(buff, 1, sp, fout);
		fclose(fout);
	}
 
	OutParser& operator << (int vu32) {
		if (vu32 <= 9) {
			write_ch(vu32 + '0');
		} else {
			(*this) << (vu32 / 10);
			write_ch(vu32 % 10 + '0');
		}
		return *this;
	}
 
	OutParser& operator << (long long vu64) {
		if (vu64 <= 9) {
			write_ch(vu64 + '0');
		} else {
			(*this) << (vu64 / 10);
			write_ch(vu64 % 10 + '0');
		}
		return *this;
	}
 
	OutParser& operator << (char ch) {
		write_ch(ch);
		return *this;
	}
	OutParser& operator << (const char *ch) {
		while (*ch) {
			write_ch(*ch);
			++ch;
		}
		return *this;
	}
};
==

Nu exista diferente intre securitate.

Topicul de forum nu a fost schimbat.