Click here to Skip to main content
16,004,977 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalhigh performance socket server...... (:() help!!!! Pin
Anonymous25-Apr-03 2:47
Anonymous25-Apr-03 2:47 
GeneralRe: high performance socket server...... (:() help!!!! Pin
Anonymous25-Apr-03 7:37
Anonymous25-Apr-03 7:37 
QuestionWhat cause such link errors? Pin
ray_li23-Apr-03 11:44
ray_li23-Apr-03 11:44 
AnswerRe: What cause such link errors? Pin
Nitron23-Apr-03 13:42
Nitron23-Apr-03 13:42 
AnswerRe: What cause such link errors? Pin
Toni7823-Apr-03 14:08
Toni7823-Apr-03 14:08 
General** CLICKETY POLICE ** Pin
Nitron23-Apr-03 14:11
Nitron23-Apr-03 14:11 
GeneralRe: ** CLICKETY POLICE ** Pin
Toni7823-Apr-03 14:16
Toni7823-Apr-03 14:16 
QuestionHow would you name this class ? Pin
Sendel23-Apr-03 10:42
Sendel23-Apr-03 10:42 
Hi, I have written a nice class (well, I think it's nice... may be other don't Wink | ;) )

I have called it class Stream but I think it's a wrong name for that, but how do I name it ?!

What the class do:

Stream.begin();
void * Stream.end();
Stream.clear();
Stream.add(void * data, int size);


example on how to use it:
Stream myStream;
// Data for testing:
void * t1 = allocateMem(11); // 11 Bytes
void * t2 = allocateMem(21); // 21 Bytes
void * t3 = allocateMem(31); // 31 Bytes
// void * allocateMem(int size) is my function for allocating Memory... you can use memalloc as well
// strings as Data -> don't for get the ending Zero pointer ('\0')
memmove(t1,"1________x\0",11);
memmove(t2,"2________xa________x\0",21);
memmove(t3,"3________x_________xb________x\0",31);
//          1234567890123456789012345678901
/////////////////////1/////////2/////////3////////////////////////////

myStream.begin(); // tell the class to clear old stream and prepare for new
printf(" fill stream:\n"); myStream.add(t1,11); // adding data to stream
printf(" fill stream:\n"); myStream.add(t2,21);
printf(" fill stream:\n"); myStream.add(t3,31);
printf(" --- stream completed ---\n");

// end stream and return the resolving data with header and block information:
char * myData = (char *) myStream.end(); 

/////////////////////////////////////////////////////////////////////
// rebuild data from stream:
//

// get header information:
tStreamheader * pStreamheader = (tStreamheader *)myData;

// how many blocks ?
printf(" num of blocks: %i\n",pStreamheader->numblocks);

// first block size?
unsigned long * pBlocksize;
char * pBlockdata = NULL;

// offset to step throu stream
unsigned long myoffset = sizeof(tStreamheader); // we want the data, so skip the header

// loop to print out the data of the block
for (int i = 0; i< (int) pStreamheader->numblocks; i++) // all blocks
{
  pBlocksize = (unsigned long *) (myData + myoffset); // blocksize
  myoffset+=sizeof(unsigned long); // skip blocksize to get blockinfo
  pBlockdata = (char *)allocateMem(*pBlocksize); // make room for block data
  memmove(pBlockdata, myData + myoffset,*pBlocksize); // copy block data
  myoffset+=*pBlocksize; // skip block data to get next block lenght

  // print out what we got:
  printf(" Stream Block %i size = %u\n", i, *pBlocksize);
  printf(" Stream Block data = %s\n",pBlockdata);
		
  pBlockdata = freeMem(pBlockdata); // delete blockdata 
}

t1 = freeMem(t1);
t2 = freeMem(t2);
t3 = freeMem(t3);


So, how should I call this class ?! Hmmm | :|
Do anyone need such a class ? Because it's free code and I want to make it here available...

what do you all think ?!

thanks alot Rose | [Rose] ,
Sendel

The only place for millions of bugs is the Rainforest
AnswerRe: How would you name this class ? Pin
Nitron23-Apr-03 13:46
Nitron23-Apr-03 13:46 
GeneralRe: How would you name this class ? Pin
Sendel23-Apr-03 14:29
Sendel23-Apr-03 14:29 
GeneralLines of text are different size in print preview Pin
Tim Hutzler23-Apr-03 10:42
Tim Hutzler23-Apr-03 10:42 
GeneralRe: Lines of text are different size in print preview Pin
basementman24-Apr-03 7:06
basementman24-Apr-03 7:06 
GeneralRe: Lines of text are different size in print preview Pin
Tim Hutzler24-Apr-03 11:18
Tim Hutzler24-Apr-03 11:18 
GeneralRe: Lines of text are different size in print preview Pin
basementman25-Apr-03 3:56
basementman25-Apr-03 3:56 
GeneralRe: Lines of text are different size in print preview Pin
Tim Hutzler25-Apr-03 11:51
Tim Hutzler25-Apr-03 11:51 
QuestionHow to run MFC application Pin
dudic23-Apr-03 9:58
dudic23-Apr-03 9:58 
AnswerRe: How to run MFC application Pin
Toni7823-Apr-03 10:10
Toni7823-Apr-03 10:10 
AnswerRe: How to run MFC application Pin
David Crow23-Apr-03 10:16
David Crow23-Apr-03 10:16 
AnswerRe: How to run MFC application Pin
Joan M23-Apr-03 21:34
professionalJoan M23-Apr-03 21:34 
GeneralDelete Scrollbar Pin
gmlnd23-Apr-03 9:38
gmlnd23-Apr-03 9:38 
GeneralRe: Delete Scrollbar Pin
Chris Losinger23-Apr-03 10:39
professionalChris Losinger23-Apr-03 10:39 
GeneralUGH! widechar buffer problem Pin
will138323-Apr-03 9:18
will138323-Apr-03 9:18 
GeneralRe: UGH! widechar buffer problem Pin
Tim Smith23-Apr-03 10:07
Tim Smith23-Apr-03 10:07 
GeneralRe: UGH! widechar buffer problem Pin
will138323-Apr-03 10:34
will138323-Apr-03 10:34 
GeneralI give up on GDI ! Pin
pankajdaga23-Apr-03 9:08
pankajdaga23-Apr-03 9:08 

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

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