E-MailRelay

Namespaces | Classes | Typedefs | Enumerations | Functions
G Namespace Reference

Low-level classes. More...

## Namespaces
namespace | CodePage
| Windows codepage conversion functions.
namespace | Idn
| Internationalised Domain Name encoding.
namespace | Random
| An enclosing namespace for G::Random::rand().
namespace | Range
| Utility functions for pair-of-integer ranges.
namespace | Slot
| A callback mechanism that isolates event sinks from event sources.
namespace | StringList
| Utility functions for lists of strings.

## 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_omembuf
| An output streambuf that writes to a fixed-size char buffer. More...
class | BasicAddress
| A structure that holds a network address as a string with no dependency on any low-level network library. 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
class | Convert
| A static class which provides string encoding conversion functions between UTF-8 and wchar_t. 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 unsorted filenames in a directory. More...
class | DirectoryIteratorImp
| A pimple-pattern implementation class for DirectoryIterator using opendir()/readdir().
class | DirectoryList
| A iterator similar to G::DirectoryIterator but doing all file i/o in one go and providing a sorted result. 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 | fbuf
| A simple file streambuf using a "file descriptor" and three function pointers for read, write and close operations. 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.
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 | IdnImp
struct | Limits
| A set of compile-time buffer sizes. More...
struct | Limits< G::Scale::Normal >
| Normal specialisation of G::Limits. More...
struct | Limits< G::Scale::Small >
| Small-memory specialisation of G::Limits. More...
class | LogOutput
| Controls and implements low-level logging output, as used by G::Log. More...
struct | LogStream
| A non-throwing copyable wrapper for std::ostream, used by G::LogOutput and associated logging macros. 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...
class | NewProcessImp
class | NewProcessWaitable
| Holds the parameters and future results of a waitpid() system call. More...
struct | Option
| A structure representing a G::Options command-line option. More...
class | optional
| A class template like a simplified c++17 std::optional. 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 | OptionReader
| Provides a static function to read options from a config file. More...
class | Options
| A class to assemble a list of command-line options and provide access by name. More...
class | OptionsUsage
| Provides help text for a set of options. 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.
class | Path
| A Path object represents a file system path. More...
class | PidFile
| A class for creating pid files. 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 | ScopeExitSet
| A class that sets a simple variable to a particular value 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 | StateMachineImp
| A private non-template implementation class for G::StateMachine.
class | Str
| A static class which provides string helper functions. More...
class | string_view
| A class like c++17's std::string_view. More...
class | StringFieldIteratorT
| A standard forward iterator for G::StringFieldT: More...
class | StringFieldT
| A zero-copy string field iterator where the field separators are short fixed strings. More...
class | StringTokenT
| A zero-copy string token iterator where the token separators are runs of whitespace characters, with no support for escape characters. 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 | omembuf = basic_omembuf< char >
using | womembuf = basic_omembuf< wchar_t >
using | ScopeExitSetFalse = ScopeExitSet< bool, false >
using | StringArray = std::vector< std::string >
| A std::vector of std::strings. More...
using | StringField = StringFieldT< std::string >
using | StringFieldView = StringFieldT< std::string_view >
using | StringMap = std::map< std::string, std::string >
| A std::map of std::strings. More...
using | StringToken = StringTokenT< std::string >
using | StringTokenView = StringTokenT< std::string_view >

## Enumerations
enum class | Scale { Normal , Small }

