<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body 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="">On 27 May 2017, at 12:40, Gwendal Roué <<a href="mailto:gwendal.roue@gmail.com" class="">gwendal.roue@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">Le 27 mai 2017 à 11:59, David Hart <<a href="mailto:david@hartbit.com" class="">david@hartbit.com</a>> 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=""> 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=""> 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=""> 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=""> } 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=""> private</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">enum</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> Color: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span><span style="font-variant-ligatures: no-common-ligatures;" class="">, </span><span style="font-variant-ligatures: no-common-ligatures" class="">DatabaseValueConvertible</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=""> </span><span style="color: rgb(186, 45, 162);" class=""> </span> </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=""> </span><span style="color: rgb(186, 45, 162);" class=""> </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=""> </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=""> 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=""> </span><span style="color: rgb(186, 45, 162);" class=""> </span> </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=""> </span><span style="color: rgb(186, 45, 162);" class=""> </span> </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=""> </span><span style="color: rgb(186, 45, 162);" class=""> </span> </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><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="color: rgb(186, 45, 162);" class=""> </span><span style="color: rgb(186, 45, 162);" class=""> </span>}</div></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=""> </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=""> 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=""> </span><span style="color: rgb(186, 45, 162);" class=""> </span> </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=""> <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: </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=""> </span><span style="color: rgb(186, 45, 162);" class=""> </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><br class=""><div class="">As a user of GRDB: <span style="font-size: 38px;" class="">😍</span></div></body></html>