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 
27 
28 #ifndef RCUTILS__REPL_STR_H_
29 #define RCUTILS__REPL_STR_H_
30 
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #endif
35 
36 #include "rcutils/allocator.h"
37 #include "rcutils/macros.h"
39 
41 
129 char *
131  const char * str,
132  const char * from,
133  const char * to,
134  const rcutils_allocator_t * allocator);
135 
136 // Implementation copied from above mentioned source continues in repl_str.c.
137 
138 #ifdef __cplusplus
139 }
140 #endif
141 
142 #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
A macro to make the compiler warn when the return value of a function is not used.
Definition: macros.h:27
visibility_control.h
rcutils_allocator_t
Encapsulation of an allocator.
Definition: allocator.h:47
allocator.h
RCUTILS_PUBLIC
#define RCUTILS_PUBLIC
Definition: visibility_control.h:23