A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
ascii-file.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012 University of Washington
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mitch Watrous (watrous@u.washington.edu)
7
*
8
* This file is based on pcap-file.h by Craig Dowell (craigdo@ee.washington.edu)
9
*/
10
11
#ifndef ASCII_FILE_H
12
#define ASCII_FILE_H
13
14
#include <fstream>
15
#include <stdint.h>
16
#include <string>
17
18
namespace
ns3
19
{
20
21
/**
22
* \brief A class representing an ascii file.
23
*
24
* This class represents an ascii file
25
*/
26
class
AsciiFile
27
{
28
public
:
29
AsciiFile
();
30
~AsciiFile
();
31
32
/**
33
* \return true if the 'fail' bit is set in the underlying iostream, false otherwise.
34
*/
35
bool
Fail
()
const
;
36
/**
37
* \return true if the 'eof' bit is set in the underlying iostream, false otherwise.
38
*/
39
bool
Eof
()
const
;
40
41
/**
42
* Create a new ascii file or open an existing ascii file.
43
*
44
* \param filename String containing the name of the file.
45
* \param mode the access mode for the file.
46
*/
47
void
Open
(
const
std::string& filename, std::ios::openmode mode);
48
49
/**
50
* Close the underlying file.
51
*/
52
void
Close
();
53
54
/**
55
* \brief Read next line from file
56
*
57
* \param line [out] line from file
58
*
59
*/
60
void
Read
(std::string& line);
61
62
/**
63
* \brief Compare two ASCII files line-by-line
64
*
65
* \return true if files are different, false otherwise
66
*
67
* \param f1 First ASCII file name
68
* \param f2 Second ASCII file name
69
* \param lineNumber [out] Line number of first different line.
70
*/
71
static
bool
Diff
(
const
std::string& f1,
const
std::string& f2, uint64_t& lineNumber);
72
73
private
:
74
std::string
m_filename
;
//!< output file name
75
std::fstream
m_file
;
//!< output file
76
};
77
78
}
// namespace ns3
79
80
#endif
/* ASCII_FILE_H */
ns3::AsciiFile
A class representing an ascii file.
Definition
ascii-file.h:27
ns3::AsciiFile::Eof
bool Eof() const
Definition
ascii-file.cc:46
ns3::AsciiFile::Close
void Close()
Close the underlying file.
Definition
ascii-file.cc:52
ns3::AsciiFile::Fail
bool Fail() const
Definition
ascii-file.cc:40
ns3::AsciiFile::AsciiFile
AsciiFile()
Definition
ascii-file.cc:27
ns3::AsciiFile::m_file
std::fstream m_file
output file
Definition
ascii-file.h:75
ns3::AsciiFile::m_filename
std::string m_filename
output file name
Definition
ascii-file.h:74
ns3::AsciiFile::~AsciiFile
~AsciiFile()
Definition
ascii-file.cc:33
ns3::AsciiFile::Open
void Open(const std::string &filename, std::ios::openmode mode)
Create a new ascii file or open an existing ascii file.
Definition
ascii-file.cc:58
ns3::AsciiFile::Read
void Read(std::string &line)
Read next line from file.
Definition
ascii-file.cc:67
ns3::AsciiFile::Diff
static bool Diff(const std::string &f1, const std::string &f2, uint64_t &lineNumber)
Compare two ASCII files line-by-line.
Definition
ascii-file.cc:76
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
core
model
ascii-file.h
Generated on Fri Nov 8 2024 13:58:59 for ns-3 by
1.11.0