Files
Ivazovsky/plugins/EasyXMLParser/Source/EasyXMLParser/Private/EasyXMLObject.cpp
T
2023-02-06 17:17:44 +05:00

50 lines
975 B
C++

// Copyright 2019 ayumax. All Rights Reserved.
#include "EasyXMLObject.h"
#include "Utils/CustomXMLParser.h"
int32 UEasyXMLObject::GetIntValue(int32 DefaultValue)
{
if (Value.IsEmpty()) return DefaultValue;
int32 _index = 0;
if (Value.IsNumeric() && !Value.FindChar(TEXT('.'), _index))
{
return FCString::Atoi(*Value);
}
return DefaultValue;
}
float UEasyXMLObject::GetFloatValue(float DefaultValue)
{
if (Value.IsEmpty()) return DefaultValue;
auto isSuccess = Value.IsNumeric();
return isSuccess ? FCString::Atof(*Value) : DefaultValue;
}
FString UEasyXMLObject::GetStringValue(FString DefaultValue)
{
if (Value.IsEmpty()) return DefaultValue;
return Value;
}
bool UEasyXMLObject::GetBoolValue(bool DefaultValue)
{
if (Value.IsEmpty()) return DefaultValue;
if (Value.Equals(TEXT("true"), ESearchCase::IgnoreCase))
{
return true;
}
else if (Value.Equals(TEXT("false"), ESearchCase::IgnoreCase))
{
return false;
}
return DefaultValue;
}