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

#include <unicode.h>

Collaboration diagram for TUniChDb::TUcdFileReader:

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.

References Fail.

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.

References Open().

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

Here is the call graph for this function:

TUniChDb::TUcdFileReader::~TUcdFileReader ( )
inline

Definition at line 1685 of file unicode.h.

References Close().

1685 { Close(); }

Here is the call graph for this function:

Member Function Documentation

int TUniChDb::TUcdFileReader::GetCh ( )
inlineprotected

Definition at line 1658 of file unicode.h.

References f, and putBackCh.

Referenced by ReadNextLine().

1658  {
1659  if (putBackCh >= 0) { int c = putBackCh; putBackCh = EOF; return c; }
1660  return fgetc(f); }

Here is the caller graph for this function:

bool TUniChDb::TUcdFileReader::GetNextLine ( TStrV dest)
inline

Definition at line 1686 of file unicode.h.

References buf, TVec< TVal, TSizeTy >::Clr(), TStr::Len(), TVec< TVal, TSizeTy >::Len(), ReadNextLine(), TStr::SplitOnAllCh(), and TStr::ToTrunc().

Referenced by TUniChDb::InitDerivedCoreProperties(), TUniChDb::InitLineBreaks(), TUniChDb::InitPropList(), TUniChDb::InitScripts(), TUniChDb::InitSpecialCasing(), TUniChDb::InitWordAndSentenceBoundaryFlags(), TUniCaseFolding::LoadTxt(), TUniChDb::LoadTxt(), TUniChDb::TestComposition(), and TUniChDb::TestFindNextWordOrSentenceBoundary().

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:575
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:1022
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

Here is the call graph for this function:

Here is the caller graph for this function:

void TUniChDb::TUcdFileReader::Open ( const TStr fileName)
inline

Definition at line 1683 of file unicode.h.

References Close(), TStr::CStr(), f, IAssertR, and putBackCh.

Referenced by TUniChDb::InitDerivedCoreProperties(), TUniChDb::InitLineBreaks(), TUniChDb::InitPropList(), TUniChDb::InitScripts(), TUniChDb::InitSpecialCasing(), TUniChDb::InitWordAndSentenceBoundaryFlags(), TUniCaseFolding::LoadTxt(), TUniChDb::LoadTxt(), TUniChDb::TestComposition(), TUniChDb::TestFindNextWordOrSentenceBoundary(), and TUcdFileReader().

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

Here is the call graph for this function:

Here is the caller graph for this function:

TUcdFileReader& TUniChDb::TUcdFileReader::operator= ( const TUcdFileReader r)
inlineprivate

Definition at line 1678 of file unicode.h.

References Fail.

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.

References IAssertR, and TStr::IsHexInt().

Referenced by TUniChDb::InitSpecialCasing(), TUniCaseFolding::LoadTxt(), TUniChDb::LoadTxt(), ParseCodePointRange(), and TUniChDb::TestFindNextWordOrSentenceBoundary().

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

Here is the call graph for this function:

Here is the caller graph for this function:

static void TUniChDb::TUcdFileReader::ParseCodePointList ( const TStr s,
TIntV dest,
bool  ClrDestP = true 
)
inlinestatic

Definition at line 1697 of file unicode.h.

References TVec< TVal, TSizeTy >::Add(), TVec< TVal, TSizeTy >::Clr(), IAssertR, TVec< TVal, TSizeTy >::Len(), and TStr::SplitOnWs().

Referenced by TUniChDb::InitSpecialCasing(), TUniCaseFolding::LoadTxt(), TUniChDb::LoadTxt_ProcessDecomposition(), TUniChDb::TestCaseConversion(), and TUniChDb::TestComposition().

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:575
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:1022
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:602

Here is the call graph for this function:

Here is the caller graph for this function:

static void TUniChDb::TUcdFileReader::ParseCodePointRange ( const TStr s,
int &  from,
int &  to 
)
inlinestatic

Definition at line 1703 of file unicode.h.

References TStr::GetSubStr(), TStr::Len(), ParseCodePoint(), and TStr::SearchStr().

Referenced by TUniChDb::InitDerivedCoreProperties(), TUniChDb::InitLineBreaks(), TUniChDb::InitPropList(), TUniChDb::InitScripts(), and TUniChDb::InitWordAndSentenceBoundaryFlags().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void TUniChDb::TUcdFileReader::PutBack ( int  c)
inlineprotected

Definition at line 1661 of file unicode.h.

References Assert, and putBackCh.

Referenced by ReadNextLine().

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

Here is the caller graph for this function:

bool TUniChDb::TUcdFileReader::ReadNextLine ( )
inlineprotected

Definition at line 1663 of file unicode.h.

References buf, TChA::Clr(), comment, GetCh(), and PutBack().

Referenced by GetNextLine().

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

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

TChA TUniChDb::TUcdFileReader::buf
protected

Definition at line 1652 of file unicode.h.

Referenced by GetNextLine(), and ReadNextLine().

TChA TUniChDb::TUcdFileReader::comment

Definition at line 1654 of file unicode.h.

Referenced by TUniChDb::TSubcatHelper::ProcessComment(), and ReadNextLine().

FILE* TUniChDb::TUcdFileReader::f
protected

Definition at line 1656 of file unicode.h.

Referenced by Close(), GetCh(), and Open().

int TUniChDb::TUcdFileReader::putBackCh
protected

Definition at line 1657 of file unicode.h.

Referenced by Close(), GetCh(), Open(), and PutBack().


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