Features:
- Reflection (to XML)
- UnWrapping (from XML)
- Class and StructSupport
- Array and Dictionary Support
- Inheritance support (OOP)
/**
* NOTE: we use 32 bit RGBA values when storing color data (This also stores the alpha value)
* NOTE: XML is used as the storage syntax. JSON could be used but there was no apparent benefit so XML it is
*/
let temp = Temp(NSColor.redColor())
let xml = Reflection.toXML(temp)/*Reflection*/
print(xml.XMLString)//Output: <Temp><color type="NSColor">FFFF0000</color></Temp>
let newInstance = Temp.unWrap(xml)!/*UnWrapping*/
print(newInstance.color.hexString)//Output: FF0000
class Temp{
var color:NSColor
init(_ color:NSColor){
self.color = color
}
}
extension Temp:UnWrappable{
static func unWrap<T>(xml:XML) -> T? {
let color:NSColor? = unWrap(xml,"color")
return Temp(color!) as? T
}
}