/* LICENSE BEGIN This file is part of the SixtyFPS Project -- https://sixtyfps.io Copyright (c) 2020 Olivier Goffart Copyright (c) 2020 Simon Hausmann SPDX-License-Identifier: GPL-3.0-only This file is also available under commercial licensing terms. Please contact info@sixtyfps.io for more information. LICENSE END */ #pragma once #include "sixtyfps.h" #include "sixtyfps_interpreter_internal.h" #include namespace sixtyfps::interpreter { class Value { public: Value() { cbindgen_private::sixtyfps_interpreter_value_new(&inner); } Value(const Value &); Value(Value &&); Value &operator=(Value &&); Value &operator=(const Value &); ~Value() { cbindgen_private::sixtyfps_interpreter_value_destructor(&inner); } using Type = cbindgen_private::ValueType; // only works on Type::Struct std::optional get_field(std::string_view) const; // only works on Type::Struct bool set_field(std::string_view, Value); // returns false if Value is not a Struct // optional to_int() const; // optional to_float() const; std::optional to_number() const; std::optional to_string() const; std::optional to_bool() const; std::optional> to_array() const; std::optional>> to_model() const; std::optional to_brush() const; // std::optional to_struct() const; // template std::optional get() const; Value(double); Value(const SharedString &); Value(bool); Value(const SharedVector &); Value(const std::shared_ptr> &); Value(const sixtyfps::Brush &); // Value(const Struct &); explicit Value(Type); Type type() const { return cbindgen_private::sixtyfps_interpreter_value_type(&inner); } private: sixtyfps::cbindgen_private::ValueOpaque inner; }; }