A Discrete-Event Network Simulator
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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mitch Watrous (watrous@u.washington.edu)
18 *
19 * This file is based on pcap-file.h by Craig Dowell (craigdo@ee.washington.edu)
20 */
21
22#ifndef ASCII_FILE_H
23#define ASCII_FILE_H
24
25#include <fstream>
26#include <stdint.h>
27#include <string>
28
29namespace ns3
30{
31
38{
39 public:
40 AsciiFile();
41 ~AsciiFile();
42
46 bool Fail() const;
50 bool Eof() const;
51
58 void Open(const std::string& filename, std::ios::openmode mode);
59
63 void Close();
64
71 void Read(std::string& line);
72
82 static bool Diff(const std::string& f1, const std::string& f2, uint64_t& lineNumber);
83
84 private:
85 std::string m_filename;
86 std::fstream m_file;
87};
88
89} // namespace ns3
90
91#endif /* ASCII_FILE_H */
A class representing an ascii file.
Definition: ascii-file.h:38
bool Eof() const
Definition: ascii-file.cc:57
void Close()
Close the underlying file.
Definition: ascii-file.cc:63
bool Fail() const
Definition: ascii-file.cc:51
std::fstream m_file
output file
Definition: ascii-file.h:86
std::string m_filename
output file name
Definition: ascii-file.h:85
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:69
void Read(std::string &line)
Read next line from file.
Definition: ascii-file.cc:78
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:87
Every class exported by the ns3 library is enclosed in the ns3 namespace.