Skip to content

Commit 5307b50

Browse files
committed
Add utils_string and update utils_port header
Add common/include/common/utils/utils_string.h introducing a constexpr common::ConstStrLen for compile-time string length calculation (with include guard and <cstdint> include). Update common/include/common/utils/utils_port.h header comment to correct the @file name and extend the copyright range to 2025-2026.
1 parent b3a1b53 commit 5307b50

2 files changed

Lines changed: 46 additions & 2 deletions

File tree

common/include/common/utils/utils_port.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
2-
* @file dmxnode_utils.h
2+
* @file utils_port.h
33
*
44
*/
5-
/* Copyright (C) 2025 by Arjan van Vught mailto:info@gd32-dmx.org
5+
/* Copyright (C) 2025-2026 by Arjan van Vught mailto:info@gd32-dmx.org
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* @file utils_string.h
3+
*
4+
*/
5+
/* Copyright (C) 2026 by Arjan van Vught mailto:info@gd32-dmx.org
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
26+
#ifndef COMMON_UTILS_UTILS_STRING_H_
27+
#define COMMON_UTILS_UTILS_STRING_H_
28+
29+
#include <cstdint>
30+
31+
namespace common
32+
{
33+
constexpr uint32_t ConstStrLen(const char* s)
34+
{
35+
uint32_t len = 0;
36+
while (s[len] != '\0')
37+
{
38+
++len;
39+
}
40+
return len;
41+
}
42+
} // namespace common
43+
44+
#endif // COMMON_UTILS_UTILS_STRING_H_

0 commit comments

Comments
 (0)