value_util.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2018 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 COMPONENTS_MIRRORING_SERVICE_VALUE_UTIL_H_
  5. #define COMPONENTS_MIRRORING_SERVICE_VALUE_UTIL_H_
  6. #include <string>
  7. #include "base/component_export.h"
  8. #include "base/values.h"
  9. namespace mirroring {
  10. // Read certain type of data from dictionary |value| if |key| exits. Return
  11. // false if |key| exists and the type of the data mismatches. Return true
  12. // otherwise.
  13. COMPONENT_EXPORT(MIRRORING_SERVICE)
  14. bool GetInt(const base::Value& value, const std::string& key, int32_t* result);
  15. COMPONENT_EXPORT(MIRRORING_SERVICE)
  16. bool GetDouble(const base::Value& value,
  17. const std::string& key,
  18. double* result);
  19. COMPONENT_EXPORT(MIRRORING_SERVICE)
  20. bool GetString(const base::Value& value,
  21. const std::string& key,
  22. std::string* result);
  23. COMPONENT_EXPORT(MIRRORING_SERVICE)
  24. bool GetBool(const base::Value& value, const std::string& key, bool* result);
  25. COMPONENT_EXPORT(MIRRORING_SERVICE)
  26. bool GetIntArray(const base::Value& value,
  27. const std::string& key,
  28. std::vector<int32_t>* result);
  29. COMPONENT_EXPORT(MIRRORING_SERVICE)
  30. bool GetStringArray(const base::Value& value,
  31. const std::string& key,
  32. std::vector<std::string>* result);
  33. } // namespace mirroring
  34. #endif // COMPONENTS_MIRRORING_SERVICE_VALUE_UTIL_H_