SNAP Library 2.1, Developer Reference  2013-09-25 10:47:25
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TUniChDb::TUcdFileReader Class Reference

#include <unicode.h>

Collaboration diagram for TUniChDb::TUcdFileReader:

List of all members.

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) [inline, private]

Definition at line 1679 of file unicode.h.

References Fail.

{ Fail; }

Definition at line 1681 of file unicode.h.

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

Definition at line 1682 of file unicode.h.

References Open().

: f(0), putBackCh(EOF) { Open(fileName); }

Here is the call graph for this function:

Definition at line 1685 of file unicode.h.

References Close().

{ Close(); }

Here is the call graph for this function:


Member Function Documentation

int TUniChDb::TUcdFileReader::GetCh ( ) [inline, protected]

Definition at line 1658 of file unicode.h.

References f, and putBackCh.

Referenced by ReadNextLine().

                            {
                        if (putBackCh >= 0) { int c = putBackCh; putBackCh = EOF; return c; }
                        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().

                                              {
                        dest.Clr();
                        while (true) {
                                if (! ReadNextLine()) return false;
                                TStr line = buf; line.ToTrunc();
                                if (line.Len() <= 0) continue;
                                line.SplitOnAllCh(';', dest, false);
                                for (int i = 0; i < dest.Len(); i++) dest[i].ToTrunc();
                                return true; }}

Here is the call graph for this function:

Here is the caller graph for this function:

TUcdFileReader& TUniChDb::TUcdFileReader::operator= ( const TUcdFileReader r) [inline, private]

Definition at line 1678 of file unicode.h.

References Fail.

{ Fail; return *((TUcdFileReader *) 0); }
static int TUniChDb::TUcdFileReader::ParseCodePoint ( const TStr s) [inline, static]

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

                                                         {
                        int c; bool ok = s.IsHexInt(true, 0, 0x10ffff, c); IAssertR(ok, s); return c; }

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 
) [inline, static]

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

                                                                                                 { // space-separated list
                        if (ClrDestP) dest.Clr();
                        TStrV parts; s.SplitOnWs(parts);
                        for (int i = 0; i < parts.Len(); i++) {
                                int c; bool ok = parts[i].IsHexInt(true, 0, 0x10ffff, c); IAssertR(ok, s);
                                dest.Add(c); } }

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 
) [inline, static]

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

                                                                                   { // xxxx or xxxx..yyyy
                        int i = s.SearchStr(".."); if (i < 0) { from = ParseCodePoint(s); to = from; return; }
                        from = ParseCodePoint(s.GetSubStr(0, i - 1));
                        to = ParseCodePoint(s.GetSubStr(i + 2, s.Len() - 1)); }

Here is the call graph for this function:

Here is the caller graph for this function:

void TUniChDb::TUcdFileReader::PutBack ( int  c) [inline, protected]

Definition at line 1661 of file unicode.h.

References Assert, and putBackCh.

Referenced by ReadNextLine().

{ Assert(putBackCh == EOF); putBackCh = c; }

Here is the caller graph for this function:

bool TUniChDb::TUcdFileReader::ReadNextLine ( ) [inline, protected]

Definition at line 1663 of file unicode.h.

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

Referenced by GetNextLine().

                                    {
                        buf.Clr(); comment.Clr();
                        bool inComment = false, first = true;
                        while (true) {
                                int c = GetCh();
                                if (c == EOF) return ! first;
                                else if (c == 13) {
                                        c = GetCh(); if (c != 10) PutBack(c);
                                        return true; }
                                else if (c == 10) return true;
                                else if (c == '#') inComment = true;
                                if (! inComment) buf += char(c);
                                else comment += char(c); }
                                /*first = false;*/}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 1652 of file unicode.h.

Referenced by GetNextLine(), and ReadNextLine().

FILE* TUniChDb::TUcdFileReader::f [protected]

Definition at line 1656 of file unicode.h.

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

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: