Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convenience functions for cxx::string #1431

Open
FerdinandSpitzschnueffler opened this issue Jun 29, 2022 · 1 comment
Open

Convenience functions for cxx::string #1431

FerdinandSpitzschnueffler opened this issue Jun 29, 2022 · 1 comment
Labels
enhancement New feature

Comments

@FerdinandSpitzschnueffler
Copy link
Contributor

FerdinandSpitzschnueffler commented Jun 29, 2022

Brief feature description

This is an issue to collect convenience functions for the cxx::string which would be nice to have but are not urgently needed.

Detailed information

  • add c'tor that constructs the iox::string with count copies of a character
    iox::string<10> str(TruncateToCapacity, count, 'M');    // count as runtime parameter
    iox::string<10> str(count, 'M');    // count as compile time constant
    
  • remove characters from the iox::string
    iox::string<10> str("someString");
    str.erase(5, 2);    // str == someSing
    str.erase(7);    // str == someSin
    
@elBoberido
Copy link
Member

Nice. But is TruncateToCapacity necessary? I guess yes when count is a runtime parameter but can we also have one with a compile time constant and then just a iox::cxx::string<10> a(5, 'M'); with a compile time error on iox::cxx::string<10> a(15, 'M'); ?

lucabart97 added a commit to lucabart97/iceoryx that referenced this issue Nov 18, 2023
…access to iox::string

Introduce two methods to directly access the string pointer. This
function enables checking the string's size and capacity after each
call, minimizing the risk of encountering invalid strings.

The first one auto compute the string size, the second one set the size
passed by the user checking if the terminator position is fine.

Signed-off-by: Luca Bartoli <[email protected]>
lucabart97 added a commit to lucabart97/iceoryx that referenced this issue Nov 19, 2023
Implement a method that provides direct access to the string's
underlying pointer. This allows data to be written directly to
the string, eliminating the need for copies. The string's
length is checked on each call to ensure the null terminator
is in the correct position.

Signed-off-by: Luca Bartoli <[email protected]>
lucabart97 added a commit to lucabart97/iceoryx that referenced this issue Nov 19, 2023
Implement a method that provides direct access to the string's
underlying pointer. This allows data to be written directly to
the string, eliminating the need for copies. The string's
length is checked on each call to ensure the null terminator
is in the correct position.

Signed-off-by: Luca Bartoli <[email protected]>
lucabart97 added a commit to lucabart97/iceoryx that referenced this issue Nov 19, 2023
Implement a method that provides direct access to the string's
underlying pointer. This allows data to be written directly to
the string, eliminating the need for copies. The string's
length is checked on each call to ensure the null terminator
is in the correct position.

Signed-off-by: Luca Bartoli <[email protected]>
lucabart97 added a commit to lucabart97/iceoryx that referenced this issue Nov 19, 2023
Implement a method that provides direct access to the string's
underlying pointer. This allows data to be written directly to
the string, eliminating the need for copies. The string's
length is checked on each call to ensure the null terminator
is in the correct position.

Signed-off-by: Luca Bartoli <[email protected]>
lucabart97 added a commit to lucabart97/iceoryx that referenced this issue Nov 19, 2023
Implement a method that provides direct access to the string's
underlying pointer. This allows data to be written directly to
the string, eliminating the need for copies. The string's
length is checked on each call to ensure the null terminator
is in the correct position.

Signed-off-by: Luca Bartoli <[email protected]>
elBoberido added a commit that referenced this issue Nov 20, 2023
…tring

iox-#1431: Add unsafe_raw_access to iox::string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature
Projects
None yet
Development

No branches or pull requests

2 participants