MCPcopy Create free account
hub / github.com/RcppCore/Rcpp / Attribute

Class Attribute

src/attributes.cpp:314–418  ·  view source on GitHub ↗

Attribute (w/ optional params and signature of function it qualifies)

Source from the content-addressed store, hash-verified

312
313 // Attribute (w/ optional params and signature of function it qualifies)
314 class Attribute {
315 public:
316 Attribute() {}
317 Attribute(const std::string& name,
318 const std::vector<Param>& params,
319 const Function& function,
320 const std::vector<std::string>& roxygen)
321 : name_(name), params_(params), function_(function), roxygen_(roxygen)
322 {
323 }
324
325 bool empty() const { return name().empty(); } // #nocov start
326
327 bool operator==(const Attribute& other) const {
328 return name_ == other.name_ &&
329 params_ == other.params_ &&
330 function_ == other.function_ &&
331 roxygen_ == other.roxygen_;
332 }; // #nocov end
333
334 bool operator!=(const Attribute& other) const {
335 return !(*this == other);
336 };
337
338
339 const std::string& name() const { return name_; }
340
341 const std::vector<Param>& params() const { return params_; }
342
343 Param paramNamed(const std::string& name) const;
344
345 bool hasParameter(const std::string& name) const {
346 return !paramNamed(name).empty();
347 }
348
349 const Function& function() const { return function_; }
350
351 bool isExportedFunction() const {
352 return (name() == kExportAttribute) && !function().empty();
353 }
354
355 std::string exportedName() const {
356
357 // check for explicit name parameter
358 if (hasParameter(kExportName))
359 {
360 return paramNamed(kExportName).value(); // #nocov
361 }
362 // otherwise un-named parameter in the first slot
363 else if (!params().empty() && params()[0].value().empty())
364 {
365 return params()[0].name(); // #nocov
366 }
367 // otherwise the actual function name
368 {
369 return function().name();
370 }
371 }

Callers 1

parseAttributeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected