-
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathstring_operations.h
More file actions
86 lines (73 loc) · 2.18 KB
/
string_operations.h
File metadata and controls
86 lines (73 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/* Copyright (c) 2024 Julian Benda
*
* This file is part of inkCPP which is released under MIT license.
* See file LICENSE.txt or go to
* https://github.com/JBenda/inkcpp for full license details.
*/
#pragma once
/// defines operations allowed on strings.
namespace ink::runtime::internal
{
namespace casting
{
// define valid castings
// when operate on float and string, the result is a string
template<>
struct cast<value_type::float32, value_type::string> {
static constexpr value_type value = value_type::string;
};
template<>
struct cast<value_type::int32, value_type::string> {
static constexpr value_type value = value_type::string;
};
template<>
struct cast<value_type::uint32, value_type::string> {
static constexpr value_type value = value_type::string;
};
template<>
struct cast<value_type::boolean, value_type::string> {
static constexpr value_type value = value_type::string;
};
template<>
struct cast<value_type::string, value_type::newline> {
static constexpr value_type value = value_type::string;
};
} // namespace casting
// operation declaration add
template<>
class operation<Command::ADD, value_type::string, void> : public operation_base<string_table>
{
public:
using operation_base::operation_base;
void operator()(basic_eval_stack& stack, value* vals);
};
// operation declaration equality
template<>
class operation<Command::IS_EQUAL, value_type::string, void> : public operation_base<void>
{
public:
using operation_base::operation_base;
void operator()(basic_eval_stack& stack, value* vals);
};
template<>
class operation<Command::NOT_EQUAL, value_type::string, void> : public operation_base<void>
{
public:
using operation_base::operation_base;
void operator()(basic_eval_stack& stack, value* vals);
};
template<>
class operation<Command::HAS, value_type::string, void> : public operation_base<void>
{
public:
using operation_base::operation_base;
void operator()(basic_eval_stack& stack, value* vals);
};
template<>
class operation<Command::HASNT, value_type::string, void> : public operation_base<void>
{
public:
using operation_base::operation_base;
void operator()(basic_eval_stack& stack, value* vals);
};
} // namespace ink::runtime::internal