SNAP Library, User Reference  2012-10-15 15:06:59
SNAP, a general purpose network analysis and graph mining library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ut.h File Reference

Go to the source code of this file.

Classes

class  TTypeNm< Type >
class  TNullNotify
class  TCallbackNotify
class  TNativeCallbackNotify
class  TStdNotify
class  TStdErrNotify
class  TLogNotify

Defines

#define Try   try {
#define Catch   } catch (PExcept Except){ErrNotify(Except->GetMsgStr());}
#define CatchFull   } catch (PExcept Except){ErrNotify(Except->GetStr());}
#define CatchAll   } catch (...){}

Typedefs

typedef void(__stdcall * TCallbackF )(const TNotifyType &Type, const TStr &MsgStr)
typedef void(__stdcall * TNativeCallbackF )(int Type, const char *MsgStr)
typedef void(* TOnExceptF )(const TStr &MsgStr)

Enumerations

enum  TNotifyType { ntInfo, ntWarn, ntErr, ntStat }

Functions

template<class Type >
TStr GetTypeNm (const Type &Var)
void InfoNotify (const TStr &MsgStr)
void WarnNotify (const TStr &MsgStr)
void ErrNotify (const TStr &MsgStr)
void StatNotify (const TStr &MsgStr)
ClassTP(TNotify, PNotify)
private TNotify
operator= (const TNotify &)
 TNotify ()
virtual ~TNotify ()
virtual void OnNotify (const TNotifyType &, const TStr &)
virtual void OnStatus (const TStr &)
virtual void OnLn (const TStr &)
virtual void OnTxt (const TStr &)
void OnNotifyFmt (const TNotifyType &Type, const char *FmtStr,...)
void OnStatusFmt (const char *FmtStr,...)
void OnLnFmt (const char *FmtStr,...)
void OnTxtFmt (const char *FmtStr,...)
static TStr GetTypeStr (const TNotifyType &Type, const bool &Brief=true)
static void OnNotify (const PNotify &Notify, const TNotifyType &Type, const TStr &MsgStr)
static void OnStatus (const PNotify &Notify, const TStr &MsgStr)
static void OnLn (const PNotify &Notify, const TStr &MsgStr)
static void OnTxt (const PNotify &Notify, const TStr &MsgStr)
static void DfOnNotify (const TNotifyType &Type, const TStr &MsgStr)
 UndefDefaultCopyAssign (TExcept)
 TExcept (const TStr &_MsgStr)
 TExcept (const TStr &_MsgStr, const TStr &_LocStr)
virtual ~TExcept ()
TStr GetMsgStr () const
TStr GetLocStr () const
TStr GetStr () const
static bool IsOnExceptF ()
static void PutOnExceptF (TOnExceptF _OnExceptF)
static TOnExceptF GetOnExceptF ()
static void Throw (const TStr &MsgStr)
static void Throw (const TStr &MsgStr, const TStr &ArgStr)
static void Throw (const TStr &MsgStr, const TStr &ArgStr1, const TStr &ArgStr2)
static void ThrowFull (const TStr &MsgStr, const TStr &LocStr)

Variables

static const PNotify NullNotify = TNullNotify::New()
static const PNotify StdNotify = TStdNotify::New()
static const PNotify StdErrNotify = TStdErrNotify::New()
ClassTP(TExcept, PExcept)
private TStr 
LocStr
static TOnExceptF OnExceptF = NULL

Define Documentation

#define Catch   } catch (PExcept Except){ErrNotify(Except->GetMsgStr());}

Definition at line 200 of file ut.h.

#define CatchAll   } catch (...){}

Definition at line 202 of file ut.h.

#define CatchFull   } catch (PExcept Except){ErrNotify(Except->GetStr());}

Definition at line 201 of file ut.h.

#define Try   try {

Definition at line 199 of file ut.h.


Typedef Documentation

typedef void(__stdcall * TCallbackF)(const TNotifyType &Type, const TStr &MsgStr)

Definition at line 78 of file ut.h.

typedef void(__stdcall * TNativeCallbackF)(int Type, const char *MsgStr)

Definition at line 101 of file ut.h.

typedef void(* TOnExceptF)(const TStr &MsgStr)

Definition at line 176 of file ut.h.


Enumeration Type Documentation

Enumerator:
ntInfo 
ntWarn 
ntErr 
ntStat 

Definition at line 26 of file ut.h.


Function Documentation

void TNotify::DfOnNotify ( const TNotifyType Type,
const TStr MsgStr 
) [static]

Definition at line 54 of file ut.cpp.

                                                                   {
  switch (Type){
    case ntInfo: InfoNotify(MsgStr); break;
    case ntWarn: WarnNotify(MsgStr); break;
    case ntErr: ErrNotify(MsgStr); break;
    case ntStat: StatNotify(MsgStr); break;
    default: Fail;
  }
}
void ErrNotify ( const TStr MsgStr) [inline]

Definition at line 23 of file ut.h.

{ErrNotify(MsgStr.CStr());}
TStr GetLocStr ( ) const

Definition at line 170 of file ut.h.

{return LocStr;}
TStr GetMsgStr ( ) const

Definition at line 169 of file ut.h.

{return MsgStr;}
static TOnExceptF GetOnExceptF ( ) [static]

Definition at line 180 of file ut.h.

{return OnExceptF;}
TStr GetStr ( ) const

Definition at line 171 of file ut.h.

                      {
    if (LocStr.Empty()){return GetMsgStr();}
    else {return GetLocStr()+": "+GetMsgStr();}}
template<class Type >
TStr GetTypeNm ( const Type &  Var)

Definition at line 14 of file ut.h.

                               {
  TStr TypeNm=TStr(typeid(Var).name());
  return TTypeNm<Type>::GetNrTypeNm(TypeNm);
}
static TStr GetTypeStr ( const TNotifyType Type,
const bool &  Brief = true 
) [static]
void InfoNotify ( const TStr MsgStr) [inline]

Definition at line 21 of file ut.h.

{InfoNotify(MsgStr.CStr());}
static bool IsOnExceptF ( ) [static]

Definition at line 178 of file ut.h.

{return OnExceptF!=NULL;}
virtual void OnLn ( const TStr ) [virtual]

Definition at line 38 of file ut.h.

{}
static void OnLn ( const PNotify &  Notify,
const TStr MsgStr 
) [static]

Definition at line 54 of file ut.h.

                                                             {
    if (!Notify.Empty()){Notify->OnLn(MsgStr);}}
void TNotify::OnLnFmt ( const char *  FmtStr,
  ... 
)

Definition at line 21 of file ut.cpp.

                                             {
  char Bf[10*1024];
  va_list valist;
  va_start(valist, FmtStr);
  const int RetVal=vsnprintf(Bf, 10*1024-2, FmtStr, valist);
  va_end(valist);
  if (RetVal!=-1) { OnLn(TStr(Bf)); }
}
virtual void OnNotify ( const TNotifyType ,
const TStr  
) [virtual]

Definition at line 36 of file ut.h.

{}
static void OnNotify ( const PNotify &  Notify,
const TNotifyType Type,
const TStr MsgStr 
) [static]

Definition at line 49 of file ut.h.

                                               {
    if (!Notify.Empty()){Notify->OnNotify(Type, MsgStr);}}
void TNotify::OnNotifyFmt ( const TNotifyType Type,
const char *  FmtStr,
  ... 
)

Definition at line 3 of file ut.cpp.

                                                                          {
  char Bf[10*1024];
  va_list valist;
  va_start(valist, FmtStr);
  const int RetVal=vsnprintf(Bf, 10*1024-2, FmtStr, valist);
  va_end(valist);
  if (RetVal!=-1) { OnNotify(Type, TStr(Bf)); }
}
virtual void OnStatus ( const TStr ) [virtual]

Definition at line 37 of file ut.h.

{}
static void OnStatus ( const PNotify &  Notify,
const TStr MsgStr 
) [static]

Definition at line 52 of file ut.h.

                                                                 {
    if (!Notify.Empty()){Notify->OnStatus(MsgStr);}}
void TNotify::OnStatusFmt ( const char *  FmtStr,
  ... 
)

Definition at line 12 of file ut.cpp.

                                                 {
  char Bf[10*1024];
  va_list valist;
  va_start(valist, FmtStr);
  const int RetVal=vsnprintf(Bf, 10*1024-2, FmtStr, valist);
  va_end(valist);
  if (RetVal!=-1) { OnStatus(TStr(Bf)); }
}
virtual void OnTxt ( const TStr ) [virtual]

Definition at line 39 of file ut.h.

{}
static void OnTxt ( const PNotify &  Notify,
const TStr MsgStr 
) [static]

Definition at line 56 of file ut.h.

                                                              {
    if (!Notify.Empty()){Notify->OnTxt(MsgStr);}}
void TNotify::OnTxtFmt ( const char *  FmtStr,
  ... 
)

Definition at line 30 of file ut.cpp.

                                              {
  char Bf[10*1024];
  va_list valist;
  va_start(valist, FmtStr);
  const int RetVal=vsnprintf(Bf, 10*1024-2, FmtStr, valist);
  va_end(valist);
  if (RetVal!=-1) { OnTxt(TStr(Bf)); }
}
ClassTP (TNotify, PNotify) private TNotify& operator= ( const TNotify )
static void PutOnExceptF ( TOnExceptF  _OnExceptF) [static]

Definition at line 179 of file ut.h.

{OnExceptF=_OnExceptF;}
void StatNotify ( const TStr MsgStr) [inline]

Definition at line 24 of file ut.h.

{StatNotify(MsgStr.CStr());}
TExcept ( const TStr _MsgStr)

Definition at line 165 of file ut.h.

: MsgStr(_MsgStr), LocStr(){}
TExcept ( const TStr _MsgStr,
const TStr _LocStr 
)

Definition at line 166 of file ut.h.

: MsgStr(_MsgStr), LocStr(_LocStr){}
static void Throw ( const TStr MsgStr) [static]

Definition at line 183 of file ut.h.

                                       {
    if (IsOnExceptF()){(*OnExceptF)(MsgStr);}
    else {throw PExcept(new TExcept(MsgStr));}}
static void Throw ( const TStr MsgStr,
const TStr ArgStr 
) [static]

Definition at line 186 of file ut.h.

                                                           {
    TStr FullMsgStr=MsgStr+" ("+ArgStr+")";
    if (IsOnExceptF()){(*OnExceptF)(FullMsgStr);}
    else {throw PExcept(new TExcept(FullMsgStr));}}
static void Throw ( const TStr MsgStr,
const TStr ArgStr1,
const TStr ArgStr2 
) [static]

Definition at line 190 of file ut.h.

                                                                                 {
    TStr FullMsgStr=MsgStr+" ("+ArgStr1+", "+ArgStr2+")";
    if (IsOnExceptF()){(*OnExceptF)(FullMsgStr);}
    else {throw PExcept(new TExcept(FullMsgStr));}}
static void ThrowFull ( const TStr MsgStr,
const TStr LocStr 
) [static]

Definition at line 194 of file ut.h.

                                                               {
    if (IsOnExceptF()){(*OnExceptF)(MsgStr);}
    else {throw PExcept(new TExcept(MsgStr, LocStr));}}
TNotify ( )

Definition at line 33 of file ut.h.

{}
void WarnNotify ( const TStr MsgStr) [inline]

Definition at line 22 of file ut.h.

{WarnNotify(MsgStr.CStr());}
virtual ~TExcept ( ) [virtual]

Definition at line 167 of file ut.h.

{}
virtual ~TNotify ( ) [virtual]

Definition at line 34 of file ut.h.

{}

Variable Documentation

Definition at line 159 of file ut.h.

const PNotify TNotify::NullNotify = TNullNotify::New() [static]

Definition at line 60 of file ut.h.

Definition at line 177 of file ut.h.

const PNotify TNotify::StdErrNotify = TStdErrNotify::New() [static]

Definition at line 62 of file ut.h.

const PNotify TNotify::StdNotify = TStdNotify::New() [static]

Definition at line 61 of file ut.h.