Skip to content

Commit 2dd519c

Browse files
Merge pull request #1858 from ApexAI/iox-1560-split-up-helplets
iox-1560 Split up `helplets.hpp`
2 parents dae578d + df01843 commit 2dd519c

File tree

165 files changed

+2023
-1838
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+2023
-1838
lines changed

doc/design/error-handling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ int32_t myAlgorithm(int32_t* ptr) {
217217
}
218218
```
219219

220-
Note that in the case of ``nullptr`` checks it is also an option to use references in arguments (or ``not_null`` if it is supposed to be stored since references are not copyable). It should be considered that ``not_null`` incurs a runtime cost, which may be undesirable.
220+
Note that in the case of ``nullptr`` checks it is also an option to use references in arguments (or ``iox::not_null`` if it is supposed to be stored since references are not copyable). It should be considered that ``iox::not_null`` incurs a runtime cost, which may be undesirable.
221221
When Expects and Ensures are implemented to leave no trace in release mode, we do not incur a runtime cost using them. For this reason, it is advised to use them to document and verify assumptions where appropriate.
222222

223223
### `expected`

doc/website/release-notes/iceoryx-unreleased.md

Lines changed: 94 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -318,16 +318,85 @@
318318
}
319319
```
320320

321-
14. Remove `forEach` from helplets
321+
14. Moved or removed various functions from helplets
322322

323323
```cpp
324324
// before
325+
#include "iceoryx_hoofs/cxx/helplets.hpp"
325326
iox::cxx::forEach(container, [&] (element) { /* do stuff with element */ });
326327

327328
// after
328329
for (const auto& element: container) { /* do stuff with element */ }
329330
```
330331

332+
```cpp
333+
// before
334+
#include "iceoryx_hoofs/cxx/helplets.hpp"
335+
iox::cxx::greater_or_equal(..);
336+
iox::cxx::range(..);
337+
iox::cxx::BestFittingType(..);
338+
iox::cxx::isPowerOfTwo(..);
339+
340+
// after
341+
#include "iceoryx_hoofs/cxx/algorithm.hpp"
342+
iox::greater_or_equal(..);
343+
iox::range(..);
344+
iox::BestFittingType(..);
345+
iox::isPowerOfTwo(..);
346+
```
347+
348+
```cpp
349+
// before
350+
#include "iceoryx_hoofs/cxx/helplets.hpp"
351+
iox::cxx::align(..);
352+
iox::cxx::alignedAlloc(..);
353+
iox::cxx::alignedFree(..);
354+
iox::cxx::maxAlignment(..);
355+
iox::cxx::maxSize(..);
356+
357+
// after
358+
#include "iox/memory.hpp"
359+
iox::align(..);
360+
iox::alignedAlloc(..);
361+
iox::alignedFree(..);
362+
iox::maxAlignment(..);
363+
iox::maxSize(..);
364+
```
365+
366+
```cpp
367+
// before
368+
#include "iceoryx_hoofs/cxx/helplets.hpp"
369+
iox::cxx::isValidPathEntry(..);
370+
iox::cxx::isValidFileName(..);
371+
iox::cxx::isValidPathToFile(..);
372+
iox::cxx::isValidPathToDirectory(..);
373+
iox::cxx::doesEndWithPathSeparator(..);
374+
375+
// after
376+
#include "iceoryx_hoofs/cxx/filesystem.hpp"
377+
iox::cxx::isValidPathEntry(..);
378+
iox::cxx::isValidFileName(..);
379+
iox::cxx::isValidPathToFile(..);
380+
iox::cxx::isValidPathToDirectory(..);
381+
iox::cxx::doesEndWithPathSeparator(..);
382+
```
383+
384+
```cpp
385+
// before
386+
#include "iceoryx_hoofs/cxx/helplets.hpp"
387+
template <>
388+
constexpr DestType
389+
iox::cxx::from<SourceType, DestType>(const SourceType value);
390+
iox::cxx::into(..);
391+
392+
// after
393+
#include "iox/into.hpp"
394+
template <>
395+
constexpr DestType
396+
iox::from<SourceType, DestType>(const SourceType value);
397+
iox::into(..);
398+
```
399+
331400
15. Remove `enumTypeAsUnderlyingType`
332401

333402
```cpp
@@ -352,7 +421,7 @@
352421
std::cout << SOME_ENUM_STRINGS[static_cast<uint64_t>(someEnum)] << std::endl;
353422
```
354423

355-
17. Replace `strlen2` with more generic `arrayCapacity`
424+
17. Replace `strlen2` with more generic `iox::size`
356425

357426
```cpp
358427
constexpr const char LITERAL1[] {"FOO"};
@@ -364,9 +433,10 @@
364433
std::cout << iox::cxx::strlen2(LITERAL2) << std::endl; // prints 19
365434

366435
// after
367-
std::cout << arrayCapacity(LITERAL1) << std::endl; // prints 4
368-
std::cout << arrayCapacity(LITERAL2) << std::endl; // prints 20
369-
std::cout << arrayCapacity(ARRAY) << std::endl; // prints 42
436+
#include "iox/size.hpp"
437+
std::cout << iox::size(LITERAL1) << std::endl; // prints 4
438+
std::cout << iox::size(LITERAL2) << std::endl; // prints 20
439+
std::cout << iox::size(ARRAY) << std::endl; // prints 42
370440
```
371441

372442
18. Rename `cxx::GenericRAII` to `cxx::ScopeGuard`
@@ -890,6 +960,23 @@
890960

891961
// after
892962
#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp"
963+
```
964+
965+
```cpp
966+
// before
967+
#include "iceoryx_hoofs/cxx/serialization.hpp"
968+
969+
// after
970+
#include "iceoryx_dust/cxx/serialization.hpp"
971+
```
972+
973+
```cpp
974+
// before
975+
#include "iceoryx_hoofs/cxx/convert.hpp"
976+
977+
// after
978+
#include "iceoryx_dust/cxx/convert.hpp"
979+
```
893980

894981
43. Move the conversions functions for `std::string` to `iceoryx_dust`:
895982

@@ -906,7 +993,7 @@
906993

907994
std::string myStdString("foo");
908995
// std::string to iox::string
909-
iox::string<3> myIoxString = iox::cxx::into<iox::string<3>>(myStdString);
996+
iox::string<3> myIoxString = iox::into<iox::string<3>>(myStdString);
910997
// iox::string to std::string
911-
std::string myConvertedIoxString = iox::cxx::into<std::string>(myIoxString);
998+
std::string myConvertedIoxString = iox::into<std::string>(myIoxString);
912999
```

iceoryx_dust/README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ Compared to hoofs classes in `iceoryx_dust`, the difference is that the classes
77
There are a wide variety of building blocks
88
grouped together in categories or namespace, depending on where or how they are used.
99

10-
| class/file | description |
11-
|:---------------------:|:------------------------------------------------------------------------------------------------------------------------|
12-
|`forward_list` | Heap and exception free, relocatable implementation of `std::forward_list` |
13-
|`ObjectPool` | Container which stores raw objects without calling the ctor of the objects. |
14-
|`FileReader` | Wrapper for opening files and reading them. |
15-
|`MessageQueue` | Interface for Message Queues, see [ManPage mq_overview](https://www.man7.org/linux/man-pages/man7/mq_overview.7.html). |
16-
|`SignalWatcher` | Batteries included signal handling with polling and optional blocking wait for `SIGINT` and `SIGTERM`. |
17-
|`NamedPipe` | Shared memory based ipc channel. Mainly a `UnixDomainSocket` replacement on Windows. |
18-
|`relocatable_ptr` | |
19-
|`static_storage` | Untyped aligned static storage. |
10+
| class/file | description |
11+
|:---------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
12+
|`forward_list` | Heap and exception free, relocatable implementation of `std::forward_list` |
13+
|`ObjectPool` | Container which stores raw objects without calling the ctor of the objects. |
14+
|`FileReader` | Wrapper for opening files and reading them. |
15+
|`MessageQueue` | Interface for Message Queues, see [ManPage mq_overview](https://www.man7.org/linux/man-pages/man7/mq_overview.7.html). |
16+
|`SignalWatcher` | Batteries included signal handling with polling and optional blocking wait for `SIGINT` and `SIGTERM`. |
17+
|`NamedPipe` | Shared memory based IPC channel. Mainly a `UnixDomainSocket` replacement on Windows. |
18+
|`relocatable_ptr` | |
19+
|`static_storage` | Untyped aligned static storage. |
20+
|`convert` | Converting a number into a string is easy, converting it back can be hard. You can use functions like `strtoll`, but you still have to handle errors like under- and overflow, or converting invalid strings into number. Here we abstract all the error handling so that you can convert strings into numbers safely. |
21+
|`serialization` | Implements a simple serialization concept for classes based on the idea presented here [ISOCPP serialization](https://isocpp.org/wiki/faq/serialization#serialize-text-format). |

iceoryx_hoofs/include/iceoryx_hoofs/cxx/convert.hpp renamed to iceoryx_dust/include/iceoryx_dust/cxx/convert.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
// limitations under the License.
1616
//
1717
// SPDX-License-Identifier: Apache-2.0
18-
#ifndef IOX_HOOFS_CXX_CONVERT_HPP
19-
#define IOX_HOOFS_CXX_CONVERT_HPP
18+
#ifndef IOX_DUST_CXX_CONVERT_HPP
19+
#define IOX_DUST_CXX_CONVERT_HPP
2020

2121
#include "iceoryx_hoofs/posix_wrapper/posix_call.hpp"
2222
#include "iox/string.hpp"
@@ -45,7 +45,7 @@ namespace cxx
4545
/// if ( cxx::convert::fromString("-123", a) ) {} // will fail since -123 is not unsigned
4646
/// @endcode
4747
/// @todo iox-#260 Refactor 'convert' so that one can use 'into' to directly to convert numbers to strings:
48-
/// 'ClassExpectingAnIoxString(iox::cxx::into<iox::string<100>>(42)'
48+
/// 'ClassExpectingAnIoxString(iox::into<iox::string<100>>(42)'
4949
class convert
5050
{
5151
public:
@@ -105,6 +105,6 @@ class convert
105105
} // namespace cxx
106106
} // namespace iox
107107

108-
#include "iceoryx_hoofs/internal/cxx/convert.inl"
108+
#include "iceoryx_dust/internal/cxx/convert.inl"
109109

110-
#endif // IOX_HOOFS_CXX_CONVERT_HPP
110+
#endif // IOX_DUST_CXX_CONVERT_HPP

iceoryx_dust/include/iceoryx_dust/cxx/forward_list.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#ifndef IOX_DUST_CXX_FORWARD_LIST_HPP
1919
#define IOX_DUST_CXX_FORWARD_LIST_HPP
2020

21-
#include "iceoryx_hoofs/cxx/helplets.hpp"
21+
#include "iceoryx_hoofs/cxx/requires.hpp"
2222
#include "iox/uninitialized_array.hpp"
2323

2424
#include <cstdint>

iceoryx_hoofs/include/iceoryx_hoofs/cxx/serialization.hpp renamed to iceoryx_dust/include/iceoryx_dust/cxx/serialization.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
// limitations under the License.
1515
//
1616
// SPDX-License-Identifier: Apache-2.0
17-
#ifndef IOX_HOOFS_CXX_SERIALIZATION_HPP
18-
#define IOX_HOOFS_CXX_SERIALIZATION_HPP
17+
#ifndef IOX_DUST_CXX_SERIALIZATION_HPP
18+
#define IOX_DUST_CXX_SERIALIZATION_HPP
1919

20-
#include "iceoryx_hoofs/cxx/convert.hpp"
20+
#include "iceoryx_dust/cxx/convert.hpp"
2121

2222
#include <iostream>
2323
#include <sstream>
@@ -140,6 +140,6 @@ class Serialization
140140
} // namespace cxx
141141
} // namespace iox
142142

143-
#include "iceoryx_hoofs/internal/cxx/serialization.inl"
143+
#include "iceoryx_dust/internal/cxx/serialization.inl"
144144

145-
#endif // IOX_HOOFS_CXX_SERIALIZATION_HPP
145+
#endif // IOX_DUST_CXX_SERIALIZATION_HPP

iceoryx_dust/include/iceoryx_dust/cxx/std_string_support.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@
1616
#ifndef IOX_DUST_STD_STRING_SUPPORT_HPP
1717
#define IOX_DUST_STD_STRING_SUPPORT_HPP
1818

19-
#include "iceoryx_hoofs/cxx/helplets.hpp"
20-
#include "iceoryx_hoofs/cxx/string.hpp"
19+
#include "iox/into.hpp"
20+
#include "iox/string.hpp"
2121

2222
#include <string>
2323

2424
namespace iox
2525
{
26-
namespace cxx
27-
{
2826
template <uint64_t N>
2927
struct FromImpl<string<N>, std::string>
3028
{
@@ -36,7 +34,6 @@ struct FromImpl<std::string, string<N>>
3634
{
3735
static string<N> fromImpl(const std::string& value) noexcept;
3836
};
39-
} // namespace cxx
4037
} // namespace iox
4138

4239
#include "iceoryx_dust/internal/cxx/std_string_support.inl"

iceoryx_dust/include/iceoryx_dust/internal/cli/arguments.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#define IOX_DUST_CLI_ARGUMENTS_HPP
1818

1919
#include "iceoryx_dust/cli/types.hpp"
20+
#include "iceoryx_dust/cxx/convert.hpp"
2021
#include "iceoryx_dust/internal/cli/option.hpp"
21-
#include "iceoryx_hoofs/cxx/convert.hpp"
2222
#include "iceoryx_hoofs/cxx/vector.hpp"
2323
#include "iox/expected.hpp"
2424

iceoryx_dust/include/iceoryx_dust/internal/cli/option_manager.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ inline T OptionManager::defineOption(T& referenceToMember,
6262
{
6363
constexpr bool IS_NO_SWITCH = false;
6464
m_optionSet.addOption(OptionWithDetails{
65-
{shortName, IS_NO_SWITCH, name, cxx::into<Argument_t>(cxx::convert::toString(defaultArgumentValue))},
65+
{shortName, IS_NO_SWITCH, name, into<Argument_t>(cxx::convert::toString(defaultArgumentValue))},
6666
description,
6767
optionType,
6868
{cxx::TypeInfo<T>::NAME}});

iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/convert.inl renamed to iceoryx_dust/include/iceoryx_dust/internal/cxx/convert.inl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
// limitations under the License.
1616
//
1717
// SPDX-License-Identifier: Apache-2.0
18-
#ifndef IOX_HOOFS_CXX_CONVERT_INL
19-
#define IOX_HOOFS_CXX_CONVERT_INL
18+
#ifndef IOX_DUST_CXX_CONVERT_INL
19+
#define IOX_DUST_CXX_CONVERT_INL
2020

21-
#include "iceoryx_hoofs/cxx/convert.hpp"
21+
#include "iceoryx_dust/cxx/convert.hpp"
2222
#include "iceoryx_hoofs/log/logging.hpp"
2323

2424
namespace iox
@@ -431,4 +431,4 @@ inline bool convert::fromString<bool>(const char* v, bool& dest) noexcept
431431
} // namespace cxx
432432
} // namespace iox
433433

434-
#endif // IOX_HOOFS_CXX_CONVERT_INL
434+
#endif // IOX_DUST_CXX_CONVERT_INL

0 commit comments

Comments
 (0)