Chromium Code Reviews| 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 BoolFlag (which is an Auto/False/True) allow yo u 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 BoolFlag, and no <value> is specified, | |
| 355 // GetMeta will return false. A simple boolean field creates ambiguity w ith | |
| 356 // a default <value>. | |
| 357 // | |
| 358 // Example: | |
| 359 // type MyStruct struct { | |
| 360 // TFlag BoolFlag `gae:"$flag1,true"` // defaults to true | |
|
Vadim Sh.
2015/07/24 18:53:00
update to Toggle & on\off
iannucci
2015/07/24 20:58:10
Done.
| |
| 361 // FFlag BoolFlag `gae:"$flag2,false"` // defaults to false | |
| 362 // Flag BoolFlag `gae:"$flag3"` // defaults to false | |
| 363 // } | |
| 350 GetMeta(key string) (interface{}, error) | 364 GetMeta(key string) (interface{}, error) |
| 351 | 365 |
| 352 // SetMeta allows you to set the current value of the meta-keyed field. | 366 // SetMeta allows you to set the current value of the meta-keyed field. |
| 353 SetMeta(key string, val interface{}) error | 367 SetMeta(key string, val interface{}) error |
| 354 | 368 |
| 355 // Problem indicates that this PLS has a fatal problem. Usually this is | 369 // 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 | 370 // set when the underlying struct has recursion, invalid field types, ne sted |
| 357 // slices, etc. | 371 // slices, etc. |
| 358 Problem() error | 372 Problem() error |
| 359 } | 373 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 430 return err | 444 return err |
| 431 } | 445 } |
| 432 pm["$"+key] = []Property{prop} | 446 pm["$"+key] = []Property{prop} |
| 433 return nil | 447 return nil |
| 434 } | 448 } |
| 435 | 449 |
| 436 // Problem implements PropertyLoadSaver.Problem. It ALWAYS returns nil. | 450 // Problem implements PropertyLoadSaver.Problem. It ALWAYS returns nil. |
| 437 func (pm PropertyMap) Problem() error { | 451 func (pm PropertyMap) Problem() error { |
| 438 return nil | 452 return nil |
| 439 } | 453 } |
| OLD | NEW |