values.h 914 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2016 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 VALUES_H_
  5. #define VALUES_H_
  6. #include <memory>
  7. #include <string>
  8. #include <vector>
  9. namespace base {
  10. class Value {
  11. public:
  12. using ListStorage = std::vector<Value>;
  13. ListStorage& GetList();
  14. const ListStorage& GetList() const;
  15. protected:
  16. ListStorage list_;
  17. };
  18. class ListValue : public Value {
  19. public:
  20. void Clear();
  21. size_t GetSize() const;
  22. bool empty() const;
  23. void Reserve(size_t);
  24. void AppendBoolean(bool);
  25. void AppendInteger(int);
  26. void AppendDouble(double);
  27. void AppendString(std::string);
  28. void Append(std::unique_ptr<Value> in_value);
  29. void AppendStrings(const std::vector<std::string>& in_values);
  30. bool AppendIfNotPresent(std::unique_ptr<Value> in_value);
  31. };
  32. } // namespace base
  33. #endif // VALUES_H_