value_conversions.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_VALUE_CONVERSIONS_H_
  5. #define BASE_VALUE_CONVERSIONS_H_
  6. // This file contains methods to convert things to a |Value| and back.
  7. //
  8. // Deprecated: use the base/util/values/values_util.h functions instead.
  9. #include <memory>
  10. #include "base/base_export.h"
  11. #include "base/compiler_specific.h"
  12. namespace base {
  13. class FilePath;
  14. class Time;
  15. class TimeDelta;
  16. class UnguessableToken;
  17. class Value;
  18. // In GetValueAs*() functions, the caller owns the object pointed by the output
  19. // parameter, e.g. |file_path|. If false is returned, the value of the object
  20. // pointed by the output parameter is not changed. It is okay to pass nullptr to
  21. // the output parameter.
  22. // Warning: The Values involved could be stored on persistent storage like files
  23. // on disks. Therefore, changes in implementation could lead to data corruption
  24. // and must be done with caution.
  25. BASE_EXPORT Value CreateFilePathValue(const FilePath& in_value);
  26. BASE_EXPORT bool GetValueAsFilePath(const Value& value,
  27. FilePath* file_path) WARN_UNUSED_RESULT;
  28. BASE_EXPORT Value CreateTimeValue(const Time& time);
  29. BASE_EXPORT bool GetValueAsTime(const Value& value,
  30. Time* time) WARN_UNUSED_RESULT;
  31. BASE_EXPORT Value CreateTimeDeltaValue(const TimeDelta& time_delta);
  32. BASE_EXPORT bool GetValueAsTimeDelta(const Value& value,
  33. TimeDelta* time_delta) WARN_UNUSED_RESULT;
  34. BASE_EXPORT Value CreateUnguessableTokenValue(const UnguessableToken& token);
  35. BASE_EXPORT bool GetValueAsUnguessableToken(const Value& value,
  36. UnguessableToken* token)
  37. WARN_UNUSED_RESULT;
  38. } // namespace base
  39. #endif // BASE_VALUE_CONVERSIONS_H_