F´ Flight Software - C/C++ Documentation
devel
A framework for building embedded system applications to NASA flight quality standards.
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
z
Functions
a
b
c
d
g
h
i
m
o
p
r
s
t
v
w
Variables
Typedefs
a
b
c
d
e
f
g
h
l
o
p
r
s
t
u
w
Enumerations
Enumerator
a
b
c
f
h
i
n
o
p
s
v
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
~
Functions
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
~
Variables
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
w
Typedefs
c
e
s
t
u
w
Enumerations
b
c
d
g
h
m
o
q
s
t
u
w
Enumerator
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Related Symbols
a
b
c
d
f
g
h
l
p
r
s
t
u
Files
File List
File Members
All
_
a
b
c
d
f
g
h
i
l
m
n
p
r
s
t
u
v
Functions
c
i
m
p
s
u
Variables
_
b
c
f
i
l
p
r
s
Typedefs
b
c
f
i
n
p
s
u
Enumerations
Enumerator
a
b
c
d
f
g
h
p
r
s
t
Macros
_
a
c
d
f
g
h
i
l
m
p
r
s
t
u
v
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Loading...
Searching...
No Matches
StringUtils.cpp
Go to the documentation of this file.
1
#include "
StringUtils.hpp
"
2
#include <
Fw/Types/Assert.hpp
>
3
#include <cstring>
4
5
char
*
Fw::StringUtils::string_copy
(
char
* destination,
const
char
* source, U32 num) {
6
// Handle self-copy and 0 bytes copy
7
if
(destination == source || num == 0) {
8
return
destination;
9
}
10
11
// Copying an overlapping range is undefined
12
U32 source_len =
string_length
(source, num) + 1;
13
FW_ASSERT
(source + source_len <= destination || destination + num <= source);
14
15
char
* returned = strncpy(destination, source, num);
16
destination[num - 1] =
'\0'
;
17
return
returned;
18
}
5
char
*
Fw::StringUtils::string_copy
(
char
* destination,
const
char
* source, U32 num) {
…
}
19
20
U32
Fw::StringUtils::string_length
(
const
CHAR
* source, U32 max_len) {
21
U32 length = 0;
22
FW_ASSERT
(source !=
nullptr
);
23
for
(length = 0; length < max_len; length++) {
24
if
(source[length] ==
'\0'
) {
25
break
;
26
}
27
}
28
return
length;
29
}
20
U32
Fw::StringUtils::string_length
(
const
CHAR
* source, U32 max_len) {
…
}
Assert.hpp
FW_ASSERT
#define FW_ASSERT(...)
Definition
Assert.hpp:14
CHAR
char CHAR
Definition
BasicTypes.h:28
StringUtils.hpp
Fw::StringUtils::string_copy
char * string_copy(char *destination, const char *source, U32 num)
copy string with null-termination guaranteed
Definition
StringUtils.cpp:5
Fw::StringUtils::string_length
U32 string_length(const CHAR *source, U32 max_len)
get the length of the source string or max_len if the string is longer than max_len.
Definition
StringUtils.cpp:20
Fw
Types
StringUtils.cpp
Generated by
1.10.0