implemented str_slice
This commit is contained in:
parent
c4cb696721
commit
5fb2db2380
@ -38,11 +38,12 @@ static inline Array_ Array_copy(Array_ src){
|
|||||||
|
|
||||||
#define struct_castTo_Array(STRUCT_PTR) Array_construct_size((STRUCT_PTR), sizeof(*STRUCT_PTR))
|
#define struct_castTo_Array(STRUCT_PTR) Array_construct_size((STRUCT_PTR), sizeof(*STRUCT_PTR))
|
||||||
|
|
||||||
|
///@return a[0..n]
|
||||||
static inline Array(u8) Array_sliceBefore(Array(u8) a, u32 n){
|
static inline Array(u8) Array_sliceBefore(Array(u8) a, u32 n){
|
||||||
return Array_construct_size(a.data, n);
|
return Array_construct_size(a.data, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///@return a[n...]
|
||||||
static inline Array(u8) Array_sliceAfter(Array(u8) a, u32 n){
|
static inline Array(u8) Array_sliceAfter(Array(u8) a, u32 n){
|
||||||
return Array_construct_size((u8*)a.data + n, a.size - n);
|
return Array_construct_size((u8*)a.data + n, a.size - n);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,3 +59,14 @@ str hex_to_str(Array(u8) buf, bool uppercase);
|
|||||||
|
|
||||||
/// @brief removes blank characters from start and end of the line
|
/// @brief removes blank characters from start and end of the line
|
||||||
void str_trim(str* line, bool set_zero_at_end);
|
void str_trim(str* line, bool set_zero_at_end);
|
||||||
|
|
||||||
|
|
||||||
|
///@return s[0..n]
|
||||||
|
static inline str str_sliceBefore(str s, u32 n){
|
||||||
|
return str_construct(s.data, n, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
///@return s[n...]
|
||||||
|
static inline str str_sliceAfter(str s, u32 n){
|
||||||
|
return str_construct(s.data + n, s.size - n, s.isZeroTerminated);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user