Skip to content

Commit 80b72f2

Browse files
committed
iox-#846 Use upper camel case for enums tags in filesystem.hpp
1 parent 795d5de commit 80b72f2

File tree

29 files changed

+273
-276
lines changed

29 files changed

+273
-276
lines changed

doc/website/FAQ.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ SharedMemory still there, doing an unlink of /root
8383
Reserving 27902400 bytes in the shared memory [/root]
8484
While setting the acquired shared memory to zero a fatal SIGBUS signal appeared
8585
caused by memset. The shared memory object with the following properties
86-
[ name = /root, sizeInBytes = 27902400, access mode = AccessMode::READ_WRITE,
86+
[ name = /root, sizeInBytes = 27902400, access mode = AccessMode::ReadWrite,
8787
ownership = OwnerShip::MINE, baseAddressHint = (nil), permissions = 0 ] maybe
8888
requires more memory than it is currently available in the system.
8989
```

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@
309309
iox::optional<iox::NamedSemaphore> semaphore;
310310
auto result = iox::NamedSemaphoreBuilder()
311311
.name("mySemaphoreName")
312-
.openMode(iox::OpenMode::OPEN_OR_CREATE)
312+
.openMode(iox::OpenMode::OpenOrCreate)
313313
.permissions(iox::perms::owner_all)
314314
.initialValue(0U)
315315
.create(semaphore);

iceoryx_hoofs/filesystem/include/iox/detail/filesystem.inl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ inline bool isValidPathEntry(const iox::string<StringCapacity>& name,
2929

3030
if ((name == currentDirectory) || (name == parentDirectory))
3131
{
32-
return relativePathComponents == RelativePathComponents::ACCEPT;
32+
return relativePathComponents == RelativePathComponents::Accept;
3333
}
3434

3535
const auto nameSize = name.size();
@@ -75,7 +75,7 @@ inline bool isValidFileName(const iox::string<StringCapacity>& name) noexcept
7575
}
7676

7777
// check if the file contains only valid characters
78-
return isValidPathEntry(name, RelativePathComponents::REJECT);
78+
return isValidPathEntry(name, RelativePathComponents::Reject);
7979
}
8080

8181
template <uint64_t StringCapacity>
@@ -160,7 +160,7 @@ inline bool isValidPathToDirectory(const iox::string<StringCapacity>& name) noex
160160
}
161161
else // we reached the last entry, if its a valid file name the path is valid
162162
{
163-
return isValidPathEntry(remaining, RelativePathComponents::ACCEPT);
163+
return isValidPathEntry(remaining, RelativePathComponents::Accept);
164164
}
165165
}
166166

@@ -191,32 +191,32 @@ inline constexpr const char* asStringLiteral(const OpenMode mode) noexcept
191191
{
192192
switch (mode)
193193
{
194-
case OpenMode::EXCLUSIVE_CREATE:
195-
return "OpenMode::EXCLUSIVE_CREATE";
196-
case OpenMode::PURGE_AND_CREATE:
197-
return "OpenMode::PURGE_AND_CREATE";
198-
case OpenMode::OPEN_OR_CREATE:
199-
return "OpenMode::OPEN_OR_CREATE";
200-
case OpenMode::OPEN_EXISTING:
201-
return "OpenMode::OPEN_EXISTING";
194+
case OpenMode::ExclusiveCreate:
195+
return "OpenMode::ExclusiveCreate";
196+
case OpenMode::PurgeAndCreate:
197+
return "OpenMode::PurgeAndCreate";
198+
case OpenMode::OpenOrCreate:
199+
return "OpenMode::OpenOrCreate";
200+
case OpenMode::OpenExisting:
201+
return "OpenMode::OpenExisting";
202202
}
203203

204-
return "OpenMode::UNDEFINED_VALUE";
204+
return "OpenMode::UndefinedValue";
205205
}
206206

207207
inline constexpr const char* asStringLiteral(const AccessMode mode) noexcept
208208
{
209209
switch (mode)
210210
{
211-
case AccessMode::READ_ONLY:
212-
return "AccessMode::READ_ONLY";
213-
case AccessMode::READ_WRITE:
214-
return "AccessMode::READ_WRITE";
215-
case AccessMode::WRITE_ONLY:
216-
return "AccessMode::WRITE_ONLY";
211+
case AccessMode::ReadOnly:
212+
return "AccessMode::ReadOnly";
213+
case AccessMode::ReadWrite:
214+
return "AccessMode::ReadWrite";
215+
case AccessMode::WriteOnly:
216+
return "AccessMode::WriteOnly";
217217
}
218218

219-
return "AccessMode::UNDEFINED_VALUE";
219+
return "AccessMode::UndefinedValue";
220220
}
221221

222222

iceoryx_hoofs/filesystem/include/iox/filesystem.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ constexpr char ASCII_UNDERSCORE{'_'};
4242

4343
enum class RelativePathComponents : uint8_t
4444
{
45-
REJECT,
46-
ACCEPT
45+
Reject,
46+
Accept
4747
};
4848

4949
/// @brief checks if the given string is a valid path entry. A path entry is the string between
@@ -93,22 +93,22 @@ bool doesEndWithPathSeparator(const string<StringCapacity>& name) noexcept;
9393

9494
enum class AccessMode : uint8_t
9595
{
96-
READ_ONLY = 0U,
97-
READ_WRITE = 1U,
98-
WRITE_ONLY = 2U
96+
ReadOnly = 0U,
97+
ReadWrite = 1U,
98+
WriteOnly = 2U
9999
};
100100

101101
/// @brief describes how the shared memory is opened or created
102102
enum class OpenMode : uint8_t
103103
{
104104
/// @brief creates the shared memory, if it exists already the construction will fail
105-
EXCLUSIVE_CREATE = 0U,
105+
ExclusiveCreate = 0U,
106106
/// @brief creates the shared memory, if it exists it will be deleted and recreated
107-
PURGE_AND_CREATE = 1U,
107+
PurgeAndCreate = 1U,
108108
/// @brief creates the shared memory, if it does not exist otherwise it opens it
109-
OPEN_OR_CREATE = 2U,
109+
OpenOrCreate = 2U,
110110
/// @brief opens the shared memory, if it does not exist it will fail
111-
OPEN_EXISTING = 3U
111+
OpenExisting = 3U
112112
};
113113

114114
/// @brief converts OpenMode into a string literal

iceoryx_hoofs/filesystem/source/filesystem.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ int convertToOflags(const AccessMode accessMode) noexcept
180180
{
181181
switch (accessMode)
182182
{
183-
case AccessMode::READ_ONLY:
183+
case AccessMode::ReadOnly:
184184
return O_RDONLY;
185-
case AccessMode::READ_WRITE:
185+
case AccessMode::ReadWrite:
186186
return O_RDWR;
187-
case AccessMode::WRITE_ONLY:
187+
case AccessMode::WriteOnly:
188188
return O_WRONLY;
189189
}
190190

@@ -196,12 +196,12 @@ int convertToOflags(const OpenMode openMode) noexcept
196196
{
197197
switch (openMode)
198198
{
199-
case OpenMode::OPEN_EXISTING:
199+
case OpenMode::OpenExisting:
200200
return 0;
201-
case OpenMode::OPEN_OR_CREATE:
201+
case OpenMode::OpenOrCreate:
202202
return O_CREAT;
203-
case OpenMode::EXCLUSIVE_CREATE:
204-
case OpenMode::PURGE_AND_CREATE:
203+
case OpenMode::ExclusiveCreate:
204+
case OpenMode::PurgeAndCreate:
205205
// wrapped inside function so that the user does not have to use bitwise operations; operands have positive
206206
// values and result is within integer range
207207
// NOLINTNEXTLINE(hicpp-signed-bitwise)
@@ -216,12 +216,12 @@ int convertToProtFlags(const AccessMode accessMode) noexcept
216216
{
217217
switch (accessMode)
218218
{
219-
case AccessMode::READ_ONLY:
219+
case AccessMode::ReadOnly:
220220
return PROT_READ;
221-
case AccessMode::READ_WRITE:
221+
case AccessMode::ReadWrite:
222222
// NOLINTNEXTLINE(hicpp-signed-bitwise) enum type is defined by POSIX, no logical fault
223223
return PROT_READ | PROT_WRITE;
224-
case AccessMode::WRITE_ONLY:
224+
case AccessMode::WriteOnly:
225225
return PROT_WRITE;
226226
}
227227

iceoryx_hoofs/posix/filesystem/include/iox/file.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,16 @@ class File : public FileManagementInterface<File>
169169
static constexpr int INVALID_FILE_DESCRIPTOR{-1};
170170

171171
int m_file_descriptor{INVALID_FILE_DESCRIPTOR};
172-
AccessMode m_access_mode{AccessMode::READ_ONLY};
172+
AccessMode m_access_mode{AccessMode::ReadOnly};
173173
};
174174

175175
class FileBuilder
176176
{
177177
private:
178178
IOX_BUILDER_PARAMETER(Ownership, owner, Ownership::from_process())
179179
IOX_BUILDER_PARAMETER(access_rights, permissions, perms::owner_read)
180-
IOX_BUILDER_PARAMETER(AccessMode, access_mode, AccessMode::READ_ONLY)
181-
IOX_BUILDER_PARAMETER(OpenMode, open_mode, OpenMode::OPEN_EXISTING)
180+
IOX_BUILDER_PARAMETER(AccessMode, access_mode, AccessMode::ReadOnly)
181+
IOX_BUILDER_PARAMETER(OpenMode, open_mode, OpenMode::OpenExisting)
182182

183183
public:
184184
expected<File, FileCreationError> create(const FilePath& name) noexcept;

iceoryx_hoofs/posix/filesystem/source/file.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace iox
2626
{
2727
expected<File, FileCreationError> FileBuilder::create(const FilePath& name) noexcept
2828
{
29-
if (m_open_mode == OpenMode::PURGE_AND_CREATE)
29+
if (m_open_mode == OpenMode::PurgeAndCreate)
3030
{
3131
if (File::remove(name).has_error())
3232
{
@@ -59,7 +59,7 @@ expected<File, FileCreationError> FileBuilder::open(const FilePath& name) noexce
5959
return err(FileCreationError::PermissionDenied);
6060
}
6161

62-
if (m_access_mode == AccessMode::READ_ONLY || m_access_mode == AccessMode::READ_WRITE)
62+
if (m_access_mode == AccessMode::ReadOnly || m_access_mode == AccessMode::ReadWrite)
6363
{
6464
if ((perms->value() & perms::owner_read.value()) == 0)
6565
{
@@ -69,7 +69,7 @@ expected<File, FileCreationError> FileBuilder::open(const FilePath& name) noexce
6969
}
7070
}
7171

72-
if (m_access_mode == AccessMode::WRITE_ONLY || m_access_mode == AccessMode::READ_WRITE)
72+
if (m_access_mode == AccessMode::WriteOnly || m_access_mode == AccessMode::ReadWrite)
7373
{
7474
if ((perms->value() & perms::owner_write.value()) == 0)
7575
{
@@ -328,7 +328,7 @@ expected<uint64_t, FileReadError> File::read(uint8_t* const buffer, const uint64
328328
expected<uint64_t, FileReadError>
329329
File::read_at(const uint64_t offset, uint8_t* const buffer, const uint64_t buffer_len) const noexcept
330330
{
331-
if (m_access_mode == AccessMode::WRITE_ONLY)
331+
if (m_access_mode == AccessMode::WriteOnly)
332332
{
333333
IOX_LOG(Error, "Unable to read from file since it is opened for writing only.");
334334
return err(FileReadError::NotOpenedForReading);
@@ -384,7 +384,7 @@ expected<uint64_t, FileWriteError> File::write(const uint8_t* const buffer, cons
384384
expected<uint64_t, FileWriteError>
385385
File::write_at(const uint64_t offset, const uint8_t* const buffer, const uint64_t buffer_len) const noexcept
386386
{
387-
if (m_access_mode == AccessMode::READ_ONLY)
387+
if (m_access_mode == AccessMode::ReadOnly)
388388
{
389389
IOX_LOG(Error, "Unable to write to file since it is opened for reading only.");
390390
return err(FileWriteError::NotOpenedForWriting);

iceoryx_hoofs/posix/filesystem/source/file_lock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ expected<FileLock, FileLockError> FileLockBuilder::create() noexcept
5656
fileLockPath.unsafe_append(FileLock::LOCK_FILE_SUFFIX);
5757

5858
auto openCall = IOX_POSIX_CALL(iox_ext_open)(fileLockPath.c_str(),
59-
convertToOflags(AccessMode::READ_ONLY, OpenMode::OPEN_OR_CREATE),
59+
convertToOflags(AccessMode::ReadOnly, OpenMode::OpenOrCreate),
6060
m_permission.value())
6161
.failureReturnValue(-1)
6262
.evaluate();

iceoryx_hoofs/posix/ipc/include/iox/detail/posix_memory_map.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class PosixMemoryMapBuilder
8383

8484
/// @brief Defines if the memory should be mapped read only or with write access.
8585
/// A read only memory section will cause a segmentation fault when written to.
86-
IOX_BUILDER_PARAMETER(AccessMode, accessMode, AccessMode::READ_WRITE)
86+
IOX_BUILDER_PARAMETER(AccessMode, accessMode, AccessMode::ReadWrite)
8787

8888
/// @brief Sets the flags defining how the mapped data should be handled
8989
IOX_BUILDER_PARAMETER(PosixMemoryMapFlags, flags, PosixMemoryMapFlags::SHARE_CHANGES)

iceoryx_hoofs/posix/ipc/include/iox/detail/posix_shared_memory.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class PosixSharedMemory : public FileManagementInterface<PosixSharedMemory>
7676

7777
/// @brief this class has the ownership of the shared memory when the shared
7878
/// memory was created by this class. This is the case when this class
79-
/// was successful created with EXCLUSIVE_CREATE, PURGE_AND_CREATE or OPEN_OR_CREATE
79+
/// was successful created with ExclusiveCreate, PurgeAndCreate or OpenOrCreate
8080
/// and the shared memory was created. If an already available shared memory
8181
/// is opened then this class does not have the ownership.
8282
bool hasOwnership() const noexcept;
@@ -116,10 +116,10 @@ class PosixSharedMemoryBuilder
116116

117117
/// @brief Defines if the memory should be mapped read only or with write access.
118118
/// A read only memory section will cause a segmentation fault when written to.
119-
IOX_BUILDER_PARAMETER(AccessMode, accessMode, AccessMode::READ_ONLY)
119+
IOX_BUILDER_PARAMETER(AccessMode, accessMode, AccessMode::ReadOnly)
120120

121121
/// @brief Defines how the shared memory is acquired
122-
IOX_BUILDER_PARAMETER(OpenMode, openMode, OpenMode::OPEN_EXISTING)
122+
IOX_BUILDER_PARAMETER(OpenMode, openMode, OpenMode::OpenExisting)
123123

124124
/// @brief Defines the access permissions of the shared memory
125125
IOX_BUILDER_PARAMETER(access_rights, filePermissions, perms::none)

0 commit comments

Comments
 (0)