OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package datastore | 5 package datastore |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "encoding/base64" | 9 "encoding/base64" |
10 "errors" | 10 "errors" |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 o = v.Bytes() | 317 o = v.Bytes() |
318 } | 318 } |
319 case reflect.Struct: | 319 case reflect.Struct: |
320 if t == typeOfTime { | 320 if t == typeOfTime { |
321 tim := v.Interface().(time.Time) | 321 tim := v.Interface().(time.Time) |
322 if !tim.IsZero() { | 322 if !tim.IsZero() { |
323 o = RoundTime(v.Interface().(time.Time)) | 323 o = RoundTime(v.Interface().(time.Time)) |
324 } | 324 } |
325 } | 325 } |
326 } | 326 } |
| 327 |
| 328 switch t { |
| 329 case typeOfKey: |
| 330 if v.IsNil() { |
| 331 return nil |
| 332 } |
| 333 } |
327 return o | 334 return o |
328 } | 335 } |
329 | 336 |
330 // Value returns the current value held by this property. It's guaranteed to | 337 // Value returns the current value held by this property. It's guaranteed to |
331 // be a valid value type (i.e. `p.SetValue(p.Value(), true)` will never return | 338 // be a valid value type (i.e. `p.SetValue(p.Value(), true)` will never return |
332 // an error). | 339 // an error). |
333 func (p *Property) Value() interface{} { | 340 func (p *Property) Value() interface{} { |
334 switch p.propType { | 341 switch p.propType { |
335 case PTBytes: | 342 case PTBytes: |
336 return p.value.(byteSequence).bytes() | 343 return p.value.(byteSequence).bytes() |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 if string(s) == string(t) { | 979 if string(s) == string(t) { |
973 return 0, true | 980 return 0, true |
974 } | 981 } |
975 if string(s) < string(t) { | 982 if string(s) < string(t) { |
976 return -1, true | 983 return -1, true |
977 } | 984 } |
978 return 0, true | 985 return 0, true |
979 } | 986 } |
980 return 0, false | 987 return 0, false |
981 } | 988 } |
OLD | NEW |