Motor Driver Evaluation Kit NEVB-MTR1-t01-1.0.0
Firmware for NEVB-MTR1-KIT1 for trapezoidal control of BLDC motors using Hall-effect sensors
Loading...
Searching...
No Matches
SCPI_String_Array Class Reference

Variable size string array class. More...

#include <scpi_types.h>

Inheritance diagram for SCPI_String_Array:
[legend]

Public Member Functions

char * operator[] (const byte index) const
 Read-only array indexing.
 
void Append (char *value)
 Append a new string to the array (LIFO push).
 
char * Pop ()
 Remove and return the last string (LIFO pop).
 
char * First () const
 Get the first appended string.
 
char * Last () const
 Get the last appended string.
 
uint8_t Size () const
 Get the number of stored strings.
 

Public Attributes

bool overflow_error = false
 Flag set when exceeding storage_size.
 
const uint8_t storage_size = 6
 Max number of entries allowed.
 

Protected Attributes

uint8_t size_ = 0
 Current size of the array.
 
char * values_ [6]
 Internal storage for string pointers.
 

Detailed Description

Variable size string array class.

This class represents a simple container for storing and managing a list of string tokens.

Strings can be added using Append (which acts like a LIFO stack push), and removed using Pop. The current size can be queried via Size. Indexing is supported via operator[]. Methods First and Last return the respective elements in the array.

Overflow protection is built-in, and the array size is bounded by the compile-time constant SCPI_ARRAY_SYZE.

Definition at line 49 of file scpi_types.h.

Member Function Documentation

◆ Append()

void SCPI_String_Array::Append ( char * value)

Append a new string to the array (LIFO push).

Append a new string to the array.

Acts like a LIFO stack push. If the array is full, sets overflow_error.

Parameters
valuePointer to the null-terminated string to append.

Definition at line 55 of file scpi_types.cpp.

56{
59 return;
60 values_[size_] = value;
61 size_++;
62}
uint8_t size_
Current size of the array.
Definition scpi_types.h:61
bool overflow_error
Flag set when exceeding storage_size.
Definition scpi_types.h:58
const uint8_t storage_size
Max number of entries allowed.
Definition scpi_types.h:59
char * values_[6]
Internal storage for string pointers.
Definition scpi_types.h:62
Here is the caller graph for this function:

◆ First()

char * SCPI_String_Array::First ( ) const

Get the first appended string.

Get the first element in the array.

Returns
Pointer to the first string, or NULL if empty.

Definition at line 84 of file scpi_types.cpp.

85{
86 if (size_ == 0)
87 return NULL;
88 return values_[0];
89}

◆ Last()

char * SCPI_String_Array::Last ( ) const

Get the last appended string.

Get the last element in the array.

Returns
Pointer to the last string, or NULL if empty.

Definition at line 96 of file scpi_types.cpp.

97{
98 if (size_ == 0)
99 return NULL;
100 return values_[size_ - 1];
101}

◆ operator[]()

char * SCPI_String_Array::operator[] ( const byte index) const

Read-only array indexing.

Indexing operator.

Provides array-like access to internal values.

Parameters
indexIndex of the element to retrieve.
Returns
Pointer to the string at the given index, or NULL if out of bounds.

Definition at line 41 of file scpi_types.cpp.

42{
43 if (index >= size_)
44 return NULL; // Invalid index
45 return values_[index];
46}

◆ Pop()

char * SCPI_String_Array::Pop ( )

Remove and return the last string (LIFO pop).

Pop the last string from the array.

Acts like a LIFO stack pop. Removes and returns the last inserted string.

Returns
Pointer to the last string, or NULL if the array is empty.

Definition at line 71 of file scpi_types.cpp.

72{
73 if (size_ == 0)
74 return NULL; // Empty array
75 size_--;
76 return values_[size_];
77}
Here is the caller graph for this function:

◆ Size()

uint8_t SCPI_String_Array::Size ( ) const

Get the number of stored strings.

Get the current number of strings in the array.

Returns
Number of elements in the array.

Definition at line 108 of file scpi_types.cpp.

109{
110 return size_;
111}
Here is the caller graph for this function:

Member Data Documentation

◆ overflow_error

bool SCPI_String_Array::overflow_error = false

Flag set when exceeding storage_size.

Definition at line 58 of file scpi_types.h.

◆ size_

uint8_t SCPI_String_Array::size_ = 0
protected

Current size of the array.

Definition at line 61 of file scpi_types.h.

◆ storage_size

const uint8_t SCPI_String_Array::storage_size = 6

Max number of entries allowed.

Definition at line 59 of file scpi_types.h.

◆ values_

char* SCPI_String_Array::values_[6]
protected

Internal storage for string pointers.

Definition at line 62 of file scpi_types.h.


The documentation for this class was generated from the following files: