From db9c49893c2a9475cb5efa4a53bc481a5f66231f Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 12 Sep 2008 16:07:50 +0000 Subject: [PATCH] Move mspdatatool source to its own directory Add an overload of LoaderFunc1 that passes the statement as-is Make Loader::load(const Statement &) private since it's called through a base class reference now --- Build | 2 +- source/loader.h | 7 +++---- source/loaderaction.h | 19 +++++++++++++++++++ tool.cpp => tool/tool.cpp | 31 +++++++++++-------------------- tool/tool.h | 22 ++++++++++++++++++++++ 5 files changed, 56 insertions(+), 25 deletions(-) rename tool.cpp => tool/tool.cpp (76%) create mode 100644 tool/tool.h diff --git a/Build b/Build index d7e7238..53a4ebd 100644 --- a/Build +++ b/Build @@ -21,7 +21,7 @@ package "mspdatafile" program "mspdatatool" { - source "tool.cpp"; + source "tool"; install true; build_info { diff --git a/source/loader.h b/source/loader.h index 9314ab3..0c1dda2 100644 --- a/source/loader.h +++ b/source/loader.h @@ -43,14 +43,13 @@ See also classes BasicLoader and BasicLoader2. */ class Loader { -public: +private: /** - Loads data from a statement. This is normally only used by the Loader class - itself for loading sub-items, but needs to be public so it can be accessed - in derived objects. + Loads data from a statement. */ void load(const Statement &st); +public: /** Loads statements from a parser. */ diff --git a/source/loaderaction.h b/source/loaderaction.h index 2a2a8fc..ff478ec 100644 --- a/source/loaderaction.h +++ b/source/loaderaction.h @@ -95,6 +95,25 @@ private: }; +/** +Loads a statement by calling a function with the statement itself as argument. +*/ +template +class LoaderFunc1: public LoaderAction +{ +public: + typedef void (L::*FuncType)(const Statement &); + + LoaderFunc1(FuncType f): func(f) { } + void execute(Loader &l, const Statement &st) const + { + (dynamic_cast(l).*func)(st); + } +private: + FuncType func; +}; + + template class LoaderFunc2: public LoaderAction { diff --git a/tool.cpp b/tool/tool.cpp similarity index 76% rename from tool.cpp rename to tool/tool.cpp index 1e4da9a..ca415d3 100644 --- a/tool.cpp +++ b/tool/tool.cpp @@ -1,31 +1,22 @@ -/* $Id$ */ -#include -#include +/* $Id$ + +This file is part of libmspdatafile +Copyright © 2008 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include #include #include #include -#include "source/parser.h" -#include "source/statement.h" -#include "source/writer.h" +#include +#include +#include +#include "tool.h" using namespace std; using namespace Msp; -class DataTool: public Application -{ -private: - string in_fn; - string out_fn; - bool binary; -public: - DataTool(int argc, char **argv); - int main(); - - static Application::RegApp reg; -}; - - DataTool::DataTool(int argc, char **argv): in_fn("-"), out_fn("-") diff --git a/tool/tool.h b/tool/tool.h new file mode 100644 index 0000000..99e8297 --- /dev/null +++ b/tool/tool.h @@ -0,0 +1,22 @@ +/* $Id$ + +This file is part of libmspdatafile +Copyright © 2008 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + +#include +#include + +class DataTool: public Msp::Application +{ +private: + std::string in_fn; + std::string out_fn; + bool binary; +public: + DataTool(int argc, char **argv); + int main(); + + static Application::RegApp reg; +}; -- 2.43.0