Software and Services, Portable Libraries  2019.Mar.01
A library for managing digital certificates
SoftwareAndServices::Library::Common::Error Class Reference

A generic error message class. More...

#include "<SaS/Common/Error.hpp>"

+ Inheritance diagram for SoftwareAndServices::Library::Common::Error:
+ Collaboration diagram for SoftwareAndServices::Library::Common::Error:

Public Types

typedef const Tree_t< Error > * const_Tree
 A const_Tree is a (const Tree_t<T>*) More...
 
enum  LocalErrno { ACCESS_DENIED = 1045, UNKNOWN_HOST = 2005 }
 Status of error message. More...
 
typedef Tree_t< Error > * Tree
 A Tree is a (Tree_t<T>*) More...
 
typedef void(* TreeAction_fn_t) (const Tree_t< Error > **, VISIT Leaf, int Depth)
 Perform action on Tree_t<T> More...
 
typedef int(* TreeCompare_fn_t) (const Error *One, const Error *Two)
 Tree compare function. More...
 
typedef void(* TreeFree_fn_t) (Tree_t< Error > *TreeToFree)
 Free Tree_t. More...
 

Public Member Functions

 Error (const char *Guid)
 Error - default Constructor. More...
 
virtual ~Error ()
 Error - Destructor. More...
 
virtual InstanceCount_t decInstance () const
 Decrement the instance. More...
 
Tree_t< Error > * Find (Tree_t< Error > *Rootp, const Tree_t< Error > *ToFind, TreeCompare_fn_t Cmp)
 Tree find, for locating cached messages. More...
 
int GetCharOffset () const
 
const char * GetCombinedGuid ()
 
const DateTimeGetDateTime () const
 
int GetErrno (unsigned int MsgNum, const char *DefaultMsg, const char *Locale=nullptr)
 Get the error ID in the default message database. More...
 
int GetErrno () const
 Get this objcet error number. More...
 
const char * GetGuid ()
 
virtual InstanceCount_t getInstance () const
 
int GetLineNumber () const
 
const char * GetLocale () const
 
const char * GetMsg (unsigned int MsgNum, const char *DefaultMsg, const char *Locale=nullptr)
 Get the message in the default message database. More...
 
const char * GetMsg (const char *Guid, unsigned int MsgNum, const char *DefaultMsg, const char *Locale=nullptr)
 Get the message in the guid message database. More...
 
const char * GetMsg () const
 
const char * GetProductGuid ()
 
virtual InstanceCount_t incInstance () const
 Increment the instance. More...
 
bool Insert (Tree_t< Error > **Rootp, const Tree_t< Error > *ToInsert, TreeCompare_fn_t Cmp)
 Insert a new node into the tree. More...
 
void operator delete (void *ToFree)
 
bool Remove (Tree_t< Error > **Rootp, const Tree_t< Error > *ToRemove, TreeCompare_fn_t Cmp)
 Insert a new node into the tree. More...
 
void SetGuid (const char *newGuid)
 
void SetMsg (const char *Guid, unsigned int MsgNum, const char *Msg, const char *Locale)
 Add an new message to the database. More...
 
void SetMsg (const char *Guid, unsigned int MsgNum, const char *Msg)
 Add an new message to the database. More...
 
void SetPosition (int Line, int CharOffset=-1)
 Set the line number and column offset of the error. More...
 
void SetProductGuid (const char *Guid)
 Set the product GUID. More...
 
void Walk (const Tree_t< Error > *Root, TreeAction_fn_t Walk)
 Walk the tree, calling walk for each node found. More...
 

Static Public Member Functions

static Error ** Delete (const void *Key, Tree_t< Error > **VRootP, TreeCompare_fn_t CompareFunction)
 
static Error ** Find (const Error *Key, Tree_t< Error > *const *VRootP, TreeCompare_fn_t CompareFunction)
 
static int GetErrno (void *Guid, unsigned int MsgNum, const char *DefaultMsg, const char *Locale=nullptr)
 Get the message ID from a message number in the guid message database. More...
 
static const ErrorGetError (unsigned int MsgNum, const char *DefaultMsg, const char *Locale=nullptr)
 Get the error from a message number in the default message database. More...
 
