A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
raw-text-config.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 INRIA
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: Mathieu Lacage <mathieu.lacage@cutebugs.net>
18 */
19
20#ifndef RAW_TEXT_CONFIG_H
21#define RAW_TEXT_CONFIG_H
22
23#include "file-config.h"
24
25#include <fstream>
26#include <string>
27
28namespace ns3
29{
30
31/**
32 * \ingroup configstore
33 * \brief A class to enable saving of configuration store in a raw text file
34 *
35 */
37{
38 public:
39 RawTextConfigSave(); //!< default constructor
40 ~RawTextConfigSave() override; //!< destructor
41 // Inherited
42 void SetFilename(std::string filename) override;
43 void Default() override;
44 void Global() override;
45 void Attributes() override;
46
47 private:
48 /// Config store output stream
49 std::ofstream* m_os;
50};
51
52/**
53 * \ingroup configstore
54 * \brief A class to enable loading of configuration store from a raw text file
55 *
56 */
58{
59 public:
60 RawTextConfigLoad(); //!< default constructor
61 ~RawTextConfigLoad() override; //!< destructor
62 // Inherited
63 void SetFilename(std::string filename) override;
64 void Default() override;
65 void Global() override;
66 void Attributes() override;
67
68 private:
69 /**
70 * Parse (potentially multi-) line configs into type, name, and values.
71 * This will return \c false for blank lines, comments (lines beginning with '#'),
72 * and incomplete entries. An entry is considered complete when a type and name
73 * have been found and the value contains two delimiting quotation marks '"'.
74 * \param line the config file line
75 * \param type the config type {default, global, value}
76 * \param name the config attribute name
77 * \param value the value to set
78 * \returns true if all of type, name, and value parsed; false otherwise
79 *
80 */
81 virtual bool ParseLine(const std::string& line,
82 std::string& type,
83 std::string& name,
84 std::string& value);
85
86 /**
87 * Strip out attribute value
88 * \param value the input string
89 * \returns the updated string
90 */
91 std::string Strip(std::string value);
92 /// Config store input stream
93 std::ifstream* m_is;
94};
95
96} // namespace ns3
97
98#endif /* RAW_TEXT_CONFIG_H */
base class for ConfigStore classes using files
Definition: file-config.h:34
A class to enable loading of configuration store from a raw text file.
void SetFilename(std::string filename) override
Set the file name.
void Attributes() override
Load or save the attributes values.
RawTextConfigLoad()
default constructor
virtual bool ParseLine(const std::string &line, std::string &type, std::string &name, std::string &value)
Parse (potentially multi-) line configs into type, name, and values.
void Global() override
Load or save the global values.
std::ifstream * m_is
Config store input stream.
std::string Strip(std::string value)
Strip out attribute value.
void Default() override
Load or save the default values.
~RawTextConfigLoad() override
destructor
A class to enable saving of configuration store in a raw text file.
std::ofstream * m_os
Config store output stream.
void Attributes() override
Load or save the attributes values.
void Global() override
Load or save the global values.
RawTextConfigSave()
default constructor
~RawTextConfigSave() override
destructor
void SetFilename(std::string filename) override
Set the file name.
void Default() override
Load or save the default values.
Every class exported by the ns3 library is enclosed in the ns3 namespace.