AXCEL C++ Framework
Elegance through abstraction
Namespaces | Classes | Functions | Variables
axcel Namespace Reference

Everything. More...

Namespaces

namespace  color
namespace  fs
 

File system.


namespace  io
 

Input/Output.


namespace  net
 

Network and protocols.


namespace  proc
 

Process and runtime.


Classes

class  object
 Common base class. More...
class  data
 File-like buffer. More...
class  string
 String. More...
class  timer
 Time keeper. More...
class  console
 Console I/O and manipulation. More...
struct  errno_str
class  exception
 Exception class. More...

Functions

char * strcpy2 (char *s1, const char *s2)
char * strncpy2 (char *s1, const char *s2, size_t n)
void die (const char *format,...)
 Print formatted string and exit.
unsigned short cksum (const char *buf)
 string checksum
int rand (int min=0, int max=0)
 Get random integer.
int rands (unsigned int seed, int min=0, int max=0)
 Get random integer.
char * memrev (char *s, size_t size, size_t n)
 Reverse memory block.
char * memrol (char *s, size_t size, size_t n)
 Rotate left memory block.
char * memror (char *s, size_t size, size_t n)
 Rotate right memory block.
char * memshr (char *s, size_t size, size_t n)
 Shift right memory block.
char * memshl (char *s, size_t size, size_t n)
 Shift left memory block.
string chop (const char *str)
 Remove last character from string.
string chomp (const char *str, const char *eat="\r\n")
 Remove existing string from end of string.
string cut (const char *str)
 Remove first character from string.
string munch (const char *str, const char *eat)
 Remove existing string from beginning of string.
string ltrim (const char *str)
 Remove leading whitespace.
string rtrim (const char *str)
 Remove trailing whitespace.
string strip (const char *str)
 Remove leading and trailing whitespace.
string substr (const char *str, size_t offset, size_t length)
 Get substring.
string lc (const char *str)
 Lowercase string.
string lcfirst (const char *str)
 Lowercase first character.
string uc (const char *str)
 Uppercase string.
string ucfirst (const char *str)
 Uppercase first character.
long rindex (const char *str, const char *find)
 Find last string.
long rindex (const char *str, int find)
 Find last character.
string q (const char *str)
 Single quote string.
string qq (const char *str)
 Double quote string.
string qx (const char *exec)
 Execute command and return io::output.
string scat (const char *s1, const char *s2)
 Concatenate strings.
string sdup (const char *str, int x)
 Duplicate string.
string tok (size_t index, const char *str, const char *delim=" ")
 Extract token from string.
string tok (size_t index, const char *str, int delim)
 Extract token from string.
long ntok (const char *str, const char *delim=" ")
 Count string tokens.
long ntok (const char *str, int delim)
 Count string tokens.
long itok (size_t index, const char *str, const char *delim=" ")
 Get index of token.
long itok (size_t index, const char *str, int delim)
 Get index of token.
std::deque< axcel::stringsplit (const char *str, const char *delim)
 Split string.
std::deque< axcel::stringsplit (const char *str, int delim)
 Split string.
string join (std::deque< axcel::string > v, const char *delim=" ")
 Join string deque.
string join (std::deque< axcel::string > v, int delim)
 Join string deque.
time_t axcel_timegm (struct tm *tm)
const char * strstrs (const char *src,...)
int strstrc (const char *src,...)
template<typename type >
type stoi (const char *s, int base=10)
 string to integer
template<typename type >
type stof (const char *s)
 string to floating point
template<typename type >
string itos (type t, int base=10, bool showbase=false)
 Integer to string.
template<typename type >
string ftos (type t, bool sci=false)
 Floating-point to string.
void print (const char *s, FILE *stream=stdout)
 Print string.
void print (int ch, FILE *stream=stdout)
 Print character.
long index (const char *str, const char *find)
 Find first string.
long index (const char *str, int find)
 Find first character.
long length (const char *str)
 Length of string.
bool eq (const char *s1, const char *s2)
 Compare strings.
bool sfront (const char *s1, const char *s2)
 Compare beginning of string.
bool sback (const char *s1, const char *s2)
 Compare end of string.
long dec (const char *str)
 string to decimal long int
long bin (const char *str)
 string to binary long int
long oct (const char *str)
 string to octal long int
long hex (const char *str)
 string to hexadecimal long int

Variables

struct errno_str errno_strs []
console con

Detailed Description

Everything.


Function Documentation

time_t axcel::axcel_timegm ( struct tm *  tm)

Definition at line 5162 of file axcel.cpp.

