SNAP Library 3.0, User Reference  2016-07-20 17:56:49
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>

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

Constructor & Destructor Documentation

TUInt::TUInt ( )
inline

Definition at line 1157 of file dt.h.

1157 : Val(0){}
uint Val
Definition: dt.h:1151
TUInt::TUInt ( const uint _Val)
inline

Definition at line 1158 of file dt.h.

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

Definition at line 1160 of file dt.h.

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

Member Function Documentation

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

Definition at line 1198 of file dt.h.

1198  {
1199  if (Val>100*1000){return GetStr(Val/1000)+"K";}
1200  else if (Val>1000){return GetStr(Val/1000)+"."+GetStr((Val%1000)/100)+"K";}
1201  else {return GetStr(Val);}}
TStr GetStr() const
Definition: dt.h:1189
uint Val
Definition: dt.h:1151
static TStr TUInt::GetMegaStr ( const uint Val)
inlinestatic

Definition at line 1202 of file dt.h.

1202  {
1203  if (Val>100*1000000){return GetStr(Val/1000000)+"M";}
1204  else if (Val>1000000){
1205  return GetStr(Val/1000000)+"."+GetStr((Val%1000000)/100000)+"M";}
1206  else {return GetKiloStr(Val);}}
static TStr GetKiloStr(const uint &Val)
Definition: dt.h:1198
TStr GetStr() const
Definition: dt.h:1189
uint Val
Definition: dt.h:1151
int TUInt::GetMemUsed ( ) const
inline

Definition at line 1182 of file dt.h.

1182 {return sizeof(TUInt);}
TUInt()
Definition: dt.h:1157
int TUInt::GetPrimHashCd ( ) const
inline

Definition at line 1184 of file dt.h.

1184 {return int(Val);}
uint Val
Definition: dt.h:1151
static uint TUInt::GetRnd ( const uint Range = 0)
inlinestatic

Definition at line 1187 of file dt.h.

1187 {return Rnd.GetUniDevUInt(Range);}
uint GetUniDevUInt(const uint &Range=0)
Definition: dt.cpp:45
static TRnd Rnd
Definition: dt.h:1155
int TUInt::GetSecHashCd ( ) const
inline

Definition at line 1185 of file dt.h.

1185 {return Val/0x10;}
uint Val
Definition: dt.h:1151
TStr TUInt::GetStr ( ) const
inline

Definition at line 1189 of file dt.h.

1189 {return TUInt::GetStr(Val);}
TStr GetStr() const
Definition: dt.h:1189
uint Val
Definition: dt.h:1151
static TStr TUInt::GetStr ( const uint Val)
inlinestatic

Definition at line 1190 of file dt.h.

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

Definition at line 1192 of file dt.h.

1192  {
1193  return GetStr(UInt.Val);}
TStr GetStr() const
Definition: dt.h:1189
uint Val
Definition: dt.h:1151
TStr TUInt::GetStr ( const uint Val,
const char *  FmtStr 
)
static

Definition at line 2086 of file dt.cpp.

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:1189
Definition: dt.h:412
uint Val
Definition: dt.h:1151
static TStr TUInt::GetStr ( const uint Val,
const TStr FmtStr 
)
inlinestatic

Definition at line 1195 of file dt.h.

1195  {
1196  return GetStr(Val, FmtStr.CStr());}
TStr GetStr() const
Definition: dt.h:1189
uint Val
Definition: dt.h:1151
char * CStr()
Definition: dt.h:476
TStr TUInt::GetStrFromIpUInt ( const uint Ip)
static

Definition at line 2117 of file dt.cpp.

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
uint TUInt::GetUIntFromIpStr ( const TStr IpStr,
const char &  SplitCh = '.' 
)
static

Definition at line 2107 of file dt.cpp.

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
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:429
bool TUInt::IsIpStr ( const TStr IpStr,
uint Ip,
const char &  SplitCh = '.' 
)
static

Definition at line 2096 of file dt.cpp.

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:547
void SplitOnAllCh(const char &SplitCh, TStrV &StrV, const bool &SkipEmpty=true) const
Definition: dt.cpp:926
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:429
static bool TUInt::IsIpStr ( const TStr IpStr,
const char &  SplitCh = '.' 
)
inlinestatic

Definition at line 1217 of file dt.h.

1217 { 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
bool TUInt::IsIpv6Str ( const TStr IpStr,
const char &  SplitCh = ':' 
)
static

Definition at line 2122 of file dt.cpp.

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:547
void SplitOnAllCh(const char &SplitCh, TStrV &StrV, const bool &SkipEmpty=true) const
Definition: dt.cpp:926
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:429
static uint TUInt::JavaUIntToCppUInt ( const uint JavaUInt)
inlinestatic

Definition at line 1208 of file dt.h.

1208  {
1209  uint B1=(JavaUInt & 0xFF000000) >> 24;
1210  uint B2=(JavaUInt & 0x00FF0000) >> 16;
1211  uint B3=(JavaUInt & 0x0000FF00) >> 8;
1212  uint B4=(JavaUInt & 0x000000FF) >> 0;
1213  uint CppUInt=(B4<<24)+(B3<<16)+(B2<<8)+(B1<<0);
1214  return CppUInt;}
unsigned int uint
Definition: bd.h:11
void TUInt::Load ( TSIn SIn)
inline

Definition at line 1161 of file dt.h.

1161 {SIn.Load(Val);}
void Load(bool &Bool)
Definition: fl.h:84
uint Val
Definition: dt.h:1151
void TUInt::LoadXml ( const PXmlTok XmlTok,
const TStr Nm 
)

Definition at line 2077 of file dt.cpp.

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:1151
TUInt::operator uint ( ) const
inline

Definition at line 1159 of file dt.h.

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

Definition at line 1177 of file dt.h.

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

Definition at line 1174 of file dt.h.

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

Definition at line 1175 of file dt.h.

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

Definition at line 1168 of file dt.h.

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

Definition at line 1169 of file dt.h.

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

Definition at line 1181 of file dt.h.

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

Definition at line 1166 of file dt.h.

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

Definition at line 1167 of file dt.h.

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

Definition at line 1180 of file dt.h.

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

Definition at line 1179 of file dt.h.

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

Definition at line 1178 of file dt.h.

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

Definition at line 1176 of file dt.h.

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

Definition at line 1162 of file dt.h.

1162 {SOut.Save(Val);}
void Save(const bool &Bool)
Definition: fl.h:173
uint Val
Definition: dt.h:1151
void TUInt::SaveXml ( TSOut SOut,
const TStr Nm 
) const

Definition at line 2082 of file dt.cpp.

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

Member Data Documentation

const uint TUInt::Mn =0
static

Definition at line 1153 of file dt.h.

const uint TUInt::Mx =UINT_MAX
static

Definition at line 1154 of file dt.h.

TRnd TUInt::Rnd
static

Definition at line 1155 of file dt.h.

uint TUInt::Val

Definition at line 1151 of file dt.h.


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