SNAP Library 4.0, Developer Reference  2017-07-27 13:18:06
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 1239 of file dt.h.

Constructor & Destructor Documentation

TUInt::TUInt ( )
inline

Definition at line 1247 of file dt.h.

Referenced by GetMemUsed().

1247 : Val(0){}
uint Val
Definition: dt.h:1241

Here is the caller graph for this function:

TUInt::TUInt ( const uint _Val)
inline

Definition at line 1248 of file dt.h.

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

Definition at line 1250 of file dt.h.

References TSIn::Load(), and Val.

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

Here is the call graph for this function:

Member Function Documentation

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

Definition at line 1288 of file dt.h.

References GetStr().

Referenced by GetMegaStr().

1288  {
1289  if (Val>100*1000){return GetStr(Val/1000)+"K";}
1290  else if (Val>1000){return GetStr(Val/1000)+"."+GetStr((Val%1000)/100)+"K";}
1291  else {return GetStr(Val);}}
TStr GetStr() const
Definition: dt.h:1279
uint Val
Definition: dt.h:1241

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

References GetKiloStr(), and GetStr().

1292  {
1293  if (Val>100*1000000){return GetStr(Val/1000000)+"M";}
1294  else if (Val>1000000){
1295  return GetStr(Val/1000000)+"."+GetStr((Val%1000000)/100000)+"M";}
1296  else {return GetKiloStr(Val);}}
static TStr GetKiloStr(const uint &Val)
Definition: dt.h:1288
TStr GetStr() const
Definition: dt.h:1279
uint Val
Definition: dt.h:1241

Here is the call graph for this function:

int TUInt::GetMemUsed ( ) const
inline

Definition at line 1272 of file dt.h.

References TUInt().

Referenced by TSecTm::GetMemUsed().

1272 {return sizeof(TUInt);}
TUInt()
Definition: dt.h:1247

Here is the call graph for this function:

Here is the caller graph for this function:

int TUInt::GetPrimHashCd ( ) const
inline

Definition at line 1274 of file dt.h.

References Val.

Referenced by TSecTm::GetPrimHashCd().

1274 {return int(Val);}
uint Val
Definition: dt.h:1241

Here is the caller graph for this function:

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

Definition at line 1277 of file dt.h.

References TRnd::GetUniDevUInt(), and Rnd.

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

Here is the call graph for this function:

int TUInt::GetSecHashCd ( ) const
inline

Definition at line 1275 of file dt.h.

References Val.

Referenced by TSecTm::GetSecHashCd().

1275 {return Val/0x10;}
uint Val
Definition: dt.h:1241

Here is the caller graph for this function:

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

Definition at line 1280 of file dt.h.

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

Definition at line 1282 of file dt.h.

References GetStr(), and Val.

1282  {
1283  return GetStr(UInt.Val);}
TStr GetStr() const
Definition: dt.h:1279
uint Val
Definition: dt.h:1241

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:1279
Definition: dt.h:412
uint Val
Definition: dt.h:1241

Here is the call graph for this function:

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

Definition at line 1285 of file dt.h.

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

1285  {
1286  return GetStr(Val, FmtStr.CStr());}
TStr GetStr() const
Definition: dt.h:1279
uint Val
Definition: dt.h:1241
char * CStr()
Definition: dt.h:476

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:476

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

References IsIpStr().

Referenced by IsIpStr().

1307 { 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 1298 of file dt.h.

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

Definition at line 1251 of file dt.h.

References TSIn::Load(), and Val.

Referenced by TSecTm::Load().

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

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:1241

Here is the call graph for this function:

TUInt::operator uint ( ) const
inline

Definition at line 1249 of file dt.h.

References Val.

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

Definition at line 1267 of file dt.h.

References Val.

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

Definition at line 1264 of file dt.h.

References Val.

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

Definition at line 1265 of file dt.h.

References Val.

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

Definition at line 1258 of file dt.h.

References Val.

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

Definition at line 1259 of file dt.h.

References Val.

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

Definition at line 1271 of file dt.h.

References Val.

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

Definition at line 1256 of file dt.h.

References Val.

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

Definition at line 1257 of file dt.h.

References Val.

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

Definition at line 1270 of file dt.h.

References Val.

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

Definition at line 1269 of file dt.h.

References Val.

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

Definition at line 1268 of file dt.h.

References Val.

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

Definition at line 1266 of file dt.h.

References Val.

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

Definition at line 1252 of file dt.h.

References TSOut::Save(), and Val.

Referenced by TSecTm::Save().

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

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:1197
#define XSaveBETagArg(Nm, ArgNm, ArgVal)
Definition: bd.h:327
uint Val
Definition: dt.h:1241

Here is the call graph for this function:

Member Data Documentation

const uint TUInt::Mn =0
static

Definition at line 1243 of file dt.h.

Referenced by TUniCodec::GetRndUint().

TRnd TUInt::Rnd
static

Definition at line 1245 of file dt.h.

Referenced by GetRnd().


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