SNAP Library 2.0, Developer Reference  2013-05-13 16:33:57
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TUInt Class Reference

#include <dt.h>

Collaboration diagram for TUInt:

List of all members.

Public Member Functions

 TUInt ()
 TUInt (const uint &_Val)
 operator uint () const
 TUInt (TSIn &SIn)
void Load (TSIn &SIn)
void Save (TSOut &SOut) const
void LoadXml (const PXmlTok &XmlTok, const TStr &Nm)
void SaveXml (TSOut &SOut, const TStr &Nm) const
TUIntoperator= (const TUInt &UInt)
TUIntoperator= (const uint &_Val)
TUInt operator++ (int)
TUInt operator-- (int)
uint operator() () const
uintoperator() ()
TUIntoperator~ ()
TUIntoperator&= (const TUInt &UInt)
TUIntoperator|= (const TUInt &UInt)
TUIntoperator^= (const TUInt &UInt)
TUIntoperator>>= (const int &ShiftBits)
TUIntoperator<<= (const int &ShiftBits)
int GetMemUsed () const
int GetPrimHashCd () const
int GetSecHashCd () const
TStr GetStr () const

Static Public Member Functions

static uint GetRnd (const uint &Range=0)
static TStr GetStr (const uint &Val)
static TStr GetStr (const TUInt &UInt)
static TStr GetStr (const uint &Val, const char *FmtStr)
static TStr GetStr (const uint &Val, const TStr &FmtStr)
static TStr GetKiloStr (const uint &Val)
static TStr GetMegaStr (const uint &Val)
static uint JavaUIntToCppUInt (const uint &JavaUInt)
static bool IsIpStr (const TStr &IpStr, uint &Ip, const char &SplitCh= '.')
static bool IsIpStr (const TStr &IpStr, const char &SplitCh= '.')
static uint GetUIntFromIpStr (const TStr &IpStr, const char &SplitCh= '.')
static TStr GetStrFromIpUInt (const uint &Ip)
static bool IsIpv6Str (const TStr &IpStr, const char &SplitCh= ':')

Public Attributes

uint Val

Static Public Attributes

static const uint Mn = 0
static const uint Mx = UINT_MAX
static TRnd Rnd

Detailed Description

Definition at line 1146 of file dt.h.


Constructor & Destructor Documentation

TUInt::TUInt ( ) [inline]

Definition at line 1154 of file dt.h.

Referenced by GetMemUsed().

: Val(0){}

Here is the caller graph for this function:

TUInt::TUInt ( const uint _Val) [inline]

Definition at line 1155 of file dt.h.

: Val(_Val){}
TUInt::TUInt ( TSIn SIn) [inline, explicit]

Definition at line 1157 of file dt.h.

References TSIn::Load(), and Val.

{SIn.Load(Val);}

Here is the call graph for this function:


Member Function Documentation

static TStr TUInt::GetKiloStr ( const uint Val) [inline, static]

Definition at line 1195 of file dt.h.

References GetStr().

Referenced by GetMegaStr().

                                         {
    if (Val>100*1000){return GetStr(Val/1000)+"K";}
    else if (Val>1000){return GetStr(Val/1000)+"."+GetStr((Val%1000)/100)+"K";}
    else {return GetStr(Val);}}

Here is the call graph for this function:

Here is the caller graph for this function:

static TStr TUInt::GetMegaStr ( const uint Val) [inline, static]

Definition at line 1199 of file dt.h.

References GetKiloStr(), and GetStr().

                                         {
    if (Val>100*1000000){return GetStr(Val/1000000)+"M";}
    else if (Val>1000000){
      return GetStr(Val/1000000)+"."+GetStr((Val%1000000)/100000)+"M";}
    else {return GetKiloStr(Val);}}

Here is the call graph for this function:

int TUInt::GetMemUsed ( ) const [inline]

Definition at line 1179 of file dt.h.

References TUInt().

Referenced by TSecTm::GetMemUsed().

{return sizeof(TUInt);}

Here is the call graph for this function:

Here is the caller graph for this function:

int TUInt::GetPrimHashCd ( ) const [inline]

Definition at line 1181 of file dt.h.

References Val.

Referenced by TSecTm::GetPrimHashCd().

{return int(Val);}

Here is the caller graph for this function:

static uint TUInt::GetRnd ( const uint Range = 0) [inline, static]

Definition at line 1184 of file dt.h.

References TRnd::GetUniDevUInt(), and Rnd.

{return Rnd.GetUniDevUInt(Range);}

Here is the call graph for this function:

int TUInt::GetSecHashCd ( ) const [inline]

Definition at line 1182 of file dt.h.

References Val.

Referenced by TSecTm::GetSecHashCd().

{return Val/0x10;}

Here is the caller graph for this function:

static TStr TUInt::GetStr ( const uint Val) [inline, static]

Definition at line 1187 of file dt.h.

                                     {
    char Bf[255]; sprintf(Bf, "%u", Val); return TStr(Bf);}
static TStr TUInt::GetStr ( const TUInt UInt) [inline, static]

Definition at line 1189 of file dt.h.

References GetStr(), and Val.

                                       {
    return GetStr(UInt.Val);}

Here is the call graph for this function:

TStr TUInt::GetStr ( const uint Val,
const char *  FmtStr 
) [static]

Definition at line 2086 of file dt.cpp.

References GetStr().

                                                     {
  if (FmtStr==NULL){
    return GetStr(Val);
  } else {
    char Bf[255];
    sprintf(Bf, FmtStr, Val);
    return TStr(Bf);
  }
}

Here is the call graph for this function:

static TStr TUInt::GetStr ( const uint Val,
const TStr FmtStr 
) [inline, static]

Definition at line 1192 of file dt.h.

References TStr::CStr(), and GetStr().

                                                         {
    return GetStr(Val, FmtStr.CStr());}

Here is the call graph for this function:

TStr TUInt::GetStrFromIpUInt ( const uint Ip) [static]

Definition at line 2117 of file dt.cpp.

References TStr::Fmt().

                                           {
  return TStr::Fmt("%d.%d.%d.%d", ((Ip>>24) & 0xFF),
   ((Ip>>16) & 0xFF), ((Ip>>8) & 0xFF), (Ip & 0xFF));
}

Here is the call graph for this function:

uint TUInt::GetUIntFromIpStr ( const TStr IpStr,
const char &  SplitCh = '.' 
) [static]

Definition at line 2107 of file dt.cpp.

References TStr::CStr(), EAssertR, TStr::Fmt(), and TStr::SplitOnAllCh().

                                                                   {
        TStrV IpStrV; IpStr.SplitOnAllCh(SplitCh, IpStrV);
    uint Ip = 0; int Byte = 0;
        EAssertR(IpStrV[0].IsInt(true, 0, 255, Byte), TStr::Fmt("Bad IP: '%s;", IpStr.CStr())); Ip = (uint)Byte;
        EAssertR(IpStrV[1].IsInt(true, 0, 255, Byte), TStr::Fmt("Bad IP: '%s;", IpStr.CStr())); Ip = (Ip << 8) | (uint)Byte;
        EAssertR(IpStrV[2].IsInt(true, 0, 255, Byte), TStr::Fmt("Bad IP: '%s;", IpStr.CStr())); Ip = (Ip << 8) | (uint)Byte;
        EAssertR(IpStrV[3].IsInt(true, 0, 255, Byte), TStr::Fmt("Bad IP: '%s;", IpStr.CStr())); Ip = (Ip << 8) | (uint)Byte;
        return Ip;
}

Here is the call graph for this function:

bool TUInt::IsIpStr ( const TStr IpStr,
uint Ip,
const char &  SplitCh = '.' 
) [static]

Definition at line 2096 of file dt.cpp.

References TVec< TVal, TSizeTy >::Len(), and TStr::SplitOnAllCh().

                                                                    {
        TStrV IpStrV; IpStr.SplitOnAllCh(SplitCh, IpStrV);
    Ip = 0; int Byte = 0;
        if (IpStrV.Len() != 4) { return false; }
        if (!IpStrV[0].IsInt(true, 0, 255, Byte)) { return false; }; Ip = (uint)Byte;
        if (!IpStrV[1].IsInt(true, 0, 255, Byte)) { return false; }; Ip = (Ip << 8) | (uint)Byte;
        if (!IpStrV[2].IsInt(true, 0, 255, Byte)) { return false; }; Ip = (Ip << 8) | (uint)Byte;
        if (!IpStrV[3].IsInt(true, 0, 255, Byte)) { return false; }; Ip = (Ip << 8) | (uint)Byte;
        return true;
}

Here is the call graph for this function:

static bool TUInt::IsIpStr ( const TStr IpStr,
const char &  SplitCh = '.' 
) [inline, static]

Definition at line 1214 of file dt.h.

References IsIpStr().

Referenced by IsIpStr().

{ uint Ip; return IsIpStr(IpStr, Ip, SplitCh); }

Here is the call graph for this function:

Here is the caller graph for this function:

bool TUInt::IsIpv6Str ( const TStr IpStr,
const char &  SplitCh = ':' 
) [static]

Definition at line 2122 of file dt.cpp.

