4 #include "ns3/global-value.h"
5 #include "ns3/string.h"
7 #include "ns3/config.h"
29 m_os =
new std::ofstream ();
30 m_os->open (filename.c_str (), std::ios::out);
38 RawTextDefaultIterator (std::ostream *os) {
42 virtual void StartVisitTypeId (std::string name) {
45 virtual void DoVisitAttribute (std::string name, std::string defaultValue) {
46 *
m_os <<
"default " << m_typeId <<
"::" << name <<
" \"" << defaultValue <<
"\"" << std::endl;
52 RawTextDefaultIterator iterator = RawTextDefaultIterator (
m_os);
61 (*i)->GetValue (value);
62 *
m_os <<
"global " << (*i)->GetName () <<
" \"" << value.
Get () <<
"\"" << std::endl;
71 RawTextAttributeIterator (std::ostream *os)
74 virtual void DoVisitAttribute (
Ptr<Object> object, std::string name) {
76 object->GetAttribute (name, str);
77 *
m_os <<
"value " << GetCurrentPath () <<
" \"" << str.
Get () <<
"\"" << std::endl;
82 RawTextAttributeIterator iter = RawTextAttributeIterator (
m_os);
102 m_is =
new std::ifstream ();
103 m_is->open (filename.c_str (), std::ios::in);
108 std::string::size_type
start = value.find (
"\"");
109 std::string::size_type end = value.find (
"\"", 1);
112 return value.substr (start+1, end-start-1);
120 std::string type, name, value;
121 *
m_is >> type >> name >> value;
122 while (
m_is->good ())
124 NS_LOG_DEBUG (
"type=" << type <<
", name=" << name <<
", value=" << value);
125 value =
Strip (value);
126 if (type ==
"default")
130 *
m_is >> type >> name >> value;
138 std::string type, name, value;
139 *
m_is >> type >> name >> value;
140 while (
m_is->good ())
142 NS_LOG_DEBUG (
"type=" << type <<
", name=" << name <<
", value=" << value);
143 value =
Strip (value);
144 if (type ==
"global")
148 *
m_is >> type >> name >> value;
155 std::string type, path, value;
156 *
m_is >> type >> path >> value;
157 while (
m_is->good ())
159 NS_LOG_DEBUG (
"type=" << type <<
", path=" << path <<
", value=" << value);
160 value =
Strip (value);
165 *
m_is >> type >> path >> value;
std::string Get(void) const
virtual void Attributes(void)
hold variables of type string
virtual void SetFilename(std::string filename)
#define NS_ASSERT(condition)
Vector::const_iterator Iterator
NS_LOG_COMPONENT_DEFINE("RawTextConfig")
void Set(std::string path, const AttributeValue &value)
virtual void SetFilename(std::string filename)
virtual ~RawTextConfigLoad()
virtual ~RawTextConfigSave()
static Iterator Begin(void)
virtual void Global(void)
void SetDefault(std::string name, const AttributeValue &value)
std::string Strip(std::string value)
virtual void Attributes(void)
virtual void Default(void)
static Iterator End(void)
#define NS_LOG_DEBUG(msg)
This class is used internally by ConfigStore and GtkConfigStore.
virtual void Global(void)
void SetGlobal(std::string name, const AttributeValue &value)
virtual void Default(void)