E-MailRelay
Namespaces | Classes | Typedefs | Functions
G Namespace Reference

Low-level classes. More...

Namespaces

namespace  AlignImp
 An implementation namespace for G::align().
 
namespace  EightBitImp
 An implementation namespace for G::eightbit().
 
namespace  LogOutputImp
 An implementation namespace for G::LogOutput.
 
namespace  Md5Imp
 An implementation namespace for G::Md5.
 
namespace  Slot
 A callback mechanism that isolates event sinks from event sources.
 
namespace  StrImp
 An implementation namespace for G::Str.
 
namespace  StringViewImp
 An implementation namespace for G::basic_string_view.
 

Classes

class  Arg
 A class which holds a represention of the argc/argv command line array, and supports simple command-line parsing. More...
 
class  Base64
 A base64 codec class. More...
 
class  basic_imembuf
 An input streambuf that takes its data from a fixed-size const buffer. More...
 
class  basic_string_view
 A class template like c++17's std::basic_string_view. More...
 
class  BatchFile
 A class for reading and writing windows-style startup batch files containing a single command-line, optionally using "start". More...
 
class  BrokenDownTime
 An encapsulation of 'struct std::tm'. More...
 
struct  Buffer
 A substitute for std::vector<char> that has more useful alignment guarantees and explicitly avoids default initialisation of each element. More...
 
class  CallFrame
 An object to represent a nested execution context. More...
 
class  CallStack
 A linked list of CallFrame pointers. More...
 
class  Cleanup
 A static interface for registering cleanup functions that are called when the process terminates abnormally. More...
 
class  CleanupImp
 A static implementation class used by G::Cleanup. More...
 
class  Convert
 A static class which provides string encoding conversion functions. More...
 
class  Daemon
 A static interface for daemonising the calling process. More...
 
class  Date
 A day-month-year date class. More...
 
class  DateTime
 A static class that knows about timezone offsets. More...
 
class  Directory
 An encapsulation of a file system directory that works with G::DirectoryIterator. More...
 
class  DirectoryIterator
 A iterator that returns filenames in a directory. More...
 
class  DirectoryIteratorImp
 A pimple-pattern implementation class for DirectoryIterator using opendir()/readdir(). More...
 
class  DirectoryList
 A iterator similar to G::DirectoryIterator but doing all file i/o in one go. More...
 
class  Environment
 Holds a set of environment variables and also provides static methods to wrap getenv() and putenv(). More...
 
class  Exception
 A general-purpose exception class derived from std::exception and containing an error message. More...
 
class  ExecutableCommand
 A structure representing an external program, holding a path and a set of arguments. More...
 
class  File
 A simple static class for dealing with files. More...
 
class  format
 A simple version of boost::format for formatting strings in an i18n-friendly way. More...
 
class  GetOpt
 A command-line option parser. More...
 
class  Hash
 A class for creating HMACs using an arbitrary cryptographic hash function as per RFC-2104. More...
 
class  HashState
 Functions for representing the intermediate state of a hash function as a non-printable string. More...
 
class  HashStateImp
 The non-template part of G::HashState. More...
 
class  Identity
 A combination of user-id and group-id, with a very low-level interface to the get/set/e/uid/gid functions. More...
 
class  limits
 A scoping structure for a set of buffer sizes. More...
 
class  Log
 A class for doing iostream-based logging. More...
 
class  LogOutput
 Controls and implements low-level logging output, as used by G::Log. More...
 
class  MapFile
 A class for reading, writing and editing key=value files, supporting variable expansion of percent-key-percent values, comments, creation of backup files, and logging. More...
 
class  Md5
 MD5 message digest class. More...
 
class  Msg
 Wrappers for sendmsg() and recvmsg(). More...
 
class  NewProcess
 A class for creating new processes. More...
 
struct  NewProcessConfig
 Provides syntactic sugar for the G::NewProcess constructor. More...
 
class  NewProcessImp
 A pimple-pattern implementation class used by G::NewProcess. More...
 
class  NewProcessWaitable
 Holds the parameters and future results of a waitpid() system call, as performed by the wait() method. More...
 
class  omembuf
 An output streambuf that writes to a fixed-size char buffer. More...
 
class  OptionMap
 A multimap-like container for command-line options and their values. More...
 
class  OptionParser
 A parser for command-line arguments that operates according to an Options specification and returns an OptionValue multimap. More...
 
class  Options
 A class to represent allowed command-line options and to provide command-line usage text. More...
 
struct  OptionsLayout
 Describes the layout for G::Options output. More...
 
class  OptionValue
 A simple structure encapsulating the value of a command-line option. More...
 
class  Pam
 A thin interface to the system PAM library, with two pure virtual methods that derived classes should implement: the converse() method supplies passwords etc. More...
 
class  PamImp
 A pimple-pattern implementation class for G::Pam. More...
 
class  Path
 A Path object represents a file system path. More...
 
class  PathImp
 A private implementation class used by G::Path providing a set of static methods. More...
 
class  PidFile
 A class for creating pid files. More...
 
class  Pipe
 A private implementation class used by G::NewProcess that wraps a unix pipe. More...
 
class  Process
 A static interface for doing things with processes. More...
 
class  ReadWrite
 An abstract interface for reading and writing from a non-blocking i/o channel. More...
 
class  Root
 A class which acquires the process's special privileges on construction and releases them on destruction. More...
 
class  ScopeExit
 A class that calls an exit function at the end of its scope. More...
 
class  ScopeExitSetFalse
 A class that sets a boolean variable to false at the end of its scope. More...
 
class  SignalSafe
 An empty structure that is used to indicate a signal-safe, reentrant implementation. More...
 
class  StateMachine
 A finite state machine class template. More...
 
class  Str
 A static class which provides string helper functions. More...
 
class  StringWrap
 A word-wrap class. More...
 
class  SystemTime
 Represents a unix-epoch time with microsecond resolution. More...
 
class  Test
 A static interface for enabling test features at run-time. More...
 
struct  threading
 Helper class for std::thread capabilities. More...
 
class  Time
 A simple time-of-day (hh/mm/ss) class. More...
 
class  TimeInterval
 An interval between two G::SystemTime values or two G::TimerTime values. More...
 
class  TimerTime
 A monotonically increasing subsecond-resolution timestamp, notionally unrelated to time_t. More...
 
class  Xtext
 An xtext codec class, encoding space as "+20" etc. More...
 

Typedefs

using imembuf = basic_imembuf< char >
 
using wimembuf = basic_imembuf< wchar_t >
 
using StringArray = std::vector< std::string >
 A std::vector of std::strings. More...
 
using StringMap = std::map< std::string, std::string >
 A std::map of std::strings. More...
 
using string_view = basic_string_view< char >
 
using wstring_view = basic_string_view< wchar_t >
 

Functions

template<typename T >
void * align (const char *buffer, std::size_t buffer_size)
 Returns a pointer inside the given buffer that is aligned for values of type T. More...
 
template<typename T >
void * align (const unsigned char *buffer, std::size_t buffer_size)
 Returns a pointer inside the given unsigned-char buffer that is aligned for values of type T. More...
 
template<typename T >
constexpr std::size_t align_shift (std::size_t n)
 Divides the number of bytes in a range to give the number of whole Ts. More...
 
template<typename T >
constexpr std::size_t align_mask (std::size_t n)
 Rounds down the number of bytes in a range to give a number of bytes that will hold an exact number of Ts. More...
 
template<typename Uptr , typename T = char>
Uptr buffer_cast (Buffer< T > &buffer)
 
template<typename Uptr , typename T = char>
Uptr buffer_cast (Buffer< T > &buffer, std::nothrow_t)
 
template<typename Uptr , typename T = char>
Uptr buffer_cast (const Buffer< T > &buffer)
 
template<typename T >
void swap (Buffer< T > &a, Buffer< T > &b) noexcept
 
std::ostream & operator<< (std::ostream &, const SystemTime &)
 
std::ostream & operator<< (std::ostream &, const TimeInterval &)
 
template<typename... T>
void ignore (T &&...)
 
constexpr bool is_windows ()
 
constexpr bool is_linux ()
 
constexpr bool is_free_bsd ()
 
constexpr bool is_open_bsd ()
 
constexpr bool is_bsd ()
 
bool eightbit (const unsigned char *p, std::size_t n)
 Returns true if the given data buffer contains a byte greater than 127. More...
 
bool eightbit (const char *p, std::size_t n)
 Returns true if the given data buffer contains a character greater than 127. More...
 
bool eightbit (const unsigned char *p, std::size_t n, int)
 Returns true if the given data buffer contains a byte greater than 127. More...
 
bool eightbit (const char *p, std::size_t n, int)
 Returns true if the given data buffer contains a character greater than 127. More...
 
std::ostream & operator<< (std::ostream &stream, const format &f)
 
std::string str (const format &f)
 
void gettext_init (const std::string &localedir, const std::string &name)
 Initialises the gettext() library. More...
 
constexpr const char * gettext_noop (const char *p)
 Marks a string for translation at build-time, but no translation is applied at run-time. More...
 
const char * gettext (const char *)
 Returns the message translation in the current locale's codeset, eg. More...
 
std::string hostname ()
 Returns the hostname. More...
 
std::ostream & operator<< (std::ostream &stream, const Identity &identity)
 
std::ostream & operator<< (std::ostream &stream, const Path &path)
 