static const ErrorGetError (const char *Guid, unsigned int MsgNum, const char *DefaultMsg, const char *Locale=nullptr)
 Get the error from a message number in the guid message database. More...
 
static Error ** Search (const Error *Key, Tree_t< Error > *const *VRootP, TreeCompare_fn_t CompareFunction)
 

Public Attributes

const void * key
 
struct node_tleft
 
unsigned int red
 
struct node_tright
 

Protected Attributes

int _CharOffset
 For line oriented message, the character offset in the line. More...
 
const char * _CombinedGuid
 Combined GUID - calculated. More...
 
DateTime _Dt
 Our errno. More...
 
int _Errno
 The errono - our errno, not the systems. More...
 
const char * _Guid
 The current application GUID. More...
 
int _LineNumber
 For line oriented message, the line number. More...
 
const char * _Locale
 The locale for the message. More...
 
const char * _Msg
 The message - per locale tree. More...
 
const char * _ProductGuid
 The current product GUID. More...
 

Detailed Description

A generic error message class.

Get error messages from the L10N databases.

Definition at line 95 of file Error.hpp.

Member Typedef Documentation

◆ const_Tree

A const_Tree is a (const Tree_t<T>*)

Definition at line 75 of file TreeSearch.hpp.

◆ Tree

A Tree is a (Tree_t<T>*)

Definition at line 70 of file TreeSearch.hpp.

◆ TreeAction_fn_t

typedef void(* SoftwareAndServices::Library::Common::Tree_t< Error >::TreeAction_fn_t) (const Tree_t< Error > **, VISIT Leaf, int Depth)
inherited

Perform action on Tree_t<T>

Parameters
RootThe root node to work with.
Leafa VISIT value.
LevelA depth.

Definition at line 99 of file TreeSearch.hpp.

◆ TreeCompare_fn_t

typedef int(* SoftwareAndServices::Library::Common::Tree_t< Error >::TreeCompare_fn_t) (const Error *One, const Error *Two)
inherited

Tree compare function.

Parameters
OneThe first T to compare.
TwoThe second T to compare.
Returns
(-1) when One < Two. (0) When One == Two. (1) When One > Two.

Definition at line 88 of file TreeSearch.hpp.

◆ TreeFree_fn_t

typedef void(* SoftwareAndServices::Library::Common::Tree_t< Error >::TreeFree_fn_t) (Tree_t< Error > *TreeToFree)
inherited

Free Tree_t.

Parameters
TreeToFreeThe node to free.

Definition at line 108 of file TreeSearch.hpp.

Member Enumeration Documentation

◆ LocalErrno

Status of error message.

Definition at line 323 of file Error.hpp.

Constructor & Destructor Documentation

◆ Error()

SoftwareAndServices::Library::Common::Error::Error ( const char *  Guid)

Error - default Constructor.

Parameters
GuidThe GUID of the erroring library or program.

◆ ~Error()

virtual SoftwareAndServices::Library::Common::Error::~Error ( )
virtual

Error - Destructor.

Member Function Documentation

◆ decInstance()

virtual InstanceCount_t SoftwareAndServices::Library::Common::instance< Error >::decInstance ( ) const
inlinevirtualinherited

Decrement the instance.

Returns
The instance count, after decrementing it.

Definition at line 129 of file instance.hpp.

◆ Find()

Tree_t<Error>* SoftwareAndServices::Library::Common::Error::Find ( Tree_t< Error > *  Rootp,
const Tree_t< Error > *  ToFind,
TreeCompare_fn_t  Cmp 
)

Tree find, for locating cached messages.

Parameters
RootpThe root of the tree.
ToFindThe object to find.
CmpThe compare method to call to compare toFind with each node found.
Returns
The tree object that matched, or nullptr if none.

◆ GetCharOffset()

int SoftwareAndServices::Library::Common::Error::GetCharOffset ( ) const
Returns
The column number of the error, or -1 if not known.

◆ GetCombinedGuid()

const char* SoftwareAndServices::Library::Common::Error::GetCombinedGuid ( )
Returns
The company and product guid.

◆ GetDateTime()

const DateTime* SoftwareAndServices::Library::Common::Error::GetDateTime ( ) const
Returns
The date-time the error was generated.

◆ GetErrno() [1/3]

int SoftwareAndServices::Library::Common::Error::GetErrno ( unsigned int  MsgNum,
const char *  DefaultMsg,
const char *  Locale = nullptr 
)

Get the error ID in the default message database.

Parameters
MsgNumThe error message number to get.
DefaultMsgIf the L10N database can not be opened, the use this default message.
LocaleWhat locale to use, nullptr means default.
Returns
The error code.

◆ GetErrno() [2/3]

static int SoftwareAndServices::Library::Common::Error::GetErrno ( void *  Guid,
unsigned int  MsgNum,
const char *  DefaultMsg,
const char *  Locale = nullptr 
)
static

Get the message ID from a message number in the guid message database.

Parameters
GuidThe GUID database to use.
MsgNumThe error message number to get.
DefaultMsgIf the L10N database can not be opened, the use this default message.
LocaleWhat locale to use, nullptr means default.
Returns
The error code.

◆ GetErrno() [3/3]

int SoftwareAndServices::Library::Common::Error::GetErrno ( ) const

Get this objcet error number.

Returns
The error number.

◆ GetError() [1/2]

static const Error* SoftwareAndServices::Library::Common::Error::GetError ( unsigned int  MsgNum,
const char *  DefaultMsg,
const char *  Locale = nullptr 
)
static

Get the error from a message number in the default message database.

Parameters
MsgNumThe error message number to get.
DefaultMsgIf the L10N database can not be opened, the use this default message.
LocaleWhat locale to use, nullptr means default.
Returns
A new error object, to be deleted by the caller when no longer needed.

◆ GetError() [2/2]

static const Error* SoftwareAndServices::Library::Common::Error::GetError ( const char *  Guid,
unsigned int  MsgNum,
const char *  DefaultMsg,
const char *  Locale = nullptr 
)
static

Get the error from a message number in the guid message database.

Parameters
GuidThe GUID database to use.
MsgNumThe error message number to get.
DefaultMsgIf the L10N database can not be opened, the use this default message.
LocaleWhat locale to use, nullptr means default.
Returns
A new error object, to be deleted by the caller when no longer needed.

◆ GetGuid()

const char* SoftwareAndServices::Library::Common::Error::GetGuid ( )
Returns
The GUID of the current application running.

◆ getInstance()

virtual InstanceCount_t SoftwareAndServices::Library::Common::instance< Error >::getInstance ( ) const
inlinevirtualinherited
Returns
The current instance count.

Definition at line 118 of file instance.hpp.

◆ GetLineNumber()

int SoftwareAndServices::Library::Common::Error::GetLineNumber ( ) const
Returns
The line number of the error, or -1 if not known.

◆ GetLocale()

const char* SoftwareAndServices::Library::Common::Error::GetLocale ( ) const
Returns
The current locale.

◆ GetMsg() [1/3]

const char* SoftwareAndServices::Library::Common::Error::GetMsg ( unsigned int  MsgNum,
const char *  DefaultMsg,
const char *  Locale = nullptr 
)

Get the message in the default message database.

Parameters
MsgNumThe error message number to get.
DefaultMsgIf the L10N database can not be opened, the use this default message.
LocaleWhat locale to use, nullptr means default.
Returns
A pointer to a string message. The string is stored in StringCache

◆ GetMsg() [2/3]

const char* SoftwareAndServices::Library::Common::Error::GetMsg ( const char *  Guid,
unsigned int  MsgNum,
const char *  DefaultMsg,
const char *  Locale = nullptr 
)

Get the message in the guid message database.

Parameters
GuidThe GUID database to use.
MsgNumThe error message number to get.
DefaultMsgIf the L10N database can not be opened, the use this default message.
LocaleWhat locale to use, nullptr means default.
Returns
A pointer to a string message. The string is stored in StringCache

◆ GetMsg() [3/3]

const char* SoftwareAndServices::Library::Common::Error::GetMsg ( ) const
Returns
The error message.

◆ GetProductGuid()

const char* SoftwareAndServices::Library::Common::Error::GetProductGuid ( )
Returns
The product GUID.

◆ incInstance()

virtual InstanceCount_t SoftwareAndServices::Library::Common::instance< Error >::incInstance ( ) const
inlinevirtualinherited

