AXCEL C++ Framework
Elegance through abstraction
Classes | Namespaces | Defines | Typedefs | Enumerations | Functions
axcel.h File Reference
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cstdarg>
#include <cmath>
#include <climits>
#include <cctype>
#include <deque>
#include <errno.h>
#include <ctime>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <poll.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <termios.h>
#include <wordexp.h>
#include <signal.h>
#include <pthread.h>
#include <semaphore.h>
#include <dlfcn.h>

Go to the source code of this file.

Classes

class  axcel::object
 Common base class. More...
class  axcel::io::iofmt
 Stream format options. More...
class  axcel::io::iob
 I/O stream base. More...
class  axcel::io::input
 Input stream. More...
class  axcel::io::output
 Output stream. More...
class  axcel::io::ios
 Input/Output stream. More...
class  axcel::data
 File-like buffer. More...
class  axcel::string
 String. More...
class  axcel::fs::file
 File. More...
class  axcel::net::ipaddr
 IPv4 or IPv6 address. More...
class  axcel::net::socket::tcp
 Transmission Control Protocol socket. More...
class  axcel::net::socket::udp
 User Datagram Protocol socket. More...
class  axcel::net::dgram
 Datagram for socket::udp. More...
class  axcel::timer
 Time keeper. More...
class  axcel::console
 Console I/O and manipulation. More...
class  axcel::proc::thread
 Multithreading. More...
class  axcel::proc::library
 Dynamic library loading. More...
class  axcel::proc::mutex
 Mutex. More...
class  axcel::proc::semaphore
 Semaphore. More...
class  axcel::proc::pstream
 Pipe stdin and stdout of a process. More...
class  axcel::proc::environment
 Build an environment block. More...
struct  axcel::proc::environment::p
class  axcel::net::irc::msg
 IRC message. More...
class  axcel::net::http::query
 HTTP query string from a header request file. More...
struct  axcel::net::http::query::svarpair
class  axcel::net::http::field
 HTTP header field. More...
struct  axcel::net::http::field::svarpair
class  axcel::net::http::request
 HTTP header request. More...
class  axcel::net::http::response
 HTTP header response. More...
class  axcel::net::http::header
 HTTP header. More...
class  axcel::exception
 Exception class. More...

Namespaces

namespace  axcel
 

Everything.


namespace  axcel::io
 

Input/Output.


namespace  axcel::fs
 

File system.


namespace  axcel::proc
 

Process and runtime.


namespace  axcel::net
 

Network and protocols.


namespace  axcel::net::socket
 

Internet sockets.


namespace  axcel::net::irc
 

Internet Relay Chat.


namespace  axcel::net::http
 

Hyper Text Transfer Protocol.


namespace  axcel::color

Defines

#define use   using namespace
#define unless(x)   if (!(x))
#define until(x)   while (!(x))
#define loop()   for (;;)
#define crap(...)
#define craps(x,...)
#define warn(...)   fprintf(stderr, __VA_ARGS__);

Typedefs

typedef unsigned char uchar
typedef unsigned short ushort
typedef unsigned int uint
typedef unsigned long ulong

Enumerations

enum  {
  axcel::color::black, axcel::color::red, axcel::color::green, axcel::color::yellow,
  axcel::color::blue, axcel::color::purple, axcel::color::aqua, axcel::color::white
}

Functions

template<typename T >
bool gt (T a, T b)
template<typename T >
bool lt (T a, T b)
template<typename T >
bool eq (T a, T b)
template<typename T >
bool gte (T a, T b)
template<typename T >
bool lte (T a, T b)
template<typename T >
bool neq (T a, T b)
char * strcpy2 (char *s1, const char *s2)
char * strncpy2 (char *s1, const char *s2, size_t n)
const char * strstrs (const char *src,...)
int strstrc (const char *src,...)
time_t axcel::axcel_timegm (struct tm *tm)
template<typename type >
type axcel::stoi (const char *s, int base=10)
 string to integer
template<typename type >
type axcel::stof (const char *s)
 string to floating point
template<typename type >
string axcel::itos (type t, int base=10, bool showbase=false)
 Integer to string.
template<typename type >
string axcel::ftos (type t, bool sci=false)
 Floating-point to string.
void axcel::die (const char *format,...)
 Print formatted string and exit.
void axcel::print (const char *s, FILE *stream=stdout)
 Print string.