long axcel::bin ( const char *  str) [inline]

string to binary long int

Parameters:
strThe string
Returns:
long int value of the number the string represents

Definition at line 1567 of file axcel.h.

string axcel::chomp ( const char *  str,
const char *  eat = "\r\n" 
)

Remove existing string from end of string.

Parameters:
strThe string
eatstring to remove
Returns:
string object result

Removes string eat from end of string str if it exists.

Definition at line 4911 of file axcel.cpp.

string axcel::chop ( const char *  str)

Remove last character from string.

Parameters:
Thestring
Returns:
string object result

Removes last character from string str and returns it as a string object. If the last characters are "\\r\\n", then both characters are removed.

Definition at line 4906 of file axcel.cpp.

unsigned short axcel::cksum ( const char *  buf)

string checksum

Parameters:
bufThe string
Returns:
BSD checksum of string

Definition at line 4845 of file axcel.cpp.

string axcel::cut ( const char *  str)

Remove first character from string.

Parameters:
strThe string
Returns:
string object result

Removes the first character from string str and returns result as a string object.

Definition at line 4916 of file axcel.cpp.

long axcel::dec ( const char *  str) [inline]

string to decimal long int

Parameters:
strThe string
Returns:
long int value of the number the string represents

Definition at line 1561 of file axcel.h.

void axcel::die ( const char *  format,
  ... 
)

Print formatted string and exit.

Parameters:
formatFormat string
...Token arguments

Calls printf() to display an error message and terminates the program. See printf() documentation from the Standard C libraryrary for details.

Definition at line 4838 of file axcel.cpp.

bool axcel::eq ( const char *  s1,
const char *  s2 
) [inline]

Compare strings.

Parameters:
s1A string
s2Another string
Returns:
true if equal content, false if not.

Definition at line 1509 of file axcel.h.

template<typename type >
string axcel::ftos ( type  t,
bool  sci = false 
)

Floating-point to string.

Parameters:
tConstant value of floating-point template type to convert
sciScientific-notation

Converts the floating-point decimal value to it's string representation. Valid template types are the same for the stof function.

Definition at line 1337 of file axcel.h.

long axcel::hex ( const char *  str) [inline]

string to hexadecimal long int

Parameters:
strThe string
Returns:
long int value of the number the string represents

Definition at line 1579 of file axcel.h.

long axcel::index ( const char *  str,
const char *  find 
) [inline]

Find first string.

Parameters:
strThe string to search through
findThe string to find
Returns:
index of first occurrence or -1 if not found

Definition at line 1489 of file axcel.h.

long axcel::index ( const char *  str,
int  find 
) [inline]

Find first character.

Parameters:
strThe string to search through
findThe character to find
Returns:
index of first occurrence of -1 if not found

Definition at line 1496 of file axcel.h.

long axcel::itok ( size_t  index,
const char *  str,
const char *  delim = " " 
)

Get index of token.

Parameters:
indexToken index
strstring to tokenate
delimDelimiting characters
Returns:
io::inputdex of token in string, or -1 if not found

Definition at line 5013 of file axcel.cpp.

long axcel::itok ( size_t  index,
const char *  str,
int  delim 
)

Get index of token.

Parameters:
indexToken index
strstring to tokenate
delimDelimiting character
Returns:
index of token in string, or -1 if not found

Definition at line 5017 of file axcel.cpp.

template<typename type >
string axcel::itos ( type  t,
int  base = 10,
bool  showbase = false 
)

Integer to string.

Parameters:
tConstant value of numeric template type to convert
baseNumeric base
showbasePrefix base prefix (default false)

Converts template type t to a string representing it's value. Valid templates for this function are the same for the stoi function. Valid values for the base parameter are 16, 10, and 8. If showbase is set to true then the string will be prefixed with "0x" if it's base 16, "0" if it's base 8, and no prefix for base 10.

Definition at line 1319 of file axcel.h.

string axcel::join ( std::deque< axcel::string v,
const char *  delim = " " 
)

Join string deque.

Parameters:
vDeque of string s to join
Concatenationseperator string
Returns:
Joined string object

Definition at line 5031 of file axcel.cpp.

string axcel::join ( std::deque< axcel::string v,
int  delim 
)

Join string deque.

Parameters:
vDeque of string s to join
Concatenationseperator character
Returns:
Joined string object

Definition at line 5041 of file axcel.cpp.

string axcel::lc ( const char *  str)

Lowercase string.

Parameters:
strThe string
Returns:
The string as a string object with each character in lowercase

Definition at line 4945 of file axcel.cpp.

string axcel::lcfirst ( const char *  str)

Lowercase first character.

Parameters:
strThe string
Returns:
The string as a string object with the first character in lowercase

Definition at line 4949 of file axcel.cpp.

long axcel::length ( const char *  str) [inline]

Length of string.

Parameters:
strThe string
Returns:
Number of characters in string not including '\0'

Definition at line 1502 of file axcel.h.

string axcel::ltrim ( const char *  str)

Remove leading whitespace.

Parameters:
strThe string
Returns:
string object result

Removes all leading whitespace from str. Whitespace is all characters for which isspace() returns true.

Definition at line 4926 of file axcel.cpp.

char * axcel::memrev ( char *  s,
size_t  size,
size_t  n 
)

Reverse memory block.

Parameters:
sMemory block
sizeSize of element
nNumber of elements

Definition at line 4867 of file axcel.cpp.

char * axcel::memrol ( char *  s,
size_t  size,
size_t  n 
)

Rotate left memory block.

Parameters:
sMemory block
sizeSize of element
nNumber of elements

Definition at line 4878 of file axcel.cpp.

char * axcel::memror ( char *  s,
size_t  size,
size_t  n 
)

Rotate right memory block.

Parameters:
sMemory block
sizeSize of element
nNumber of elements

Definition at line 4888 of file axcel.cpp.

char * axcel::memshl ( char *  s,
size_t  size,
size_t  n 
)

Shift left memory block.

Parameters:
sMemory block
sizeSize of element
nNumber of elements

Definition at line 4901 of file axcel.cpp.

char * axcel::memshr ( char *  s,
size_t  size,
size_t  n 
)

Shift right memory block.

Parameters:
sMemory block
sizeSize of element
nNumber of elements

Definition at line 4897 of file axcel.cpp.

string axcel::munch ( const char *  str,
const char *  eat 
)

Remove existing string from beginning of string.

Parameters:
strThe string
eatstring to remove
Returns:
string object result

Removes string eat from beginning of string str if it exists.

Definition at line 4921 of file axcel.cpp.

long axcel::ntok ( const char *  str,
const char *  delim = " " 
)

Count string tokens.

Parameters:
strThe string
delimDelimiting characters
Returns:
Number of tokens available

Definition at line 5004 of file axcel.cpp.

long axcel::ntok ( const char *  str,
int  delim 
)

Count string tokens.

Parameters:
strThe string
delimDelimiting character
Returns:
Number of tokens available

Definition at line 5008 of file axcel.cpp.

long axcel::oct ( const char *  str) [inline]

string to octal long int

Parameters:
strThe string
Returns:
long int value of the number the string represents

Definition at line 1573 of file axcel.h.

void axcel::print ( int  ch,
FILE *  stream = stdout 
) [inline]

Print character.

Parameters:
chstring to print
streamfile handle

Calls fputc(ch, stream) and flushes the stream. The stream is, by default, stdout.

Definition at line 1368 of file axcel.h.

void axcel::print ( const char *  s,
FILE *  stream = stdout 
) [inline]

Print string.

Parameters:
sstring to print
streamfile handle

Calls fputs(s, stream). Stream is, by default, stdout.

Definition at line 1360 of file axcel.h.

string axcel::q ( const char *  str)

Single quote string.

Parameters:
strthe string
Returns:
string object of str enclosed with single quotes

Definition at line 4974 of file axcel.cpp.

string axcel::qq ( const char *  str)

Double quote string.

Parameters:
strThe string
Returns:
Double quoted string object

Definition at line 4978 of file axcel.cpp.

string axcel::qx ( const char *  exec)

Execute command and return io::output.

Parameters:
execThe system shell command
Returns:
string output of command

Definition at line 4982 of file axcel.cpp.

int axcel::rand ( int  min = 0,
int  max = 0 
)

Get random integer.

Parameters:
minMinimum value
maxMaximum value
Returns:
Random integer

Definition at line 4856 of file axcel.cpp.

int axcel::rands ( unsigned int  seed,
int  min = 0,
int  max = 0 
)

Get random integer.

Parameters:
seedRNG seed intializer
minMinimum value
maxMaximum value
Returns:
Random integer

Definition at line 4861 of file axcel.cpp.

long axcel::rindex ( const char *  str,
int  find 
)

Find last character.

Parameters:
strThe string to search through
findCharacter to find
Returns:
index of last occurrence of character find, or -1 if not found

Definition at line 4969 of file axcel.cpp.

long axcel::rindex ( const char *  str,
const char *  find 
)

Find last string.