Increment the instance.

Returns
The instance value, after incrementing it.

Definition at line 109 of file instance.hpp.

◆ Insert()

bool SoftwareAndServices::Library::Common::Error::Insert ( Tree_t< Error > **  Rootp,
const Tree_t< Error > *  ToInsert,
TreeCompare_fn_t  Cmp 
)

Insert a new node into the tree.

Parameters
RootpThe root of the node.
ToInsertThe object to insert.
CmpThe compare method to call to compare toFind with each node.
Returns
TRUE if inserted.

◆ Remove()

bool SoftwareAndServices::Library::Common::Error::Remove ( Tree_t< Error > **  Rootp,
const Tree_t< Error > *  ToRemove,
TreeCompare_fn_t  Cmp 
)

Insert a new node into the tree.

Parameters
RootpThe root of the node.
ToRemoveThe object to remove.
CmpThe compare method to call to compare toFind with each node.
Returns
TRUE if inserted.

◆ SetGuid()

void SoftwareAndServices::Library::Common::Error::SetGuid ( const char *  newGuid)
Parameters
newGuidThe guid to use.

◆ SetMsg() [1/2]

void SoftwareAndServices::Library::Common::Error::SetMsg ( const char *  Guid,
unsigned int  MsgNum,
const char *  Msg,
const char *  Locale 
)

Add an new message to the database.

Parameters
GuidThe GUID database to use.
MsgNumThe message number to use.
MsgThe message to use.
LocaleThe locale to use.

◆ SetMsg() [2/2]

void SoftwareAndServices::Library::Common::Error::SetMsg ( const char *  Guid,
unsigned int  MsgNum,
const char *  Msg 
)

Add an new message to the database.

Parameters
GuidThe GUID database to use.
MsgNumThe message number to use.
MsgThe message to use.

◆ SetPosition()

void SoftwareAndServices::Library::Common::Error::SetPosition ( int  Line,
int  CharOffset = -1 
)

Set the line number and column offset of the error.

Parameters
LineThe line number (if -1 not known).
CharOffsetThe column offset (if -1 not known).

◆ SetProductGuid()

void SoftwareAndServices::Library::Common::Error::SetProductGuid ( const char *  Guid)

Set the product GUID.

◆ Walk()

void SoftwareAndServices::Library::Common::Error::Walk ( const Tree_t< Error > *  Root,
TreeAction_fn_t  Walk 
)

Walk the tree, calling walk for each node found.

Parameters
RootThe root of the tree.
WalkThe callback function to call when each node is found.

Member Data Documentation

◆ _CharOffset

int SoftwareAndServices::Library::Common::Error::_CharOffset
protected

For line oriented message, the character offset in the line.

Definition at line 439 of file Error.hpp.

◆ _CombinedGuid

const char* SoftwareAndServices::Library::Common::Error::_CombinedGuid
mutableprotected

Combined GUID - calculated.

Definition at line 408 of file Error.hpp.

◆ _Dt

DateTime SoftwareAndServices::Library::Common::Error::_Dt
protected

Our errno.

Set to constructor creation time of this object.

Definition at line 428 of file Error.hpp.

◆ _Errno

int SoftwareAndServices::Library::Common::Error::_Errno
protected

The errono - our errno, not the systems.

Definition at line 423 of file Error.hpp.

◆ _Guid

const char* SoftwareAndServices::Library::Common::Error::_Guid
protected

The current application GUID.

Definition at line 397 of file Error.hpp.

◆ _LineNumber

int SoftwareAndServices::Library::Common::Error::_LineNumber
protected

For line oriented message, the line number.

Definition at line 433 of file Error.hpp.

◆ _Locale

const char* SoftwareAndServices::Library::Common::Error::_Locale
protected

The locale for the message.

Definition at line 418 of file Error.hpp.

◆ _Msg

const char* SoftwareAndServices::Library::Common::Error::_Msg
protected

The message - per locale tree.

Definition at line 413 of file Error.hpp.

◆ _ProductGuid

const char* SoftwareAndServices::Library::Common::Error::_ProductGuid
mutableprotected

The current product GUID.

May be nullptr.

Definition at line 403 of file Error.hpp.


The documentation for this class was generated from the following file: