refactor: use new line character instead of std::endl

This commit is contained in:
Jan
2024-03-24 20:24:22 +01:00
parent 1b13f1f1b4
commit 132cccb971
49 changed files with 213 additions and 217 deletions

View File

@ -41,7 +41,7 @@ bool CodeGenerator::GenerateCodeForTemplate(RenderingContext* context, ICodeTemp
if (!stream.is_open())
{
std::cout << "Failed to open file '" << p.string() << "'" << std::endl;
std::cout << "Failed to open file '" << p.string() << "'\n";
return false;
}
@ -58,7 +58,7 @@ bool CodeGenerator::GetAssetWithName(IDataRepository* repository, const std::str
auto* def = repository->GetDataDefinitionByName(name);
if (def == nullptr)
{
std::cout << "Could not find type with name '" << name << "'" << std::endl;
std::cout << "Could not find type with name '" << name << "'\n";
return false;
}
@ -66,13 +66,13 @@ bool CodeGenerator::GetAssetWithName(IDataRepository* repository, const std::str
auto* info = defWithMembers != nullptr ? repository->GetInformationFor(defWithMembers) : nullptr;
if (info == nullptr)
{
std::cout << "Could not find type with name '" << name << "'" << std::endl;
std::cout << "Could not find type with name '" << name << "'\n";
return false;
}
if (!StructureComputations(info).IsAsset())
{
std::cout << "Type is not an asset '" << name << "'" << std::endl;
std::cout << "Type is not an asset '" << name << "'\n";
return false;
}
@ -100,7 +100,7 @@ bool CodeGenerator::GenerateCode(IDataRepository* repository)
const auto foundTemplate = m_template_mapping.find(templateName);
if (foundTemplate == m_template_mapping.end())
{
std::cout << "Unknown template '" << generationTask.m_template_name << "'." << std::endl;
std::cout << "Unknown template '" << generationTask.m_template_name << "'.\n";
return false;
}
@ -134,7 +134,7 @@ bool CodeGenerator::GenerateCode(IDataRepository* repository)
const auto end = std::chrono::steady_clock::now();
if (m_args->m_verbose)
{
std::cout << "Generating code took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
std::cout << "Generating code took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms\n";
}
return true;

View File

@ -30,7 +30,7 @@ bool CommandsFileReader::OpenBaseStream()
auto stream = std::make_unique<ParserFilesystemStream>(m_filename);
if (!stream->IsOpen())
{
std::cout << "Could not open commands file" << std::endl;
std::cout << "Could not open commands file\n";
return false;
}
@ -68,7 +68,7 @@ bool CommandsFileReader::ReadCommandsFile(IDataRepository* repository)
{
if (m_args->m_verbose)
{
std::cout << "Reading commands file: " << m_filename << std::endl;
std::cout << "Reading commands file: " << m_filename << "\n";
}
if (!OpenBaseStream())
@ -85,7 +85,7 @@ bool CommandsFileReader::ReadCommandsFile(IDataRepository* repository)
if (m_args->m_verbose)
{
std::cout << "Processing commands took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
std::cout << "Processing commands took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms\n";
}
if (!result)

View File

@ -29,7 +29,7 @@ bool HeaderFileReader::OpenBaseStream()
auto stream = std::make_unique<ParserFilesystemStream>(m_filename);
if (!stream->IsOpen())
{
std::cout << "Could not open header file" << std::endl;
std::cout << "Could not open header file\n";
return false;
}
@ -66,7 +66,7 @@ bool HeaderFileReader::ReadHeaderFile(IDataRepository* repository)
{
if (m_args->m_verbose)
{
std::cout << "Reading header file: " << m_filename << std::endl;
std::cout << "Reading header file: " << m_filename << "\n";
}
if (!OpenBaseStream())
@ -85,7 +85,7 @@ bool HeaderFileReader::ReadHeaderFile(IDataRepository* repository)
if (m_args->m_verbose)
{
std::cout << "Processing header took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
std::cout << "Processing header took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms\n";
}
if (!result)

View File

@ -96,7 +96,7 @@ bool HeaderParserState::ResolveForwardDeclarations()
if (dataDefinition == nullptr)
{
std::cout << "Forward declaration \"" << forwardDeclaration->GetFullName() << "\" was not defined" << std::endl;
std::cout << "Forward declaration \"" << forwardDeclaration->GetFullName() << "\" was not defined\n";
return false;
}

View File

@ -269,7 +269,7 @@ bool CalculateSizeAndAlignPostProcessor::PostProcess(IDataRepository* repository
{
if (repository->GetArchitecture() == Architecture::UNKNOWN)
{
std::cout << "You must set an architecture!" << std::endl;
std::cout << "You must set an architecture!\n";
return false;
}
@ -277,7 +277,7 @@ bool CalculateSizeAndAlignPostProcessor::PostProcess(IDataRepository* repository
{
if (!CalculateFields(repository, structDefinition))
{
std::cout << std::endl;
std::cout << "\n";
return false;
}
}
@ -286,7 +286,7 @@ bool CalculateSizeAndAlignPostProcessor::PostProcess(IDataRepository* repository
{
if (!CalculateFields(repository, unionDefinition))
{
std::cout << std::endl;
std::cout << "\n";
return false;
}
}
@ -295,7 +295,7 @@ bool CalculateSizeAndAlignPostProcessor::PostProcess(IDataRepository* repository
{
if (!CalculateFields(repository, typedefDeclaration->m_type_declaration.get()))
{
std::cout << std::endl;
std::cout << "\n";
return false;
}
}

View File

@ -21,7 +21,7 @@ bool UnionsPostProcessor::ProcessUnion(StructureInformation* info)
if (entriesWithoutConditionCount > 1 && !info->m_usages.empty() && !info->m_is_leaf)
{
std::cout << "Union '" << info->m_definition->GetFullName() << "' has more than one entry without a condition!" << std::endl;
std::cout << "Union '" << info->m_definition->GetFullName() << "' has more than one entry without a condition!\n";
return false;
}

View File

@ -14,9 +14,7 @@ PrettyPrinter::PrettyPrinter(std::ostream& stream, const IDataRepository* reposi
void PrettyPrinter::PrintSeparator() const
{
m_stream << std::endl
<< "==========================================================================================================" << std::endl
<< std::endl;
m_stream << "\n==========================================================================================================\n\n";
}
void PrettyPrinter::PrintVariablePointerToArray(Variable* variable) const
@ -51,7 +49,7 @@ void PrettyPrinter::PrintVariablePointerToArray(Variable* variable) const
m_stream << variable->m_name << ")";
for (auto size : arraySize)
m_stream << '[' << size << ']';
m_stream << std::endl;
m_stream << "\n";
}
void PrettyPrinter::PrintVariableArrayOfPointers(Variable* variable) const
@ -86,7 +84,7 @@ void PrettyPrinter::PrintVariableArrayOfPointers(Variable* variable) const
m_stream << " " << variable->m_name;
for (auto size : arraySize)
m_stream << '[' << size << ']';
m_stream << std::endl;
m_stream << "\n";
}
void PrettyPrinter::PrintVariable(Variable* variable) const
@ -94,7 +92,7 @@ void PrettyPrinter::PrintVariable(Variable* variable) const
const auto& declarationModifiers = variable->m_type_declaration->m_declaration_modifiers;
if (declarationModifiers.empty())
{
std::cout << " " << variable->m_type_declaration->m_type->GetFullName() << " " << variable->m_name << std::endl;
std::cout << " " << variable->m_type_declaration->m_type->GetFullName() << " " << variable->m_name << "\n";
}
else
{
@ -147,7 +145,7 @@ void PrettyPrinter::PrintTypedefPointerToArray(TypedefDefinition* typedefDefinit
m_stream << typedefDefinition->m_name << ")";
for (auto size : arraySize)
m_stream << '[' << size << ']';
m_stream << std::endl;
m_stream << "\n";
}
void PrettyPrinter::PrintTypedefArrayOfPointers(TypedefDefinition* typedefDefinition) const
@ -182,84 +180,84 @@ void PrettyPrinter::PrintTypedefArrayOfPointers(TypedefDefinition* typedefDefini
m_stream << " " << typedefDefinition->m_name;
for (auto size : arraySize)
m_stream << '[' << size << ']';
m_stream << std::endl;
m_stream << "\n";
}
void PrettyPrinter::PrintEnums() const
{
const auto& allEnums = m_repository->GetAllEnums();
m_stream << allEnums.size() << " enums:" << std::endl;
m_stream << allEnums.size() << " enums:\n";
for (auto* enumDefinition : allEnums)
{
m_stream << " Name: " << enumDefinition->GetFullName() << std::endl;
m_stream << " Alignment: " << enumDefinition->GetAlignment() << std::endl;
m_stream << " Size: " << enumDefinition->GetSize() << std::endl;
m_stream << " Name: " << enumDefinition->GetFullName() << "\n";
m_stream << " Alignment: " << enumDefinition->GetAlignment() << "\n";
m_stream << " Size: " << enumDefinition->GetSize() << "\n";
for (const auto& enumMember : enumDefinition->m_members)
{
m_stream << " " << enumMember->m_name << " = " << enumMember->m_value << std::endl;
m_stream << " " << enumMember->m_name << " = " << enumMember->m_value << "\n";
}
m_stream << std::endl;
m_stream << "\n";
}
}
void PrettyPrinter::PrintStructs() const
{
const auto& allStructs = m_repository->GetAllStructs();
m_stream << allStructs.size() << " structs:" << std::endl;
m_stream << allStructs.size() << " structs:\n";
for (auto* structDefinition : allStructs)
{
m_stream << " Name: " << structDefinition->GetFullName() << std::endl;
m_stream << " Alignment: " << structDefinition->GetAlignment() << std::endl;
m_stream << " Size: " << structDefinition->GetSize() << std::endl;
m_stream << " Name: " << structDefinition->GetFullName() << "\n";
m_stream << " Alignment: " << structDefinition->GetAlignment() << "\n";
m_stream << " Size: " << structDefinition->GetSize() << "\n";
for (const auto& variable : structDefinition->m_members)
{
PrintVariable(variable.get());
}
m_stream << std::endl;
m_stream << "\n";
}
}
void PrettyPrinter::PrintUnions() const
{
const auto& allUnions = m_repository->GetAllUnions();
m_stream << allUnions.size() << " unions:" << std::endl;
m_stream << allUnions.size() << " unions:\n";
for (auto* unionDefinition : allUnions)
{
m_stream << " Name: " << unionDefinition->GetFullName() << std::endl;
m_stream << " Alignment: " << unionDefinition->GetAlignment() << std::endl;
m_stream << " Size: " << unionDefinition->GetSize() << std::endl;
m_stream << " Name: " << unionDefinition->GetFullName() << "\n";
m_stream << " Alignment: " << unionDefinition->GetAlignment() << "\n";
m_stream << " Size: " << unionDefinition->GetSize() << "\n";
for (const auto& variable : unionDefinition->m_members)
{
PrintVariable(variable.get());
}
m_stream << std::endl;
m_stream << "\n";
}
}
void PrettyPrinter::PrintTypedefs() const
{
const auto& allTypedefs = m_repository->GetAllTypedefs();
m_stream << allTypedefs.size() << " typedefs:" << std::endl;
m_stream << allTypedefs.size() << " typedefs:\n";
for (auto* typedefDefinition : allTypedefs)
{
m_stream << " Name: " << typedefDefinition->GetFullName() << std::endl;
m_stream << " Alignment: " << typedefDefinition->GetAlignment() << std::endl;
m_stream << " Size: " << typedefDefinition->GetSize() << std::endl;
m_stream << " Name: " << typedefDefinition->GetFullName() << "\n";
m_stream << " Alignment: " << typedefDefinition->GetAlignment() << "\n";
m_stream << " Size: " << typedefDefinition->GetSize() << "\n";
const auto& declarationModifiers = typedefDefinition->m_type_declaration->m_declaration_modifiers;
if (declarationModifiers.empty())
{
std::cout << " " << typedefDefinition->m_type_declaration->m_type->GetFullName() << std::endl;
std::cout << " " << typedefDefinition->m_type_declaration->m_type->GetFullName() << "\n";
}
else
{
@ -279,7 +277,7 @@ void PrettyPrinter::PrintTypedefs() const
}
}
m_stream << std::endl;
m_stream << "\n";
}
}

View File

@ -172,7 +172,7 @@ bool ZoneCodeGeneratorArguments::ParseArgs(const int argc, const char** argv, bo
}
else
{
std::cout << "At least one header file must be specified via -h / --header." << std::endl;
std::cout << "At least one header file must be specified via -h / --header.\n";
return false;
}
@ -184,7 +184,7 @@ bool ZoneCodeGeneratorArguments::ParseArgs(const int argc, const char** argv, bo
}
else
{
std::cout << "At least one commands file must be specified via -c / --commands-file." << std::endl;
std::cout << "At least one commands file must be specified via -c / --commands-file.\n";
return false;
}
@ -206,7 +206,7 @@ bool ZoneCodeGeneratorArguments::ParseArgs(const int argc, const char** argv, bo
if (m_task_flags == 0)
{
std::cout << "There was no output task specified." << std::endl;
std::cout << "There was no output task specified.\n";
PrintUsage();
return false;
}