From e1f64147e3eedccbbc59658ddb6cf7992dbd50c1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 4 Jul 2008 21:27:40 +0200 Subject: [PATCH] first stubs --- CollectionReader.cpp | 14 ++++++++++++++ CollectionReader.h | 21 +++++++++++++++++++++ FileReaderInput.cpp | 20 ++++++++++++++++++++ FileReaderInput.h | 25 +++++++++++++++++++++++++ Makefile | 15 +++++++++++++-- ReaderInput.cpp | 9 +++++++++ ReaderInput.h | 19 +++++++++++++++++++ 7 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 CollectionReader.cpp create mode 100644 CollectionReader.h create mode 100644 FileReaderInput.cpp create mode 100644 FileReaderInput.h create mode 100644 ReaderInput.cpp create mode 100644 ReaderInput.h diff --git a/CollectionReader.cpp b/CollectionReader.cpp new file mode 100644 index 0000000..27f9ca6 --- /dev/null +++ b/CollectionReader.cpp @@ -0,0 +1,14 @@ +/** + * © 2008 by David Roden + */ + +#include "CollectionReader.h" + +CollectionReader::CollectionReader(ReaderInput* readerInput) { + this->readerInput = readerInput; +} + +CollectionReader::~CollectionReader() { + delete readerInput; +} + diff --git a/CollectionReader.h b/CollectionReader.h new file mode 100644 index 0000000..2936e25 --- /dev/null +++ b/CollectionReader.h @@ -0,0 +1,21 @@ +/** + * © 2008 by David Roden + */ + +#ifndef __ECPARSE_COLLECTIONREADER_H__ +#define __ECPARSE_COLLECTIONREADER_H__ + +#include "ReaderInput.h" + +class CollectionReader { + +public: + CollectionReader(ReaderInput* readerInput); + ~CollectionReader(); + +private: + ReaderInput* readerInput; + +}; + +#endif diff --git a/FileReaderInput.cpp b/FileReaderInput.cpp new file mode 100644 index 0000000..14fc0c6 --- /dev/null +++ b/FileReaderInput.cpp @@ -0,0 +1,20 @@ +/** + * © 2008 by David Roden + */ + +#include "FileReaderInput.h" + +FileReaderInput::FileReaderInput(FILE *file) { + this->file = file; +} + +FileReaderInput::~FileReaderInput() { + fclose(file); +} + +int FileReaderInput::read(void* buffer, size_t length) { + size_t readBytes; + + readBytes = fread(buffer, 1, length, file); + return 0; +} diff --git a/FileReaderInput.h b/FileReaderInput.h new file mode 100644 index 0000000..4398bbf --- /dev/null +++ b/FileReaderInput.h @@ -0,0 +1,25 @@ +/** + * © 2008 by David Roden + */ + +#ifndef __ECPARSE_FILEREADERINPUT_H__ +#define __ECPARSE_FILEREADERINPUT_H__ + +#include +#include "ReaderInput.h" + +class FileReaderInput : public ReaderInput { + +public: + FileReaderInput(FILE *file); + ~FileReaderInput(); + + int read(void* buffer, size_t length); + +private: + FILE* file; + +}; + +#endif + diff --git a/Makefile b/Makefile index b8cb93e..03442d8 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -CC=gcc +CC=g++ ifdef DEBUG CC_OPTS=-Wall -g @@ -7,9 +7,20 @@ else CC_OPTS=-Wall -O2 endif +.c.o .cpp.o: + $(CC) $(CC_OPTS) -c -o $@ $< + all: ecparse -ecparse: +ecparse: ReaderInput.o FileReaderInput.o CollectionReader.o Main.o + $(CC) -o $@ $^ + +ReaderInput.o: ReaderInput.cpp ReaderInput.h + +FileReaderInput.o: FileReaderInput.cpp FileReaderInput.h ReaderInput.h + +CollectionReader.o: CollectionReader.cpp ReaderInput.h clean: rm -f ecparse + rm -f *.o diff --git a/ReaderInput.cpp b/ReaderInput.cpp new file mode 100644 index 0000000..7969683 --- /dev/null +++ b/ReaderInput.cpp @@ -0,0 +1,9 @@ +/** + * © 2008 by David Roden + */ + +#include "ReaderInput.h" + +ReaderInput::~ReaderInput() { +} + diff --git a/ReaderInput.h b/ReaderInput.h new file mode 100644 index 0000000..8c6f7e2 --- /dev/null +++ b/ReaderInput.h @@ -0,0 +1,19 @@ +/** + * © 2008 by David Roden + */ + +#ifndef __ECPARSE_READERINPUT_H__ +#define __ECPARSE_READERINPUT_H__ + +#include + +class ReaderInput { + +public: + virtual ~ReaderInput(); + + virtual int read(void* buffer, size_t length) = 0; + +}; + +#endif -- 2.7.4