Still working out parsing buffer stuff.
This commit is contained in:
parent
0243468d44
commit
ccfab5aecf
@ -2,10 +2,11 @@
|
||||
# define __IMFBoundary_h__
|
||||
|
||||
#include "StreamReader.h"
|
||||
#include "Parser.h"
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
class IMFBoundary {
|
||||
class IMFBoundary : public Parser {
|
||||
|
||||
public:
|
||||
IMFBoundary(StreamReader &reader, ZString boundary);
|
||||
|
||||
@ -5,7 +5,9 @@
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
IMFHeader::IMFHeader(int fd) {
|
||||
IMFHeader::IMFHeader(int fd) {}
|
||||
|
||||
virtual int parse() {
|
||||
char ch;
|
||||
int rc = ::read(fd, &ch, 1);
|
||||
while(ch != '\r') {
|
||||
|
||||
10
IMFHeader.h
10
IMFHeader.h
@ -1,18 +1,22 @@
|
||||
#ifndef __IMFHeader_h__
|
||||
# define __IMFHeader_h__
|
||||
|
||||
# include "StreamReader.h"
|
||||
# include "Parser.h"
|
||||
# include "IMFHeaderField.h"
|
||||
# include <vector>
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
class IMFHeader {
|
||||
class IMFHeader : public Parser {
|
||||
|
||||
public:
|
||||
IMFHeader(int fd);
|
||||
IMFHeader(StreamReader &reader);
|
||||
|
||||
virtual int parse();
|
||||
|
||||
private:
|
||||
std::vector<IMFHeaderField*> headers;
|
||||
std::vector<IMFHeaderField *> headers;
|
||||
|
||||
};
|
||||
|
||||
|
||||
14
Parser.cpp
14
Parser.cpp
@ -1,4 +1,5 @@
|
||||
#include "Parser.h"
|
||||
#include "StreamReader.h"
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
@ -6,6 +7,15 @@ namespace coreutils {
|
||||
|
||||
Parser::~Parser() {}
|
||||
|
||||
int Parser::parse() {}
|
||||
|
||||
int Parser::doParse() {
|
||||
buffer << reader.unparsed();
|
||||
reader.setParsed();
|
||||
}
|
||||
|
||||
bool Parser::checkParse(Parser &parser);
|
||||
|
||||
int Parser::Parse() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
32
Parser.h
32
Parser.h
@ -15,16 +15,42 @@ namespace coreutils {
|
||||
class Parser {
|
||||
|
||||
public:
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
|
||||
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
|
||||
///
|
||||
/// doParse is the entry and re-entry point method to continue the parsing process.
|
||||
///
|
||||
|
||||
int doParse();
|
||||
|
||||
///
|
||||
/// Inside of parse() you can call another parser object with the checkParse method to
|
||||
/// determine if the parsing should branch to the new passed parsing object.
|
||||
///
|
||||
|
||||
bool checkParse(Parser &parser); <--- can be called in parse to see if the parsing should branch
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
|
||||
virtual int parse();
|
||||
|
||||
private:
|
||||
protected:
|
||||
MString buffer;
|
||||
|
||||
private:
|
||||
Parser *parser;
|
||||
vector<Parser *> chain;
|
||||
|
||||
|
||||
@ -2,8 +2,14 @@
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
StreamReader::StreamReader(int fd) {}
|
||||
StreamReader::StreamReader(int fd) fd(fd) {}
|
||||
|
||||
StreamReader::~StreamReader() {}
|
||||
|
||||
|
||||
int StreamReader::read() {
|
||||
setSize(4096);
|
||||
int len = ::read(fd, getData(), 4096);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#ifndef __StreamReader_h__
|
||||
#define __StreamReader_h__
|
||||
|
||||
#include "MString.h"
|
||||
#include "Parser.h"
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
@ -15,10 +17,13 @@ namespace coreutils {
|
||||
class StreamReader {
|
||||
|
||||
public:
|
||||
StreamReader(int fd);
|
||||
StreamReader(int fd, Parser *parser);
|
||||
virtual ~StreamReader();
|
||||
|
||||
int read();
|
||||
|
||||
private:
|
||||
int fd;
|
||||
vector<MString> buffer;
|
||||
|
||||
};
|
||||
|
||||
@ -585,6 +585,11 @@ namespace coreutils {
|
||||
return ZString(cursor, data + length - cursor);
|
||||
}
|
||||
|
||||
int ZString::setParsed() {
|
||||
cursor = data + length;
|
||||
return length;
|
||||
}
|
||||
|
||||
void ZString::reset() {
|
||||
cursor = data;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user