Loading...
Searching...
No Matches
ValueConversion.hpp
1#pragma once
2#include <State/Value.hpp>
3
4#include <QChar>
5#include <QString>
6#include <QStringList>
7#include <QVariant>
8
9namespace State
10{
11namespace convert
12{
13
14template <typename To>
15To value(const ossia::value& val)
16{
17 static_assert(sizeof(To) == -1, "Type not supported.");
18}
19
20template <>
21SCORE_LIB_STATE_EXPORT QVariant value(const ossia::value& val);
22template <>
23SCORE_LIB_STATE_EXPORT int value(const ossia::value& val);
24template <>
25SCORE_LIB_STATE_EXPORT float value(const ossia::value& val);
26template <>
27SCORE_LIB_STATE_EXPORT bool value(const ossia::value& val);
28template <>
29SCORE_LIB_STATE_EXPORT double value(const ossia::value& val);
30template <>
31SCORE_LIB_STATE_EXPORT QString value(const ossia::value& val);
32template <>
33SCORE_LIB_STATE_EXPORT QChar value(const ossia::value& val);
34template <>
35SCORE_LIB_STATE_EXPORT std::string value(const ossia::value& val);
36template <>
37SCORE_LIB_STATE_EXPORT char value(const ossia::value& val);
38template <>
39SCORE_LIB_STATE_EXPORT vec2f value(const ossia::value& val);
40template <>
41SCORE_LIB_STATE_EXPORT vec3f value(const ossia::value& val);
42template <>
43SCORE_LIB_STATE_EXPORT vec4f value(const ossia::value& val);
44template <>
45SCORE_LIB_STATE_EXPORT list_t value(const ossia::value& val);
46template <>
47SCORE_LIB_STATE_EXPORT ossia::value_map_type value(const ossia::value& val);
48
49SCORE_LIB_STATE_EXPORT bool convert(const ossia::value& orig, ossia::value& toConvert);
50
51// Adornishments to allow to differentiate between different value types, e.g.
52// 'a', ['a', 12], or "str" for a string.
53SCORE_LIB_STATE_EXPORT QString toPrettyString(const ossia::value& val);
54
55// We require the type to crrectly read back (e.g. int / float / char)
56// and as an optimization, since we may need it multiple times,
57// we chose to leave the caller save it however he wants. Hence the specific
58// API.
59SCORE_LIB_STATE_EXPORT QString
60textualType(const ossia::value& val); // For JSONValue serialization
61SCORE_LIB_STATE_EXPORT ossia::value fromQVariant(const QVariant& val);
62SCORE_LIB_STATE_EXPORT QString
63prettyType(const ossia::value& val); // For display to the user, translated
64SCORE_LIB_STATE_EXPORT
65QString prettyType(ossia::val_type); // For display to the user, translated
66SCORE_LIB_STATE_EXPORT const std::array<const QString, 11>&
67ValuePrettyTypesArray(); // For display to the user, translated
68SCORE_LIB_STATE_EXPORT const QStringList&
69ValuePrettyTypesList(); // For display to the user, translated
70SCORE_LIB_STATE_EXPORT const std::array<std::pair<QString, ossia::val_type>, 10>&
71ValuePrettyTypesMap();
72}
73}
Utilities for OSSIA data structures.
Definition DeviceInterface.hpp:33