SNAP Library 6.0, Developer Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
TUInt Class Reference

#include <dt.h>

Collaboration diagram for TUInt:

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 1242 of file dt.h.

Constructor & Destructor Documentation

TUInt::TUInt ( )
inline

Definition at line 1250 of file dt.h.

Referenced by GetMemUsed().

1250 : Val(0){}
uint Val
Definition: dt.h:1244

Here is the caller graph for this function:

TUInt::TUInt ( const uint _Val)
inline

Definition at line 1251 of file dt.h.

1251 : Val(_Val){}
uint Val
Definition: dt.h:1244
TUInt::TUInt ( TSIn SIn)
inlineexplicit

Definition at line 1253 of file dt.h.

References TSIn::Load().

1253 {SIn.Load(Val);}
void Load(bool &Bool)
Definition: fl.h:84
uint Val
Definition: dt.h:1244

Here is the call graph for this function:

Member Function Documentation

static TStr TUInt::GetKiloStr ( const uint Val)
inlinestatic

Definition at line 1291 of file dt.h.

References GetStr().

Referenced by GetMegaStr().

1291  {
1292  if (Val>100*1000){return GetStr(Val/1000)+"K";}
1293  else if (Val>1000){return GetStr(Val/1000)+"."+GetStr((Val%1000)/100)+"K";}
1294  else {return GetStr(Val);}}
TStr GetStr() const
Definition: dt.h:1282
uint Val
Definition: dt.h:1244

Here is the call graph for this function:

Here is the caller graph for this function:

static TStr TUInt::GetMegaStr ( const uint Val)
inlinestatic

Definition at line 1295 of file dt.h.

References GetKiloStr(), and GetStr().

1295  {
1296  if (Val>100*1000000){return GetStr(Val/1000000)+"M";}
1297  else if (Val>1000000){
1298  return GetStr(Val/1000000)+"."+GetStr((Val%1000000)/100000)+"M";}
1299  else {return GetKiloStr(Val);}}
static TStr GetKiloStr(const uint &Val)
Definition: dt.h:1291
TStr GetStr() const
Definition: dt.h:1282
uint Val
Definition: dt.h:1244

Here is the call graph for this function:

int TUInt::GetMemUsed ( ) const
inline

Definition at line 1275 of file dt.h.

References TUInt().

Referenced by TSecTm::GetMemUsed().

1275 {return sizeof(TUInt);}
TUInt()
Definition: dt.h:1250

Here is the call graph for this function:

Here is the caller graph for this function:

int TUInt::GetPrimHashCd ( ) const
inline

Definition at line 1277 of file dt.h.

Referenced by TSecTm::GetPrimHashCd().

1277 {return int(Val);}
uint Val
Definition: dt.h:1244

Here is the caller graph for this function:

static uint TUInt::GetRnd ( const uint Range = 0)
inlinestatic

Definition at line 1280 of file dt.h.

References TRnd::GetUniDevUInt().

1280 {return Rnd.GetUniDevUInt(Range);}
uint GetUniDevUInt(const uint &Range=0)
Definition: dt.cpp:45
static TRnd Rnd
Definition: dt.h:1248

Here is the call graph for this function:

int TUInt::GetSecHashCd ( ) const
inline

Definition at line 1278 of file dt.h.

Referenced by TSecTm::GetSecHashCd().

1278 {return Val/0x10;}
uint Val
Definition: dt.h:1244

Here is the caller graph for this function:

TStr TUInt::GetStr ( ) const
inline
static TStr TUInt::GetStr ( const uint Val)
inlinestatic

Definition at line 1283 of file dt.h.

1283  {
1284  char Bf[255]; sprintf(Bf, "%u", Val); return TStr(Bf);}
Definition: dt.h:412
uint Val
Definition: dt.h:1244
static TStr TUInt::GetStr ( const TUInt UInt)
inlinestatic

Definition at line 1285 of file dt.h.

References GetStr(), and Val.

1285  {
1286  return GetStr(UInt.Val);}
TStr GetStr() const
Definition: dt.h:1282
uint Val
Definition: dt.h:1244

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().

2086  {
2087  if (FmtStr==NULL){
2088  return GetStr(Val);
2089  } else {
2090  char Bf[255];
2091  sprintf(Bf, FmtStr, Val);
2092  return TStr(Bf);
2093  }
2094 }
TStr GetStr() const
Definition: dt.h:1282
Definition: dt.h:412
uint Val
Definition: dt.h:1244

Here is the call graph for this function:

static TStr TUInt::GetStr ( const uint Val,
const TStr FmtStr 
)
inlinestatic

Definition at line 1288 of file dt.h.

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

1288  {
1289  return GetStr(Val, FmtStr.CStr());}
TStr GetStr() const
Definition: dt.h:1282
uint Val
Definition: dt.h:1244
char * CStr()
Definition: dt.h:479

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().

2117  {
2118  return TStr::Fmt("%d.%d.%d.%d", ((Ip>>24) & 0xFF),
2119  ((Ip>>16) & 0xFF), ((Ip>>8) & 0xFF), (Ip & 0xFF));
2120 }
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599

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().

2107  {
2108  TStrV IpStrV; IpStr.SplitOnAllCh(SplitCh, IpStrV);
2109  uint Ip = 0; int Byte = 0;
2110  EAssertR(IpStrV[0].IsInt(true, 0, 255, Byte), TStr::Fmt("Bad IP: '%s;", IpStr.CStr())); Ip = (uint)Byte;
2111  EAssertR(IpStrV[1].IsInt(true, 0, 255, Byte), TStr::Fmt("Bad IP: '%s;", IpStr.CStr())); Ip = (Ip << 8) | (uint)Byte;
2112  EAssertR(IpStrV[2].IsInt(true, 0, 255, Byte), TStr::Fmt("Bad IP: '%s;", IpStr.CStr())); Ip = (Ip << 8) | (uint)Byte;
2113  EAssertR(IpStrV[3].IsInt(true, 0, 255, Byte), TStr::Fmt("Bad IP: '%s;", IpStr.CStr())); Ip = (Ip << 8) | (uint)Byte;
2114  return Ip;
2115 }
unsigned int uint
Definition: bd.h:11
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
void SplitOnAllCh(const char &SplitCh, TStrV &StrV, const bool &SkipEmpty=true) const
Definition: dt.cpp:926
#define EAssertR(Cond, MsgStr)
Definition: bd.h:283
char * CStr()
Definition: dt.h:479

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().

2096  {
2097  TStrV IpStrV; IpStr.SplitOnAllCh(SplitCh, IpStrV);
2098  Ip = 0; int Byte = 0;
2099  if (IpStrV.Len() != 4) { return false; }
2100  if (!IpStrV[0].IsInt(true, 0, 255, Byte)) { return false; }; Ip = (uint)Byte;
2101  if (!IpStrV[1].IsInt(true, 0, 255, Byte)) { return false; }; Ip = (Ip << 8) | (uint)Byte;
2102  if (!IpStrV[2].IsInt(true, 0, 255, Byte)) { return false; }; Ip = (Ip << 8) | (uint)Byte;
2103  if (!IpStrV[3].IsInt(true, 0, 255, Byte)) { return false; }; Ip = (Ip << 8) | (uint)Byte;
2104  return true;
2105 }
unsigned int uint
Definition: bd.h:11
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
void SplitOnAllCh(const char &SplitCh, TStrV &StrV, const bool &SkipEmpty=true) const
Definition: dt.cpp:926

Here is the call graph for this function:

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

Definition at line 1310 of file dt.h.

References IsIpStr().

Referenced by IsIpStr().

1310 { uint Ip; return IsIpStr(IpStr, Ip, SplitCh); }
unsigned int uint
Definition: bd.h:11
static bool IsIpStr(const TStr &IpStr, uint &Ip, const char &SplitCh= '.')
Definition: dt.cpp:2096

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().

2122  {
2123  TStrV IpStrV; IpStr.SplitOnAllCh(SplitCh, IpStrV, false);
2124  // check we have 8 groups
2125  if (IpStrV.Len() > 8) { return false; }
2126  // each group must be in hexa and in range from 0x0000 to 0xFFFF
2127  int Group = 0;
2128  for (int IpStrN = 0; IpStrN < IpStrV.Len(); IpStrN++) {
2129  if (IpStrV[IpStrN].Empty()) { continue; }
2130  if (IpStrV[IpStrN].IsHexInt(true, 0x0000, 0xFFFF, Group)) { continue; }
2131  return false;
2132  }
2133  // all fine
2134  return true;
2135 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
void SplitOnAllCh(const char &SplitCh, TStrV &StrV, const bool &SkipEmpty=true) const
Definition: dt.cpp:926

Here is the call graph for this function:

static uint TUInt::JavaUIntToCppUInt ( const uint JavaUInt)
inlinestatic

Definition at line 1301 of file dt.h.

1301  {
1302  uint B1=(JavaUInt & 0xFF000000) >> 24;
1303  uint B2=(JavaUInt & 0x00FF0000) >> 16;
1304  uint B3=(JavaUInt & 0x0000FF00) >> 8;
1305  uint B4=(JavaUInt & 0x000000FF) >> 0;
1306  uint CppUInt=(B4<<24)+(B3<<16)+(B2<<8)+(B1<<0);
1307  return CppUInt;}
unsigned int uint
Definition: bd.h:11
void TUInt::Load ( TSIn SIn)
inline

Definition at line 1254 of file dt.h.

References TSIn::Load().

Referenced by TSecTm::Load().

1254 {SIn.Load(Val);}
void Load(bool &Bool)
Definition: fl.h:84
uint Val
Definition: dt.h:1244

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.

2077  {
2078  XLoadHd(Nm);
2079  Val=TXmlObjSer::GetIntArg(XmlTok, "Val");
2080 }
#define XLoadHd(Nm)
Definition: bd.h:312
static int GetIntArg(const PXmlTok &XmlTok, const TStr &Nm)
Definition: xml.cpp:74
uint Val
Definition: dt.h:1244

Here is the call graph for this function:

TUInt::operator uint ( ) const
inline

Definition at line 1252 of file dt.h.

References Val.

1252 {return Val;}
uint Val
Definition: dt.h:1244
TUInt& TUInt::operator&= ( const TUInt UInt)
inline

Definition at line 1270 of file dt.h.

References Val.

1270 {Val&=UInt.Val; return *this;}
uint Val
Definition: dt.h:1244
uint TUInt::operator() ( ) const
inline

Definition at line 1267 of file dt.h.

References Val.

1267 {return Val;}
uint Val
Definition: dt.h:1244
uint& TUInt::operator() ( )
inline

Definition at line 1268 of file dt.h.

References Val.

1268 {return Val;}
uint Val
Definition: dt.h:1244
TUInt TUInt::operator++ ( int  )
inline

Definition at line 1261 of file dt.h.

1261 {Val++; return *this;}
uint Val
Definition: dt.h:1244
TUInt TUInt::operator-- ( int  )
inline

Definition at line 1262 of file dt.h.

1262 {Val--; return *this;}
uint Val
Definition: dt.h:1244
TUInt& TUInt::operator<<= ( const int &  ShiftBits)
inline

Definition at line 1274 of file dt.h.

1274 {Val<<=ShiftBits; return *this;}
uint Val
Definition: dt.h:1244
TUInt& TUInt::operator= ( const TUInt UInt)
inline

Definition at line 1259 of file dt.h.

References Val.

1259 {Val=UInt.Val; return *this;}
uint Val
Definition: dt.h:1244
TUInt& TUInt::operator= ( const uint _Val)
inline

Definition at line 1260 of file dt.h.

1260 {Val=_Val; return *this;}
uint Val
Definition: dt.h:1244
TUInt& TUInt::operator>>= ( const int &  ShiftBits)
inline

Definition at line 1273 of file dt.h.

1273 {Val>>=ShiftBits; return *this;}
uint Val
Definition: dt.h:1244
TUInt& TUInt::operator^= ( const TUInt UInt)
inline

Definition at line 1272 of file dt.h.

References Val.

1272 {Val^=UInt.Val; return *this;}
uint Val
Definition: dt.h:1244
TUInt& TUInt::operator|= ( const TUInt UInt)
inline

Definition at line 1271 of file dt.h.

References Val.

1271 {Val|=UInt.Val; return *this;}
uint Val
Definition: dt.h:1244
TUInt& TUInt::operator~ ( )
inline

Definition at line 1269 of file dt.h.

1269 {Val=~Val; return *this;}
uint Val
Definition: dt.h:1244
void TUInt::Save ( TSOut SOut) const
inline

Definition at line 1255 of file dt.h.

References TSOut::Save().

Referenced by TSecTm::Save().

1255 {SOut.Save(Val);}
void Save(const bool &Bool)
Definition: fl.h:173
uint Val
Definition: dt.h:1244

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.

2082  {
2083  XSaveBETagArg(Nm, "Val", TInt::GetStr(Val));
2084 }
TStr GetStr() const
Definition: dt.h:1200
#define XSaveBETagArg(Nm, ArgNm, ArgVal)
Definition: bd.h:327
uint Val
Definition: dt.h:1244

Here is the call graph for this function:

Member Data Documentation

const uint TUInt::Mn =0
static

Definition at line 1246 of file dt.h.

Referenced by TUniCodec::GetRndUint().

TRnd TUInt::Rnd
static

Definition at line 1248 of file dt.h.


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