aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.util/tabulate.ccm
diff options
context:
space:
mode:
authorLexi Winter <lexi@le-fay.org>2025-07-01 17:07:04 +0100
committerLexi Winter <lexi@le-fay.org>2025-07-01 17:07:04 +0100
commit2e2d1bd3b6c7776b77c33b94f30ead89367a71e6 (patch)
tree54d37ffadf8e677938d9b7a28e4e9b71be1e75c1 /nihil.util/tabulate.ccm
parent36427c0966faa7aecd586b397ed9b845f18172f5 (diff)
downloadnihil-2e2d1bd3b6c7776b77c33b94f30ead89367a71e6.tar.gz
nihil-2e2d1bd3b6c7776b77c33b94f30ead89367a71e6.tar.bz2
add nihil.std
Diffstat (limited to 'nihil.util/tabulate.ccm')
-rw-r--r--nihil.util/tabulate.ccm55
1 files changed, 20 insertions, 35 deletions
diff --git a/nihil.util/tabulate.ccm b/nihil.util/tabulate.ccm
index 5998b24..8f5c22e 100644
--- a/nihil.util/tabulate.ccm
+++ b/nihil.util/tabulate.ccm
@@ -1,53 +1,38 @@
-/*
- * This source code is released into the public domain.
- */
-
-module;
-
-#include <algorithm>
-#include <cstdlib>
-#include <format>
-#include <ranges>
-#include <iterator>
-#include <vector>
-
+// This source code is released into the public domain.
export module nihil.util:tabulate;
+import nihil.std;
import nihil.error;
import :ctype;
namespace nihil {
-/*
- * tabulate: format the given range in an ASCII table and write the output
- * to the given output iterator. The range's values will be converted to
- * strings as if by std::format.
- *
- * tabulate is implemented by copying the range; this allows it to work on
- * input/forward ranges at the cost of slightly increased memory use.
- *
- * The table spec is a string consisting of zero or more field formats,
- * formatted as {flags:fieldname}; both flags and fieldname are optional.
- * If there are fewer field formats than fields, the remaining fields
- * are formatted as if by {:}.
- *
- * The following flags are supported:
- *
- * < left-align this column (default)
- * > right-align this column
- */
+// tabulate: format the given range in an ASCII table and write the output
+// to the given output iterator. The range's values will be converted to
+// strings as if by std::format.
+//
+// tabulate is implemented by copying the range; this allows it to work on
+// input/forward ranges at the cost of slightly increased memory use.
+//
+// The table spec is a string consisting of zero or more field formats,
+// formatted as {flags:fieldname}; both flags and fieldname are optional.
+// If there are fewer field formats than fields, the remaining fields
+// are formatted as if by {:}.
+//
+// The following flags are supported:
+//
+// < left-align this column (default)
+// > right-align this column
// Exception thrown when a table spec is invalid.
export struct table_spec_error : error {
- table_spec_error(std::string_view what)
+ explicit table_spec_error(std::string_view what)
: error(what)
{
}
};
-/*
- * The specification for a single field.
- */
+// The specification for a single field.
template<typename Char>
struct field_spec {
enum align_t { left, right };