25 #include "ns3/config.h"
26 #include "ns3/global-value.h"
28 #include "ns3/string.h"
61 m_os =
new std::ofstream();
62 m_os->open(filename, std::ios::out);
73 RawTextDefaultIterator(std::ostream* os)
84 void StartVisitTypeId(std::string name)
override
89 void DoVisitAttribute(std::string name, std::string defaultValue)
override
103 if (supportLevel == TypeId::SupportLevel::OBSOLETE)
105 NS_LOG_WARN(
"Global attribute " << m_typeId <<
"::" << name
106 <<
" was not saved because it is OBSOLETE");
108 else if ((supportLevel == TypeId::SupportLevel::DEPRECATED) &&
111 NS_LOG_WARN(
"Global attribute " << m_typeId <<
"::" << name
112 <<
" was not saved because it is DEPRECATED");
116 *
m_os <<
"default " << m_typeId <<
"::" << name <<
" \"" << defaultValue <<
"\""
121 std::string m_typeId;
126 RawTextDefaultIterator iterator = RawTextDefaultIterator(
m_os);
138 (*i)->GetValue(
value);
140 *
m_os <<
"global " << (*i)->GetName() <<
" \"" <<
value.Get() <<
"\"" << std::endl;
152 RawTextAttributeIterator(std::ostream* os)
163 void DoVisitAttribute(
Ptr<Object> object, std::string name)
override
168 TypeId tid =
object->GetInstanceTypeId();
173 if (tmp.
name == name)
179 if (supportLevel == TypeId::SupportLevel::OBSOLETE)
182 <<
" was not saved because it is OBSOLETE");
184 else if ((supportLevel == TypeId::SupportLevel::DEPRECATED) &&
188 <<
" was not saved because it is DEPRECATED");
192 object->GetAttribute(name, str);
194 *
m_os <<
"value " << GetCurrentPath() <<
" \"" << str.
Get() <<
"\"" << std::endl;
202 RawTextAttributeIterator iter = RawTextAttributeIterator(
m_os);
228 m_is =
new std::ifstream();
229 m_is->open(filename, std::ios::in);
236 std::string::size_type
start =
value.find(
'\"');
237 std::string::size_type end =
value.find(
'\"', 1);
252 for (std::string line; std::getline(*
m_is, line);)
261 if (
type ==
"default")
280 for (std::string line; std::getline(*
m_is, line);)
289 if (
type ==
"global")
308 for (std::string line; std::getline(*
m_is, line);)
337 std::istringstream iss(line);
345 if (line.front() ==
'#')
351 if (
type.empty() && name.empty())
353 std::istringstream iss(line);
354 iss >>
type >> name >> std::ws;
355 std::getline(iss,
value);
365 return std::count(
value.begin(),
value.end(),
'"') == 2;
Iterator to iterate on the default values of attributes of an ns3::Object.
Iterator to iterate on the values of attributes of an ns3::Object.
void SetSaveDeprecated(bool saveDeprecated)
Set if to save deprecated attributes.
bool m_saveDeprecated
save deprecated attributes
Vector::const_iterator Iterator
Iterator type for the list of all global values.
static Iterator Begin()
The Begin iterator.
static Iterator End()
The End iterator.
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
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.
Hold variables of type string.
a unique identifier for an interface.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
struct TypeId::AttributeInformation GetAttribute(std::size_t i) const
Get Attribute information by index.
std::size_t GetAttributeN() const
Get the number of attributes.
SupportLevel
The level of support or deprecation for attributes or trace sources.
void SetGlobal(std::string name, const AttributeValue &value)
void SetDefault(std::string name, const AttributeValue &value)
void Set(std::string path, const AttributeValue &value)
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Every class exported by the ns3 library is enclosed in the ns3 namespace.