MCPcopy Create free account
hub / github.com/NativeScript/android / to_string

Method to_string

test-app/runtime/src/main/cpp/ada/ada.cpp:12542–12590  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12540}
12541
12542[[nodiscard]] std::string url::to_string() const {
12543 if (!is_valid) {
12544 return "null";
12545 }
12546 std::string answer;
12547 auto back = std::back_insert_iterator(answer);
12548 answer.append("{\n");
12549 answer.append("\t\"protocol\":\"");
12550 helpers::encode_json(get_protocol(), back);
12551 answer.append("\",\n");
12552 if (has_credentials()) {
12553 answer.append("\t\"username\":\"");
12554 helpers::encode_json(username, back);
12555 answer.append("\",\n");
12556 answer.append("\t\"password\":\"");
12557 helpers::encode_json(password, back);
12558 answer.append("\",\n");
12559 }
12560 if (host.has_value()) {
12561 answer.append("\t\"host\":\"");
12562 helpers::encode_json(host.value(), back);
12563 answer.append("\",\n");
12564 }
12565 if (port.has_value()) {
12566 answer.append("\t\"port\":\"");
12567 answer.append(std::to_string(port.value()));
12568 answer.append("\",\n");
12569 }
12570 answer.append("\t\"path\":\"");
12571 helpers::encode_json(path, back);
12572 answer.append("\",\n");
12573 answer.append("\t\"opaque path\":");
12574 answer.append((has_opaque_path ? "true" : "false"));
12575 if (has_search()) {
12576 answer.append(",\n");
12577 answer.append("\t\"query\":\"");
12578 // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
12579 helpers::encode_json(query.value(), back);
12580 answer.append("\"");
12581 }
12582 if (hash.has_value()) {
12583 answer.append(",\n");
12584 answer.append("\t\"hash\":\"");
12585 helpers::encode_json(hash.value(), back);
12586 answer.append("\"");
12587 }
12588 answer.append("\n}");
12589 return answer;
12590}
12591
12592[[nodiscard]] bool url::has_valid_domain() const noexcept {
12593 if (!host.has_value()) {

Callers 3

parse_url_implFunction · 0.60
set_hrefMethod · 0.60

Calls 6

encode_jsonFunction · 0.85
to_stringFunction · 0.85
valueMethod · 0.80
appendMethod · 0.65
has_valueMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected