Added an iterator class that can iterate through both sequence and map nodes.

This commit is contained in:
Jesse Beder 2008-07-02 01:22:39 +00:00
parent f7358701f2
commit d56b54b34f
16 changed files with 393 additions and 105 deletions

View file

@ -1,6 +1,8 @@
#include "scalar.h"
#include "scanner.h"
#include "token.h"
#include "exceptions.h"
#include <sstream>
namespace YAML
{
@ -28,4 +30,57 @@ namespace YAML
out << " ";
out << m_data << std::endl;
}
void Scalar::Read(std::string& s)
{
s = m_data;
}
void Scalar::Read(int& i)
{
std::stringstream data(m_data);
data >> i;
if(!data)
throw InvalidScalar();
}
void Scalar::Read(unsigned& u)
{
std::stringstream data(m_data);
data >> u;
if(!data)
throw InvalidScalar();
}
void Scalar::Read(long& l)
{
std::stringstream data(m_data);
data >> l;
if(!data)
throw InvalidScalar();
}
void Scalar::Read(float& f)
{
std::stringstream data(m_data);
data >> f;
if(!data)
throw InvalidScalar();
}
void Scalar::Read(double& d)
{
std::stringstream data(m_data);
data >> d;
if(!data)
throw InvalidScalar();
}
void Scalar::Read(char& c)
{
std::stringstream data(m_data);
data >> c;
if(!data)
throw InvalidScalar();
}
}