TReK C++  5.3.3
Telemetry/Command API
trek::StringArray Class Reference

This class provides a wrapper for std::vector and std::string so different versions of the standard template library don't cause problems. The array is zero based. More...

#include <string_array.h>

Public Member Functions

void Clear ()
 Removes all of the strings from the array.
 
uint32_t Size ()
 Returns the number of items in the string array.
 
const char * GetAt (uint32_t index)
 Returns the string at the given location. More...
 
void Add (const char *item)
 Adds the item to the end of the array. More...
 
int32_t Replace (uint32_t index, const char *item)
 Replaces the string at the given location. More...
 
void Resize (uint32_t input)
 Resizes the array to the input size.
 
Constructors, Destructor, and Other Basic Methods
 StringArray ()
 Default constructor of the class.
 
 StringArray (StringArray &input)
 Copy constructor of the class.
 
virtual ~StringArray ()
 Class destructor. More...
 
void operator= (StringArray &right_side)
 Provides the equal operator.
 
StringArrayClone ()
 Returns an exact copy of the object;.
 

Detailed Description

This class provides a wrapper for std::vector and std::string so different versions of the standard template library don't cause problems. The array is zero based.

Examples
cmd_api_cpp/cmd_api_cpp_main.cpp, extract_packet/extract_packet.cpp, tlm_api_cpp_newest/cpp_newest_main.cpp, and tlm_api_cpp_next/cpp_next_main.cpp.

Constructor & Destructor Documentation

◆ ~StringArray()

trek::StringArray::~StringArray ( )
virtual

Class destructor.

Removes all resources created with this instance of the class.

Member Function Documentation

◆ Add()

void trek::StringArray::Add ( const char *  item)

Adds the item to the end of the array.

Parameters
[in]itemThe string to add to the end of the array

Example:

StringArray my_array;
my_array.Add("Larry");
my_array.Add("Moe");
my_array.Add("Curly");
This class provides a wrapper for std::vector and std::string so different versions of the standard t...
Definition: string_array.h:19
void Add(const char *item)
Adds the item to the end of the array.
Definition: string_array.cpp:111

◆ GetAt()

const char * trek::StringArray::GetAt ( uint32_t  index)

Returns the string at the given location.

If the index does not exists, a NULL pointer is returned.

Parameters
[in]indexThe index to get the string for

Example:

StringArray my_array;
char *my_ptr;
my_ptr = my_array.GetAt(2);
if( my_ptr ) // otherwise index doesn't exist
printf("%s\n", my_ptr);
const char * GetAt(uint32_t index)
Returns the string at the given location.
Definition: string_array.cpp:89
Examples
cmd_api_cpp/cmd_api_cpp_main.cpp, extract_packet/extract_packet.cpp, and tlm_api_cpp_newest/cpp_newest_main.cpp.

◆ Replace()

int32_t trek::StringArray::Replace ( uint32_t  index,
const char *  item 
)

Replaces the string at the given location.

If the specified index does not exist, an error is returned and no changes are made to the array.

Parameters
[in]indexThe location to change
[in]itemThe new string for the location
Returns
SUCCESS
FAIL
TREK_DATA_NULL_PTR

Example:

StringArray my_array;
// assuming you've added 3 stooges.
my_array.Replace( 2, "Shemp" );
int32_t Replace(uint32_t index, const char *item)
Replaces the string at the given location.
Definition: string_array.cpp:140