TextFile Class Reference

TextFile class implementation. More...

Inherits Simba::Support::IFile.

List of all members.

Public Member Functions

virtual void Clear ()
 Erase contents of the current file, setting the size to 0.
virtual void Close ()
 Closes this file.
virtual simba_int64 Extend (simba_int64 in_size)
 Extend the file to a size of precisely length bytes. If the file previously was shorter, it is extended, and the content of extended part is not defined. If the file was same size, it is not extended and the actual size of the file is returned. If the file previously was larger than this size, return -1.
virtual void Flush ()
 Flush text to file.
virtual const simba_wstringGetName () const
 Gets the file name.
virtual simba_int64 GetPosition ()
 Gets current file position.
simba_size_t GetSize ()
 Gets the size of the file in bytes.
virtual bool IsOpen ()
 Determines if file is currently open.
void LockFile ()
 Create an interprocess-lock based on this file and the OpenMode used to create this file.
virtual simba_int64 Read (void *io_buffer, simba_int64 in_size)
 Read from the file into buffer.
bool ReadLine (simba_string &out_line)
 Read text from the file into string.
virtual bool ReOpen (FileOpenMode in_openmode)
 Re-open file with new mode.
virtual simba_int64 Seek (simba_int64 in_position, SeekDirection in_direction)
 Navigate to the certain position within file.
 TextFile (const simba_wstring &in_filename, simba_filehandle in_handle)
 Constructor. Wraps an existing file handle. The TextFile does not take ownership of the file handle.
 TextFile (const simba_wstring &in_fileName, FileOpenMode in_openMode)
 Constructor.
void Truncate ()
 Truncates this file to zero bytes.
void TruncateAtCurrent ()
 Truncates this file to the current position.
void UnlockFile ()
 Unlock this file if it was locked using LockFile().
virtual simba_int64 Write (const void *in_buffer, simba_int64 in_length)
 Write raw data to the file.
void WriteFormattedString (const simba_char *in_format, va_list &in_varArgs)
 Write a formatted string.
void WriteFormattedString (const simba_string &in_format, va_list &in_varArgs)
 Write a formatted string.
void WriteLine (const simba_char *in_str, simba_size_t in_length)
 Write string and end of line.
void WriteLine (const simba_char *in_str)
 Write string and end of line.
void WriteLine (const simba_string &in_str)
 Write string and end of line.
void WriteLine (const simba_wstring &in_str)
 Write string and end of line.
void WriteLine ()
 Write a blank line.
void WriteString (const simba_char *in_str, simba_size_t in_length)
 Write the given string.
void WriteString (const simba_char *in_str)
 Write the given string.
void WriteString (const simba_string &in_str)
 Write the given string.
void WriteString (const simba_wstring &in_str)
 Write the given string.
 ~TextFile ()
 Destructor.

Detailed Description

TextFile class implementation.


Constructor & Destructor Documentation

TextFile ( const simba_wstring in_fileName,
FileOpenMode  in_openMode 
)

Constructor.

Parameters:
in_fileName File name.
in_openMode Open mode.
TextFile ( const simba_wstring in_filename,
simba_filehandle  in_handle 
)

Constructor. Wraps an existing file handle. The TextFile does not take ownership of the file handle.

Parameters:
in_filename The name of the file associated with the handle.
in_handle The file handle to wrap. This does not get closed on destruction.
~TextFile (  ) 

Destructor.


Member Function Documentation

virtual void Clear (  )  [virtual]

Erase contents of the current file, setting the size to 0.

Exceptions:
ErrorException if there was an error clearing the file.

Implements IFile.

virtual void Close (  )  [virtual]

Closes this file.

Implements IFile.

virtual simba_int64 Extend ( simba_int64  in_size  )  [virtual]

Extend the file to a size of precisely length bytes. If the file previously was shorter, it is extended, and the content of extended part is not defined. If the file was same size, it is not extended and the actual size of the file is returned. If the file previously was larger than this size, return -1.

Parameters:
in_size New size in bytes.
Returns:
The new size of the file or -1.

Implements IFile.

virtual void Flush (  )  [virtual]

Flush text to file.

Implements IFile.

virtual const simba_wstring& GetName (  )  const [virtual]

Gets the file name.

Returns:
The name of the binary file.

Implements IFile.

virtual simba_int64 GetPosition (  )  [virtual]

Gets current file position.

Returns:
Absolute position from the beginning of the file. Returns -1 on error.

Implements IFile.

simba_size_t GetSize (  ) 

Gets the size of the file in bytes.

Returns:
The size of the file in bytes.
virtual bool IsOpen (  )  [virtual]

Determines if file is currently open.

Returns:
True if file is open; false otherwise.

Implements IFile.

void LockFile (  ) 

Create an interprocess-lock based on this file and the OpenMode used to create this file.

virtual simba_int64 Read ( void *  io_buffer,
simba_int64  in_size 
) [virtual]

Read from the file into buffer.

Parameters:
io_buffer Buffer to read into.
in_size Size of the provided buffer.
Returns:
Number of bytes read.

Implements IFile.

bool ReadLine ( simba_string out_line  ) 

Read text from the file into string.

The output string does not include trailing '
' (or \r\n on Windows).

Parameters:
out_line The line read as a string.
Returns:
false if at end of the file, true otherwise.
virtual bool ReOpen ( FileOpenMode  in_openmode  )  [virtual]

Re-open file with new mode.

Parameters:
in_openmode Open mode as defined in OPENMODE enum.
Returns:
true on success; false otherwise.

Implements IFile.

virtual simba_int64 Seek ( simba_int64  in_position,
SeekDirection  in_direction 
) [virtual]

Navigate to the certain position within file.

Parameters:
in_position Offset from the current position.
in_direction Direction.
Returns:
Absolute position from the beginning of the file. Returns -1 on error.

Implements IFile.

void Truncate (  ) 

Truncates this file to zero bytes.

This file must have been created with a write OpenMode.

void TruncateAtCurrent (  ) 

Truncates this file to the current position.

This file must have been created with a write OpenMode.

void UnlockFile (  ) 

Unlock this file if it was locked using LockFile().

This is called automatically when the file is destroyed.

virtual simba_int64 Write ( const void *  in_buffer,
simba_int64  in_length 
) [virtual]

Write raw data to the file.

Parameters:
in_buffer Buffer containing data to write. (NOT OWN)
in_length Length of the raw data.
Returns:
number of bytes written.

Implements IFile.

void WriteFormattedString ( const simba_char in_format,
va_list &  in_varArgs 
)

Write a formatted string.

Parameters:
in_format The printf-style format string. (NOT OWN)
in_varArgs The variable argument list.
void WriteFormattedString ( const simba_string in_format,
va_list &  in_varArgs 
)

Write a formatted string.

Parameters:
in_format The printf-style format string.
in_varArgs The variable argument list.
void WriteLine ( const simba_char in_str,
simba_size_t  in_length 
)

Write string and end of line.

Parameters:
in_str String to write. (NOT OWN)
in_length The length of the string to write.
void WriteLine ( const simba_char in_str  ) 

Write string and end of line.

Parameters:
in_str String to write. (NOT OWN)
void WriteLine ( const simba_string in_str  ) 

Write string and end of line.

Parameters:
in_str String to write.
void WriteLine ( const simba_wstring in_str  ) 

Write string and end of line.

Parameters:
in_str String to write.
void WriteLine (  ) 

Write a blank line.

void WriteString ( const simba_char in_str,
simba_size_t  in_length 
)

Write the given string.

Parameters:
in_str String to write. (NOT OWN)
in_length The length of the string to write.
void WriteString ( const simba_char in_str  ) 

Write the given string.

Parameters:
in_str String to write. (NOT OWN)
void WriteString ( const simba_string in_str  ) 

Write the given string.

Parameters:
in_str String to write.
void WriteString ( const simba_wstring in_str  ) 

Write the given string.

Parameters:
in_str String to write.

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

Generated on Wed May 17 14:21:19 2017 for SimbaEngine 10.1.3.1011 by simba