Stream, Formatter, Serialize (2)

xiaoxiao2021-03-06  50

Today, I was basically transferred to the code, but I haven't tested it yet. Because Visual C 6.0, it is far from the C standard, which brings a lot of difficulties. Obviously compiled well in Linux, finished all according to the standard, to Visual C 6.0, indeed full screen error, from your heart a little disappointed with Microsoft's technology, maybe his expertise is not here.

The last story said stream, this time telling Formatter

Formatter

The formatter is a concept that M $ is proposed in .NET, he has abstract a layer between Object -> stream. So now the mode programming Object -> Formatter -> Stream

Formatter determines the object to be sent to the flow, (BTW: stream is a carrier of data, or the container, he does not care about the format of data)

For example, we define an object, we can choose different formatters to save to the file.

E.g:

Save objects into binary forms

Protocal :: HeartBeat HB;

Std :: OFStream OFS ("protocol.dat");

SSP :: binformatter formatter;

Formatter. WriteObject (OFS, HB);

Save objects

Protocal :: HeartBeat HB;

Std :: OFSCOL.Enc "); SSP :: EncryptFormatter Formatter; Formatter. WriteObject (OFS, HB); Save object :: HeartBeat Hb; std :: OFSTREAM OFS (" Protocol.xml "); Ssp :: XMLFormatter formatter; formatter. WriteObject (OFS, HB); Unfortunately, in Java, Formatter and Stream are combined together, so for data in different formats, it must be re-implemented. I said that I will come back to Microsoft's concept. I really mention it. I continue to say serialize.

转载请注明原文地址:https://www.9cbs.com/read-115833.html

New Post(0)