24 #include "ns3/global-value.h"
25 #include "ns3/string.h"
27 #include "ns3/config.h"
49 m_os =
new std::ofstream ();
50 m_os->open (filename.c_str (), std::ios::out);
58 RawTextDefaultIterator (std::ostream *os) {
62 virtual void StartVisitTypeId (std::string name) {
65 virtual void DoVisitAttribute (std::string name, std::string defaultValue) {
66 *
m_os <<
"default " << m_typeId <<
"::" << name <<
" \"" << defaultValue <<
"\"" << std::endl;
72 RawTextDefaultIterator iterator = RawTextDefaultIterator (
m_os);
81 (*i)->GetValue (value);
82 *
m_os <<
"global " << (*i)->GetName () <<
" \"" << value.
Get () <<
"\"" << std::endl;
91 RawTextAttributeIterator (std::ostream *os)
94 virtual void DoVisitAttribute (
Ptr<Object> object, std::string name) {
96 object->GetAttribute (name, str);
97 *
m_os <<
"value " << GetCurrentPath () <<
" \"" << str.
Get () <<
"\"" << std::endl;
102 RawTextAttributeIterator iter = RawTextAttributeIterator (
m_os);
122 m_is =
new std::ifstream ();
123 m_is->open (filename.c_str (), std::ios::in);
128 std::string::size_type
start = value.find (
"\"");
129 std::string::size_type end = value.find (
"\"", 1);
132 return value.substr (start+1, end-start-1);
140 std::string type, name, value;
141 *
m_is >> type >> name >> value;
142 while (
m_is->good ())
144 NS_LOG_DEBUG (
"type=" << type <<
", name=" << name <<
", value=" << value);
145 value =
Strip (value);
146 if (type ==
"default")
150 *
m_is >> type >> name >> value;
158 std::string type, name, value;
159 *
m_is >> type >> name >> value;
160 while (
m_is->good ())
162 NS_LOG_DEBUG (
"type=" << type <<
", name=" << name <<
", value=" << value);
163 value =
Strip (value);
164 if (type ==
"global")
168 *
m_is >> type >> name >> value;
175 std::string type, path, value;
176 *
m_is >> type >> path >> value;
177 while (
m_is->good ())
179 NS_LOG_DEBUG (
"type=" << type <<
", path=" << path <<
", value=" << value);
180 value =
Strip (value);
185 *
m_is >> type >> path >> value;
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.
virtual void Global(void)
std::string Strip(std::string value)
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)