Loading...
Searching...
No Matches
XrdOucECMsg Class Reference

`#include <XrdOucECMsg.hh>`

Collaboration diagram for XrdOucECMsg:

## Public Member Functions

| XrdOucECMsg (const char *msgid=0)
| ~XrdOucECMsg ()
XrdOucECMsg & | Append (char dlm='\n')
int | Get (std::string &ecm, bool rst=true)
bool | hasMsg () const
std::string | Msg ()
void | Msg (const char *pfx, const char *txt1, const char *txt2=0, const char *txt3=0, const char *txt4=0, const char *txt5=0)
void | Msgf (const char *pfx, const char *fmt,...)
void | MsgVA (const char *pfx, const char *fmt, std::va_list aP)
void | MsgVec (const char *pfx, char const *const *vecP, int vecN)
XrdOucECMsg & | operator= (const char *rhs)
XrdOucECMsg & | operator= (const int rhs)
| Assignment operators for convenience.
XrdOucECMsg & | operator= (const std::string &rhs)
XrdOucECMsg & | operator= (XrdOucECMsg &rhs)
void | Set (int ecc, const char *ecm="")
void | Set (int ecc, std::string &ecm)
int | SetErrno (int ecc, int ret=-1, const char *alt=0)

## Detailed Description

Definition at line 38 of file XrdOucECMsg.hh.

## Constructor & Destructor Documentation

## XrdOucECMsg()

XrdOucECMsg::XrdOucECMsg | ( | const char * | msgid = 0 | ) |

inline

Definition at line 181 of file XrdOucECMsg.hh.

: msgID(msgid), eCode(0), Delim(0) {}

Referenced by Append(), operator=(), operator=(), operator=(), and operator=().

Here is the caller graph for this function:

## ~XrdOucECMsg()

XrdOucECMsg::~XrdOucECMsg | ( |  | ) |

inline

Definition at line 182 of file XrdOucECMsg.hh.

{}

## Member Function Documentation

## Append()

XrdOucECMsg & XrdOucECMsg::Append | ( | char | dlm = '\n' | ) |

inline

Append subsequent message to contents of ecMsg using delimeter. Append allows method chaining for a more natural progamming style.

Parameters

  dlm | !0 -> The character to use as message separator. dlm =0 -> Turns off appending, next message replaces ecMsg.

Returns
  Reference to the subject object.

Definition at line 52 of file XrdOucECMsg.hh.

{ecMTX.Lock(); Delim = dlm; ecMTX.UnLock(); return *this;}

References XrdOucECMsg().

Here is the call graph for this function:

## Get()

int XrdOucECMsg::Get | ( | std::string & | ecm,
|  | bool | rst = true )

Get err code and error message.

Parameters

  ecm | Reference to std:string where message is to be placed.
  rst | When true, the eCode and internal string are set to null.

Returns
  the error code, eCode, and associated error message.

Definition at line 41 of file XrdOucECMsg.cc.

{
XrdSysMutexHelper mScope(ecMTX);
if (!rst)
{ecm = ecMsg;
return eCode;
}
int ec = eCode;
eCode = 0;
ecm = std::move(ecMsg);
ecMsg.erase();
return ec;
}
ec
ec
Definition XrdSysFAttrSun.icc:100

References ec.

Referenced by XrdPosixXrootd::QueryError(), and XrdPosixXrootd::QueryError().

Here is the caller graph for this function:

## hasMsg()

bool XrdOucECMsg::hasMsg | ( |  | ) | const

inline

Determine if an error text message exists.

Returns
  true if an error text message exists, false otherwise.

Definition at line 72 of file XrdOucECMsg.hh.

{ecMTX.Lock(); bool hm = !ecMsg.empty();
ecMTX.UnLock(); return hm;
}

## Msg() [1/2]

std::string XrdOucECMsg::Msg | ( |  | ) |

inline

Return the message string.

Returns
  A reference to the message string.

Definition at line 82 of file XrdOucECMsg.hh.

{ecMTX.Lock(); std::string m = ecMsg; ecMTX.UnLock();
return m;
}

## Msg() [2/2]

void XrdOucECMsg::Msg | ( | const char * | pfx,
|  | const char * | txt1,
|  | const char * | txt2 = 0,
|  | const char * | txt3 = 0,
|  | const char * | txt4 = 0,
|  | const char * | txt5 = 0 )

Insert a space delimited error message into ecMsg string.

Parameters

  pfx | !0 -> the text to prefix the message; the message is formed as pfx: txt1 [txt2] [txt3] pfx =0 -> insert message into ecMsg without a prefix.
  txt1,txt2,txt3,txt4,txt5 | the message to be inserted to ecMsg.

Definition at line 61 of file XrdOucECMsg.cc.

{
const char *vecP[10];
int n = 0;
bool xSpace = false;
if (txt1 && *txt1) {vecP[n++] = txt1; xSpace = true;}
if (txt2 && *txt2) {if (xSpace) vecP[n++] = " ";
vecP[n++] = txt2; xSpace = true;
}
if (txt3 && *txt3) {if (xSpace) vecP[n++] = " ";
vecP[n++] = txt3; xSpace = true;
}
if (txt4 && *txt4) {if (xSpace) vecP[n++] = " ";
vecP[n++] = txt4; xSpace = true;
}
if (txt5 && *txt5) {if (xSpace) vecP[n++] = " ";
vecP[n++] = txt5;
}
// Route the message appropriately
//
MsgVec(pfx, vecP, n);
}
XrdOucECMsg::MsgVec
void MsgVec(const char *pfx, char const *const *vecP, int vecN)
Definition XrdOucECMsg.cc:137

References MsgVec().

Here is the call graph for this function:

## Msgf()

void XrdOucECMsg::Msgf | ( | const char * | pfx,
|  | const char * | fmt,
|  |  | ... )

Insert a formated error message into ecMsg using variable args.

Parameters

  pfx | !0 -> the text to prefix the message; the message is formed as <pfx>: <formated_text> pfx =0 -> insert message without a prefix.
  fmt | the message formatting template (i.e. sprintf format).
  ... | the arguments that should be used with the template. The formatted message is truncated at 2048 bytes.

Definition at line 93 of file XrdOucECMsg.cc.

{
char buffer[2048];
va_list args;
va_start (args, fmt);
// Format the message
//
int n = vsnprintf(buffer, sizeof(buffer), fmt, args);
// Append as needed
//
if (n > (int)sizeof(buffer)) n = sizeof(buffer);
ecMTX.Lock();
Setup(pfx, n);
ecMsg.append(buffer);
ecMTX.UnLock();
}

## MsgVA()

void XrdOucECMsg::MsgVA | ( | const char * | pfx,
|  | const char * | fmt,
|  | std::va_list | aP )

Insert a formated error message into the ecMsg using a va_list.

Parameters

  pfx | !0 -> the text to prefix the message; the message is formed as <pfx>: <formated_text> pfx =0 -> add message to the log without a prefix.
  fmt | the message formatting template (i.e. sprintf format).
  aP | the arguments that should be used with the template. The formatted message is truncated at 2048 bytes.

Definition at line 116 of file XrdOucECMsg.cc.

{
char buffer[2048];
// Format the message
//
int n = vsnprintf(buffer, sizeof(buffer), fmt, aP);
// Append as needed
//
if (n > (int)sizeof(buffer)) n = sizeof(buffer);
ecMTX.Lock();
Setup(pfx, n);
ecMsg.append(buffer);
ecMTX.UnLock();
}

## MsgVec()

void XrdOucECMsg::MsgVec | ( | const char * | pfx,
|  | char const *const * | vecP,
|  | int | vecN )

Insert a formated error message into ecMsg using an iovec.

Parameters

  pfx | !0 -> the text to prefix the message; the message is formed as pfx: <iovec> pfx =0 -> insert message into ecMsg without a prefix.
  vecP | pointer to a vector strings to insert into the message. Spaces are not inserted between the elements.
  vecN | the number of elements in vecP.

Definition at line 137 of file XrdOucECMsg.cc.

{
int n = 0;
for (int i = 0; i < vecN; i++) n += strlen(vecP[i]);
ecMTX.Lock();
Setup(pfx, n);
for (int i = 0; i < vecN; i++) ecMsg.append(vecP[i]);
ecMTX.UnLock();
}

Referenced by Msg().

Here is the caller graph for this function:

## operator=() [1/4]

XrdOucECMsg & XrdOucECMsg::operator= | ( | const char * | rhs | ) |

inline

Definition at line 173 of file XrdOucECMsg.hh.

{ecMTX.Lock(); ecMsg = rhs; ecMTX.UnLock(); return *this;}

References XrdOucECMsg().

Here is the call graph for this function:

## operator=() [2/4]

XrdOucECMsg & XrdOucECMsg::operator= | ( | const int | rhs | ) |

inline

Assignment operators for convenience.

Definition at line 167 of file XrdOucECMsg.hh.

{ecMTX.Lock(); eCode = rhs; ecMTX.UnLock(); return *this;}

References XrdOucECMsg().

Here is the call graph for this function:

## operator=() [3/4]

XrdOucECMsg & XrdOucECMsg::operator= | ( | const std::string & | rhs | ) |

inline

Definition at line 170 of file XrdOucECMsg.hh.

{ecMTX.Lock(); ecMsg = rhs; ecMTX.UnLock(); return *this;}

References XrdOucECMsg().

Here is the call graph for this function:

## operator=() [4/4]

XrdOucECMsg & XrdOucECMsg::operator= | ( | XrdOucECMsg & | rhs | ) |

inline

Definition at line 176 of file XrdOucECMsg.hh.

{ecMTX.Lock(); ecMsg = rhs.ecMsg; eCode = rhs.eCode; ecMTX.UnLock();
return *this;
}

References XrdOucECMsg().

Here is the call graph for this function:

## Set() [1/2]

void XrdOucECMsg::Set | ( | int | ecc,
|  | const char * | ecm = "" )

inline

Set error message and error code.

Parameters

  ecc | The error code.
  ecm | The error message, if nil then message is not changed.

Definition at line 145 of file XrdOucECMsg.hh.

{ecMTX.Lock(); eCode = ecc; if (ecm) ecMsg = ecm; ecMTX.UnLock();}

Referenced by XrdPosixMap::Entry2Buf().

Here is the caller graph for this function:

## Set() [2/2]

void XrdOucECMsg::Set | ( | int | ecc,
|  | std::string & | ecm )

inline

Definition at line 148 of file XrdOucECMsg.hh.

{ecMTX.Lock(); eCode = ecc; ecMsg = ecm; ecMTX.UnLock();}

## SetErrno()

int XrdOucECMsg::SetErrno | ( | int | ecc,
|  | int | ret = -1,
|  | const char * | alt = 0 )

Set default error message, error code, and errno.

Parameters

  ecc | The error code.
  ret | The value to be returned, default -1.
  alt | Alternative message, default text of ecc error.

Returns
  The ret parameter value is returned.

Definition at line 152 of file XrdOucECMsg.cc.

{
XrdSysMutexHelper mScope(ecMTX);
if (!alt || *alt != '*')
{if (!alt) alt = XrdSysE2T(ecc);
Setup(msgID, strlen(alt));
ecMsg.append(alt);
}
errno = eCode = ecc;
return ret;
}
XrdSysE2T
const char * XrdSysE2T(int errcode)
Definition XrdSysE2T.cc:104

References XrdSysE2T().

Referenced by XrdPosixExtra::pgRead(), XrdPosixExtra::pgWrite(), XrdPosixXrootd::Pread(), and XrdPosixXrootd::Pwrite().

Here is the call graph for this function:
Here is the caller graph for this function:

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

- XrdOucECMsg.hh
- XrdOucECMsg.cc