Continued work on Parser.
This commit is contained in:
parent
d54aec1f06
commit
0243468d44
@ -5,7 +5,26 @@
|
||||
namespace coreutils {
|
||||
|
||||
IMFBoundary(StreamReader &reader, ZString boundary) : boundary(boundary) {
|
||||
if(reader.unparsed().getLength()
|
||||
|
||||
}
|
||||
|
||||
int IMFBoundary::parse() {
|
||||
switch(state) {
|
||||
case PREFIX:
|
||||
if(buffer.remaining() > 3)
|
||||
if(reader.nextIf("\r\n--"))
|
||||
state = BOUNDARY;
|
||||
case BOUNDARY:
|
||||
while(buffer.getTokenInclude(""));
|
||||
if(buffer.eod())
|
||||
return 2;
|
||||
else if(buffer.remaining() > 1)
|
||||
if(buffer.ifNext("--"))
|
||||
state = LAST_BOUNDARY;
|
||||
case LAST_BOUNDARY:
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -10,6 +10,8 @@ namespace coreutils {
|
||||
public:
|
||||
IMFBoundary(StreamReader &reader, ZString boundary);
|
||||
|
||||
virtual int parse();
|
||||
|
||||
private:
|
||||
ZString boundary;
|
||||
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
#include "StreamReader.h"
|
||||
#include "Parser.h"
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
StreamReader::StreamReader(int fd) {}
|
||||
Parser::Parser(StreamReader &reader) : parser(parser) {}
|
||||
|
||||
StreamReader::~StreamReader() {}
|
||||
Parser::~Parser() {}
|
||||
|
||||
int Parser::parse() {}
|
||||
|
||||
}
|
||||
|
||||
11
Parser.h
11
Parser.h
@ -15,11 +15,18 @@ namespace coreutils {
|
||||
class Parser {
|
||||
|
||||
public:
|
||||
Parser(int fd);
|
||||
Parser(StreamReader &reader, Parser *parser);
|
||||
virtual ~Parser();
|
||||
|
||||
int doParse(); <--- copy the buffer available in read to here and call parse();
|
||||
bool checkParse(Parser &parser); <--- can be called in parse to see if the parsing should branch
|
||||
|
||||
virtual int parse();
|
||||
|
||||
private:
|
||||
vector<MString> buffer;
|
||||
MString buffer;
|
||||
Parser *parser;
|
||||
vector<Parser *> chain;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user