Rcpp Version 1.0.14
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 - 2022 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
#if __cplusplus < 201103L
30
class
StringTransformer
:
public
std::unary_function<const char*, const char*> {
31
#else
32
class
StringTransformer
:
public
std::function<const char*(const char*)> {
33
#endif
34
public
:
35
StringTransformer
(
const
UnaryOperator
&
op_
):
op
(
op_
),
buffer
(){}
36
~StringTransformer
(){}
37
38
const
char
*
operator()
(
const
char
*
input
) {
39
buffer
=
input
;
40
std::transform(
buffer
.begin(),
buffer
.end(),
buffer
.begin(),
op
);
41
return
buffer
.c_str();
42
}
43
44
private
:
45
const
UnaryOperator
&
op
;
46
std::string
buffer
;
47
};
48
49
template
<
typename
UnaryOperator>
50
StringTransformer<UnaryOperator>
make_string_transformer
(
const
UnaryOperator
& fun){
51
return
StringTransformer<UnaryOperator>
( fun );
52
}
53
54
}
55
56
#endif
RcppCommon.h
Rcpp::StringTransformer
Definition
StringTransformer.h:30
Rcpp::StringTransformer::StringTransformer
StringTransformer(const UnaryOperator &op_)
Definition
StringTransformer.h:35
Rcpp::StringTransformer::buffer
std::string buffer
Definition
StringTransformer.h:46
Rcpp::StringTransformer::~StringTransformer
~StringTransformer()
Definition
StringTransformer.h:36
Rcpp::StringTransformer::operator()
const char * operator()(const char *input)
Definition
StringTransformer.h:38
Rcpp::StringTransformer::op
const UnaryOperator & op
Definition
StringTransformer.h:45
Rcpp
Rcpp API.
Definition
algo.h:28
Rcpp::make_string_transformer
StringTransformer< UnaryOperator > make_string_transformer(const UnaryOperator &fun)
Definition
StringTransformer.h:50
Rcpp::as
T as(SEXP x)
Definition
as.h:151
inst
include
Rcpp
StringTransformer.h
Generated on Sun Jan 12 2025 11:21:43 for Rcpp Version 1.0.14 by
1.9.8