O2S C Library
1.8.2
Provide high-level data-structures and other fundamental tools for C projects
Loading...
Searching...
No Matches
apply.c
1
/* ************************************************************************** */
2
/* ____ _ _____ ____ _ _ _ _____ _ _ ____ ____ */
3
/* / ___| / \ | ___| _ \ / \ | \ | | |_ _| || | | _ \/ ___| */
4
/* \___ \ / _ \ | |_ | |_) | / _ \ | \| | | | | || |_| | | \___ \ */
5
/* ___) / ___ \| _| | _ < / ___ \| |\ | | | |__ _| |_| |___) | */
6
/* |____/_/ \_|_| |_| \_/_/ \_|_| \_| |_| |_| |____/|____/ */
7
/* */
8
/* Copyright 2023, SAFRAN T4DS, ALL RIGHTS RESERVED */
9
/* */
10
/* @file apply.c */
11
/* @author Antoine GAGNIERE */
12
/* */
13
/* ************************************************************************** */
14
15
#include "
o2s/string.h
"
16
17
#include <ctype.h>
// tolower, toupper
18
31
void
string_apply_inplace(
string_t
* self,
char
(*function)(
char
))
32
{
33
for
(
char
* c = self->
start
; c < (
char
*)self->
start
+ self->
capacity
* self->
type_size
; c++)
34
*c = function(*c);
35
}
36
37
#pragma GCC diagnostic push
38
#pragma GCC diagnostic ignored "-Wcast-function-type"
39
41
void
string_tolower_inplace(
string_t
* self)
42
{
43
string_apply_inplace(self, (
char
(*)(
char
))tolower);
44
}
45
47
void
string_toupper_inplace(
string_t
* self)
48
{
49
string_apply_inplace(self, (
char
(*)(
char
))toupper);
50
}
51
52
#pragma GCC diagnostic pop
string.h
Dynamic string implementation.
string_t
array_t string_t
A string is an array of char.
Definition
string.h:30
array_t::start
void * start
Underlying storage.
Definition
array.h:25
array_t::type_size
size_t type_size
Size in bytes of a single element.
Definition
array.h:26
array_t::capacity
size_t capacity
Number of elements that can fit in the storage.
Definition
array.h:28
src
string
apply.c
Generated on
for O2S C Library by
1.14.0