Snel
A shell implementation for A.U.TH (Operating Systems Lab)
|
#include <sequencer.h>
Public Types | |
using | type = typename std::string::value_type |
Basic data type (aka char) | |
using | vtype = type * |
Vector type. | |
using | vtype_ptr = vtype * |
Pointer to vector type. | |
Public Member Functions | |
~ArgList () | |
ArgList (const ArgList &)=default | |
ArgList (ArgList &&)=default | |
ArgList & | push_back (const std::string &item) |
A vector::push_back wrapper. More... | |
vtype | front () |
A vector::front() wrapper. | |
size_t | size () |
A vector::size() wrapper. | |
vtype_ptr | data () noexcept |
return a pointer to underling data for execvp() | |
vtype_ptr | operator* () noexcept |
same as data() | |
Private Attributes | |
std::vector< vtype > | args_ {nullptr} |
underling data for the execvp() arguments | |
A vector based wrapper above execvp()'s char* argv[]
interface. We use a vector for convenience and resizing capabilities. We can then use a pointer to underling data to pass to execvp() std::vector elements guaranteed to be contiguous. To quote the standard
The elements of a vector are stored contiguously, meaning that if v is a vector<T, Allocator> where T is some type other than bool, then it obeys the identity &v[n] == &v[0] + n for all 0 <= n < v.size().
See also cppreference
Definition at line 52 of file sequencer.h.
snel::ArgList::~ArgList | ( | ) |
destructor to free up all the allocations
Definition at line 88 of file sequencer.cpp.
ArgList & snel::ArgList::push_back | ( | const std::string & | item | ) |
A vector::push_back wrapper.
A push_back wrapper to our underling vector. This ensures NULL terminating argument list for exec() sys-call.
item | The argument to push |
Definition at line 99 of file sequencer.cpp.