# HG changeset patch # User František Kučera # Date 1615660093 -3600 # Node ID 8b8175615adbd8555df4da992dffa4e38a7dc4f2 # Parent 2179f13227f4df1dd4f6fb5b47fddf76de8a1fdf AbstractParser: remove unnecessary delegation (put only private methods in AbstractParserImpl) diff -r 2179f13227f4 -r 8b8175615adb src/lib/AbstractParser.cpp --- a/src/lib/AbstractParser.cpp Sat Mar 13 17:58:09 2021 +0100 +++ b/src/lib/AbstractParser.cpp Sat Mar 13 19:28:13 2021 +0100 @@ -32,33 +32,6 @@ virtual ~AbstractParserImpl() { } - - void write(const char* buffer, const size_t length) { - // TODO: update pointers and positions - try { - // TODO: call an overridable method to get preferred minimum block size and run cycle only if we have enough data or EOF - interface->update(); - commit(); - } catch (const AbstractParser::ReadBufferUnderflowException& e) { - rollback(); - } catch (const AbstractParser::ExplicitRollbackException& e) { - rollback(); - } - } - - void rollback() { - // FIXME: store content of the current buffer + update pointers and positions - // TODO: notify rollback listeners? (they can monitor the performance / frequency of rollbacks) - } - - void commit() { - } - - void read(char* buffer, const size_t length) { - } - - void peek(char* buffer, const size_t length) { - } }; AbstractParser::AbstractParser() { @@ -66,30 +39,37 @@ } AbstractParser::~AbstractParser() { - delete (AbstractParserImpl*) implementation; + delete implementation; } void AbstractParser::write(const char* buffer, const size_t length) { - ((AbstractParserImpl*) implementation)->write(buffer, length); + // TODO: update pointers and positions + try { + // TODO: call an overridable method to get preferred minimum block size and run cycle only if we have enough data or EOF + update(); + commit(); + } catch (const AbstractParser::ReadBufferUnderflowException& e) { + rollback(); + } catch (const AbstractParser::ExplicitRollbackException& e) { + rollback(); + } +} + +void AbstractParser::rollback() { + // FIXME: store content of the current buffer + update pointers and positions + // TODO: notify rollback listeners? (they can monitor the performance / frequency of rollbacks) } void AbstractParser::commit() { - ((AbstractParserImpl*) implementation)->commit(); -} - -void AbstractParser::rollback() { - ((AbstractParserImpl*) implementation)->rollback(); } void AbstractParser::read(char* buffer, const size_t length) { - ((AbstractParserImpl*) implementation)->read(buffer, length); } void AbstractParser::peek(char* buffer, const size_t length) { - ((AbstractParserImpl*) implementation)->peek(buffer, length); } } } } -} \ No newline at end of file +}