SCM

SCM Repository

[tm] Diff of /pkg/R/source.R
ViewVC logotype

Diff of /pkg/R/source.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1336, Sat Apr 19 08:59:39 2014 UTC revision 1346, Mon Apr 21 08:21:14 2014 UTC
# Line 6  Line 6 
6     c("DataframeSource", "DirSource", "URISource", "VectorSource", "XMLSource")     c("DataframeSource", "DirSource", "URISource", "VectorSource", "XMLSource")
7    
8  SimpleSource <-  SimpleSource <-
9  function(reader = readPlain,  function(encoding = "",
          encoding = "",  
10           length = NA_integer_,           length = NA_integer_,
11           names = NA_character_,           names = NA_character_,
12           position = 0,           position = 0,
13             reader = readPlain,
14           ...,           ...,
15           class)           class)
16  {  {
17        if (!is.character(encoding))
18            stop("invalid encoding")
19        if (!is.integer(length))
20            stop("invalid length entry denoting the number of elements")
21        if (!is.character(names) && !is.null(names))
22            stop("invalid element names")
23        if (!is.null(names) && !is.na(names) && (length != length(names)))
24            stop("incorrect number of element names")
25        if (!is.numeric(position))
26            stop("invalid position")
27      if (!is.function(reader))      if (!is.function(reader))
28          stop("invalid default reader")          stop("invalid default reader")
     else if (!is.character(encoding))  
         warning("invalid encoding")  
     else if (!is.integer(length))  
         warning("invalid length entry denoting the number of elements")  
     else if (!is.character(names) && !is.null(names))  
         warning("invalid element names")  
     else if (!is.numeric(position))  
         warning("invalid position")  
     else if (!is.null(names) && !is.na(names) && (length != length(names)))  
         warning("incorrect number of element names")  
29    
30      structure(list(reader = reader, encoding = encoding, length = length,      structure(list(encoding = encoding, length = length, names = names,
31                     names = names, position = position, ...),                     position = position, reader = reader, ...),
32                class = unique(c(class, "SimpleSource", "Source")))                class = unique(c(class, "SimpleSource", "Source")))
33  }  }
34    
# Line 74  Line 74 
74          !identical(mode, ""))          !identical(mode, ""))
75          stop(sprintf("invalid mode '%s'", mode))          stop(sprintf("invalid mode '%s'", mode))
76    
77      SimpleSource(encoding = encoding, length = length(x), uri = x, mode = mode,      SimpleSource(encoding = encoding, length = length(x), mode = mode, uri = x,
78                   class = "URISource")                   class = "URISource")
79  }  }
80    
# Line 92  Line 92 
92      content <- parser(tree)      content <- parser(tree)
93      XML::free(tree)      XML::free(tree)
94    
95      SimpleSource(reader = reader, length = length(content), content = content,      SimpleSource(length = length(content), reader = reader, content = content,
96                   uri = x, class = "XMLSource")                   uri = x, class = "XMLSource")
97  }  }
98    

Legend:
Removed from v.1336  
changed lines
  Added in v.1346

R-Forge@R-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business University of Wisconsin - Madison Powered By FusionForge