Still parsing work.
This commit is contained in:
parent
d79697775b
commit
ba85c5f2e5
@ -3,13 +3,11 @@
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
Parser::Parser(StreamReader &reader) : parser(parser) {}
|
||||
Parser::Parser(int socket) : socket(socket) {}
|
||||
|
||||
Parser::~Parser() {}
|
||||
|
||||
Status Parser::doParse() {
|
||||
buffer << reader.unparsed();
|
||||
reader.setParsed();
|
||||
}
|
||||
|
||||
bool Parser::checkParse(Parser &parser);
|
||||
|
||||
8
Parser.h
8
Parser.h
@ -12,7 +12,7 @@ namespace coreutils {
|
||||
/// consistency regardless of the packet delivery for the stream.
|
||||
///
|
||||
|
||||
class Parser {
|
||||
class Parser : public MString {
|
||||
|
||||
public:
|
||||
|
||||
@ -20,7 +20,7 @@ namespace coreutils {
|
||||
///
|
||||
///
|
||||
|
||||
Parser(StreamReader &reader, Parser *parser);
|
||||
Parser(int socket);
|
||||
|
||||
///
|
||||
///
|
||||
@ -28,7 +28,8 @@ namespace coreutils {
|
||||
|
||||
enum class Status {
|
||||
COMPLETE,
|
||||
INCOMPLETE
|
||||
INCOMPLETE,
|
||||
DATA_AVAIL
|
||||
};
|
||||
|
||||
///
|
||||
@ -60,6 +61,7 @@ namespace coreutils {
|
||||
MString buffer;
|
||||
|
||||
private:
|
||||
int socket;
|
||||
Parser *parser;
|
||||
vector<Parser *> chain;
|
||||
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
#include "StreamReader.h"
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
StreamReader::StreamReader(int fd, Parser *parser) fd(fd) {}
|
||||
|
||||
StreamReader::~StreamReader() {}
|
||||
|
||||
int StreamReader::read() {
|
||||
setSize(4096);
|
||||
int len = ::read(fd, getData(), 4096);
|
||||
|
||||
parser.parse();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
#ifndef __StreamReader_h__
|
||||
#define __StreamReader_h__
|
||||
|
||||
#include "MString.h"
|
||||
#include "Parser.h"
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
///
|
||||
/// Use the StreamReader to read data from a socket and buffer it for use by
|
||||
/// various stream parsers such as IMFMessage. The reader maintains data
|
||||
/// consistency regardless of the packet delivery for the stream.
|
||||
///
|
||||
|
||||
class StreamReader {
|
||||
|
||||
public:
|
||||
StreamReader(int fd, Parser *parser);
|
||||
virtual ~StreamReader();
|
||||
|
||||
int read();
|
||||
|
||||
private:
|
||||
int fd;
|
||||
vector<MString> buffer;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
14
testing/parser_test.cpp
Normal file
14
testing/parser_test.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include <iostream>
|
||||
#include "../MString.h"
|
||||
#include "../LineParser.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
coreutils::LineParser line(0);
|
||||
Parse.Status status = line.doParse();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user