Rcpp Version 1.1.2
Loading...
Searching...
No Matches
StringTransformer.h
Go to the documentation of this file.
1
2
// clone.h: Rcpp R/C++ interface class library -- clone RObject's
3
//
4
// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois
5
//
6
// This file is part of Rcpp.
7
//
8
// Rcpp is free software: you can redistribute it and/or modify it
9
// under the terms of the GNU General Public License as published by
10
// the Free Software Foundation, either version 2 of the License, or
11
// (at your option) any later version.
12
//
13
// Rcpp is distributed in the hope that it will be useful, but
14
// WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
// GNU General Public License for more details.
17
//
18
// You should have received a copy of the GNU General Public License
19
// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
20
21
#ifndef Rcpp__StringTransformer_h
22
#define Rcpp__StringTransformer_h
23
24
#include <
RcppCommon.h
>
25
26
namespace
Rcpp
{
27
28
template
<
typename
UnaryOperator>
29
class
StringTransformer
:
public
std::function<const char*(const char*)> {
30
public
:
31
StringTransformer
(
const
UnaryOperator& op_ ):
op
(op_),
buffer
(){}
32
~StringTransformer
(){}
33
34
const
char
*
operator()
(
const
char
* input ) {
35
buffer
= input;
36
std::transform(
buffer
.begin(),
buffer
.end(),
buffer
.begin(),
op
);
37
return
buffer
.c_str();
38
}
39
40
private
:
41
const
UnaryOperator&
op
;
42
std::string
buffer
;
43
};
44
45
template
<
typename
UnaryOperator>
46
StringTransformer<UnaryOperator>
make_string_transformer
(
const
UnaryOperator& fun){
47
return
StringTransformer<UnaryOperator>
( fun );
48
}
49
50
}
51
52
#endif
RcppCommon.h
Rcpp::StringTransformer
Definition
StringTransformer.h:29
Rcpp::StringTransformer::StringTransformer
StringTransformer(const UnaryOperator &op_)
Definition
StringTransformer.h:31
Rcpp::StringTransformer::buffer
std::string buffer
Definition
StringTransformer.h:42
Rcpp::StringTransformer::~StringTransformer
~StringTransformer()
Definition
StringTransformer.h:32
Rcpp::StringTransformer::operator()
const char * operator()(const char *input)
Definition
StringTransformer.h:34
Rcpp::StringTransformer::op
const UnaryOperator & op
Definition
StringTransformer.h:41
Rcpp
Rcpp API.
Definition
algo.h:28
Rcpp::make_string_transformer
StringTransformer< UnaryOperator > make_string_transformer(const UnaryOperator &fun)
Definition
StringTransformer.h:46
inst
include
Rcpp
StringTransformer.h
Generated on
for Rcpp Version 1.1.2 by
1.15.0