References TVec< TVal, TSizeTy >::Len(), and TStr::SplitOnAllCh().

                                                            {
        TStrV IpStrV; IpStr.SplitOnAllCh(SplitCh, IpStrV, false);
        // check we have 8 groups
        if (IpStrV.Len() > 8) { return false; }
        // each group must be in hexa and in range from 0x0000 to 0xFFFF
        int Group = 0;
        for (int IpStrN = 0; IpStrN < IpStrV.Len(); IpStrN++) {
                if (IpStrV[IpStrN].Empty()) { continue; }
                if (IpStrV[IpStrN].IsHexInt(true, 0x0000, 0xFFFF, Group)) { continue; }
                return false; 
        }
        // all fine
        return true;
}

Here is the call graph for this function:

static uint TUInt::JavaUIntToCppUInt ( const uint JavaUInt) [inline, static]

Definition at line 1205 of file dt.h.

                                                     {
    uint B1=(JavaUInt & 0xFF000000) >> 24;
    uint B2=(JavaUInt & 0x00FF0000) >> 16;
    uint B3=(JavaUInt & 0x0000FF00) >> 8;
    uint B4=(JavaUInt & 0x000000FF) >> 0;
    uint CppUInt=(B4<<24)+(B3<<16)+(B2<<8)+(B1<<0);
    return CppUInt;}
void TUInt::Load ( TSIn SIn) [inline]

Definition at line 1158 of file dt.h.

References TSIn::Load(), and Val.

Referenced by TSecTm::Load().

{SIn.Load(Val);}

Here is the call graph for this function:

Here is the caller graph for this function:

void TUInt::LoadXml ( const PXmlTok XmlTok,
const TStr Nm 
)

Definition at line 2077 of file dt.cpp.

References TXmlObjSer::GetIntArg(), Val, and XLoadHd.

                                                        {
  XLoadHd(Nm);
  Val=TXmlObjSer::GetIntArg(XmlTok, "Val");
}

Here is the call graph for this function:

TUInt::operator uint ( ) const [inline]

Definition at line 1156 of file dt.h.

References Val.

{return Val;}
TUInt& TUInt::operator&= ( const TUInt UInt) [inline]

Definition at line 1174 of file dt.h.

References Val.

{Val&=UInt.Val; return *this;}
uint TUInt::operator() ( ) const [inline]

Definition at line 1171 of file dt.h.

References Val.

{return Val;}
uint& TUInt::operator() ( ) [inline]

Definition at line 1172 of file dt.h.

References Val.

{return Val;}
TUInt TUInt::operator++ ( int  ) [inline]

Definition at line 1165 of file dt.h.

References Val.

{Val++; return *this;}
TUInt TUInt::operator-- ( int  ) [inline]

Definition at line 1166 of file dt.h.

References Val.

{Val--; return *this;}
TUInt& TUInt::operator<<= ( const int &  ShiftBits) [inline]

Definition at line 1178 of file dt.h.

References Val.

{Val<<=ShiftBits; return *this;}
TUInt& TUInt::operator= ( const TUInt UInt) [inline]

Definition at line 1163 of file dt.h.

References Val.

{Val=UInt.Val; return *this;}
TUInt& TUInt::operator= ( const uint _Val) [inline]

Definition at line 1164 of file dt.h.

References Val.

{Val=_Val; return *this;}
TUInt& TUInt::operator>>= ( const int &  ShiftBits) [inline]

Definition at line 1177 of file dt.h.

References Val.

{Val>>=ShiftBits; return *this;}
TUInt& TUInt::operator^= ( const TUInt UInt) [inline]

Definition at line 1176 of file dt.h.

References Val.

{Val^=UInt.Val; return *this;}
TUInt& TUInt::operator|= ( const TUInt UInt) [inline]

Definition at line 1175 of file dt.h.

References Val.

{Val|=UInt.Val; return *this;}
TUInt& TUInt::operator~ ( ) [inline]

Definition at line 1173 of file dt.h.

References Val.

{Val=~Val; return *this;}
void TUInt::Save ( TSOut SOut) const [inline]

Definition at line 1159 of file dt.h.

References TSOut::Save(), and Val.

Referenced by TSecTm::Save().

{SOut.Save(Val);}

Here is the call graph for this function:

Here is the caller graph for this function:

void TUInt::SaveXml ( TSOut SOut,
const TStr Nm 
) const

Definition at line 2082 of file dt.cpp.

References TInt::GetStr(), Val, and XSaveBETagArg.

                                                     {
  XSaveBETagArg(Nm, "Val", TInt::GetStr(Val));
}

Here is the call graph for this function:


Member Data Documentation

const uint TUInt::Mn = 0 [static]

Definition at line 1150 of file dt.h.

Referenced by TUniCodec::GetRndUint().

TRnd TUInt::Rnd [static]

Definition at line 1152 of file dt.h.

Referenced by GetRnd().


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