rcutils  master
C API providing common utilities and data structures.
repl_str.h
Go to the documentation of this file.
1 // Copyright 2015-2016 Laird Shaw
2 // Copyright 2017 Open Source Robotics Foundation, Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 // This function is based on the repl_str() from (on 2017-04-25):
17 //
18 // http://creativeandcritical.net/str-replace-c
19 //
20 // It is released under the Public Domain, and has been placed additionally
21 // under the Apache 2.0 license by me (William Woodall).
22 //
23 // It has been modified to take a custom allocator and to fit some of our
24 // style standards.
25 
26 #ifndef RCUTILS__REPL_STR_H_
27 #define RCUTILS__REPL_STR_H_
28 
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #endif
33 
34 #include "rcutils/allocator.h"
35 #include "rcutils/macros.h"
37 
39 
127 char *
129  const char * str,
130  const char * from,
131  const char * to,
132  const rcutils_allocator_t * allocator);
133 
134 // Implementation copied from above mentioned source continues in repl_str.c.
135 
136 #ifdef __cplusplus
137 }
138 #endif
139 
140 #endif // RCUTILS__REPL_STR_H_
rcutils_repl_str
char * rcutils_repl_str(const char *str, const char *from, const char *to, const rcutils_allocator_t *allocator)
Replace all the occurrences of one string for another in the given string.
macros.h
RCUTILS_WARN_UNUSED
#define RCUTILS_WARN_UNUSED
Definition: macros.h:24
visibility_control.h
rcutils_allocator_t
Encapsulation of an allocator.
Definition: allocator.h:45
allocator.h
RCUTILS_PUBLIC
#define RCUTILS_PUBLIC
Definition: visibility_control.h:23