24 #include "ns3/global-value.h"
25 #include "ns3/string.h"
27 #include "ns3/config.h"
52 m_os =
new std::ofstream ();
53 m_os->open (filename.c_str (), std::ios::out);
62 RawTextDefaultIterator (std::ostream *os) {
66 virtual void StartVisitTypeId (std::string name) {
69 virtual void DoVisitAttribute (std::string name, std::string defaultValue) {
71 *
m_os <<
"default " << m_typeId <<
"::" << name <<
" \"" << defaultValue <<
"\"" << std::endl;
77 RawTextDefaultIterator iterator = RawTextDefaultIterator (
m_os);
87 (*i)->GetValue (value);
89 *
m_os <<
"global " << (*i)->GetName () <<
" \"" << value.
Get () <<
"\"" << std::endl;
99 RawTextAttributeIterator (std::ostream *os)
102 virtual void DoVisitAttribute (
Ptr<Object> object, std::string name) {
104 object->GetAttribute (name, str);
106 *
m_os <<
"value " << GetCurrentPath () <<
" \"" << str.
Get () <<
"\"" << std::endl;
111 RawTextAttributeIterator iter = RawTextAttributeIterator (
m_os);
134 m_is =
new std::ifstream ();
135 m_is->open (filename.c_str (), std::ios::in);
140 std::string::size_type
start = value.find (
"\"");
141 std::string::size_type end = value.find (
"\"", 1);
144 return value.substr (start+1, end-start-1);
153 std::string type, name, value;
154 *
m_is >> type >> name >> value;
155 while (
m_is->good ())
157 NS_LOG_DEBUG (
"type=" << type <<
", name=" << name <<
", value=" << value);
158 value =
Strip (value);
159 if (type ==
"default")
163 *
m_is >> type >> name >> value;
172 std::string type, name, value;
173 *
m_is >> type >> name >> value;
174 while (
m_is->good ())
176 NS_LOG_DEBUG (
"type=" << type <<
", name=" << name <<
", value=" << value);
177 value =
Strip (value);
178 if (type ==
"global")
182 *
m_is >> type >> name >> value;
191 std::string type, path, value;
192 *
m_is >> type >> path >> value;
193 while (
m_is->good ())
195 NS_LOG_DEBUG (
"type=" << type <<
", path=" << path <<
", value=" << value);
196 value =
Strip (value);
201 *
m_is >> type >> path >> value;
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
std::string Get(void) const
virtual void Attributes(void)
Hold variables of type string.
void Set(std::string path, const AttributeValue &value)
virtual void SetFilename(std::string filename)
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Vector::const_iterator Iterator
Iterator type for the list of all global values.
virtual void SetFilename(std::string filename)
virtual ~RawTextConfigLoad()
virtual ~RawTextConfigSave()
static Iterator Begin(void)
The Begin iterator.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
virtual void Global(void)
std::string Strip(std::string value)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void Attributes(void)
virtual void Default(void)
void SetGlobal(std::string name, const AttributeValue &value)
static Iterator End(void)
The End iterator.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
void SetDefault(std::string name, const AttributeValue &value)
This class is used internally by ConfigStore and GtkConfigStore.
virtual void Global(void)
virtual void Default(void)