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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@cutebugs.net>
7 */
8
9#ifndef RAW_TEXT_CONFIG_H
10#define RAW_TEXT_CONFIG_H
11
12#include "file-config.h"
13
14#include <fstream>
15#include <string>
16
17namespace ns3
18{
19
20/**
21 * \ingroup configstore
22 * \brief A class to enable saving of configuration store in a raw text file
23 *
24 */
26{
27 public:
28 RawTextConfigSave(); //!< default constructor
29 ~RawTextConfigSave() override; //!< destructor
30 // Inherited
31 void SetFilename(std::string filename) override;
32 void Default() override;
33 void Global() override;
34 void Attributes() override;
35
36 private:
37 /// Config store output stream
38 std::ofstream* m_os;
39};
40
41/**
42 * \ingroup configstore
43 * \brief A class to enable loading of configuration store from a raw text file
44 *
45 */
47{
48 public:
49 RawTextConfigLoad(); //!< default constructor
50 ~RawTextConfigLoad() override; //!< destructor
51 // Inherited
52 void SetFilename(std::string filename) override;
53 void Default() override;
54 void Global() override;
55 void Attributes() override;
56
57 private:
58 /**
59 * Parse (potentially multi-) line configs into type, name, and values.
60 * This will return \c false for blank lines, comments (lines beginning with '#'),
61 * and incomplete entries. An entry is considered complete when a type and name
62 * have been found and the value contains two delimiting quotation marks '"'.
63 * \param line the config file line
64 * \param type the config type {default, global, value}
65 * \param name the config attribute name
66 * \param value the value to set
67 * \returns true if all of type, name, and value parsed; false otherwise
68 *
69 */
70 virtual bool ParseLine(const std::string& line,
71 std::string& type,
72 std::string& name,
73 std::string& value);
74
75 /**
76 * Strip out attribute value
77 * \param value the input string
78 * \returns the updated string
79 */
80 std::string Strip(std::string value);
81 /// Config store input stream
82 std::ifstream* m_is;
83};
84
85} // namespace ns3
86
87#endif /* RAW_TEXT_CONFIG_H */
base class for ConfigStore classes using files
Definition file-config.h:23
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.