1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
// ParseLine.cpp: implementation of the ParseLine class.
//
//////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "ParseLine.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
ParseLine::ParseLine()
{
Val1 = NULL;
ValCnt = 0;
}
ParseLine::ParseLine(char *Buff)
{
Val1 = NULL;
ValCnt = 0;
ParseBuf(Buff);
}
ParseLine::~ParseLine()
{
Clear();
}
void ParseLine::Clear()
{
ParseValue *Crnt;
ParseValue *Nxt;
Crnt = Val1;
while(Crnt != NULL)
{
Nxt = Crnt->nxt();
delete Crnt;
Crnt = Nxt;
}
Val1 = NULL;
}
void ParseLine::ParseBuf(char *Buff)
{
char tbuf[255];
char *p = Buff;
char *b = tbuf;
bool go = true;
ParseValue *cVal = new ParseValue;
Val1 = cVal;
ValCnt = 1;
while(go)
{
switch(*p)
{
case ',':
*b = 0;
cVal->SetDta(tbuf);
cVal->Next = new ParseValue;
cVal = cVal->Next;
b = tbuf;
ValCnt++;
break;
case 0x0a:
case 0x0d:
case 0:
go = false;
*b = 0;
cVal->SetDta(tbuf);
cVal->Next = NULL;
break;
default:
*b++ = *p;
break;
}
p++;
}
}
|