8 #include <hilti/ast/builder/expression.h> 9 #include <hilti/ast/operators/common.h> 10 #include <hilti/ast/types/bool.h> 11 #include <hilti/ast/types/bytes.h> 12 #include <hilti/ast/types/string.h> 16 STANDARD_OPERATOR_2(
string, Equal, type::Bool(), type::String(), type::String(),
17 "Compares two strings lexicographically.")
18 STANDARD_OPERATOR_2(
string, Unequal, type::Bool(), type::String(), type::String(),
19 "Compares two strings lexicographically.")
20 STANDARD_OPERATOR_1(
string, Size, type::UnsignedInteger(64), type::String(),
21 "Returns the number of characters the
string contains.");
22 STANDARD_OPERATOR_2(
string, Sum, type::String(), type::String(), type::String(),
23 "Returns the concatenation of two strings.");
25 BEGIN_METHOD(
string, Encode)
26 const auto& signature()
const {
27 static auto _signature =
28 Signature{.self = type::constant(type::String()),
29 .result = type::Bytes(),
31 .args = {{
"charset", type::Enum(type::Wildcard()),
false, builder::id(
"hilti::Charset::UTF8")}},
34 Converts the string into a binary representation encoded with the given character set. 40 BEGIN_OPERATOR_CUSTOM(
string, Modulo)
43 bool isLhs()
const {
return false; }
44 auto priority()
const {
return hilti::operator_::Priority::Normal; }
46 const std::vector<Operand>& operands()
const {
47 static std::vector<Operand> _operands = {{{}, type::String()}, {{}, type::Any()}};
51 void validate(
const expression::ResolvedOperator& , operator_::position_t )
const {
58 std::string doc()
const {
return "Renders a printf-style format string."; }
Definition: operator-registry.h:15