Pathoperator+= (Path &p, const std::string &str)
 
Path operator+ (const Path &p, const std::string &str)
 
void swap (Path &p1, Path &p2) noexcept
 
std::ostream & operator<< (std::ostream &stream, const G::Process::Id &id)
 
template<typename Tchar >
std::basic_string< Tchar > sv_to_string (basic_string_view< Tchar > sv)
 
std::ostream & operator<< (std::ostream &stream, const string_view &sv)
 
std::wostream & operator<< (std::wostream &stream, const wstring_view &sv)
 
template<typename Tchar >
void swap (basic_string_view< Tchar > &a, basic_string_view< Tchar > b) noexcept
 
bool operator== (const std::string &s, string_view sv)
 
bool operator== (string_view sv, const std::string &s)
 
bool operator!= (const std::string &s, string_view sv)
 
bool operator!= (string_view sv, const std::string &s)
 

Detailed Description

Low-level classes.

The G namespace contains low-level classes for file-system abstraction, date and time representation, string utility functions, logging, command line parsing etc.

Key classes are:

Typedef Documentation

◆ imembuf

using G::imembuf = typedef basic_imembuf<char>

Definition at line 32 of file gimembuf.h.

◆ string_view

using G::string_view = typedef basic_string_view<char>

Definition at line 33 of file gstringview.h.

◆ StringArray

using G::StringArray = typedef std::vector<std::string>

A std::vector of std::strings.

Definition at line 31 of file gstrings.h.

◆ StringMap

using G::StringMap = typedef std::map<std::string,std::string>

A std::map of std::strings.

Definition at line 32 of file gstrings.h.

◆ wimembuf

using G::wimembuf = typedef basic_imembuf<wchar_t>

Definition at line 33 of file gimembuf.h.

◆ wstring_view

using G::wstring_view = typedef basic_string_view<wchar_t>

Definition at line 34 of file gstringview.h.

Function Documentation

◆ align() [1/2]

template<typename T >
void * G::align ( const char *  buffer,
std::size_t  buffer_size 
)
inline

Returns a pointer inside the given buffer that is aligned for values of type T.

Definition at line 70 of file galign.h.

◆ align() [2/2]

template<typename T >
void * G::align ( const unsigned char *  buffer,
std::size_t  buffer_size 
)
inline

Returns a pointer inside the given unsigned-char buffer that is aligned for values of type T.

Definition at line 79 of file galign.h.

◆ align_mask()

template<typename T >
constexpr std::size_t G::align_mask ( std::size_t  n)
inlineconstexpr

Rounds down the number of bytes in a range to give a number of bytes that will hold an exact number of Ts.

Definition at line 99 of file galign.h.

◆ align_shift()

template<typename T >
constexpr std::size_t G::align_shift ( std::size_t  n)
inlineconstexpr

Divides the number of bytes in a range to give the number of whole Ts.

Definition at line 89 of file galign.h.

◆ buffer_cast() [1/3]

template<typename Uptr , typename T = char>
Uptr G::buffer_cast ( Buffer< T > &  buffer)

Definition at line 193 of file gbuffer.h.

◆ buffer_cast() [2/3]

template<typename Uptr , typename T = char>
Uptr G::buffer_cast ( Buffer< T > &  buffer,
std::nothrow_t   
)

Definition at line 204 of file gbuffer.h.

◆ buffer_cast() [3/3]

template<typename Uptr , typename T = char>
Uptr G::buffer_cast ( const Buffer< T > &  buffer)

Definition at line 215 of file gbuffer.h.

◆ eightbit() [1/4]

bool G::eightbit ( const char *  p,
std::size_t  n 
)
inline

Returns true if the given data buffer contains a character greater than 127.

An overload for a char buffer.

Definition at line 117 of file geightbit.h.

◆ eightbit() [2/4]

bool G::eightbit ( const char *  p,
std::size_t  n,
int   
)
inline

Returns true if the given data buffer contains a character greater than 127.

An overload for a char buffer, with no optimisation.

Definition at line 135 of file geightbit.h.

◆ eightbit() [3/4]

bool G::eightbit ( const unsigned char *  p,
std::size_t  n 
)
inline

Returns true if the given data buffer contains a byte greater than 127.

An overload for an unsigned char buffer.

Definition at line 108 of file geightbit.h.

◆ eightbit() [4/4]

bool G::eightbit ( const unsigned char *  p,
std::size_t  n,
int   
)
inline

Returns true if the given data buffer contains a byte greater than 127.

An overload for an unsigned char buffer, with no optimisation.

Definition at line 126 of file geightbit.h.

◆ gettext()

const char * G::gettext ( const char *  p)
inline

Returns the message translation in the current locale's codeset, eg.

