mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Added support for emitting and represeting null
This commit is contained in:
@@ -83,6 +83,12 @@ namespace YAML
|
||||
return false;
|
||||
}
|
||||
|
||||
template <>
|
||||
bool Converter<_Null>::Convert(const std::string& input, _Null& /*output*/)
|
||||
{
|
||||
return input.empty() || input == "~" || input == "null" || input == "Null" || input == "NULL";
|
||||
}
|
||||
|
||||
template <>
|
||||
bool Converter<std::wstring>::Convert(const std::string& input, std::wstring& output)
|
||||
{
|
||||
|
@@ -666,4 +666,16 @@ namespace YAML
|
||||
Utils::WriteComment(m_stream, comment.content, m_pState->GetPostCommentIndent());
|
||||
return *this;
|
||||
}
|
||||
|
||||
Emitter& Emitter::Write(const _Null& /*null*/)
|
||||
{
|
||||
if(!good())
|
||||
return *this;
|
||||
|
||||
PreAtomicWrite();
|
||||
EmitSeparationIfNecessary();
|
||||
m_stream << "~";
|
||||
PostAtomicWrite();
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#include "aliascontent.h"
|
||||
#include "iterpriv.h"
|
||||
#include "emitter.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
@@ -85,6 +86,9 @@ namespace YAML
|
||||
m_pContent = new Map;
|
||||
break;
|
||||
default:
|
||||
// std::stringstream str;
|
||||
// str << TokenNames[pScanner->peek().type];
|
||||
// throw std::runtime_error(str.str());
|
||||
break;
|
||||
}
|
||||
|
||||
|
6
src/null.cpp
Normal file
6
src/null.cpp
Normal file
@@ -0,0 +1,6 @@
|
||||
#include "null.h"
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
_Null Null;
|
||||
}
|
Reference in New Issue
Block a user