SNAP Library 2.0, User Reference  2013-05-13 16:33:57
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>

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.

{ 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.

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

Definition at line 1685 of file unicode.h.

{ Close(); }

Member Function Documentation

Definition at line 1684 of file unicode.h.

{ putBackCh = EOF; if (f) { fclose(f); f = 0; }}
int TUniChDb::TUcdFileReader::GetCh ( ) [inline, protected]

Definition at line 1658 of file unicode.h.

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

Definition at line 1686 of file unicode.h.

                                              {
                        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; }}
void TUniChDb::TUcdFileReader::Open ( const TStr fileName) [inline]

Definition at line 1683 of file unicode.h.

{ Close(); f = fopen(fileName.CStr(), "rt"); IAssertR(f, fileName); putBackCh = EOF; }
TUcdFileReader& TUniChDb::TUcdFileReader::operator= ( const TUcdFileReader r) [inline, private]

Definition at line 1678 of file unicode.h.

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

Definition at line 1695 of file unicode.h.

                                                         {
                        int c; bool ok = s.IsHexInt(true, 0, 0x10ffff, c); IAssertR(ok, s); return c; }
static void TUniChDb::TUcdFileReader::ParseCodePointList ( const TStr s,
TIntV dest,
bool  ClrDestP = true 
) [inline, static]

Definition at line 1697 of file unicode.h.

                                                                                                 { // 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); } }
static void TUniChDb::TUcdFileReader::ParseCodePointRange ( const TStr s,
int &  from,
int &  to 
) [inline, static]

Definition at line 1703 of file unicode.h.

                                                                                   { // 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)); }
void TUniChDb::TUcdFileReader::PutBack ( int  c) [inline, protected]

Definition at line 1661 of file unicode.h.

{ Assert(putBackCh == EOF); putBackCh = c; }
bool TUniChDb::TUcdFileReader::ReadNextLine ( ) [inline, protected]

Definition at line 1663 of file unicode.h.

                                    {
                        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;*/}

Member Data Documentation

Definition at line 1652 of file unicode.h.

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

Definition at line 1656 of file unicode.h.

Definition at line 1657 of file unicode.h.


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