Class TextFile

Index Home MAE > MAE Architecture > MAE Data Types > Class Index > Class TextFile

Summary
Public Methods
TextFile(filename)
TextFile(f)
bool valid() const
void clear()
TextFile& setFilename(filename)
inline const string& getFilename() const
bool load(filename)
bool load(f)
bool collect(command)
bool save(filename)
bool save(f)
bool hasChanged() const
inline bool empty() const
inline unsigned int noLines() const
inline unsigned int getLineNo() const
inline unsigned int getLinePos() const
const string& getLine(line_no) const
int getLineLength(line_no) const
bool isBlankLine(line_no) const
bool isCommentLine(line_no) const
inline string getLineToken(token_no, line_no)
vector getLineTokens(separator, line_no) const
bool setLine(newLine, line_no)
bool rmLine(line_no)
bool addLine(newline, line_no)
bool addText(text, line_no)
bool addText(text, line_no)
inline bool appendLine(newLine)
bool findText(text, fromTop)
inline void setTextPattern(pattern)
inline const string& getTextPattern() const
bool isCFile() const
bool isScriptFile() const
bool setLineNo(line_no, line_pos)
bool setLinePos(line_pos)
int getchar(reverse)
inline int peekchar(reverse)
bool ungetchar()
int putchar(c)
const string& gets()
int puts(line)
bool eof(line_no) const
bool bof(line_no) const
bool bol(line_pos) const
bool eol(line_pos) const
bool eol(line_no, line_pos) const
string getPriorIdentifer(line_no, line_pos) const
string toString(lineSeparator) const
int fromString(text)
Private Properties

#include <TextFile.h >

Summary

Class to manage a text file as a whole.

Public Methods

TextFile(filename)

const string& filename

Default value: ""


TextFile(f)

FILE* f


bool valid() const

void clear()

TextFile& setFilename(filename)

const string& filename


inline const string& getFilename() const

bool load(filename)

const string& filename

Default value: ""


bool load(f)

FILE* f


bool collect(command)

const string& command


bool save(filename)

const string& filename

Default value: ""


bool save(f)

FILE* f


bool hasChanged() const

inline bool empty() const

inline unsigned int noLines() const

inline unsigned int getLineNo() const

inline unsigned int getLinePos() const

const string& getLine(line_no) const

unsigned int line_no

Default value: 0


0 for current line

int getLineLength(line_no) const

unsigned int line_no

Default value: 0


0 for current line

bool isBlankLine(line_no) const

unsigned int line_no

Default value: 0


0 length or all whitespace

bool isCommentLine(line_no) const

unsigned int line_no

Default value: 0


line starts with "#", possibly whitespace before it

inline string getLineToken(token_no, line_no)

int token_no

Default value: 0

unsigned int line_no

Default value: 0


vector <string > getLineTokens(separator, line_no) const

const string& separator

Default value: ""

unsigned int line_no

Default value: 0


parse line into tokens

bool setLine(newLine, line_no)

const string& newLine

unsigned int line_no

Default value: 0


0 for current line

bool rmLine(line_no)

unsigned int line_no

Default value: 0


bool addLine(newline, line_no)

const string& newline

unsigned int line_no

Default value: 0


add before identified line

bool addText(text, line_no)

const string& text

unsigned int line_no

Default value: 0


add multiple lines at once

bool addText(text, line_no)

const vector <string >& text

unsigned int line_no

Default value: 0


add multiple lines at once

inline bool appendLine(newLine)

const string& newLine


bool findText(text, fromTop)

const string& text

bool fromTop

Default value: false


inline void setTextPattern(pattern)

const string& pattern


inline const string& getTextPattern() const

bool isCFile() const

bool isScriptFile() const

bool setLineNo(line_no, line_pos)

unsigned int line_no

unsigned int line_pos

Default value: 0


bool setLinePos(line_pos)

unsigned int line_pos


int getchar(reverse)

bool reverse

Default value: false


inline int peekchar(reverse)

bool reverse

Default value: false


bool ungetchar()

int putchar(c)

int c


inserted before current position

const string& gets()

int puts(line)

const string& line


bool eof(line_no) const

unsigned int line_no

Default value: 0


bool bof(line_no) const

unsigned int line_no

Default value: 0


bool bol(line_pos) const

unsigned int line_pos

Default value: 0


bool eol(line_pos) const

unsigned int line_pos

Default value: 0


bool eol(line_no, line_pos) const

unsigned int line_no

unsigned int line_pos


string getPriorIdentifer(line_no, line_pos) const

unsigned int line_no

Default value: 0

unsigned int line_pos

Default value: 0


on same line

string toString(lineSeparator) const

const string& lineSeparator

Default value: "\n"


int fromString(text)

const string& text


Private Properties

string filename

vector <string > line

unsigned int line_no

starting value is 1 (not 0)

unsigned int line_pos

starting value is 1 (not 0)

string pattern

bool changed

Flag: true if data was changed and needs to be saved