 //  Copyright (c) 2014 Stephan Zehrer. All rights reserved.
 //
 
-enum PropertyType: UInt8 {
-    case kUndefined = 0
-    case kBoolType  // bufferLength not used
-    case kLongType
-    case kUnsignedLongType
-    case kDoubleType
-    case kStringType
-    // case kNSNumberType
-    // case kNSDataType
-    // case kSOIDType
-    case kNSDateType
-    // case kNSPointType
-    case kNSRangeType
-    case kNSDecimalType
-    case kNSUUIDType
-    case kNSURLType               // may not work
+public enum PropertyType: String {
+    case kUndefined         = "1" // NO ENCODE
+    case kBoolType          = "2" // Encode: DONE
+    case kIntType           = "3" // Encode: DONE (longValue)
+    case kDoubleType        = "4" // Encode: DONE
+    case kStringType        = "5" // Encode: partially done (length check TODO)
+    case kNSDateType        = "6" // TODO
+    case kNSUUIDType        = "7" // TODO
+    
+    //case kNSURLType         = "C"  // TODO
+    //case kNSRangeType       = "B"
+    
+   
+    //case kUnsignedLongType  = "X"
+    //case kNSNumberType
+    //case kNSDecimalNumberType
+    //case kNSDataType  --> file
+    //case kSOIDType -->??
+    //case kNSPointType
 }
 
 
 public struct PROPERTY : Init {
-    
-    public static let DEFAULT_VALUE : UInt8 = 255
-
-    // header
-    var isNodeSource: Bool = false;         // 1 Byte  <- yes = property of a node / no = property of a relationship
-    var isUTF8Encoding: Bool = true;        // 1 Byte  <- yes internal string usues UTF8 / NO == UTF16
+
+    //var type: PropertyType = .kUndefined;   // 1
+    
+    var isNodeSource: Bool = false;         // 3  <- yes = property of a node / no = property of a relationship
+    //var isUTF8Encoding: Bool = true;      // --  <- yes internal string usues UTF8 / NO == UTF16
     
     // TODO use default length?
-    var bufferLength: UInt8 = 0;            // 1 Byte
-    
-    var type: PropertyType = .kUndefined;   // 1 Byte
-    
-    var sourceID: UID = 0;                  // 4 Byte <- link to the source object
-    
-    var propertyKeyNodeID: UID = 0;         // 4 Byte <- "type" of this property
-    
-    var prevPropertyID: UID = 0;            // 4 Byte <- 0 if start
-    var nextPropertyID: UID = 0;            // 4 Byte <- 0 if end
-    
-    var buffer = [UInt8](count: 20, repeatedValue: DEFAULT_VALUE)  // 20 Byte
+    //var bufferLength: UInt8 = 0;          // --
+    
+    var sourceID: UID = 0;                  //  <- link to the source object
+    
+    var propertyKeyNodeID: UID = 0;         //  <- "type" of this property
+    
+    var prevPropertyID: UID = 0;            //  !<- 0 if start
+    var nextPropertyID: UID = 0;            //  !<- 0 if end
+
     
     public init() {
         

    return lhs.uid == rhs.uid
}

public class Property : GraphElement, Coding, Equatable {
    
    //MARK: Init
    
    public var data: PROPERTY = PROPERTY()
    
    var stringHash : Int? = nil
    //var stringStoreUID : UID? = nil

    public required init() {
    }
    
    // UseCase: Init with data during read
    required public init(data: PROPERTY) {
        //phase 1

    
    }
    
    //MARK: INT 
    
    public var intValue : Int? {
        get {
            if numberData != nil {
                return numberData!.longValue
            }
            return nil
        }
        set {
            if intValue != newValue {
                dirty = true
                type = .kIntType
                
                if (newValue != nil) {
                    numberData = NSNumber(long:newValue!)
                } else {
                    numberData = nil
                }
                
            }
        }
        
    }
    
    //MARK: STRING
    
    public var stringValue : String? {
        get{
            return stringData
        }
        set {
            if stringData != newValue {
                dirty = true
                type = .kStringType
                
                stringData = newValue
            }
        }
    }
}


