#include "hadascii.h"

HAscii


class description - source file - inheritance tree (.pdf)

class HAscii : public TObject

Inheritance Chart:
TObject
<-
HAscii
<-
HAsciiKey
HAsciiRaw

    protected:
HAsciiSection* CheckActiveSection() Bool_t CheckData() Bool_t CheckDataPosition(Int_t pos) Bool_t CheckDataType(Char_t typ) Char_t* CheckFileList(HAsciiFileList& list, Char_t* name) Bool_t CheckSection() Bool_t CheckUnambiguitySection() void CloseOpenedFile() Char_t* ConvertToChar() Float_t* ConvertToFloat() Int_t* ConvertToInt() Char_t* ConvertToString() Char_t* CorrectName(Char_t* name) Char_t* ReadKeywordLine(const Char_t* name = "0") void Reset() void ResetBankData() void ResetKeyData() public:
HAscii() HAscii(const HAscii& source) virtual ~HAscii() Bool_t CheckOpenedFile() static TClass* Class() void CloseFile(const Char_t* filename = "0") Bool_t CopySection(const Char_t* sec) HAsciiFile* GetActiveFile() Char_t* GetActiveKeyword() HAsciiSection* GetActiveSection() Char_t* GetCommentKeyword() Int_t GetNumInLine() Char_t GetSeparator() virtual TClass* IsA() const Bool_t IsNextKeyword() Bool_t IsReadFile() Bool_t IsWriteFile() fstream& OpenFile(const Char_t* filename, const Char_t* mode = "read") void OpenFileList(const Char_t* filename) HAscii& operator=(const HAscii& source) Char_t* ReadRemark() Char_t* ReadString() Char_t* ReadString(const Char_t* key) Char_t* ReadString(const Char_t* sec, const Char_t* key) HAsciiSection* SetActiveSection(const Char_t* name) void SetNumInLine(Int_t num = 16) void SetSeparator(Char_t character = ) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b) void WriteError() Bool_t WriteLine(const Char_t* text, Int_t linelen = 76, Int_t keylen = 0) Bool_t WriteRemark(const Char_t* text, Char_t sign = ;, Int_t linelen = 76) Bool_t WriteSection(const Char_t* name)

Data Members

    private:
Long_t fReadAllPosition - position during reading sequentially all data protected:
HAsciiFileList fFileList - list of files and every file has its list of sections Char_t fSeparator - character used as separator (space, tab or comma) Char_t fKeyLine[128] - keyword name Int_t fDataLineLength - length of string containing data Char_t* fpDataLine - string with data as dynamically allocated array Char_t* fpCommentLine - string with commentary line Char_t* fpRemarkLine Int_t fDataCounter - number of data units of given type for keyword just read Int_t fDataBank - data bank id specifying type of data Int_t* fpDataInt Float_t* fpDataFloat Char_t* fpDataChar Char_t* fpDataString HAsciiSection* fpActiveSection - auxiliary pointer to active section HAsciiFile* fpActiveFile - auxiliary pointer to file containing active section Int_t fFileWriteState - writing file status, if file opened it is 1, 2 or 3 Char_t fFileWriteName[128] - file name opened in write mode Int_t fNumInLine - number of units (digits, characters) in line to be written public:
fstream fStreamFileWrite - stream object handling file writing

Class Description


 HAsciiSectionRaw

 Internal class used only in case of reading data in "raw" format.
 It contains information of the structure of raw data like number
 of columns, keys (keywords) names, as well as all the data banks.


 ***************************************************************************

HAscii() : fDataLineLength(0),fDataCounter(0), fDataBank(0)
 Default constructor. It resets all data and sets pointers to NULL.

~HAscii()
 Destructor releases memory allocated dynamically.

HAscii(const HAscii& source)

Char_t* CorrectName(Char_t* name)
 Function called while opening file error happened to correct file name.

Char_t* CheckFileList(HAsciiFileList& list, Char_t* name)
 It checks if file of given name is not already opened.

void WriteError()
 It checks if the error has happened during write opetarion.

void Reset()
 Resetting data of file (in write mode).

void SetSeparator(Char_t character)
 Setting separator for data units (only space, tabulation 't' or comma allowed).

Char_t GetSeparator()
 Getting current separator character for data units.

void CloseOpenedFile()
 Checking if file in write mode is opened (and closing it if yes)
 in case you want to open a new file in write mode.

fstream& OpenFile(const Char_t* filename, const Char_t* mode)
 Opening ASCII file with given 'filename' and 'mode'.

  Modes available:
  "read" or "in"
   - read mode (it is default). Unlimited number of files
     can be opened in read mode.
  "new" or "out" or "create" or "write"
   - write mode. A new file is created but only if there is
     no file with the same 'filename' existing. Only one file
     can be opened in write mode at the same time.
  "update"
   - opens existing file for writing at the end of it (to append data).
  "recreate" or "overwrite"
   - creates a new file or replaces existing in write mode.

void OpenFileList(const Char_t* filename)
 It opens and reads ASCII file with the list of files and opens all of them.
 The file with file list must be in the following syntax:
 section - 'ASCIIFileList'
 keyword - 'Files', followed by string containing all file names (and
 optionally mode), separated by commas.

 Example of file containing list of files to be opened:

  [ASCII File List]
  ; you may put commentaries, as well

  Files = mdcinit.txt, richpads.txt read,
   showercal_data.dat,
   tofcal.txt read , /scratch/tofini.dat

void CloseFile(const Char_t* filename)
 Closing file of given filename or all opened files if no filename specified.

HAsciiFile* GetActiveFile()
 Pointer to active file (that file which contains active section).

HAsciiSection* GetActiveSection()
 Pointer to active section.

Bool_t CheckUnambiguitySection()
 It checks if a new section name is  unambiguous with relation
 to previously stored while initializing next section list.

HAsciiSection* CheckActiveSection()
 Additional checking and if necessary reinitialization of section list, now not used.

HAsciiSection* SetActiveSection(const Char_t* name)
 Function for section selection. Before reading any data active
 section has to be chosen.

void ResetKeyData()
 It resets variables holding keyword information
 like name, length, data string, commentary string.

void ResetBankData()
 Resetting data bank and bank id.

Bool_t CheckSection()
 Checking if section is selected.

Bool_t CheckData()
 Checking if keyword just read has any data.

Bool_t CheckDataType(Char_t typ)
 It checks whether the call for next data unit of keyword just read
 is of the same type as while keyword reading (this is when
 calling for data without keyword specified but with type
 specified and then it is assumed to read data of last keyword read.

Bool_t CheckDataPosition(Int_t pos)
 Checking if pos is not larger than number of data units;
 in case of string there is always only 1 unit.

Char_t* GetActiveKeyword()
 It returns keyword just read (active keyword).

Char_t* GetCommentKeyword()
 Returning of commentary to the last read keyword if there was any.

Char_t* ReadString()
 Getting string data from data bank if they are present there.

Char_t* ReadString(const Char_t* key)
 Reading data of given keyword key as string.

Char_t* ReadString(const Char_t* sec, const Char_t* key)
 Reading data of given keyword key in section sec as string.

Char_t* ReadRemark()
 It returns commentary to the active section if there is any.

void SetNumInLine(Int_t num)
 Setting number of digits (characters) in one line to which
 writing of ASCII line will be formatted. Default is 16.

Int_t GetNumInLine()
 Number of units (digits, characters) to which written an ASCII line
 will be formatted.

Bool_t CheckOpenedFile()
 Checking if file in write mode is opened.

Bool_t IsReadFile()
 Returns kTRUE if any file in read mode is opened.

Bool_t IsWriteFile()
 Returns kTRUE if a file in write mode is currently opened.

Bool_t WriteLine(const Char_t* text, Int_t linelen, Int_t keylen)
 Writing ASCII line text with given length linelen taking into
 consideration that the first line may follow keyword of given length keylen.

Bool_t WriteRemark(const Char_t* text, Char_t sign, Int_t linelen)
 Writing remark text starting line from sing # or ; (default)
 with a line of length linelen.

Bool_t WriteSection(const Char_t* name)
 Writing section name, brackets [ ] are added automatically.

Bool_t CopySection(const Char_t* sec)
 Copying (writing) section sec if there is any.

Bool_t IsNextKeyword()
 Testing if in given section starting from position fReadAllPosition
 there is any keyword to be read. It is used in case of sequential data
 reading to control the loop and to stop if there are no more keywords
 to be read (i.e. we achieved the end of the section).

Char_t* ReadKeywordLine(const Char_t* name)
 Reading keyword name and keyword data as string from ASCII file.
 If keyword is not specified the sequential reading is done. Reading
 starts then from position fReadAllPosition and every next call of this
 function makes reading of next keyword (with data) until the end of section.
 If you want to read the section sequentially again you nedd to set it
 again as active section (and then fReadAllPosition is resetted).

Int_t* ConvertToInt()
 Conversion of string of data stored in fpDataLine to units of Int_t type.

Float_t* ConvertToFloat()
 Conversion of string of data stored in fpDataLine to units of Float_t type.

Char_t* ConvertToChar()
 Conversion of string of data stored in fpDataLine to units of Char_t type.
 Char_t unit is a single Char_t separated in string by white space or comma.

Char_t* ConvertToString()
 Conversion of string of data stored in fpDataLine to string unit.
 If string begins and ends with quotation marks they are removed.
 String unit is a set of characters terminated by '0'.



Inline Functions


            HAscii& operator=(const HAscii& source)
            TClass* Class()
            TClass* IsA() const
               void ShowMembers(TMemberInspector& insp, char* parent)
               void Streamer(TBuffer& b)
               void StreamerNVirtual(TBuffer& b)


Author: Witold Przygoda (przygoda@psja1.if.uj.edu.pl)
Last update: 2001/08/20 by Witold Przygoda


ROOT page - Class index - Class Hierarchy - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.