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 rawdatastore | 5 package rawdatastore |
6 | 6 |
7 import ( | 7 import ( |
8 "errors" | 8 "errors" |
9 "fmt" | 9 "fmt" |
10 "math" | 10 "math" |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 // type MyStruct struct { | 340 // type MyStruct struct { |
341 // CoolField int64 `gae:"$id,1"` | 341 // CoolField int64 `gae:"$id,1"` |
342 // } | 342 // } |
343 // val, err := helper.GetPLS(&MyStruct{}).GetMeta("id") | 343 // val, err := helper.GetPLS(&MyStruct{}).GetMeta("id") |
344 // // val == 1 | 344 // // val == 1 |
345 // // err == nil | 345 // // err == nil |
346 // | 346 // |
347 // val, err := helper.GetPLS(&MyStruct{10}).GetMeta("id") | 347 // val, err := helper.GetPLS(&MyStruct{10}).GetMeta("id") |
348 // // val == 10 | 348 // // val == 10 |
349 // // err == nil | 349 // // err == nil |
| 350 // |
| 351 // Struct fields of type Toggle (which is an Auto/On/Off) allow you to |
| 352 // specify a value of 'true' or 'false' for the default value of the str
uct |
| 353 // tag, and GetMeta will return the combined value as a regular boolean
true |
| 354 // or false value. If a field is Toggle, a <value> MUST be specified. |
| 355 // |
| 356 // Example: |
| 357 // type MyStruct struct { |
| 358 // TFlag Toggle `gae:"$flag1,true"` // defaults to true |
| 359 // FFlag Toggle `gae:"$flag2,false"` // defaults to false |
| 360 // // BadFlag Toggle `gae:"$flag3"` // ILLEGAL |
| 361 // } |
350 GetMeta(key string) (interface{}, error) | 362 GetMeta(key string) (interface{}, error) |
351 | 363 |
352 // SetMeta allows you to set the current value of the meta-keyed field. | 364 // SetMeta allows you to set the current value of the meta-keyed field. |
353 SetMeta(key string, val interface{}) error | 365 SetMeta(key string, val interface{}) error |
354 | 366 |
355 // Problem indicates that this PLS has a fatal problem. Usually this is | 367 // Problem indicates that this PLS has a fatal problem. Usually this is |
356 // set when the underlying struct has recursion, invalid field types, ne
sted | 368 // set when the underlying struct has recursion, invalid field types, ne
sted |
357 // slices, etc. | 369 // slices, etc. |
358 Problem() error | 370 Problem() error |
359 } | 371 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 return err | 442 return err |
431 } | 443 } |
432 pm["$"+key] = []Property{prop} | 444 pm["$"+key] = []Property{prop} |
433 return nil | 445 return nil |
434 } | 446 } |
435 | 447 |
436 // Problem implements PropertyLoadSaver.Problem. It ALWAYS returns nil. | 448 // Problem implements PropertyLoadSaver.Problem. It ALWAYS returns nil. |
437 func (pm PropertyMap) Problem() error { | 449 func (pm PropertyMap) Problem() error { |
438 return nil | 450 return nil |
439 } | 451 } |
OLD | NEW |