| 220 | } |
| 221 | |
| 222 | void ScriptText::ParamCheck::Encode(StringBuilder &builder, std::string_view cmd) |
| 223 | { |
| 224 | if (this->cmd.empty()) this->cmd = cmd; |
| 225 | if (this->used) return; |
| 226 | |
| 227 | struct visitor { |
| 228 | StringBuilder &builder; |
| 229 | |
| 230 | void operator()(const std::monostate &) { } |
| 231 | |
| 232 | void operator()(std::string value) |
| 233 | { |
| 234 | this->builder.PutUtf8(SCC_ENCODED_STRING); |
| 235 | StrMakeValidInPlace(value, {StringValidationSetting::ReplaceWithQuestionMark, StringValidationSetting::AllowNewline, StringValidationSetting::ReplaceTabCrNlWithSpace}); |
| 236 | this->builder.Put(value); |
| 237 | } |
| 238 | |
| 239 | void operator()(const SQInteger &value) |
| 240 | { |
| 241 | this->builder.PutUtf8(SCC_ENCODED_NUMERIC); |
| 242 | /* Sign-extend the value, then store as unsigned */ |
| 243 | this->builder.PutIntegerBase<uint64_t>(static_cast<uint64_t>(static_cast<int64_t>(value)), 16); |
| 244 | } |
| 245 | |
| 246 | void operator()(const ScriptTextRef &value) |
| 247 | { |
| 248 | this->builder.PutUtf8(SCC_ENCODED); |
| 249 | this->builder.PutIntegerBase(value->string.base(), 16); |
| 250 | } |
| 251 | }; |
| 252 | |
| 253 | builder.PutUtf8(SCC_RECORD_SEPARATOR); |
| 254 | std::visit(visitor{builder}, *this->param); |
| 255 | this->used = true; |
| 256 | } |
| 257 | |
| 258 | void ScriptText::_GetEncodedText(StringBuilder &builder, int ¶m_count, ParamSpan args, bool first) |
| 259 | { |
no test coverage detected