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> 17 STANDARD_OPERATOR_2(
string, Equal, type::Bool(), type::String(), type::String(),
18 "Compares two strings lexicographically.")
19 STANDARD_OPERATOR_2(
string, Unequal, type::Bool(), type::String(), type::String(),
20 "Compares two strings lexicographically.")
21 STANDARD_OPERATOR_1(
string, Size, type::UnsignedInteger(64), type::String(),
22 "Returns the number of characters the
string contains.");
23 STANDARD_OPERATOR_2(
string, Sum, type::String(), type::String(), type::String(),
24 "Returns the concatenation of two strings.");
26 BEGIN_METHOD(
string, Encode)
27 auto signature()
const {
28 return Signature{.self = type::constant(type::String()),
29 .result = type::Bytes(),
31 .args = {{.id =
"charset",
32 .type = type::Enum(type::Wildcard()),
33 .default_ = builder::id(
"hilti::Charset::UTF8")}},
36 Converts the string into a binary representation encoded with the given character set. 41 BEGIN_OPERATOR_CUSTOM(string, Modulo)
42 Type result(
const std::vector<Expression>& )
const {
return type::String(); }
44 bool isLhs()
const {
return false; }
46 std::vector<Operand> operands()
const {
return {{.type = type::String()}, {.type = type::Any()}}; }
48 void validate(
const expression::ResolvedOperator& , operator_::position_t )
const {
55 std::string doc()
const {
return "Renders a printf-style format string."; }