O2S C Library 1.8.2
Provide high-level data-structures and other fundamental tools for C projects
Loading...
Searching...
No Matches
pop.c
1/* ************************************************************************** */
2/* ____ _ _____ ____ _ _ _ _____ _ _ ____ ____ */
3/* / ___| / \ | ___| _ \ / \ | \ | | |_ _| || | | _ \/ ___| */
4/* \___ \ / _ \ | |_ | |_) | / _ \ | \| | | | | || |_| | | \___ \ */
5/* ___) / ___ \| _| | _ < / ___ \| |\ | | | |__ _| |_| |___) | */
6/* |____/_/ \_|_| |_| \_/_/ \_|_| \_| |_| |_| |____/|____/ */
7/* */
8/* Copyright 2023, SAFRAN T4DS, ALL RIGHTS RESERVED */
9/* */
10/* @file pop.c */
11/* @author Antoine GAGNIERE */
12/* */
13/* ************************************************************************** */
14
15#include "o2s/string.h"
16
18bool string_pop(string_t* self, char* destination)
19{
20 return array_pop_back(self, destination);
21}
22
24bool string_pop_n(string_t* self, char* destination, size_t count)
25{
26 return array_pop_back_n(self, destination, count);
27}
28
30string_t string_pop_as_string(string_t* self, size_t count)
31{
32 if (count > string_length(self))
33 return string_new();
34 string_t result = string_from(string_get(self, string_length(self) - count), count);
35 array_pop_back_n(self, NULL, count);
36 return result;
37}
38
40bool string_pop_front(string_t* self, char* destination)
41{
42 return array_pop_front(self, destination);
43}
44
46bool string_pop_front_n(string_t* self, char* destination, size_t count)
47{
48 return array_pop_front_n(self, destination, count);
49}
bool array_pop_back_n(array_t *self, void *destination, size_t count)
Moves to destination the n last elements of the array.
Definition push_pop.c:53
bool array_pop_back(array_t *self, void *destination)
Moves to destination the last element of the array.
Definition push_pop.c:68
bool array_pop_front(array_t *self, void *destination)
Moves to destination the first element of self.
Definition push_pop.c:93
bool array_pop_front_n(array_t *self, void *destination, size_t count)
Moves to destination the count first elements of self.
Definition push_pop.c:77
Dynamic string implementation.
string_t string_new(void)
Constructs an empty string.
array_t string_t
A string is an array of char.
Definition string.h:30