void axcel::print (int ch, FILE *stream=stdout)
 Print character.
int axcel::rand (int min=0, int max=0)
 Get random integer.
int axcel::rands (unsigned int seed, int min=0, int max=0)
 Get random integer.
char * axcel::memrev (char *s, size_t size, size_t n)
 Reverse memory block.
char * axcel::memrol (char *s, size_t size, size_t n)
 Rotate left memory block.
char * axcel::memror (char *s, size_t size, size_t n)
 Rotate right memory block.
char * axcel::memshl (char *s, size_t size, size_t n)
 Shift left memory block.
char * axcel::memshr (char *s, size_t size, size_t n)
 Shift right memory block.
string axcel::chop (const char *str)
 Remove last character from string.
string axcel::chomp (const char *str, const char *eat="\r\n")
 Remove existing string from end of string.
string axcel::cut (const char *str)
 Remove first character from string.
string axcel::munch (const char *str, const char *eat)
 Remove existing string from beginning of string.
string axcel::ltrim (const char *str)
 Remove leading whitespace.
string axcel::rtrim (const char *str)
 Remove trailing whitespace.
string axcel::strip (const char *str)
 Remove leading and trailing whitespace.
long axcel::index (const char *str, const char *find)
 Find first string.
long axcel::index (const char *str, int find)
 Find first character.
long axcel::length (const char *str)
 Length of string.
bool axcel::eq (const char *s1, const char *s2)
 Compare strings.
bool axcel::sfront (const char *s1, const char *s2)
 Compare beginning of string.
bool axcel::sback (const char *s1, const char *s2)
 Compare end of string.
string axcel::substr (const char *str, size_t offset, size_t length)
 Get substring.
string axcel::lc (const char *str)
 Lowercase string.
string axcel::lcfirst (const char *str)
 Lowercase first character.
string axcel::uc (const char *str)
 Uppercase string.
string axcel::ucfirst (const char *str)
 Uppercase first character.
long axcel::dec (const char *str)
 string to decimal long int
long axcel::bin (const char *str)
 string to binary long int
long axcel::oct (const char *str)
 string to octal long int
long axcel::hex (const char *str)
 string to hexadecimal long int
long axcel::rindex (const char *str, const char *find)
 Find last string.
long axcel::rindex (const char *str, int find)
 Find last character.
unsigned short axcel::cksum (const char *buf)
 string checksum
string axcel::q (const char *str)
 Single quote string.
string axcel::qq (const char *str)
 Double quote string.
string axcel::qx (const char *exec)
 Execute command and return io::output.
string axcel::scat (const char *s1, const char *s2)
 Concatenate strings.
string axcel::sdup (const char *str, int x)
 Duplicate string.
string axcel::tok (size_t index, const char *str, const char *delim=" ")
 Extract token from string.
string axcel::tok (size_t index, const char *str, int delim)
 Extract token from string.
long axcel::ntok (const char *str, const char *delim=" ")
 Count string tokens.
long axcel::ntok (const char *str, int delim)
 Count string tokens.
long axcel::itok (size_t index, const char *str, const char *delim=" ")
 Get index of token.
long axcel::itok (size_t index, const char *str, int delim)
 Get index of token.
std::deque< axcel::stringaxcel::split (const char *str, const char *delim)
 Split string.
std::deque< axcel::stringaxcel::split (const char *str, int delim)
 Split string.
string axcel::join (std::deque< axcel::string > v, const char *delim=" ")
 Join string deque.
string axcel::join (std::deque< axcel::string > v, int delim)
 Join string deque.
bool axcel::fs::cd (const char *path)
 Change current directory.
bool axcel::fs::rm (const char *fname)
 Remove file.
bool axcel::fs::md (const char *path)
 Make directory.
string axcel::fs::gcd ()
 Get current directory.
string axcel::fs::ls (const char *dir=0)
 List files.
bool axcel::fs::creat (const char *fname)
 Create file.
bool axcel::fs::trunc (const char *fname, unsigned long len)
 Resize file.
bool axcel::fs::rd (const char *dir, bool rmsub=1)
 Remove directory.
bool axcel::fs::cp (const char *src, const char *dst)
 Copy file.
bool axcel::fs::mv (const char *src, const char *dst)
 Move file.
size_t axcel::fs::fsize (const char *fname)
 Get file size.
