Commit 952fe51c authored by Jesse Beder's avatar Jesse Beder
Browse files

Added writing float/double

parent c95bcae4
...@@ -132,19 +132,28 @@ namespace YAML ...@@ -132,19 +132,28 @@ namespace YAML
if(!good()) if(!good())
return *this; return *this;
PrepareNode(EmitterNodeType::Scalar);
std::stringstream stream;
SetStreamablePrecision<T>(stream);
stream << value;
m_stream << stream.str();
StartedScalar();
return *this; return *this;
} }
template<> template<>
inline void Emitter::SetStreamablePrecision<float>(std::stringstream& str) inline void Emitter::SetStreamablePrecision<float>(std::stringstream& stream)
{ {
str.precision(GetFloatPrecision()); stream.precision(GetFloatPrecision());
} }
template<> template<>
inline void Emitter::SetStreamablePrecision<double>(std::stringstream& str) inline void Emitter::SetStreamablePrecision<double>(std::stringstream& stream)
{ {
str.precision(GetDoublePrecision()); stream.precision(GetDoublePrecision());
} }
// overloads of insertion // overloads of insertion
......
...@@ -9,7 +9,7 @@ int main() ...@@ -9,7 +9,7 @@ int main()
out << YAML::Comment("Hello"); out << YAML::Comment("Hello");
out << YAML::Anchor("a") << YAML::Comment("anchor") << "item 1" << YAML::Comment("a"); out << YAML::Anchor("a") << YAML::Comment("anchor") << "item 1" << YAML::Comment("a");
out << YAML::BeginMap << YAML::Comment("b"); out << YAML::BeginMap << YAML::Comment("b");
out << "pens" << YAML::Comment("foo") << "a" << YAML::Comment("bar"); out << "pens" << YAML::Comment("foo") << 2.3 << YAML::Comment("bar");
out << "pencils" << 15; out << "pencils" << 15;
out << YAML::EndMap << YAML::Comment("monkey"); out << YAML::EndMap << YAML::Comment("monkey");
out << "item 2"; out << "item 2";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment