Mbed OS Reference
Loading...
Searching...
No Matches
util.h
1
/* mbed Microcontroller Library
2
* Copyright (c) 2018 ARM Limited
3
* SPDX-License-Identifier: Apache-2.0
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*/
17
18
#ifndef FEATURES_NFC_SOURCE_NFC_COMMON_UTIL_H_
19
#define FEATURES_NFC_SOURCE_NFC_COMMON_UTIL_H_
20
21
#include "platform/Span.h"
22
23
namespace
mbed {
24
namespace
nfc {
25
namespace
ndef {
26
namespace
common {
27
28
/**
29
* @addtogroup nfc
30
* @{
31
*/
32
33
/**
34
* Convert a C-string into a Span<const uint8_t>.
35
*
36
* @note The NULL charactere is not present in the resulting object.
37
*
38
* @param cstr The cstr to convert into a Span.
39
*
40
* @return A Span that views cstr but doesn't include the NULL terminator
41
* character.
42
*/
43
template
<
size_t
N>
44
Span
<
const
uint8_t, N - 1 >
span_from_cstr
(
const
char
(&cstr)[N])
45
{
46
return
Span
<
const
uint8_t, N - 1 > ((
const
uint8_t *)cstr, N - 1);
47
}
48
49
/**
50
* Convert a C-string into a Span<const uint8_t>.
51
*
52
* @note The NULL charactere is not present in the resulting object.
53
*
54
* @param cstr The cstr to convert into a Span.
55
*
56
* @return A Span that views cstr but doesn't include the NULL terminator
57
* character.
58
*/
59
Span<const uint8_t>
span_from_cstr
(
const
char
*cstr);
60
61
/**
62
* @}
63
*/
64
65
}
// namespace common
66
}
// namespace ndef
67
}
// namespace nfc
68
}
// namespace mbed
69
70
#endif
/* FEATURES_NFC_SOURCE_NFC_COMMON_UTIL_H_ */
mbed::nfc::ndef::common::span_from_cstr
Span< const uint8_t, N - 1 > span_from_cstr(const char(&cstr)[N])
Convert a C-string into a Span<const uint8_t>.
Definition:
util.h:44
mbed::Span
Nonowning view to a sequence of contiguous elements.
Definition:
Span.h:215
connectivity
nfc
include
nfc
ndef
common
util.h
Generated by
1.9.5