Make EMITTER_MANIP an enum class
This fixed -Wshadow warnings emitted when compiling with clang++ Signed-off-by: Ted Lyngmo <ted@lyncon.se>
This commit is contained in:
parent
a6bbe0e50a
commit
0fbc82f98c
@ -10,7 +10,7 @@
|
||||
#include <string>
|
||||
|
||||
namespace YAML {
|
||||
enum EMITTER_MANIP {
|
||||
enum class EMITTER_MANIP {
|
||||
// general manipulators
|
||||
Auto,
|
||||
TagByKind,
|
||||
|
||||
@ -15,10 +15,10 @@
|
||||
namespace YAML {
|
||||
template <typename Seq>
|
||||
inline Emitter& EmitSeq(Emitter& emitter, const Seq& seq) {
|
||||
emitter << BeginSeq;
|
||||
emitter << EMITTER_MANIP::BeginSeq;
|
||||
for (const auto& v : seq)
|
||||
emitter << v;
|
||||
emitter << EndSeq;
|
||||
emitter << EMITTER_MANIP::EndSeq;
|
||||
return emitter;
|
||||
}
|
||||
|
||||
@ -39,10 +39,10 @@ inline Emitter& operator<<(Emitter& emitter, const std::set<T>& v) {
|
||||
|
||||
template <typename K, typename V>
|
||||
inline Emitter& operator<<(Emitter& emitter, const std::map<K, V>& m) {
|
||||
emitter << BeginMap;
|
||||
emitter << EMITTER_MANIP::BeginMap;
|
||||
for (const auto& v : m)
|
||||
emitter << Key << v.first << Value << v.second;
|
||||
emitter << EndMap;
|
||||
emitter << EMITTER_MANIP::Key << v.first << EMITTER_MANIP::Value << v.second;
|
||||
emitter << EMITTER_MANIP::EndMap;
|
||||
return emitter;
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,22 +51,22 @@ void EmitFromEvents::OnSequenceStart(const Mark&, const std::string& tag,
|
||||
EmitProps(tag, anchor);
|
||||
switch (style) {
|
||||
case EmitterStyle::Block:
|
||||
m_emitter << Block;
|
||||
m_emitter << EMITTER_MANIP::Block;
|
||||
break;
|
||||
case EmitterStyle::Flow:
|
||||
m_emitter << Flow;
|
||||
m_emitter << EMITTER_MANIP::Flow;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// Restore the global settings to eliminate the override from node style
|
||||
m_emitter.RestoreGlobalModifiedSettings();
|
||||
m_emitter << BeginSeq;
|
||||
m_emitter << EMITTER_MANIP::BeginSeq;
|
||||
m_stateStack.push(State::WaitingForSequenceEntry);
|
||||
}
|
||||
|
||||
void EmitFromEvents::OnSequenceEnd() {
|
||||
m_emitter << EndSeq;
|
||||
m_emitter << EMITTER_MANIP::EndSeq;
|
||||
assert(m_stateStack.top() == State::WaitingForSequenceEntry);
|
||||
m_stateStack.pop();
|
||||
}
|
||||
@ -77,22 +77,22 @@ void EmitFromEvents::OnMapStart(const Mark&, const std::string& tag,
|
||||
EmitProps(tag, anchor);
|
||||
switch (style) {
|
||||
case EmitterStyle::Block:
|
||||
m_emitter << Block;
|
||||
m_emitter << EMITTER_MANIP::Block;
|
||||
break;
|
||||
case EmitterStyle::Flow:
|
||||
m_emitter << Flow;
|
||||
m_emitter << EMITTER_MANIP::Flow;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// Restore the global settings to eliminate the override from node style
|
||||
m_emitter.RestoreGlobalModifiedSettings();
|
||||
m_emitter << BeginMap;
|
||||
m_emitter << EMITTER_MANIP::BeginMap;
|
||||
m_stateStack.push(State::WaitingForKey);
|
||||
}
|
||||
|
||||
void EmitFromEvents::OnMapEnd() {
|
||||
m_emitter << EndMap;
|
||||
m_emitter << EMITTER_MANIP::EndMap;
|
||||
assert(m_stateStack.top() == State::WaitingForKey);
|
||||
m_stateStack.pop();
|
||||
}
|
||||
@ -103,11 +103,11 @@ void EmitFromEvents::BeginNode() {
|
||||
|
||||
switch (m_stateStack.top()) {
|
||||
case State::WaitingForKey:
|
||||
m_emitter << Key;
|
||||
m_emitter << EMITTER_MANIP::Key;
|
||||
m_stateStack.top() = State::WaitingForValue;
|
||||
break;
|
||||
case State::WaitingForValue:
|
||||
m_emitter << Value;
|
||||
m_emitter << EMITTER_MANIP::Value;
|
||||
m_stateStack.top() = State::WaitingForKey;
|
||||
break;
|
||||
default:
|
||||
|
||||
@ -101,32 +101,32 @@ Emitter& Emitter::SetLocalValue(EMITTER_MANIP value) {
|
||||
return *this;
|
||||
|
||||
switch (value) {
|
||||
case BeginDoc:
|
||||
case EMITTER_MANIP::BeginDoc:
|
||||
EmitBeginDoc();
|
||||
break;
|
||||
case EndDoc:
|
||||
case EMITTER_MANIP::EndDoc:
|
||||
EmitEndDoc();
|
||||
break;
|
||||
case BeginSeq:
|
||||
case EMITTER_MANIP::BeginSeq:
|
||||
EmitBeginSeq();
|
||||
break;
|
||||
case EndSeq:
|
||||
case EMITTER_MANIP::EndSeq:
|
||||
EmitEndSeq();
|
||||
break;
|
||||
case BeginMap:
|
||||
case EMITTER_MANIP::BeginMap:
|
||||
EmitBeginMap();
|
||||
break;
|
||||
case EndMap:
|
||||
case EMITTER_MANIP::EndMap:
|
||||
EmitEndMap();
|
||||
break;
|
||||
case Key:
|
||||
case Value:
|
||||
case EMITTER_MANIP::Key:
|
||||
case EMITTER_MANIP::Value:
|
||||
// deprecated (these can be deduced by the parity of nodes in a map)
|
||||
break;
|
||||
case TagByKind:
|
||||
case EMITTER_MANIP::TagByKind:
|
||||
EmitKindTag();
|
||||
break;
|
||||
case Newline:
|
||||
case EMITTER_MANIP::Newline:
|
||||
EmitNewline();
|
||||
break;
|
||||
default:
|
||||
@ -392,7 +392,7 @@ void Emitter::BlockSeqPrepareNode(EmitterNodeType::value child) {
|
||||
|
||||
void Emitter::FlowMapPrepareNode(EmitterNodeType::value child) {
|
||||
if (m_pState->CurGroupChildCount() % 2 == 0) {
|
||||
if (m_pState->GetMapKeyFormat() == LongKey)
|
||||
if (m_pState->GetMapKeyFormat() == EMITTER_MANIP::LongKey)
|
||||
m_pState->SetLongKey();
|
||||
|
||||
if (m_pState->CurGroupLongKey())
|
||||
@ -530,7 +530,7 @@ void Emitter::FlowMapPrepareSimpleKeyValue(EmitterNodeType::value child) {
|
||||
|
||||
void Emitter::BlockMapPrepareNode(EmitterNodeType::value child) {
|
||||
if (m_pState->CurGroupChildCount() % 2 == 0) {
|
||||
if (m_pState->GetMapKeyFormat() == LongKey)
|
||||
if (m_pState->GetMapKeyFormat() == EMITTER_MANIP::LongKey)
|
||||
m_pState->SetLongKey();
|
||||
if (child == EmitterNodeType::BlockSeq ||
|
||||
child == EmitterNodeType::BlockMap)
|
||||
@ -681,14 +681,14 @@ void Emitter::SpaceOrIndentTo(bool requireSpace, std::size_t indent) {
|
||||
void Emitter::PrepareIntegralStream(std::stringstream& stream) const {
|
||||
|
||||
switch (m_pState->GetIntFormat()) {
|
||||
case Dec:
|
||||
case EMITTER_MANIP::Dec:
|
||||
stream << std::dec;
|
||||
break;
|
||||
case Hex:
|
||||
case EMITTER_MANIP::Hex:
|
||||
stream << "0x";
|
||||
stream << std::hex;
|
||||
break;
|
||||
case Oct:
|
||||
case EMITTER_MANIP::Oct:
|
||||
stream << "0";
|
||||
stream << std::oct;
|
||||
break;
|
||||
@ -704,9 +704,9 @@ void Emitter::StartedScalar() { m_pState->StartedScalar(); }
|
||||
|
||||
StringEscaping::value GetStringEscapingStyle(const EMITTER_MANIP emitterManip) {
|
||||
switch (emitterManip) {
|
||||
case EscapeNonAscii:
|
||||
case EMITTER_MANIP::EscapeNonAscii:
|
||||
return StringEscaping::NonAscii;
|
||||
case EscapeAsJson:
|
||||
case EMITTER_MANIP::EscapeAsJson:
|
||||
return StringEscaping::JSON;
|
||||
default:
|
||||
return StringEscaping::None;
|
||||
@ -725,7 +725,7 @@ Emitter& Emitter::Write(const std::string& str) {
|
||||
m_pState->CurGroupFlowType(), stringEscaping == StringEscaping::NonAscii);
|
||||
|
||||
if (strFormat == StringFormat::Literal || str.size() > 1024)
|
||||
m_pState->SetMapKeyFormat(YAML::LongKey, FmtScope::Local);
|
||||
m_pState->SetMapKeyFormat(YAML::EMITTER_MANIP::LongKey, FmtScope::Local);
|
||||
|
||||
PrepareNode(EmitterNodeType::Scalar);
|
||||
|
||||
@ -759,42 +759,42 @@ std::size_t Emitter::GetDoublePrecision() const {
|
||||
}
|
||||
|
||||
const char* Emitter::ComputeFullBoolName(bool b) const {
|
||||
const EMITTER_MANIP mainFmt = (m_pState->GetBoolLengthFormat() == ShortBool
|
||||
? YesNoBool
|
||||
const EMITTER_MANIP mainFmt = (m_pState->GetBoolLengthFormat() == EMITTER_MANIP::ShortBool
|
||||
? EMITTER_MANIP::YesNoBool
|
||||
: m_pState->GetBoolFormat());
|
||||
const EMITTER_MANIP caseFmt = m_pState->GetBoolCaseFormat();
|
||||
switch (mainFmt) {
|
||||
case YesNoBool:
|
||||
case EMITTER_MANIP::YesNoBool:
|
||||
switch (caseFmt) {
|
||||
case UpperCase:
|
||||
case EMITTER_MANIP::UpperCase:
|
||||
return b ? "YES" : "NO";
|
||||
case CamelCase:
|
||||
case EMITTER_MANIP::CamelCase:
|
||||
return b ? "Yes" : "No";
|
||||
case LowerCase:
|
||||
case EMITTER_MANIP::LowerCase:
|
||||
return b ? "yes" : "no";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OnOffBool:
|
||||
case EMITTER_MANIP::OnOffBool:
|
||||
switch (caseFmt) {
|
||||
case UpperCase:
|
||||
case EMITTER_MANIP::UpperCase:
|
||||
return b ? "ON" : "OFF";
|
||||
case CamelCase:
|
||||
case EMITTER_MANIP::CamelCase:
|
||||
return b ? "On" : "Off";
|
||||
case LowerCase:
|
||||
case EMITTER_MANIP::LowerCase:
|
||||
return b ? "on" : "off";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case TrueFalseBool:
|
||||
case EMITTER_MANIP::TrueFalseBool:
|
||||
switch (caseFmt) {
|
||||
case UpperCase:
|
||||
case EMITTER_MANIP::UpperCase:
|
||||
return b ? "TRUE" : "FALSE";
|
||||
case CamelCase:
|
||||
case EMITTER_MANIP::CamelCase:
|
||||
return b ? "True" : "False";
|
||||
case LowerCase:
|
||||
case EMITTER_MANIP::LowerCase:
|
||||
return b ? "true" : "false";
|
||||
default:
|
||||
break;
|
||||
@ -809,13 +809,13 @@ const char* Emitter::ComputeFullBoolName(bool b) const {
|
||||
|
||||
const char* Emitter::ComputeNullName() const {
|
||||
switch (m_pState->GetNullFormat()) {
|
||||
case LowerNull:
|
||||
case EMITTER_MANIP::LowerNull:
|
||||
return "null";
|
||||
case UpperNull:
|
||||
case EMITTER_MANIP::UpperNull:
|
||||
return "NULL";
|
||||
case CamelNull:
|
||||
case EMITTER_MANIP::CamelNull:
|
||||
return "Null";
|
||||
case TildeNull:
|
||||
case EMITTER_MANIP::TildeNull:
|
||||
// fallthrough
|
||||
default:
|
||||
return "~";
|
||||
@ -829,7 +829,7 @@ Emitter& Emitter::Write(bool b) {
|
||||
PrepareNode(EmitterNodeType::Scalar);
|
||||
|
||||
const char* name = ComputeFullBoolName(b);
|
||||
if (m_pState->GetBoolLengthFormat() == ShortBool)
|
||||
if (m_pState->GetBoolLengthFormat() == EMITTER_MANIP::ShortBool)
|
||||
m_stream << name[0];
|
||||
else
|
||||
m_stream << name;
|
||||
|
||||
@ -8,19 +8,19 @@ EmitterState::EmitterState()
|
||||
: m_isGood(true),
|
||||
m_lastError{},
|
||||
// default global manipulators
|
||||
m_charset(EmitNonAscii),
|
||||
m_strFmt(Auto),
|
||||
m_boolFmt(TrueFalseBool),
|
||||
m_boolLengthFmt(LongBool),
|
||||
m_boolCaseFmt(LowerCase),
|
||||
m_nullFmt(TildeNull),
|
||||
m_intFmt(Dec),
|
||||
m_charset(EMITTER_MANIP::EmitNonAscii),
|
||||
m_strFmt(EMITTER_MANIP::Auto),
|
||||
m_boolFmt(EMITTER_MANIP::TrueFalseBool),
|
||||
m_boolLengthFmt(EMITTER_MANIP::LongBool),
|
||||
m_boolCaseFmt(EMITTER_MANIP::LowerCase),
|
||||
m_nullFmt(EMITTER_MANIP::TildeNull),
|
||||
m_intFmt(EMITTER_MANIP::Dec),
|
||||
m_indent(2),
|
||||
m_preCommentIndent(2),
|
||||
m_postCommentIndent(1),
|
||||
m_seqFmt(Block),
|
||||
m_mapFmt(Block),
|
||||
m_mapKeyFmt(Auto),
|
||||
m_seqFmt(EMITTER_MANIP::Block),
|
||||
m_mapFmt(EMITTER_MANIP::Block),
|
||||
m_mapKeyFmt(EMITTER_MANIP::Auto),
|
||||
m_floatPrecision(std::numeric_limits<float>::max_digits10),
|
||||
m_doublePrecision(std::numeric_limits<double>::max_digits10),
|
||||
//
|
||||
@ -98,12 +98,12 @@ void EmitterState::StartedNode() {
|
||||
EmitterNodeType::value EmitterState::NextGroupType(
|
||||
GroupType::value type) const {
|
||||
if (type == GroupType::Seq) {
|
||||
if (GetFlowType(type) == Block)
|
||||
if (GetFlowType(type) == EMITTER_MANIP::Block)
|
||||
return EmitterNodeType::BlockSeq;
|
||||
return EmitterNodeType::FlowSeq;
|
||||
}
|
||||
|
||||
if (GetFlowType(type) == Block)
|
||||
if (GetFlowType(type) == EMITTER_MANIP::Block)
|
||||
return EmitterNodeType::BlockMap;
|
||||
return EmitterNodeType::FlowMap;
|
||||
|
||||
@ -146,7 +146,7 @@ void EmitterState::StartedGroup(GroupType::value type) {
|
||||
pGroup->modifiedSettings = std::move(m_modifiedSettings);
|
||||
|
||||
// set up group
|
||||
if (GetFlowType(type) == Block) {
|
||||
if (GetFlowType(type) == EMITTER_MANIP::Block) {
|
||||
pGroup->flowType = FlowType::Block;
|
||||
} else {
|
||||
pGroup->flowType = FlowType::Flow;
|
||||
@ -240,9 +240,9 @@ void EmitterState::RestoreGlobalModifiedSettings() {
|
||||
bool EmitterState::SetOutputCharset(EMITTER_MANIP value,
|
||||
FmtScope::value scope) {
|
||||
switch (value) {
|
||||
case EmitNonAscii:
|
||||
case EscapeNonAscii:
|
||||
case EscapeAsJson:
|
||||
case EMITTER_MANIP::EmitNonAscii:
|
||||
case EMITTER_MANIP::EscapeNonAscii:
|
||||
case EMITTER_MANIP::EscapeAsJson:
|
||||
_Set(m_charset, value, scope);
|
||||
return true;
|
||||
default:
|
||||
@ -252,10 +252,10 @@ bool EmitterState::SetOutputCharset(EMITTER_MANIP value,
|
||||
|
||||
bool EmitterState::SetStringFormat(EMITTER_MANIP value, FmtScope::value scope) {
|
||||
switch (value) {
|
||||
case Auto:
|
||||
case SingleQuoted:
|
||||
case DoubleQuoted:
|
||||
case Literal:
|
||||
case EMITTER_MANIP::Auto:
|
||||
case EMITTER_MANIP::SingleQuoted:
|
||||
case EMITTER_MANIP::DoubleQuoted:
|
||||
case EMITTER_MANIP::Literal:
|
||||
_Set(m_strFmt, value, scope);
|
||||
return true;
|
||||
default:
|
||||
@ -265,9 +265,9 @@ bool EmitterState::SetStringFormat(EMITTER_MANIP value, FmtScope::value scope) {
|
||||
|
||||
bool EmitterState::SetBoolFormat(EMITTER_MANIP value, FmtScope::value scope) {
|
||||
switch (value) {
|
||||
case OnOffBool:
|
||||
case TrueFalseBool:
|
||||
case YesNoBool:
|
||||
case EMITTER_MANIP::OnOffBool:
|
||||
case EMITTER_MANIP::TrueFalseBool:
|
||||
case EMITTER_MANIP::YesNoBool:
|
||||
_Set(m_boolFmt, value, scope);
|
||||
return true;
|
||||
default:
|
||||
@ -278,8 +278,8 @@ bool EmitterState::SetBoolFormat(EMITTER_MANIP value, FmtScope::value scope) {
|
||||
bool EmitterState::SetBoolLengthFormat(EMITTER_MANIP value,
|
||||
FmtScope::value scope) {
|
||||
switch (value) {
|
||||
case LongBool:
|
||||
case ShortBool:
|
||||
case EMITTER_MANIP::LongBool:
|
||||
case EMITTER_MANIP::ShortBool:
|
||||
_Set(m_boolLengthFmt, value, scope);
|
||||
return true;
|
||||
default:
|
||||
@ -290,9 +290,9 @@ bool EmitterState::SetBoolLengthFormat(EMITTER_MANIP value,
|
||||
bool EmitterState::SetBoolCaseFormat(EMITTER_MANIP value,
|
||||
FmtScope::value scope) {
|
||||
switch (value) {
|
||||
case UpperCase:
|
||||
case LowerCase:
|
||||
case CamelCase:
|
||||
case EMITTER_MANIP::UpperCase:
|
||||
case EMITTER_MANIP::LowerCase:
|
||||
case EMITTER_MANIP::CamelCase:
|
||||
_Set(m_boolCaseFmt, value, scope);
|
||||
return true;
|
||||
default:
|
||||
@ -302,10 +302,10 @@ bool EmitterState::SetBoolCaseFormat(EMITTER_MANIP value,
|
||||
|
||||
bool EmitterState::SetNullFormat(EMITTER_MANIP value, FmtScope::value scope) {
|
||||
switch (value) {
|
||||
case LowerNull:
|
||||
case UpperNull:
|
||||
case CamelNull:
|
||||
case TildeNull:
|
||||
case EMITTER_MANIP::LowerNull:
|
||||
case EMITTER_MANIP::UpperNull:
|
||||
case EMITTER_MANIP::CamelNull:
|
||||
case EMITTER_MANIP::TildeNull:
|
||||
_Set(m_nullFmt, value, scope);
|
||||
return true;
|
||||
default:
|
||||
@ -315,9 +315,9 @@ bool EmitterState::SetNullFormat(EMITTER_MANIP value, FmtScope::value scope) {
|
||||
|
||||
bool EmitterState::SetIntFormat(EMITTER_MANIP value, FmtScope::value scope) {
|
||||
switch (value) {
|
||||
case Dec:
|
||||
case Hex:
|
||||
case Oct:
|
||||
case EMITTER_MANIP::Dec:
|
||||
case EMITTER_MANIP::Hex:
|
||||
case EMITTER_MANIP::Oct:
|
||||
_Set(m_intFmt, value, scope);
|
||||
return true;
|
||||
default:
|
||||
@ -354,8 +354,8 @@ bool EmitterState::SetPostCommentIndent(std::size_t value,
|
||||
bool EmitterState::SetFlowType(GroupType::value groupType, EMITTER_MANIP value,
|
||||
FmtScope::value scope) {
|
||||
switch (value) {
|
||||
case Block:
|
||||
case Flow:
|
||||
case EMITTER_MANIP::Block:
|
||||
case EMITTER_MANIP::Flow:
|
||||
_Set(groupType == GroupType::Seq ? m_seqFmt : m_mapFmt, value, scope);
|
||||
return true;
|
||||
default:
|
||||
@ -366,7 +366,7 @@ bool EmitterState::SetFlowType(GroupType::value groupType, EMITTER_MANIP value,
|
||||
EMITTER_MANIP EmitterState::GetFlowType(GroupType::value groupType) const {
|
||||
// force flow style if we're currently in a flow
|
||||
if (CurGroupFlowType() == FlowType::Flow)
|
||||
return Flow;
|
||||
return EMITTER_MANIP::Flow;
|
||||
|
||||
// otherwise, go with what's asked of us
|
||||
return (groupType == GroupType::Seq ? m_seqFmt.get() : m_mapFmt.get());
|
||||
@ -374,8 +374,8 @@ EMITTER_MANIP EmitterState::GetFlowType(GroupType::value groupType) const {
|
||||
|
||||
bool EmitterState::SetMapKeyFormat(EMITTER_MANIP value, FmtScope::value scope) {
|
||||
switch (value) {
|
||||
case Auto:
|
||||
case LongKey:
|
||||
case EMITTER_MANIP::Auto:
|
||||
case EMITTER_MANIP::LongKey:
|
||||
_Set(m_mapKeyFmt, value, scope);
|
||||
return true;
|
||||
default:
|
||||
|
||||
@ -272,19 +272,19 @@ StringFormat::value ComputeStringFormat(const std::string& str,
|
||||
FlowType::value flowType,
|
||||
bool escapeNonAscii) {
|
||||
switch (strFormat) {
|
||||
case Auto:
|
||||
case EMITTER_MANIP::Auto:
|
||||
if (IsValidPlainScalar(str, flowType, escapeNonAscii)) {
|
||||
return StringFormat::Plain;
|
||||
}
|
||||
return StringFormat::DoubleQuoted;
|
||||
case SingleQuoted:
|
||||
case EMITTER_MANIP::SingleQuoted:
|
||||
if (IsValidSingleQuotedScalar(str, escapeNonAscii)) {
|
||||
return StringFormat::SingleQuoted;
|
||||
}
|
||||
return StringFormat::DoubleQuoted;
|
||||
case DoubleQuoted:
|
||||
case EMITTER_MANIP::DoubleQuoted:
|
||||
return StringFormat::DoubleQuoted;
|
||||
case Literal:
|
||||
case EMITTER_MANIP::Literal:
|
||||
if (IsValidLiteralScalar(str, flowType, escapeNonAscii)) {
|
||||
return StringFormat::Literal;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user