## Functions
G::StringArray::const_iterator | begin (const G::Arg &arg)
G::StringArray::const_iterator | end (const G::Arg &arg)
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 &)
bool | operator< (const TimerTime &a, const TimerTime &b) noexcept(TimerTime::less_noexcept)
template<typename... T>
void | gdef_ignore (T &&...)
constexpr bool | is_windows () noexcept
constexpr bool | is_linux () noexcept
constexpr bool | is_free_bsd () noexcept
constexpr bool | is_open_bsd () noexcept
constexpr bool | is_bsd () noexcept
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...
const char * | gettext (const char *) noexcept
| Returns the message translation in the current locale's codeset, eg. More...
constexpr const char * | gettext_noop (const char *p) noexcept
| Returns the parameter. More...
const char * | txt (const char *p) noexcept
| A briefer alternative to G::gettext(). More...
constexpr const char * | tx (const char *p) noexcept
| A briefer alternative to G::gettext_noop(). More...
constexpr std::string_view | tx (std::string_view sv) noexcept
| String view overload. More...
std::string | hostname ()
| Returns the hostname. More...
std::ostream & | operator<< (std::ostream &stream, const Identity &identity)
LogStream & | operator<< (LogStream &s, const std::string &) noexcept
LogStream & | operator<< (LogStream &s, const char *) noexcept
LogStream & | operator<< (LogStream &s, char) noexcept
LogStream & | operator<< (LogStream &s, unsigned char) noexcept
LogStream & | operator<< (LogStream &s, int) noexcept
LogStream & | operator<< (LogStream &s, unsigned int) noexcept
LogStream & | operator<< (LogStream &s, long) noexcept
LogStream & | operator<< (LogStream &s, unsigned long) noexcept
LogStream & | operator<< (LogStream &s, void *) noexcept
template<typename T >
LogStream & | operator<< (LogStream &s, const T &t) noexcept
std::ostream & | operator<< (std::ostream &stream, const Path &path)
Path & | operator/= (Path &p, const std::string &str)
Path | operator/ (const Path &p, const std::string &str)
Path & | operator+= (Path &, const std::string &)=delete
Path & | operator+ (const Path &, const std::string &)=delete
void | swap (Path &p1, Path &p2) noexcept
std::ostream & | operator<< (std::ostream &stream, const G::Process::Id &id)
template<typename T >
StringFieldIteratorT< T > | begin (StringFieldT< T > &f) noexcept
template<typename T >
StringFieldIteratorT< T > | end (StringFieldT< T > &) noexcept
G::string_view | sv_substr_noexcept (G::string_view sv, std::size_t pos, std::size_t count=std::string::npos) noexcept
bool | sv_imatch (G::string_view, G::string_view) noexcept
std::ostream & | operator<< (std::ostream &stream, const string_view &sv)
void | swap (string_view &a, string_view b) noexcept
bool | operator== (const std::string &s, string_view sv)
bool | operator!= (const std::string &s, string_view sv)
std::string | sv_to_string (string_view sv)

## Detailed Description

Low-level classes.

#include "ggettext.h"
using G::tx ;
using G::txt ;
Message msg( tx("world") ) ; // Message ctor calls gettext()
std::cout << txt("hello") << msg.translated() << "\n" ;
ggettext.h
G::txt
const char * txt(const char *p) noexcept
A briefer alternative to G::gettext().
Definition: ggettext.h:74
G::tx
constexpr const char * tx(const char *p) noexcept
A briefer alternative to G::gettext_noop().
Definition: ggettext.h:84

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:

- Directory
- File
- OptionParser
- Log
- LogOutput
- Path
- Process
- Str

## Typedef Documentation

## ◆ imembuf

using G::imembuf = typedef basic_imembuf<char>

Definition at line 31 of file gimembuf.h.

## ◆ omembuf

using G::omembuf = typedef basic_omembuf<char>

Definition at line 31 of file gomembuf.h.

## ◆ ScopeExitSetFalse

using G::ScopeExitSetFalse = typedef ScopeExitSet<bool,false>

Definition at line 32 of file gscope.h.

## ◆ StringArray

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

A std::vector of std::strings.

Definition at line 30 of file gstringarray.h.

## ◆ StringField

using G::StringField = typedef StringFieldT<std::string>

Definition at line 36 of file gstringfield.h.

## ◆ StringFieldView

using G::StringFieldView = typedef StringFieldT<std::string_view>

Definition at line 37 of file gstringfield.h.

## ◆ StringMap

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

A std::map of std::strings.

Definition at line 30 of file gstringmap.h.

## ◆ StringToken

using G::StringToken = typedef StringTokenT<std::string>

Definition at line 34 of file gstringtoken.h.

## ◆ StringTokenView

using G::StringTokenView = typedef StringTokenT<std::string_view>

Definition at line 35 of file gstringtoken.h.