Parameters:
strThe string to search through
findstring to find
Returns:
index of last occurrence of string find, or -1 if not found

Definition at line 4963 of file axcel.cpp.

string axcel::rtrim ( const char *  str)

Remove trailing whitespace.

Parameters:
strThe string
Returns:
string object result

Removes all trailing whitespace from str. Whitespace is all characters for which isspace() returns true.

Definition at line 4931 of file axcel.cpp.

bool axcel::sback ( const char *  s1,
const char *  s2 
) [inline]

Compare end of string.

Parameters:
s1A string
s2Another string
Returns:
true if s1 ends with s2, false if not

Definition at line 1523 of file axcel.h.

string axcel::scat ( const char *  s1,
const char *  s2 
)

Concatenate strings.

Parameters:
s1A string
s2Another string
Returns:
string object with s1 concatenated with s2

Definition at line 4986 of file axcel.cpp.

string axcel::sdup ( const char *  str,
int  x 
)

Duplicate string.

Parameters:
strThe string
xNumber of times to duplicate
Returns:
string object as str concatenated to itself x - 1 times;

Definition at line 4991 of file axcel.cpp.

bool axcel::sfront ( const char *  s1,
const char *  s2 
) [inline]

Compare beginning of string.

Parameters:
s1A string
s2Another string
Returns:
true if s1 starts with s2, false if not

Definition at line 1516 of file axcel.h.

std::deque< axcel::string > axcel::split ( const char *  str,
const char *  delim 
)

Split string.

Parameters:
strstring to split
delimDelimiting characters
Returns:
Deque of string objects

Definition at line 5022 of file axcel.cpp.

std::deque< axcel::string > axcel::split ( const char *  str,
int  delim 
)

Split string.

Parameters:
strstring to split
delimDelimiting character
Returns:
Deque of string objects

Definition at line 5026 of file axcel.cpp.

template<typename type >
type axcel::stof ( const char *  s)

string to floating point

Parameters:
sThe string
Returns:
Converted floating point type

Converts the initial portion of the string to the floating point template type. Valid template types are: float, double, and long double. The number represented in the string must be base 10. If an error occurs this function returns 0.

Definition at line 1243 of file axcel.h.

template<typename type >
type axcel::stoi ( const char *  s,
int  base = 10 
)

string to integer

Parameters:
sThe string
baseNumeric base
Returns:
Converted integer type

Converts the initial portion of the string to the numeric template type. Valid template types are: char, short, int, long, long long, and their unsigned equivalents. base specifies the numeric base to use. If base is 0, then the integer is read in base 16 if it begins with 0x, in base 8 if it begins with 0, and in base 10 otherwise. If there was an error this function returns 0.

Definition at line 1181 of file axcel.h.

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

Definition at line 211 of file axcel.cpp.

string axcel::strip ( const char *  str)

Remove leading and trailing whitespace.

Parameters:
Thestring
Returns:
string object result

Removes all leading and trailing whitespace from str. Whitespace is all characters for which isspace() returns true.

Definition at line 4936 of file axcel.cpp.

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

Definition at line 216 of file axcel.cpp.

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

Definition at line 5349 of file axcel.cpp.

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

Definition at line 5339 of file axcel.cpp.

string axcel::substr ( const char *  str,
size_t  offset,
size_t  length 
)

Get substring.

Parameters:
strA string
offsetOffset of substring
lengthLength of substring
Returns:
Substring as string object

Definition at line 4941 of file axcel.cpp.

string axcel::tok ( size_t  index,
const char *  str,
int  delim 
)

Extract token from string.

Parameters:
indexToken to extract by index
strThe string to tokenate
delimDelimiting character
Returns:
string object token

Definition at line 4999 of file axcel.cpp.

string axcel::tok ( size_t  index,
const char *  str,
const char *  delim = " " 
)

Extract token from string.

Parameters:
indexToken to extract by index
strThe string to tokenate
delimDelimiting characters
Returns:
string object token

Definition at line 4995 of file axcel.cpp.

string axcel::uc ( const char *  str)

Uppercase string.

Parameters:
strThe string
Returns:
The string as a string object with each character in uppercase

Definition at line 4954 of file axcel.cpp.

string axcel::ucfirst ( const char *  str)

Uppercase first character.

Parameters:
strThe string
Returns:
The string as a string object with the first character in uppercase

Definition at line 4958 of file axcel.cpp.


Variable Documentation

Definition at line 4836 of file axcel.cpp.

struct errno_str axcel::errno_strs

Definition at line 102 of file axcel.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerator Defines