nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
nros::FixedString< N > Struct Template Reference

#include <fixed_string.hpp>

Public Member Functions

const charc_str () const
 Get a pointer to the null-terminated string.
 
 FixedString ()
 Default constructor — empty string.
 
size_t length () const
 Get the length of the string (up to N-1).
 
bool operator!= (const char *s) const
 
FixedStringoperator= (const char *s)
 Assign from a C string. Truncates if longer than capacity.
 
bool operator== (const char *s) const
 Compare with a C string.
 

Static Public Member Functions

static constexpr size_t capacity ()
 Maximum number of characters (excluding null terminator).
 

Public Attributes

char data [N]
 

Detailed Description

template<size_t N>
struct nros::FixedString< N >

Fixed-capacity null-terminated string.

Wraps a char[N] buffer with safe assignment and query methods. Memory layout is identical to char[N], so the type is C-ABI compatible and can be passed across the runtime boundary by value.

Usage:

name = "hello world";
printf("%s (len=%zu)\n", name.c_str(), name.length());
Definition future.hpp:40

Constructor & Destructor Documentation

◆ FixedString()

template<size_t N>
nros::FixedString< N >::FixedString ( )
inline

Default constructor — empty string.

Member Function Documentation

◆ c_str()

template<size_t N>
const char * nros::FixedString< N >::c_str ( ) const
inline

Get a pointer to the null-terminated string.

◆ capacity()

template<size_t N>
static constexpr size_t nros::FixedString< N >::capacity ( )
inlinestaticconstexpr

Maximum number of characters (excluding null terminator).

◆ length()

template<size_t N>
size_t nros::FixedString< N >::length ( ) const
inline

Get the length of the string (up to N-1).

◆ operator!=()

template<size_t N>
bool nros::FixedString< N >::operator!= ( const char s) const
inline

◆ operator=()

template<size_t N>
FixedString & nros::FixedString< N >::operator= ( const char s)
inline

Assign from a C string. Truncates if longer than capacity.

◆ operator==()

template<size_t N>
bool nros::FixedString< N >::operator== ( const char s) const
inline

Compare with a C string.

Member Data Documentation

◆ data

template<size_t N>
char nros::FixedString< N >::data[N]

The documentation for this struct was generated from the following file: