MassBuilderSaveTool/src/UESaveFile/Debug.cpp

77 lines
3.1 KiB
C++

// MassBuilderSaveTool
// Copyright (C) 2021-2022 Guillaume Jacquemin
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "Types/UnrealPropertyBase.h"
#include "Types/ArrayProperty.h"
#include "Types/SetProperty.h"
#include "Types/StructProperty.h"
#include "Types/GenericStructProperty.h"
#include "Debug.h"
Utility::Debug& operator<<(Utility::Debug& debug, const ArrayProperty* prop) {
return debug << (*prop->name).c_str() << Utility::Debug::nospace << ":" <<
prop->propertyType.c_str() << "of" << prop->items.size() << prop->itemType.c_str();
}
Utility::Debug& operator<<(Utility::Debug& debug, const SetProperty* prop) {
return debug << (*prop->name).c_str() << Utility::Debug::nospace << ":" <<
prop->propertyType.c_str() << "of" << prop->items.size() << prop->itemType.c_str();
}
Utility::Debug& operator<<(Utility::Debug& debug, const GenericStructProperty* prop) {
debug << (*prop->name).c_str() << Utility::Debug::nospace << ":" <<
prop->structType.c_str() << "(" << Utility::Debug::nospace << prop->propertyType.c_str() << Utility::Debug::nospace <<
") Contents:";
for(const auto& item : prop->properties) {
debug << "\n " << Utility::Debug::nospace << item.get();
}
return debug;
}
Utility::Debug& operator<<(Utility::Debug& debug, const StructProperty* prop) {
auto cast = dynamic_cast<const GenericStructProperty*>(prop);
if(cast) {
return debug << cast;
}
return debug << (*prop->name).c_str() << Utility::Debug::nospace << ":" <<
prop->structType.c_str() << "(" << Utility::Debug::nospace << prop->propertyType.c_str() << Utility::Debug::nospace << ")";
}
Utility::Debug& operator<<(Utility::Debug& debug, const UnrealPropertyBase* prop) {
if(prop->propertyType == "ArrayProperty") {
auto array_prop = dynamic_cast<const ArrayProperty*>(prop);
if(array_prop) {
return debug << array_prop;
}
}
else if(prop->propertyType == "SetProperty") {
auto set_prop = dynamic_cast<const SetProperty*>(prop);
if(set_prop) {
return debug << set_prop;
}
}
else if(prop->propertyType == "StructProperty") {
auto struct_prop = dynamic_cast<const StructProperty*>(prop);
if(struct_prop) {
return debug << struct_prop;
}
}
return debug << (*prop->name).c_str() << Utility::Debug::nospace << ":" << prop->propertyType.c_str();
}