intermediate commit
Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
parent
6d26da6971
commit
fec84033af
11 changed files with 175 additions and 175 deletions
31
src/values/value.cpp
Normal file
31
src/values/value.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include "ikarus/values/value.h"
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <cppbase/templates.hpp>
|
||||
|
||||
#include <values/number_value.hpp>
|
||||
#include <values/text_value.hpp>
|
||||
#include <values/toggle_value.hpp>
|
||||
#include <values/value.hpp>
|
||||
|
||||
bool ikarus_value_is_indeterminate(IkarusValue const * value) {
|
||||
return value->indeterminate;
|
||||
}
|
||||
|
||||
char const * ikarus_value_to_string(IkarusValue const * value) {
|
||||
auto str = std::visit(
|
||||
cppbase::overloaded{
|
||||
[](IkarusToggleValue const * toggle_value) -> std::string { return toggle_value->value ? "true" : "false"; },
|
||||
[](IkarusNumberValue const * number_value) -> std::string { return fmt::format("{}", number_value->value); },
|
||||
[](IkarusTextValue const * text_value) -> std::string { return fmt::format("{}", text_value->value); },
|
||||
},
|
||||
value->data
|
||||
);
|
||||
|
||||
char * ret = new char[str.size() + 1];
|
||||
|
||||
std::strncpy(ret, str.data(), str.size() + 1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue