AXCEL C++ Framework
Elegance through abstraction
|
Build an environment block. More...
#include <axcel.h>
Classes | |
struct | p |
Public Member Functions | |
string | type () |
Get type. | |
operator string () | |
Convert to string. | |
string | vars () |
List variables. | |
string & | operator[] (const char *s) |
Get variable by name. | |
string & | at (size_t i) |
Get variable by index. | |
size_t | len () |
Variable count. | |
environment & | clear () |
Clear variables. | |
bool | empty () |
Check if empty. | |
data | bake () |
Convert to environment block. |
Build an environment block.
Hashtable-like class that can be used for building an appropriate environment block to pass to functions like execve or pstream.open. The environment block is the 3rd argument of main(). The main function can be defined as int main(int argc, char *argv[], char *envp[]) where envp is a null-pointer terminated array of character pointers (C-strings) (Note: This framework include envget and envset functions for accessing the environment as a cleaner alternative to envp). After getting/setting the environment variables associated with an object of this class using the [] operator, one should call the bake() method which returns a data object in the appropriate envp format that can be passed to a function expecting an environment block.
string & axcel::proc::environment::at | ( | size_t | i | ) |
data axcel::proc::environment::bake | ( | ) |
Convert to environment block.
Returns a data object containing a null-pointer-terminated array of C strings (pointers to null-terminated character arrays). In other words, this method converts this object into a raw environment block which can be passed to execve, axcel::proc::pstream.open, or axcel::proc::run.
proc::environment & axcel::proc::environment::clear | ( | ) |
bool axcel::proc::environment::empty | ( | ) |
size_t axcel::proc::environment::len | ( | ) |
axcel::proc::environment::operator string | ( | ) | [virtual] |
Convert to string.
Returns suitable string representation of this object. The string is in the form NAME=VALUE on a new line (
) for each variable.
Implements axcel::object.
string & axcel::proc::environment::operator[] | ( | const char * | s | ) |
string axcel::proc::environment::type | ( | ) | [virtual] |
Get type.
Returns a string representation of this class type. In this case: "proc::environment"
Implements axcel::object.
string axcel::proc::environment::vars | ( | ) |