From 83cf68cdf673ee26ac054aed799735bd7e921cee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sun, 29 Jul 2018 20:22:35 +0200 Subject: [PATCH] Do not add include bool if no col is bool --- app/Tables/CStructArrayExporter.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Tables/CStructArrayExporter.php b/app/Tables/CStructArrayExporter.php index d8055ca..32b39a9 100644 --- a/app/Tables/CStructArrayExporter.php +++ b/app/Tables/CStructArrayExporter.php @@ -36,7 +36,8 @@ class CStructArrayExporter extends BaseExporter */ protected function writeDocument() { - $fields = array_map(function (Column $c) { + $any_bool = false; + $fields = array_map(function (Column $c) use (&$any_bool) { $type = $c->type; if ($type == 'string') { $type = 'const char *'; @@ -44,13 +45,17 @@ class CStructArrayExporter extends BaseExporter $name = $this->cify($c->name); + if ($c->type == 'bool') $any_bool = true; + return (object)['name' => $c->name, 'type' => $c->type, 'ctype' => $type, 'cname' => $name]; }, $this->columns); $ctablename = $this->cify($this->table->name); // preamble - echo "#include \n\n"; + if ($any_bool) { + echo "#include \n\n"; + } echo "struct " . $ctablename . " {\n"; foreach ($fields as $field) {