bool axcel::fs::fexist (const char *fname)
 Check if file exists.
bool axcel::fs::fisdir (const char *fname)
 Check if file is directory.
bool axcel::fs::fisreg (const char *fname)
 Check if file is regular file.
string axcel::fs::fread (const char *fname, size_t len=0)
 Read from text file.
size_t axcel::fs::fread (const char *fname, char *buf, size_t len=0)
 Read from file.
data axcel::fs::fbread (const char *fname, size_t len=0)
 Read binary data from file.
size_t axcel::fs::fbwrite (const char *fname, data d, size_t len=0)
 Write binary data to file.
size_t axcel::fs::fwrite (const char *fname, const char *buf, size_t len=0)
 Write to file.
size_t axcel::fs::fcat (const char *fname, const char *buf, size_t len=0)
 Concatenate to file.
bool axcel::fs::fcmp (const char *src, const char *dst)
 Compare files.
timer axcel::fs::fatime (const char *fname)
 Get file access time.
timer axcel::fs::fmtime (const char *fname)
 Get file modification time.
string axcel::fs::tmpnam ()
 Generate temporary filename.
void axcel::proc::delay (size_t ms)
 Sleep current thread.
pid_t axcel::proc::run (const char *program, const char *argv, void *envp)
 Spawn new process.
string axcel::proc::lsproc ()
 List processes.
bool axcel::proc::killp (size_t pid)
 Kill process.
bool axcel::proc::killp (const char *name)
 Kill process.
bool axcel::proc::freeze (size_t pid)
 Suspend process.
bool axcel::proc::freeze (const char *name)
 Suspend process.
bool axcel::proc::cont (size_t pid)
 Resume process.
bool axcel::proc::cont (const char *name)
 Resume process.
bool axcel::proc::envset (const char *name, const char *value)
 Set environment variable.
string axcel::proc::envget (const char *name)
 Get environment variable.
sem_t * axcel::proc::mksem (const char *name, size_t count)
bool axcel::proc::rmsem (const char *name)
data axcel::net::http::download (const char *url, const char *port="80")

Detailed Description

Definition in file axcel.h.


Define Documentation

#define crap (   ...)
Value:
if (1) {\
        fprintf(stderr, __VA_ARGS__);\
        return;}

Print formatted string using printf to stderr and returns from current function.

#define craps (   x,
  ... 
)
Value:
if (1) {\
        fprintf(stderr, __VA_ARGS__);\
        return x; }

Print formatted string using printf to stderr and returns from current function with x as return value.

#define loop ( )    for (;;)

Perform infinite loop on statement(s).

#define unless (   x)    if (!(x))

inverse of If statement. Executes statement(s) if condition is false

#define until (   x)    while (!(x))

inverse of while statement. Executes statement(s) while condition is false

#define use   using namespace

Definition at line 82 of file axcel.h.

#define warn (   ...)    fprintf(stderr, __VA_ARGS__);

Definition at line 100 of file axcel.h.


Typedef Documentation

typedef unsigned char uchar

Definition at line 103 of file axcel.h.

typedef unsigned int uint

Definition at line 105 of file axcel.h.

typedef unsigned long ulong

Definition at line 106 of file axcel.h.

typedef unsigned short ushort

Definition at line 104 of file axcel.h.


Function Documentation

template<typename T >
bool eq ( a,
b 
) [inline]

Definition at line 115 of file axcel.h.

template<typename T >
bool gt ( a,
b 
) [inline]

Definition at line 109 of file axcel.h.

template<typename T >
bool gte ( a,
b 
) [inline]

Definition at line 118 of file axcel.h.

template<typename T >
bool lt ( a,
b 
) [inline]

Definition at line 112 of file axcel.h.

template<typename T >
bool lte ( a,
b 
) [inline]

Definition at line 121 of file axcel.h.

template<typename T >
bool neq ( a,
b 
) [inline]

Definition at line 124 of file axcel.h.

char* strcpy2 ( char *  s1,
const char *  s2 
)

Definition at line 211 of file axcel.cpp.

char* strncpy2 ( char *  s1,
const char *  s2,
size_t  n 
)

Definition at line 216 of file axcel.cpp.

int strstrc ( const char *  src,
  ... 
)

Definition at line 5349 of file axcel.cpp.

const char* strstrs ( const char *  src,
  ... 
)

Definition at line 5339 of file axcel.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerator Defines