AbstractParser: remove unnecessary delegation (put only private methods in AbstractParserImpl)
--- 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
+}