ff6046
From c4f60df10a2716c94d30462a118f60d916d537a2 Mon Sep 17 00:00:00 2001
ff6046
From: Lennart Poettering <lennart@poettering.net>
ff6046
Date: Fri, 9 Nov 2018 11:38:12 +0100
ff6046
Subject: [PATCH] format-table: add calls to query the data in a specific cell
ff6046
ff6046
(cherry picked from commit 62d99b39709f903f8a66a9aae757deb5546a53eb)
ff6046
ff6046
Related: #1689832
ff6046
---
ff6046
 src/basic/format-table.c | 22 ++++++++++++++++++++++
ff6046
 src/basic/format-table.h |  3 +++
ff6046
 2 files changed, 25 insertions(+)
ff6046
ff6046
diff --git a/src/basic/format-table.c b/src/basic/format-table.c
ff6046
index 3fcb97475c..0a1777e9a2 100644
ff6046
--- a/src/basic/format-table.c
ff6046
+++ b/src/basic/format-table.c
ff6046
@@ -1438,3 +1438,25 @@ TableCell *table_get_cell(Table *t, size_t row, size_t column) {
ff6046
 
ff6046
         return TABLE_INDEX_TO_CELL(i);
ff6046
 }
ff6046
+
ff6046
+const void *table_get(Table *t, TableCell *cell) {
ff6046
+        TableData *d;
ff6046
+
ff6046
+        assert(t);
ff6046
+
ff6046
+        d = table_get_data(t, cell);
ff6046
+        if (!d)
ff6046
+                return NULL;
ff6046
+
ff6046
+        return d->data;
ff6046
+}
ff6046
+
ff6046
+const void* table_get_at(Table *t, size_t row, size_t column) {
ff6046
+        TableCell *cell;
ff6046
+
ff6046
+        cell = table_get_cell(t, row, column);
ff6046
+        if (!cell)
ff6046
+                return NULL;
ff6046
+
ff6046
+        return table_get(t, cell);
ff6046
+}
ff6046
diff --git a/src/basic/format-table.h b/src/basic/format-table.h
ff6046
index 40fea79f78..a2bb2e0846 100644
ff6046
--- a/src/basic/format-table.h
ff6046
+++ b/src/basic/format-table.h
ff6046
@@ -68,3 +68,6 @@ size_t table_get_rows(Table *t);
ff6046
 size_t table_get_columns(Table *t);
ff6046
 
ff6046
 TableCell *table_get_cell(Table *t, size_t row, size_t column);
ff6046
+
ff6046
+const void *table_get(Table *t, TableCell *cell);
ff6046
+const void *table_get_at(Table *t, size_t row, size_t column);