ISO8859-1 or UTF-8, transcoding from the catalogue as necessary.

Definition at line 69 of file ggettext.h.

◆ gettext_init()

void G::gettext_init ( const std::string &  localedir,
const std::string &  name 
)
inline

Initialises the gettext() library.

This uses environment variables to set the CTYPE and MESSAGES facets of the global C locale as a side-effect.

Definition at line 66 of file ggettext.h.

◆ gettext_noop()

constexpr const char * G::gettext_noop ( const char *  p)
constexpr

Marks a string for translation at build-time, but no translation is applied at run-time.

Definition at line 75 of file ggettext.h.

◆ hostname()

std::string G::hostname ( )

Returns the hostname.

This may or may not relate to the host's name on some network.

Definition at line 27 of file ghostname_unix.cpp.

◆ ignore()

template<typename... T>
void G::ignore ( T &&  ...)
inline

Definition at line 968 of file gdef.h.

◆ is_bsd()

constexpr bool G::is_bsd ( )
inlineconstexpr

Definition at line 1064 of file gdef.h.

◆ is_free_bsd()

constexpr bool G::is_free_bsd ( )
inlineconstexpr

Definition at line 1054 of file gdef.h.

◆ is_linux()

constexpr bool G::is_linux ( )
inlineconstexpr

Definition at line 1049 of file gdef.h.

◆ is_open_bsd()

constexpr bool G::is_open_bsd ( )
inlineconstexpr

Definition at line 1059 of file gdef.h.

◆ is_windows()

constexpr bool G::is_windows ( )
inlineconstexpr

Definition at line 1044 of file gdef.h.

◆ operator!=() [1/2]

bool G::operator!= ( const std::string &  s,
string_view  sv 
)
inline

Definition at line 237 of file gstringview.h.

◆ operator!=() [2/2]

bool G::operator!= ( string_view  sv,
const std::string &  s 
)
inline

Definition at line 241 of file gstringview.h.

◆ operator+()

Path G::operator+ ( const Path p,
const std::string &  str 
)
inline

Definition at line 242 of file gpath.h.

◆ operator+=()

Path & G::operator+= ( Path p,
const std::string &  str 
)
inline

Definition at line 235 of file gpath.h.

◆ operator<<() [1/8]

std::ostream & G::operator<< ( std::ostream &  stream,
const SystemTime t 
)

Definition at line 377 of file gdatetime.cpp.

◆ operator<<() [2/8]

std::ostream & G::operator<< ( std::ostream &  stream,
const TimeInterval ti 
)

Definition at line 643 of file gdatetime.cpp.

◆ operator<<() [3/8]

std::ostream & G::operator<< ( std::ostream &  stream,
const format f 
)

Definition at line 96 of file gformat.cpp.

◆ operator<<() [4/8]

std::ostream & G::operator<< ( std::ostream &  stream,
const G::Process::Id id 
)
inline

Definition at line 202 of file gprocess.h.

◆ operator<<() [5/8]

std::ostream & G::operator<< ( std::ostream &  stream,
const Identity identity 
)
inline

Definition at line 107 of file gidentity.h.

◆ operator<<() [6/8]

std::ostream & G::operator<< ( std::ostream &  stream,
const Path path 
)
inline

Definition at line 229 of file gpath.h.

◆ operator<<() [7/8]

std::ostream & G::operator<< ( std::ostream &  stream,
const string_view sv 
)
inline

Definition at line 213 of file gstringview.h.

◆ operator<<() [8/8]

std::wostream & G::operator<< ( std::wostream &  stream,
const wstring_view sv 
)
inline

Definition at line 219 of file gstringview.h.

◆ operator==() [1/2]

bool G::operator== ( const std::string &  s,
string_view  sv 
)
inline

Definition at line 229 of file gstringview.h.

◆ operator==() [2/2]

bool G::operator== ( string_view  sv,
const std::string &  s 
)
inline

Definition at line 233 of file gstringview.h.

◆ str()

std::string G::str ( const format f)
inline

Definition at line 82 of file gformat.h.

◆ sv_to_string()

template<typename Tchar >
std::basic_string< Tchar > G::sv_to_string ( basic_string_view< Tchar >  sv)

Definition at line 208 of file gstringview.h.

◆ swap() [1/3]

template<typename Tchar >
void G::swap ( basic_string_view< Tchar > &  a,
basic_string_view< Tchar >  b 
)
noexcept

Definition at line 225 of file gstringview.h.

◆ swap() [2/3]

template<typename T >
void G::swap ( Buffer< T > &  a,
Buffer< T > &  b 
)
noexcept

Definition at line 221 of file gbuffer.h.

◆ swap() [3/3]

void G::swap ( Path p1,
Path p2 
)
inlinenoexcept

Definition at line 248 of file gpath.h.