<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
</head>
<body>
<div style="font-family:sans-serif"><div style="white-space:normal"><p dir="auto">Excellent! Glad that ended up working out — looking forward to seeing this improve quality of life for GRDB users and others. :)</p>
<p dir="auto">On 27 May 2017, at 3:40, Gwendal Roué wrote:</p>
</div>
<blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px"><div id="215EBB7E-12F5-4811-8483-760A78111E0F"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">Le 27 mai 2017 à 11:59, David Hart &lt;<a href="mailto:david@hartbit.com" class="">david@hartbit.com</a>&gt; a écrit :</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I didn’t know that was possible either! Really cool. Even better:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">&nbsp;if let databaseValueType = T.self as? DatabaseValueConvertible.Type {</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let databaseValue: DatabaseValue = row.value(named: key.stringValue)</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return databaseValueType.fromDatabaseValue(databaseValue) as! T</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">&nbsp;} else { … }</span></div></blockquote></div><div class=""><br class=""></div><div class="">Yes, that's even more clear like that :-)</div><div class=""><br class=""></div><div class="">And for Encodable support, it works just great (not a single line of boilerplate code):</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">&nbsp; &nbsp; private</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">enum</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> Color: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">, </span><span style="font-variant-ligatures: no-common-ligatures" class="">DatabaseValueConvertible</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Encodable</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span style="color: rgb(186, 45, 162);" class="">&nbsp; &nbsp;</span><span style="color: rgb(186, 45, 162);" class="">&nbsp;</span>&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">case</span><span style="font-variant-ligatures: no-common-ligatures" class=""> red, green, blue</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span style="color: rgb(186, 45, 162);" class="">&nbsp; &nbsp;</span><span style="color: rgb(186, 45, 162);" class="">&nbsp;</span>}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><span style="color: rgb(186, 45, 162);" class="">&nbsp; &nbsp;&nbsp;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">&nbsp; &nbsp; private</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">struct</span><span style="font-variant-ligatures: no-common-ligatures" class=""> EncodableStruct : </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Persistable</span><span style="font-variant-ligatures: no-common-ligatures" class="">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Encodable</span><span style="font-variant-ligatures: no-common-ligatures" class=""> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span style="color: rgb(186, 45, 162);" class="">&nbsp; &nbsp;</span><span style="color: rgb(186, 45, 162);" class="">&nbsp;</span>&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">static</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> databaseTableName = </span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"myTable"</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><span style="color: rgb(186, 45, 162);" class="">&nbsp; &nbsp;</span><span style="color: rgb(186, 45, 162);" class="">&nbsp;</span>&nbsp; &nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">let</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> name: </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">String</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span style="color: rgb(186, 45, 162);" class="">&nbsp; &nbsp;</span><span style="color: rgb(186, 45, 162);" class="">&nbsp;</span>&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> color: </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Color</span><span style="font-variant-ligatures: no-common-ligatures" class="">?</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="color: rgb(186, 45, 162);" class="">&nbsp; &nbsp;</span><span style="color: rgb(186, 45, 162);" class="">&nbsp;</span>}</p></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span style="color: rgb(186, 45, 162); font-family: Menlo; font-size: 11px;" class="">&nbsp; &nbsp;&nbsp;</span></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">&nbsp; &nbsp; try</span><span style="font-variant-ligatures: no-common-ligatures" class=""> dbQueue.</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">inDatabase</span><span style="font-variant-ligatures: no-common-ligatures" class=""> { db </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">in</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><span style="color: rgb(186, 45, 162);" class="">&nbsp; &nbsp;</span><span style="color: rgb(186, 45, 162);" class="">&nbsp;</span>&nbsp; &nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">try</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;<span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">EncodableStruct</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(</span><span style="font-variant-ligatures: no-common-ligatures;" class="">name:&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(209, 47, 27);" class="">"Arthur"</span><span style="font-variant-ligatures: no-common-ligatures;" class="">, color: .</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(49, 89, 93);" class="">red</span><span style="font-variant-ligatures: no-common-ligatures;" class="">)</span>.</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(49, 89, 93);" class="">insert</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(db)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span style="color: rgb(186, 45, 162);" class="">&nbsp; &nbsp;</span><span style="color: rgb(186, 45, 162);" class="">&nbsp;</span>}</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div></span></div>Gwendal<div class=""><br class=""></div></div></div></blockquote>
<div style="white-space:normal"><blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px">
</blockquote></div>
</div>
</body>
</html>