1
|
|
###########################################################################/**
|
2
|
|
# @RdocClass RspConstruct
|
3
|
|
#
|
4
|
|
# @title "The RspConstruct class"
|
5
|
|
#
|
6
|
|
# \description{
|
7
|
|
# @classhierarchy
|
8
|
|
#
|
9
|
|
# An RspConstruct object represents an RSP construct, which can either be
|
10
|
|
# (i) an RSP text (a plain text section), (ii) an RSP comment,
|
11
|
|
# (iii) an RSP preprocessing directive, or (iv) an RSP expression.
|
12
|
|
# }
|
13
|
|
#
|
14
|
|
# @synopsis
|
15
|
|
#
|
16
|
|
# \arguments{
|
17
|
|
# \item{object}{A R object.}
|
18
|
|
# \item{...}{Arguments passed to @see "RspObject".}
|
19
|
|
# \item{comment}{An optional @character string.}
|
20
|
|
# }
|
21
|
|
#
|
22
|
|
# \section{Fields and Methods}{
|
23
|
|
# @allmethods
|
24
|
|
# }
|
25
|
|
#
|
26
|
|
# @author
|
27
|
|
#
|
28
|
|
# @keyword internal
|
29
|
|
#*/###########################################################################
|
30
|
|
setConstructorS3("RspConstruct", function(object=character(), ..., comment=NULL) {
|
31
|
1
|
this <- extend(RspObject(object, ...), "RspConstruct")
|
32
|
1
|
attr(this, "#comment") <- comment
|
33
|
1
|
this
|
34
|
|
})
|
35
|
|
|
36
|
|
|
37
|
|
#########################################################################/**
|
38
|
|
# @RdocMethod getInclude
|
39
|
|
# @alias getInclude.RspText
|
40
|
|
# @alias getInclude.RspCodeChunk
|
41
|
|
# @alias getInclude.RspVariableDirective
|
42
|
|
#
|
43
|
|
# @title "Checks whether an RSP construct will include text to the output or not"
|
44
|
|
#
|
45
|
|
# \description{
|
46
|
|
# @get "title".
|
47
|
|
# }
|
48
|
|
#
|
49
|
|
# @synopsis
|
50
|
|
#
|
51
|
|
# \arguments{
|
52
|
|
# \item{...}{Not used.}
|
53
|
|
# }
|
54
|
|
#
|
55
|
|
# \value{
|
56
|
|
# Returns @TRUE of @FALSE.
|
57
|
|
# }
|
58
|
|
#
|
59
|
|
# @author
|
60
|
|
#
|
61
|
|
# \seealso{
|
62
|
|
# @seeclass
|
63
|
|
# }
|
64
|
|
#*/#########################################################################
|
65
|
|
setMethodS3("getInclude", "RspConstruct", function(object, ...) {
|
66
|
1
|
FALSE
|
67
|
|
})
|
68
|
|
|
69
|
|
|
70
|
|
|
71
|
|
#########################################################################/**
|
72
|
|
# @RdocMethod getComment
|
73
|
|
#
|
74
|
|
# @title "Gets the comment of an RSP construct"
|
75
|
|
#
|
76
|
|
# \description{
|
77
|
|
# @get "title".
|
78
|
|
# }
|
79
|
|
#
|
80
|
|
# @synopsis
|
81
|
|
#
|
82
|
|
# \arguments{
|
83
|
|
# \item{...}{Not used.}
|
84
|
|
# }
|
85
|
|
#
|
86
|
|
# \value{
|
87
|
|
# Returns a @character string.
|
88
|
|
# }
|
89
|
|
#
|
90
|
|
# @author
|
91
|
|
#
|
92
|
|
# \seealso{
|
93
|
|
# @seeclass
|
94
|
|
# }
|
95
|
|
#*/#########################################################################
|
96
|
|
setMethodS3("getComment", "RspConstruct", function(object, ...) {
|
97
|
1
|
getAttribute(object, "#comment")
|
98
|
|
})
|
99
|
|
|
100
|
|
|
101
|
|
#########################################################################/**
|
102
|
|
# @RdocMethod getSuffixSpecs
|
103
|
|
#
|
104
|
|
# @title "Gets the suffix specifications"
|
105
|
|
#
|
106
|
|
# \description{
|
107
|
|
# @get "title".
|
108
|
|
# }
|
109
|
|
#
|
110
|
|
# @synopsis
|
111
|
|
#
|
112
|
|
# \arguments{
|
113
|
|
# \item{...}{Not used.}
|
114
|
|
# }
|
115
|
|
#
|
116
|
|
# \value{
|
117
|
|
# Returns a trimmed @character string.
|
118
|
|
# }
|
119
|
|
#
|
120
|
|
# @author
|
121
|
|
#
|
122
|
|
# \seealso{
|
123
|
|
# @seeclass
|
124
|
|
# }
|
125
|
|
#*/#########################################################################
|
126
|
|
setMethodS3("getSuffixSpecs", "RspConstruct", function(object, ...) {
|
127
|
1
|
specs <- attr(object, "suffixSpecs")
|
128
|
1
|
if (is.null(specs)) return(NULL)
|
129
|
1
|
specs <- trim(specs)
|
130
|
|
## specs <- gsub("^\\[[ \t\v]*", "", specs)
|
131
|
|
## specs <- gsub("[ \t\v]*\\]$", "", specs)
|
132
|
1
|
specs
|
133
|
|
})
|
134
|
|
|
135
|
|
|
136
|
|
|
137
|
|
#########################################################################/**
|
138
|
|
# @RdocMethod "asRspString"
|
139
|
|
# @alias asRspString.RspCode
|
140
|
|
# @alias asRspString.RspCodeChunk
|
141
|
|
# @alias asRspString.RspComment
|
142
|
|
# @alias asRspString.RspDirective
|
143
|
|
# @alias asRspString.RspDocument
|
144
|
|
# @alias asRspString.RspText
|
145
|
|
# @alias asRspString.RspUnParsedDirective
|
146
|
|
# @alias asRspString.RspUnparsedDirective
|
147
|
|
#
|
148
|
|
# @title "Recreates an RSP string from an RspConstruct"
|
149
|
|
#
|
150
|
|
# \description{
|
151
|
|
# @get "title".
|
152
|
|
# }
|
153
|
|
#
|
154
|
|
# @synopsis
|
155
|
|
#
|
156
|
|
# \arguments{
|
157
|
|
# \item{...}{Not used.}
|
158
|
|
# }
|
159
|
|
#
|
160
|
|
# \value{
|
161
|
|
# Returns an @see "RspString".
|
162
|
|
# }
|
163
|
|
#
|
164
|
|
# @author
|
165
|
|
#
|
166
|
|
# \seealso{
|
167
|
|
# @seeclass
|
168
|
|
# }
|
169
|
|
#*/#########################################################################
|
170
|
|
setMethodS3("asRspString", "RspConstruct", function(object, ...) {
|
171
|
0
|
throw(sprintf("Do not know how to construct an RSP string from %s: %s", class(object)[1L], capture.output(str(object))))
|
172
|
|
})
|