Still working out parsing buffer stuff.

This commit is contained in:
Brad Arant 2025-12-17 17:07:14 -08:00
parent 0243468d44
commit ccfab5aecf
9 changed files with 78 additions and 13 deletions

View File

@ -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);

View File

@ -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') {

View File

@ -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;
};

View File

@ -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() {
}
}

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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;
};

View File

@ -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;
}

View File

@ -413,6 +413,12 @@ namespace coreutils {
///
ZString unparsed();
///
/// Set the ZString cursor to the end of the ZString.
///
int setParsed();
///
///