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

Method set_scheme

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

Source from the content-addressed store, hash-verified

14073}
14074
14075inline void url_aggregator::set_scheme(std::string_view new_scheme) noexcept {
14076 ada_log("url_aggregator::set_scheme ", new_scheme);
14077 ADA_ASSERT_TRUE(validate());
14078 ADA_ASSERT_TRUE(new_scheme.empty() || new_scheme.back() != ':');
14079 // next line could overflow but unsigned arithmetic has well-defined
14080 // overflows.
14081 uint32_t new_difference =
14082 uint32_t(new_scheme.size()) - components.protocol_end + 1;
14083
14084 type = ada::scheme::get_scheme_type(new_scheme);
14085 if (buffer.empty()) {
14086 buffer.append(helpers::concat(new_scheme, ":"));
14087 } else {
14088 buffer.erase(0, components.protocol_end);
14089 buffer.insert(0, helpers::concat(new_scheme, ":"));
14090 }
14091 components.protocol_end = uint32_t(new_scheme.size() + 1);
14092
14093 // Update the rest of the components.
14094 components.username_end += new_difference;
14095 components.host_start += new_difference;
14096 components.host_end += new_difference;
14097 components.pathname_start += new_difference;
14098 if (components.search_start != url_components::omitted) {
14099 components.search_start += new_difference;
14100 }
14101 if (components.hash_start != url_components::omitted) {
14102 components.hash_start += new_difference;
14103 }
14104 ADA_ASSERT_TRUE(validate());
14105}
14106
14107bool url_aggregator::set_protocol(const std::string_view input) {
14108 ada_log("url_aggregator::set_protocol ", input);

Callers

nothing calls this directly

Calls 8

get_scheme_typeFunction · 0.85
concatFunction · 0.85
backMethod · 0.80
eraseMethod · 0.80
appendMethod · 0.65
emptyMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected