| 6 | #define BASE_VALUE_CONVERSIONS_H_ |
| 7 |
| 8 | // This file contains methods to convert things to a |Value| and back. |
| 9 |
| 10 | #include <memory> |
| 11 |
| 12 | #include "base/base_export.h" |
| 13 | #include "base/compiler_specific.h" |
| 14 |
| 15 | namespace base { |
| 16 |
| 17 | class FilePath; |
| 18 | class Time; |
| 19 | class TimeDelta; |
| 20 | class UnguessableToken; |
| 21 | class Value; |
| 22 |
| 23 | // In GetValueAs*() functions, the caller owns the object pointed by the output |
| 24 | // parameter, e.g. |file_path|. If false is returned, the value of the object |
| 25 | // pointed by the output parameter is not changed. It is okay to pass nullptr to |
| 26 | // the output parameter. |
| 27 |
| 28 | // Warning: The Values involved could be stored on persistent storage like files |
| 29 | // on disks. Therefore, changes in implementation could lead to data corruption |
| 30 | // and must be done with caution. |
| 31 |
| 32 | BASE_EXPORT Value CreateFilePathValue(const FilePath& in_value); |
| 33 | BASE_EXPORT bool GetValueAsFilePath(const Value& value, |
| 34 | FilePath* file_path) WARN_UNUSED_RESULT; |
| 35 |
| 36 | BASE_EXPORT Value CreateTimeValue(const Time& time); |
| 37 | BASE_EXPORT bool GetValueAsTime(const Value& value, |
| 38 | Time* time) WARN_UNUSED_RESULT; |
| 39 |
| 40 | BASE_EXPORT Value CreateTimeDeltaValue(const TimeDelta& time_delta); |
| 41 | BASE_EXPORT bool GetValueAsTimeDelta(const Value& value, |
| 42 | TimeDelta* time_delta) WARN_UNUSED_RESULT; |
| 43 |
| 44 | BASE_EXPORT Value CreateUnguessableTokenValue(const UnguessableToken& token); |
| 45 | BASE_EXPORT bool GetValueAsUnguessableToken(const Value& value, |
| 46 | UnguessableToken* token) |
| 47 | WARN_UNUSED_RESULT; |
| 48 |
| 49 | } // namespace base |
| 50 |
| 51 | #endif // BASE_VALUE_CONVERSIONS_H_ |
| 52 |