mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-10 04:51:17 +00:00
Changed the way we read different types of scalars.
It's better organized now, I think - nodes only offer a single main way of getting the fundamental scalar (as a string), and now we can specialize a single template to read specific types.
This commit is contained in:
68
src/node.cpp
68
src/node.cpp
@@ -282,75 +282,11 @@ namespace YAML
|
||||
return GetValue(i);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// Extraction
|
||||
// Note: these Read() functions are identical, but
|
||||
// they're not templated because they use a Content virtual
|
||||
// function, so we'd have to #include that in node.h, and
|
||||
// I don't want to.
|
||||
|
||||
bool Node::Read(std::string& s) const
|
||||
bool Node::GetScalar(std::string& s) const
|
||||
{
|
||||
if(!m_pContent)
|
||||
return false;
|
||||
|
||||
return m_pContent->Read(s);
|
||||
}
|
||||
|
||||
bool Node::Read(int& i) const
|
||||
{
|
||||
if(!m_pContent)
|
||||
return false;
|
||||
|
||||
return m_pContent->Read(i);
|
||||
}
|
||||
|
||||
bool Node::Read(unsigned& u) const
|
||||
{
|
||||
if(!m_pContent)
|
||||
return false;
|
||||
|
||||
return m_pContent->Read(u);
|
||||
}
|
||||
|
||||
bool Node::Read(long& l) const
|
||||
{
|
||||
if(!m_pContent)
|
||||
return false;
|
||||
|
||||
return m_pContent->Read(l);
|
||||
}
|
||||
|
||||
bool Node::Read(float& f) const
|
||||
{
|
||||
if(!m_pContent)
|
||||
return false;
|
||||
|
||||
return m_pContent->Read(f);
|
||||
}
|
||||
|
||||
bool Node::Read(double& d) const
|
||||
{
|
||||
if(!m_pContent)
|
||||
return false;
|
||||
|
||||
return m_pContent->Read(d);
|
||||
}
|
||||
|
||||
bool Node::Read(char& c) const
|
||||
{
|
||||
if(!m_pContent)
|
||||
return false;
|
||||
|
||||
return m_pContent->Read(c);
|
||||
}
|
||||
|
||||
bool Node::Read(bool& b) const
|
||||
{
|
||||
if(!m_pContent)
|
||||
return false;
|
||||
|
||||
return m_pContent->Read(b);
|
||||
return m_pContent->GetScalar(s);
|
||||
}
|
||||
|
||||
std::ostream& operator << (std::ostream& out, const Node& node)
|
||||
|
Reference in New Issue
Block a user