## ◆ wimembuf

using G::wimembuf = typedef basic_imembuf<wchar_t>

Definition at line 32 of file gimembuf.h.

## ◆ womembuf

using G::womembuf = typedef basic_omembuf<wchar_t>

Definition at line 32 of file gomembuf.h.

## Enumeration Type Documentation

## ◆ Scale

enum class G::Scale
| strong

Definition at line 28 of file glimits.h.

## Function Documentation

## ◆ begin() [1/2]

G::StringArray::const_iterator G::begin | ( | const G::Arg & | arg | ) |
| inline

Definition at line 175 of file garg.h.

## ◆ begin() [2/2]

template<typename T >

StringFieldIteratorT< T > G::begin | ( | StringFieldT< T > & | f | ) |
| noexcept

Definition at line 292 of file gstringfield.h.

## ◆ buffer_cast() [1/3]

template<typename Uptr , typename T = char>

Uptr G::buffer_cast | ( | Buffer< T > & | buffer | ) |

Definition at line 196 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 207 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 218 of file gbuffer.h.

## ◆ end() [1/2]

G::StringArray::const_iterator G::end | ( | const G::Arg & | arg | ) |
| inline

Definition at line 176 of file garg.h.

## ◆ end() [2/2]

template<typename T >

StringFieldIteratorT< T > G::end | ( | StringFieldT< T > & |  | ) |
| noexcept

Definition at line 300 of file gstringfield.h.

## ◆ gdef_ignore()

template<typename... T>

void G::gdef_ignore | ( | T && | ... | ) |
| inline

Definition at line 1086 of file gdef.h.

## ◆ gettext()

const char * G::gettext | ( | const char * | p | ) |
| noexcept

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

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

Definition at line 28 of file ggettext_none.cpp.

## ◆ gettext_init()

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

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 24 of file ggettext_none.cpp.

## ◆ gettext_noop()

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

Returns the parameter.

Used to mark a string-literal for translation, with the conversion at run-time done with a call to gettext() elsewhere in the code.

< using G::gettext_noop ;
< std::cout << call_gettext( gettext_noop("hello, world") ) ;
<
G::gettext_noop
constexpr const char * gettext_noop(const char *p) noexcept
Returns the parameter.
Definition: ggettext.h:79

Definition at line 79 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. Returns the empty string on error.

Definition at line 27 of file ghostname_unix.cpp.

## ◆ is_bsd()

constexpr bool G::is_bsd | ( |  | ) |
| constexpr noexcept

Definition at line 1192 of file gdef.h.

## ◆ is_free_bsd()

constexpr bool G::is_free_bsd | ( |  | ) |
| constexpr noexcept

Definition at line 1182 of file gdef.h.

## ◆ is_linux()

constexpr bool G::is_linux | ( |  | ) |
| constexpr noexcept

Definition at line 1177 of file gdef.h.

## ◆ is_open_bsd()

constexpr bool G::is_open_bsd | ( |  | ) |
| constexpr noexcept

Definition at line 1187 of file gdef.h.

## ◆ is_windows()

constexpr bool G::is_windows | ( |  | ) |
| constexpr noexcept

Definition at line 1172 of file gdef.h.

## ◆ operator!=()

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

Definition at line 145 of file gstringview.h.

## ◆ operator/()

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

Definition at line 281 of file gpath.h.

## ◆ operator/=()

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

Definition at line 274 of file gpath.h.

## ◆ operator<()

bool G::operator< | ( | const TimerTime & | a,
|  | const TimerTime & | b
| ) |  |
| inline noexcept

Definition at line 406 of file gdatetime.h.

## ◆ operator<<() [1/17]

G::LogStream & G::operator<< | ( | LogStream & | s,
|  | char | value
| ) |  |
| noexcept

Definition at line 49 of file glogstream.cpp.

## ◆ operator<<() [2/17]

G::LogStream & G::operator<< | ( | LogStream & | s,
|  | const char * | value
| ) |  |
| noexcept

Definition at line 37 of file glogstream.cpp.

## ◆ operator<<() [3/17]

