summaryrefslogtreecommitdiff
path: root/src/text_formatter.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-09-16 14:39:26 +0200
committerCarl Hetherington <cth@carlh.net>2025-09-16 14:39:26 +0200
commitd03b2894c76430b550f9883dddf9d7f51858a896 (patch)
tree8ba400a9e2d7bcd96a9af38b13606083747a23b5 /src/text_formatter.cc
parent4e92b51166abe50693c6f71d1a148a59452c1704 (diff)
Split TextFormatter methods out to a .cc
Diffstat (limited to 'src/text_formatter.cc')
-rw-r--r--src/text_formatter.cc93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/text_formatter.cc b/src/text_formatter.cc
new file mode 100644
index 00000000..2db8b602
--- /dev/null
+++ b/src/text_formatter.cc
@@ -0,0 +1,93 @@
+/*
+ Copyright (C) 2022 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "text_formatter.h"
+
+
+using namespace dcp;
+
+
+TextFormatter::TextFormatter(boost::filesystem::path file)
+ : Formatter(file)
+{
+
+}
+
+
+void
+TextFormatter::heading(std::string const& text)
+{
+ print(text);
+}
+
+
+void
+TextFormatter::subheading(std::string const& text)
+{
+ print("");
+ print(text);
+}
+
+
+Formatter::Wrap
+TextFormatter::unordered_list()
+{
+ _indent++;
+ return Wrap(this, "", [this]() { _indent--; });
+}
+
+
+void
+TextFormatter::list_item(std::string const& text, boost::optional<std::string> type)
+{
+ LIBDCP_UNUSED(type);
+ for (int i = 0; i < _indent * 2; ++i) {
+ _file.puts(" ");
+ }
+ _file.puts("* ");
+ print(text);
+}
+
+
+std::function<std::string (std::string)>
+TextFormatter::process_string()
+{
+ return [](std::string s) {
+ return s;
+ };
+}
+
+
+std::function<std::string (std::string)>
+TextFormatter::process_filename()
+{
+ return [](std::string s) {
+ return s;
+ };
+}
+
+
+void
+TextFormatter::print(std::string const& text)
+{
+ _file.puts(text.c_str());
+ _file.puts("\n");
+}