src/core/string.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Fri, 11 Apr 2008 11:24:42 -0700
changeset 2949 a42da8051124
parent 2582 3e28107b870f
child 2965 4b28e9740e3b
permissions -rw-r--r--
allow an std::string to be an attribute

#include "string.h"

namespace ns3 {

String::String ()
  : m_value ()
{}
String::String (const char *value)
  : m_value (value)
{}
String::String (std::string value)
  : m_value (value)
{}
void 
String::Set (std::string value)
{
  m_value = value;
}
void 
String::Set (const char *value)
{
  m_value = value;
}
std::string 
String::Get (void) const
{
  return m_value;
}

String::operator std::string () const
{
  return m_value;
}

std::ostream & operator << (std::ostream &os, const String &value)
{
  os << value.Get ();
  return os;
}
std::istream &operator >> (std::istream &is, String &value)
{
  std::string str;
  is >> str;
  value = String (str);
  return is;
}

ATTRIBUTE_HELPER_CPP (String);

} // namespace ns3