A Discrete-Event Network Simulator
API
ns3::AsciiFile Class Reference

A class representing an ascii file. More...

#include "ascii-file.h"

+ Collaboration diagram for ns3::AsciiFile:

Public Member Functions

 AsciiFile ()
 
 ~AsciiFile ()
 
void Close (void)
 Close the underlying file. More...
 
bool Eof (void) const
 
bool Fail (void) const
 
void Open (std::string const &filename, std::ios::openmode mode)
 Create a new ascii file or open an existing ascii file. More...
 
void Read (std::string &line)
 Read next line from file. More...
 

Static Public Member Functions

static bool Diff (std::string const &f1, std::string const &f2, uint64_t &lineNumber)
 Compare two ASCII files line-by-line. More...
 

Private Attributes

std::fstream m_file
 output file More...
 
std::string m_filename
 output file name More...
 

Detailed Description

A class representing an ascii file.

This class represents an ascii file

Definition at line 38 of file ascii-file.h.

Constructor & Destructor Documentation

ns3::AsciiFile::AsciiFile ( )

Definition at line 35 of file ascii-file.cc.

References m_file, and ns3::FatalImpl::RegisterStream().

+ Here is the call graph for this function:

ns3::AsciiFile::~AsciiFile ( )

Definition at line 41 of file ascii-file.cc.

References Close(), m_file, and ns3::FatalImpl::UnregisterStream().

+ Here is the call graph for this function:

Member Function Documentation

void ns3::AsciiFile::Close ( void  )

Close the underlying file.

Definition at line 59 of file ascii-file.cc.

References m_file.

Referenced by ~AsciiFile().

+ Here is the caller graph for this function:

bool ns3::AsciiFile::Diff ( std::string const &  f1,
std::string const &  f2,
uint64_t &  lineNumber 
)
static

Compare two ASCII files line-by-line.

Returns
true if files are different, false otherwise
Parameters
f1First ASCII file name
f2Second ASCII file name
lineNumber[out] Line number of first different line.

Definition at line 83 of file ascii-file.cc.

References Eof(), Fail(), Open(), and Read().

+ Here is the call graph for this function:

bool ns3::AsciiFile::Eof ( void  ) const
Returns
true if the 'eof' bit is set in the underlying iostream, false otherwise.

Definition at line 53 of file ascii-file.cc.

References m_file.

Referenced by Diff().

+ Here is the caller graph for this function:

bool ns3::AsciiFile::Fail ( void  ) const
Returns
true if the 'fail' bit is set in the underlying iostream, false otherwise.

Definition at line 48 of file ascii-file.cc.

References m_file.

Referenced by Diff().

+ Here is the caller graph for this function:

void ns3::AsciiFile::Open ( std::string const &  filename,
std::ios::openmode  mode 
)

Create a new ascii file or open an existing ascii file.

Parameters
filenameString containing the name of the file.
modethe access mode for the file.

Definition at line 65 of file ascii-file.cc.

References m_file, and NS_ASSERT.

Referenced by Diff().

+ Here is the caller graph for this function:

void ns3::AsciiFile::Read ( std::string &  line)

Read next line from file.

Parameters
line[out] line from file

Definition at line 74 of file ascii-file.cc.

References m_file, and NS_ASSERT.

Referenced by Diff().

+ Here is the caller graph for this function:

Member Data Documentation

std::fstream ns3::AsciiFile::m_file
private

output file

Definition at line 89 of file ascii-file.h.

Referenced by AsciiFile(), Close(), Eof(), Fail(), Open(), Read(), and ~AsciiFile().

std::string ns3::AsciiFile::m_filename
private

output file name

Definition at line 88 of file ascii-file.h.


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