Click here to Skip to main content
Click here to Skip to main content

Anonymous DataChunk in a non-MFC way

, 14 Sep 2005 BSD
Rate this:
Please Sign up or sign in to vote.
An anonymous DataChunk class to simplify memory management.


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.


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;


I wrote the code just after reading the book << Exceptional C++ >>, so I think this can be called an Exception-Safe class Smile | :) . Hope you enjoy it, and thanks for any advice. Finally, thanks for reading this article, and sorry for my poor English.


This article, along with any associated source code and files, is licensed under The BSD License


About the Author

Web Developer
China China
No Biography provided

Comments and Discussions

QuestionWhat is the difference to std::stringstream? Pinmembercqz6gt795f16-Sep-05 0:49 
AnswerRe: What is the difference to std::stringstream? Pinmemberballoy17-Sep-05 23:13 
GeneralLike it PinmemberJerry Evans15-Sep-05 3:42 
GeneralThanks your idea Pinmemberballoy15-Sep-05 20:59 
GeneralRe: Thanks your idea PinmemberJohann Gerell18-Sep-05 22:45 
GeneralRe: Thanks your idea Pinmemberballoy18-Sep-05 23:34 
GeneralRe: Thanks your idea PinmemberJohann Gerell24-Sep-05 12:22 
GeneralThanks, I found it Pinmemberballoy25-Sep-05 17:56 
Generalmemcpy PinmemberPierre Couderc19-Sep-05 23:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150128.1 | Last Updated 14 Sep 2005
Article Copyright 2005 by balloy
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid