Skip to content

Commit

Permalink
added set functions
Browse files Browse the repository at this point in the history
  • Loading branch information
schochastics committed Oct 16, 2023
1 parent ba3392c commit 80cdfc9
Show file tree
Hide file tree
Showing 8 changed files with 537 additions and 20 deletions.
10 changes: 10 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ export(ada_has_non_empty_password)
export(ada_has_non_empty_username)
export(ada_has_port)
export(ada_has_search)
export(ada_set_hash)
export(ada_set_host)
export(ada_set_hostname)
export(ada_set_href)
export(ada_set_password)
export(ada_set_pathname)
export(ada_set_port)
export(ada_set_protocol)
export(ada_set_search)
export(ada_set_username)
export(ada_url_parse)
export(public_suffix)
export(url_decode2)
Expand Down
40 changes: 40 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,46 @@ Rcpp_ada_get_protocol <- function(url_vec, decode) {
.Call(`_adaR_Rcpp_ada_get_protocol`, url_vec, decode)
}

Rcpp_ada_set_href <- function(url_vec, subst, decode) {
.Call(`_adaR_Rcpp_ada_set_href`, url_vec, subst, decode)
}

Rcpp_ada_set_username <- function(url_vec, subst, decode) {
.Call(`_adaR_Rcpp_ada_set_username`, url_vec, subst, decode)
}

Rcpp_ada_set_password <- function(url_vec, subst, decode) {
.Call(`_adaR_Rcpp_ada_set_password`, url_vec, subst, decode)
}

Rcpp_ada_set_port <- function(url_vec, subst, decode) {
.Call(`_adaR_Rcpp_ada_set_port`, url_vec, subst, decode)
}

Rcpp_ada_set_host <- function(url_vec, subst, decode) {
.Call(`_adaR_Rcpp_ada_set_host`, url_vec, subst, decode)
}

Rcpp_ada_set_hostname <- function(url_vec, subst, decode) {
.Call(`_adaR_Rcpp_ada_set_hostname`, url_vec, subst, decode)
}

Rcpp_ada_set_pathname <- function(url_vec, subst, decode) {
.Call(`_adaR_Rcpp_ada_set_pathname`, url_vec, subst, decode)
}

Rcpp_ada_set_protocol <- function(url_vec, subst, decode) {
.Call(`_adaR_Rcpp_ada_set_protocol`, url_vec, subst, decode)
}

Rcpp_ada_set_search <- function(url_vec, subst, decode) {
.Call(`_adaR_Rcpp_ada_set_search`, url_vec, subst, decode)
}

Rcpp_ada_set_hash <- function(url_vec, subst, decode) {
.Call(`_adaR_Rcpp_ada_set_hash`, url_vec, subst, decode)
}

Rcpp_url_decode2 <- function(url) {
.Call(`_adaR_Rcpp_url_decode2`, url)
}
Expand Down
93 changes: 93 additions & 0 deletions R/set.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
.set <- function(url, decode, input, func) {
if (is.null(url)) {
return(character(0))
}
if (is.null(input)) {
return(url)
}
if (length(input) == 1) {
input <- rep(input, length(url))
}
if (length(input) != length(url)) {
stop("input must have lkength one ot the same length as url", call. = FALSE)
}
func(url, input, decode)
}

#' Set a specific component of URL
#'
#' These functions set a specific component of URL.
#' @inheritParams ada_url_parse
#' @param input character. containing new component for URL. Vector of length 1
#' or same length as url.
#' @return character, `NA` if not a valid URL
#' @examples
#' url <- "https://user_1:[email protected]:8080/dir/../api?q=1#frag"
#' ada_set_href(url, "https://google.de")
#' ada_set_username(url, "user_2")
#' ada_set_password(url, "hunter2")
#' ada_set_port(url, "1234")
#' ada_set_hash(url, "#section1")
#' ada_set_host(url, "example.de")
#' ada_set_hostname(url, "example.de")
#' ada_set_pathname(url, "path/")
#' ada_set_search(url, "q=2")
#' ada_set_protocol(url, "ws:")
#' @export
ada_set_href <- function(url, input, decode = TRUE) {
.set(url, decode, input, Rcpp_ada_set_href)
}

#' @rdname ada_set_href
#' @export
ada_set_username <- function(url, input, decode = TRUE) {
.set(url, decode, input, Rcpp_ada_set_username)
}

#' @rdname ada_set_href
#' @export
ada_set_password <- function(url, input, decode = TRUE) {
.set(url, decode, input, Rcpp_ada_set_password)
}

#' @rdname ada_set_href
#' @export
ada_set_port <- function(url, input, decode = TRUE) {
.set(url, decode, input, Rcpp_ada_set_port)
}

#' @rdname ada_set_href
#' @export
ada_set_host <- function(url, input, decode = TRUE) {
.set(url, decode, input, Rcpp_ada_set_host)
}

#' @rdname ada_set_href
#' @export
ada_set_hostname <- function(url, input, decode = TRUE) {
.set(url, decode, input, Rcpp_ada_set_hostname)
}

#' @rdname ada_set_href
#' @export
ada_set_pathname <- function(url, input, decode = TRUE) {
.set(url, decode, input, Rcpp_ada_set_pathname)
}

#' @rdname ada_set_href
#' @export
ada_set_protocol <- function(url, input, decode = TRUE) {
.set(url, decode, input, Rcpp_ada_set_protocol)
}

#' @rdname ada_set_href
#' @export
ada_set_search <- function(url, input, decode = TRUE) {
.set(url, decode, input, Rcpp_ada_set_search)
}

#' @rdname ada_set_href
#' @export
ada_set_hash <- function(url, input, decode = TRUE) {
.set(url, decode, input, Rcpp_ada_set_hash)
}
62 changes: 62 additions & 0 deletions man/ada_set_href.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

140 changes: 140 additions & 0 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,136 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}
// Rcpp_ada_set_href
CharacterVector Rcpp_ada_set_href(const CharacterVector& url_vec, const CharacterVector& subst, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_set_href(SEXP url_vecSEXP, SEXP substSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type url_vec(url_vecSEXP);
Rcpp::traits::input_parameter< const CharacterVector& >::type subst(substSEXP);
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_set_href(url_vec, subst, decode));
return rcpp_result_gen;
END_RCPP
}
// Rcpp_ada_set_username
CharacterVector Rcpp_ada_set_username(const CharacterVector& url_vec, const CharacterVector& subst, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_set_username(SEXP url_vecSEXP, SEXP substSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type url_vec(url_vecSEXP);
Rcpp::traits::input_parameter< const CharacterVector& >::type subst(substSEXP);
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_set_username(url_vec, subst, decode));
return rcpp_result_gen;
END_RCPP
}
// Rcpp_ada_set_password
CharacterVector Rcpp_ada_set_password(const CharacterVector& url_vec, const CharacterVector& subst, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_set_password(SEXP url_vecSEXP, SEXP substSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type url_vec(url_vecSEXP);
Rcpp::traits::input_parameter< const CharacterVector& >::type subst(substSEXP);
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_set_password(url_vec, subst, decode));
return rcpp_result_gen;
END_RCPP
}
// Rcpp_ada_set_port
CharacterVector Rcpp_ada_set_port(const CharacterVector& url_vec, const CharacterVector& subst, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_set_port(SEXP url_vecSEXP, SEXP substSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type url_vec(url_vecSEXP);
Rcpp::traits::input_parameter< const CharacterVector& >::type subst(substSEXP);
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_set_port(url_vec, subst, decode));
return rcpp_result_gen;
END_RCPP
}
// Rcpp_ada_set_host
CharacterVector Rcpp_ada_set_host(const CharacterVector& url_vec, const CharacterVector& subst, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_set_host(SEXP url_vecSEXP, SEXP substSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type url_vec(url_vecSEXP);
Rcpp::traits::input_parameter< const CharacterVector& >::type subst(substSEXP);
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_set_host(url_vec, subst, decode));
return rcpp_result_gen;
END_RCPP
}
// Rcpp_ada_set_hostname
CharacterVector Rcpp_ada_set_hostname(const CharacterVector& url_vec, const CharacterVector& subst, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_set_hostname(SEXP url_vecSEXP, SEXP substSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type url_vec(url_vecSEXP);
Rcpp::traits::input_parameter< const CharacterVector& >::type subst(substSEXP);
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_set_hostname(url_vec, subst, decode));
return rcpp_result_gen;
END_RCPP
}
// Rcpp_ada_set_pathname
CharacterVector Rcpp_ada_set_pathname(const CharacterVector& url_vec, const CharacterVector& subst, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_set_pathname(SEXP url_vecSEXP, SEXP substSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type url_vec(url_vecSEXP);
Rcpp::traits::input_parameter< const CharacterVector& >::type subst(substSEXP);
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_set_pathname(url_vec, subst, decode));
return rcpp_result_gen;
END_RCPP
}
// Rcpp_ada_set_protocol
CharacterVector Rcpp_ada_set_protocol(const CharacterVector& url_vec, const CharacterVector& subst, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_set_protocol(SEXP url_vecSEXP, SEXP substSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type url_vec(url_vecSEXP);
Rcpp::traits::input_parameter< const CharacterVector& >::type subst(substSEXP);
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_set_protocol(url_vec, subst, decode));
return rcpp_result_gen;
END_RCPP
}
// Rcpp_ada_set_search
CharacterVector Rcpp_ada_set_search(const CharacterVector& url_vec, const CharacterVector& subst, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_set_search(SEXP url_vecSEXP, SEXP substSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type url_vec(url_vecSEXP);
Rcpp::traits::input_parameter< const CharacterVector& >::type subst(substSEXP);
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_set_search(url_vec, subst, decode));
return rcpp_result_gen;
END_RCPP
}
// Rcpp_ada_set_hash
CharacterVector Rcpp_ada_set_hash(const CharacterVector& url_vec, const CharacterVector& subst, bool decode);
RcppExport SEXP _adaR_Rcpp_ada_set_hash(SEXP url_vecSEXP, SEXP substSEXP, SEXP decodeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const CharacterVector& >::type url_vec(url_vecSEXP);
Rcpp::traits::input_parameter< const CharacterVector& >::type subst(substSEXP);
Rcpp::traits::input_parameter< bool >::type decode(decodeSEXP);
rcpp_result_gen = Rcpp::wrap(Rcpp_ada_set_hash(url_vec, subst, decode));
return rcpp_result_gen;
END_RCPP
}
// Rcpp_url_decode2
CharacterVector Rcpp_url_decode2(CharacterVector& url);
RcppExport SEXP _adaR_Rcpp_url_decode2(SEXP urlSEXP) {
Expand Down Expand Up @@ -273,6 +403,16 @@ static const R_CallMethodDef CallEntries[] = {
{"_adaR_Rcpp_ada_get_pathname", (DL_FUNC) &_adaR_Rcpp_ada_get_pathname, 2},
{"_adaR_Rcpp_ada_get_search", (DL_FUNC) &_adaR_Rcpp_ada_get_search, 2},
{"_adaR_Rcpp_ada_get_protocol", (DL_FUNC) &_adaR_Rcpp_ada_get_protocol, 2},
{"_adaR_Rcpp_ada_set_href", (DL_FUNC) &_adaR_Rcpp_ada_set_href, 3},
{"_adaR_Rcpp_ada_set_username", (DL_FUNC) &_adaR_Rcpp_ada_set_username, 3},
{"_adaR_Rcpp_ada_set_password", (DL_FUNC) &_adaR_Rcpp_ada_set_password, 3},
{"_adaR_Rcpp_ada_set_port", (DL_FUNC) &_adaR_Rcpp_ada_set_port, 3},
{"_adaR_Rcpp_ada_set_host", (DL_FUNC) &_adaR_Rcpp_ada_set_host, 3},
{"_adaR_Rcpp_ada_set_hostname", (DL_FUNC) &_adaR_Rcpp_ada_set_hostname, 3},
{"_adaR_Rcpp_ada_set_pathname", (DL_FUNC) &_adaR_Rcpp_ada_set_pathname, 3},
{"_adaR_Rcpp_ada_set_protocol", (DL_FUNC) &_adaR_Rcpp_ada_set_protocol, 3},
{"_adaR_Rcpp_ada_set_search", (DL_FUNC) &_adaR_Rcpp_ada_set_search, 3},
{"_adaR_Rcpp_ada_set_hash", (DL_FUNC) &_adaR_Rcpp_ada_set_hash, 3},
{"_adaR_Rcpp_url_decode2", (DL_FUNC) &_adaR_Rcpp_url_decode2, 1},
{"_adaR_url_reverse", (DL_FUNC) &_adaR_url_reverse, 1},
{NULL, NULL, 0}
Expand Down
Loading

0 comments on commit 80cdfc9

Please sign in to comment.