-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathos_str.h
74 lines (64 loc) · 2.43 KB
/
os_str.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* @file os_str.h
* @author TheSomeMan
* @date 2020-10-03
* @copyright Ruuvi Innovations Ltd, license BSD-3-Clause.
*/
#ifndef RUUVI_ESP_WRAPPERS_OS_STR_H
#define RUUVI_ESP_WRAPPERS_OS_STR_H
#include <stdint.h>
#include "attribs.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef int os_str2num_base_t;
/**
* @brief This is a wrapper for stdlib strtoul which implements const-correctness and fixes portability issues (MISRA)
* @param p_str - ptr to a const string
* @param pp_end - if pp_end is not NULL, it stores the address of the first invalid character in *pp_end
* @param base - should be in range 2..36 or 0 for auto detection
* @return the result of the conversion
*/
ATTR_NONNULL(1)
uint32_t
os_str_to_uint32_cptr(
const char* __restrict const p_str,
const char** __restrict const pp_end,
const os_str2num_base_t base);
/**
* @brief This is a wrapper for stdlib strtoul which implements const-correctness and fixes portability issues (MISRA)
* @param p_str - ptr to a string
* @param pp_end - if pp_end is not NULL, it stores the address of the first invalid character in *pp_end
* @param base - should be in range 2..36 or 0 for auto detection
* @return the result of the conversion
*/
ATTR_NONNULL(1)
uint32_t
os_str_to_uint32(char* __restrict const p_str, char** __restrict const pp_end, const os_str2num_base_t base);
/**
* @brief This is a wrapper for stdlib strtol which implements const-correctness and fixes portability issues (MISRA)
* @param p_str - ptr to a const string
* @param pp_end - if pp_end is not NULL, it stores the address of the first invalid character in *pp_end
* @param base - should be in range 2..36 or 0 for auto detection
* @return the result of the conversion
*/
ATTR_NONNULL(1)
int32_t
os_str_to_int32_cptr(
const char* __restrict const p_str,
const char** __restrict const pp_end,
const os_str2num_base_t base);
/**
* @brief This is a wrapper for stdlib strtul which implements const-correctness and fixes portability issues (MISRA)
* @param p_str - ptr to a string
* @param pp_end - if pp_end is not NULL, it stores the address of the first invalid character in *pp_end
* @param base - should be in range 2..36 or 0 for auto detection
* @return the result of the conversion
*/
ATTR_NONNULL(1)
int32_t
os_str_to_int32(char* __restrict const p_str, char** __restrict const pp_end, const os_str2num_base_t base);
#ifdef __cplusplus
}
#endif
#endif // RUUVI_ESP_WRAPPERS_OS_STR_H