mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 20:51:16 +00:00
Added float/double precision setters
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "emitterstate.h"
|
||||
#include "yaml-cpp/exceptions.h"
|
||||
#include <limits>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
@@ -21,6 +22,8 @@ namespace YAML
|
||||
m_seqFmt.set(Block);
|
||||
m_mapFmt.set(Block);
|
||||
m_mapKeyFmt.set(Auto);
|
||||
m_floatPrecision.set(6);
|
||||
m_doublePrecision.set(15);
|
||||
}
|
||||
|
||||
EmitterState::~EmitterState()
|
||||
@@ -261,5 +264,21 @@ namespace YAML
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool EmitterState::SetFloatPrecision(unsigned value, FMT_SCOPE scope)
|
||||
{
|
||||
if(value > std::numeric_limits<float>::digits10)
|
||||
return false;
|
||||
_Set(m_floatPrecision, value, scope);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EmitterState::SetDoublePrecision(unsigned value, FMT_SCOPE scope)
|
||||
{
|
||||
if(value > std::numeric_limits<double>::digits10)
|
||||
return false;
|
||||
_Set(m_doublePrecision, value, scope);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user