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
TUniChDb::TUcdFileReader Class Reference

#include <unicode.h>

Public Member Functions

 TUcdFileReader ()
 
 TUcdFileReader (const TStr &fileName)
 
void Open (const TStr &fileName)
 
void Close ()
 
 ~TUcdFileReader ()
 
bool GetNextLine (TStrV &dest)
 

Static Public Member Functions

static int ParseCodePoint (const TStr &s)
 
static void ParseCodePointList (const TStr &s, TIntV &dest, bool ClrDestP=true)
 
static void ParseCodePointRange (const TStr &s, int &from, int &to)
 

Public Attributes

TChA comment
 

Protected Member Functions

int GetCh ()
 
void PutBack (int c)
 
bool ReadNextLine ()
 

Protected Attributes

TChA buf
 
FILE * f
 
int putBackCh
 

Private Member Functions

TUcdFileReaderoperator= (const TUcdFileReader &r)
 
 TUcdFileReader (const TUcdFileReader &r)
 

Detailed Description

Definition at line 1649 of file unicode.h.

Constructor & Destructor Documentation

TUniChDb::TUcdFileReader::TUcdFileReader ( const TUcdFileReader r)
inlineprivate

Definition at line 1679 of file unicode.h.

1679 { Fail; }
#define Fail
Definition: bd.h:238
TUniChDb::TUcdFileReader::TUcdFileReader ( )
inline

Definition at line 1681 of file unicode.h.

1681 : f(0) { }
TUniChDb::TUcdFileReader::TUcdFileReader ( const TStr fileName)
inline

Definition at line 1682 of file unicode.h.

1682 : f(0), putBackCh(EOF) { Open(fileName); }
void Open(const TStr &fileName)
Definition: unicode.h:1683
TUniChDb::TUcdFileReader::~TUcdFileReader ( )
inline

Definition at line 1685 of file unicode.h.

1685 { Close(); }

Member Function Documentation

void TUniChDb::TUcdFileReader::Close ( )
inline

Definition at line 1684 of file unicode.h.

1684 { putBackCh = EOF; if (f) { fclose(f); f = 0; }}
int TUniChDb::TUcdFileReader::GetCh ( )
inlineprotected

Definition at line 1658 of file unicode.h.

1658  {
1659  if (putBackCh >= 0) { int c = putBackCh; putBackCh = EOF; return c; }
1660  return fgetc(f); }
bool TUniChDb::TUcdFileReader::GetNextLine ( TStrV dest)
inline

Definition at line 1686 of file unicode.h.

1686  {
1687  dest.Clr();
1688  while (true) {
1689  if (! ReadNextLine()) return false;
1690  TStr line = buf; line.ToTrunc();
1691  if (line.Len() <= 0) continue;
1692  line.SplitOnAllCh(';', dest, false);
1693  for (int i = 0; i < dest.Len(); i++) dest[i].ToTrunc();
1694  return true; }}
int Len() const
Definition: dt.h:487
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:547
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:971
Definition: dt.h:412
TStr & ToTrunc()
Definition: dt.cpp:770
void SplitOnAllCh(const char &SplitCh, TStrV &StrV, const bool &SkipEmpty=true) const
Definition: dt.cpp:926
void TUniChDb::TUcdFileReader::Open ( const TStr fileName)
inline

Definition at line 1683 of file unicode.h.

1683 { Close(); f = fopen(fileName.CStr(), "rt"); IAssertR(f, fileName); putBackCh = EOF; }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
char * CStr()
Definition: dt.h:476
TUcdFileReader& TUniChDb::TUcdFileReader::operator= ( const TUcdFileReader r)
inlineprivate

Definition at line 1678 of file unicode.h.

1678 { Fail; return *((TUcdFileReader *) 0); }
#define Fail
Definition: bd.h:238
static int TUniChDb::TUcdFileReader::ParseCodePoint ( const TStr s)
inlinestatic

Definition at line 1695 of file unicode.h.

1695  {
1696  int c; bool ok = s.IsHexInt(true, 0, 0x10ffff, c); IAssertR(ok, s); return c; }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
bool IsHexInt(const bool &Check, const int &MnVal, const int &MxVal, int &Val) const
Definition: dt.cpp:1190
static void TUniChDb::TUcdFileReader::ParseCodePointList ( const TStr s,
TIntV dest,
bool  ClrDestP = true 
)
inlinestatic

Definition at line 1697 of file unicode.h.

1697  { // space-separated list
1698  if (ClrDestP) dest.Clr();
1699  TStrV parts; s.SplitOnWs(parts);
1700  for (int i = 0; i < parts.Len(); i++) {
1701  int c; bool ok = parts[i].IsHexInt(true, 0, 0x10ffff, c); IAssertR(ok, s);
1702  dest.Add(c); } }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:547
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:971
void SplitOnWs(TStrV &StrV) const
Definition: dt.cpp:972
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:574
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:429
static void TUniChDb::TUcdFileReader::ParseCodePointRange ( const TStr s,
int &  from,
int &  to 
)
inlinestatic

Definition at line 1703 of file unicode.h.

1703  { // xxxx or xxxx..yyyy
1704  int i = s.SearchStr(".."); if (i < 0) { from = ParseCodePoint(s); to = from; return; }
1705  from = ParseCodePoint(s.GetSubStr(0, i - 1));
1706  to = ParseCodePoint(s.GetSubStr(i + 2, s.Len() - 1)); }
int Len() const
Definition: dt.h:487
TStr GetSubStr(const int &BChN, const int &EChN) const
Definition: dt.cpp:811
int SearchStr(const TStr &Str, const int &BChN=0) const
Definition: dt.cpp:1065
static int ParseCodePoint(const TStr &s)
Definition: unicode.h:1695
void TUniChDb::TUcdFileReader::PutBack ( int  c)
inlineprotected

Definition at line 1661 of file unicode.h.

1661 { Assert(putBackCh == EOF); putBackCh = c; }
#define Assert(Cond)
Definition: bd.h:251
bool TUniChDb::TUcdFileReader::ReadNextLine ( )
inlineprotected

Definition at line 1663 of file unicode.h.

1663  {
1664  buf.Clr(); comment.Clr();
1665  bool inComment = false, first = true;
1666  while (true) {
1667  int c = GetCh();
1668  if (c == EOF) return ! first;
1669  else if (c == 13) {
1670  c = GetCh(); if (c != 10) PutBack(c);
1671  return true; }
1672  else if (c == 10) return true;
1673  else if (c == '#') inComment = true;
1674  if (! inComment) buf += char(c);
1675  else comment += char(c); }
1676  /*first = false;*/}
void Clr()
Definition: dt.h:258

Member Data Documentation

TChA TUniChDb::TUcdFileReader::buf
protected

Definition at line 1652 of file unicode.h.

TChA TUniChDb::TUcdFileReader::comment

Definition at line 1654 of file unicode.h.

FILE* TUniChDb::TUcdFileReader::f
protected

Definition at line 1656 of file unicode.h.

int TUniChDb::TUcdFileReader::putBackCh
protected

Definition at line 1657 of file unicode.h.


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