AXCEL C++ Framework
Elegance through abstraction
Classes | Public Member Functions
axcel::proc::environment Class Reference

Build an environment block. More...

#include <axcel.h>

Inheritance diagram for axcel::proc::environment:
axcel::object

List of all members.

Classes

struct  p

Public Member Functions

string type ()
 Get type.
 operator string ()
 Convert to string.
string vars ()
 List variables.
stringoperator[] (const char *s)
 Get variable by name.
stringat (size_t i)
 Get variable by index.
size_t len ()
 Variable count.
environmentclear ()
 Clear variables.
bool empty ()
 Check if empty.
data bake ()
 Convert to environment block.

Detailed Description

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.

Definition at line 2231 of file axcel.h.


Member Function Documentation

string & axcel::proc::environment::at ( size_t  i)

Get variable by index.

Returns a string reference to an environment variable value by it's 0-based index in this object.

Definition at line 5956 of file axcel.cpp.

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.

Definition at line 5976 of file axcel.cpp.

proc::environment & axcel::proc::environment::clear ( )

Clear variables.

Erases all variables and their values from this environment block object.

Definition at line 5968 of file axcel.cpp.

bool axcel::proc::environment::empty ( )

Check if empty.

Returns true if len() is 0, that is, there are no variables set in this object.

Definition at line 5972 of file axcel.cpp.

size_t axcel::proc::environment::len ( )

Variable count.

Returns the number of environment variables set using the [] operator in this object.

Definition at line 5959 of file axcel.cpp.

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.

Definition at line 5926 of file axcel.cpp.

string & axcel::proc::environment::operator[] ( const char *  s)

Get variable by name.

Returns a string reference to an environment variable value by it's name.

Definition at line 5948 of file axcel.cpp.

string axcel::proc::environment::type ( ) [virtual]

Get type.

Returns a string representation of this class type. In this case: "proc::environment"

Implements axcel::object.

Definition at line 5925 of file axcel.cpp.

string axcel::proc::environment::vars ( )

List variables.

Returns a string containing the name of each variable in this environment block on a new line (
).

Definition at line 5937 of file axcel.cpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Defines