parseScope <- function()

in R/R/sqlPackage.R [675:708]


parseScope <- function(scope)
{

    scopes <- c(0L, 1L, 0L)
    names(scopes) <- c("PUBLIC", "PRIVATE", "SHARED")

    if ((is.integer(scope) || is.numeric(scope)) && (scope%%1==0))
    {
        if ((scope >= 0L) && (scope <= 1L))
        {
            scopeIndex <- scope + 1L
            parsedScope <- names(scopes)[scopeIndex]
        }
        else
        {
            stop("Invalid scope argument value.", call. = FALSE)
        }
    }
    else if (is.character(scope) && length(scope) == 1 && toupper(scope) %in% names(scopes))
    {
        parsedScope <- scopes[[toupper(scope)]]
    }
    else
    {
        stop("Invalid scope argument value.", call. = FALSE)
    }

    if (is.na(parsedScope))
    {
        stop("Invalid scope argument value.", call. = FALSE)
    }

    parsedScope
}