Introduction
If you have used the std::string and C-style string, you must think the std::string is so convenient in memory management. You can append/delete chars in any way without considering about the memory allocation. But there isn't any class for a byte stream in the std library. So, here's an implementation for a byte stream. I often use it when using Windows APIs, such as those for file operation, network, etc.
Usage
Here's the test code, I think it's so simple that a detailed explanation is not needed:
#include <iostream>
using namespace std;
#include "Easiware\DataChunk.h"
void main()
{
Easiware::Memory::CDataChunk dc;
dc << 100
<< "test"
<< true;
int i;
std::string s;
bool b;
dc >> i >> s >> b;
cout << i << endl
<< s << endl
<< b << endl;
}
Others
I wrote the code just after reading the book << Exceptional C++ >>, so I think this can be called an Exception-Safe class :). Hope you enjoy it, and thanks for any advice. Finally, thanks for reading this article, and sorry for my poor English.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here