G::LogStream & G::operator<< | ( | LogStream & | s,
|  | const std::string & | value
| ) |  |
| noexcept

Definition at line 25 of file glogstream.cpp.

## ◆ operator<<() [4/17]

template<typename T >

LogStream & G::operator<< | ( | LogStream & | s,
|  | const T & | t
| ) |  |
| noexcept

Definition at line 59 of file glogstream.h.

## ◆ operator<<() [5/17]

G::LogStream & G::operator<< | ( | LogStream & | s,
|  | int | value
| ) |  |
| noexcept

Definition at line 75 of file glogstream.cpp.

## ◆ operator<<() [6/17]

G::LogStream & G::operator<< | ( | LogStream & | s,
|  | long | value
| ) |  |
| noexcept

Definition at line 99 of file glogstream.cpp.

## ◆ operator<<() [7/17]

G::LogStream & G::operator<< | ( | LogStream & | s,
|  | unsigned char | value
| ) |  |
| noexcept

Definition at line 62 of file glogstream.cpp.

## ◆ operator<<() [8/17]

G::LogStream & G::operator<< | ( | LogStream & | s,
|  | unsigned int | value
| ) |  |
| noexcept

Definition at line 87 of file glogstream.cpp.

## ◆ operator<<() [9/17]

G::LogStream & G::operator<< | ( | LogStream & | s,
|  | unsigned long | value
| ) |  |
| noexcept

Definition at line 111 of file glogstream.cpp.

## ◆ operator<<() [10/17]

G::LogStream & G::operator<< | ( | LogStream & | s,
|  | void * | p
| ) |  |
| noexcept

Definition at line 123 of file glogstream.cpp.

## ◆ operator<<() [11/17]

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

Definition at line 466 of file gdatetime.cpp.

## ◆ operator<<() [12/17]

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

Definition at line 764 of file gdatetime.cpp.

## ◆ operator<<() [13/17]

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

Definition at line 104 of file gformat.cpp.

## ◆ operator<<() [14/17]

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

Definition at line 257 of file gprocess.h.

## ◆ operator<<() [15/17]

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

Definition at line 125 of file gidentity.h.

## ◆ operator<<() [16/17]

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

Definition at line 268 of file gpath.h.

## ◆ operator<<() [17/17]

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

Definition at line 131 of file gstringview.h.

## ◆ operator==()

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

Definition at line 141 of file gstringview.h.

## ◆ str()

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

Definition at line 82 of file gformat.h.

## ◆ sv_imatch()

bool G::sv_imatch | ( | G::string_view | a,
|  | G::string_view | b
| ) |  |
| noexcept

Definition at line 72 of file gstringview.cpp.

## ◆ sv_substr_noexcept()

G::string_view G::sv_substr_noexcept | ( | G::string_view | sv,
|  | std::size_t | pos,
|  | std::size_t | count = `std::string::npos`
| ) |  |
| noexcept

Definition at line 77 of file gstringview.cpp.

## ◆ sv_to_string()

std::string G::sv_to_string | ( | string_view | sv | ) |
| inline

Definition at line 149 of file gstringview.h.

## ◆ swap() [1/3]

template<typename T >

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

Definition at line 224 of file gbuffer.h.

## ◆ swap() [2/3]

void G::swap | ( | Path & | p1,
|  | Path & | p2
| ) |  |
| inline noexcept

Definition at line 290 of file gpath.h.

## ◆ swap() [3/3]

void G::swap | ( | string_view & | a,
|  | string_view | b
| ) |  |
| inline noexcept

Definition at line 137 of file gstringview.h.

## ◆ tx() [1/2]

constexpr const char * G::tx | ( | const char * | p | ) |
| constexpr noexcept

A briefer alternative to G::gettext_noop().

Definition at line 84 of file ggettext.h.

## ◆ tx() [2/2]

constexpr std::string_view G::tx | ( | std::string_view | sv | ) |
| constexpr noexcept

String view overload.

Definition at line 89 of file ggettext.h.

## ◆ txt()

const char * G::txt | ( | const char * | p | ) |
| inline noexcept

A briefer alternative to G::gettext().

Definition at line 74 of file ggettext.h.