Skip to content
Snippets Groups Projects

Rename time created

Merged Fabian Tërnava requested to merge armem/dev into master
6 files
+ 132
25
Compare changes
  • Side-by-side
  • Inline
Files
6
@@ -177,33 +177,60 @@ int main(int argc, char* argv[])
}
}
auto w = CppWriterPtr(new CppWriter());
// Generate enums at top of generated header file
std::vector<MetaEnumPtr> enums = writer.getTypeEnums();
if (verbose)
{
std::cout << "Now exporting enums..." << std::endl;
}
MetaEnum::Write(enums, w);
std::string enum_file_generation_content = w->getString();
if (verbose)
{
std::cout << "Now exporting enums... done!" << std::endl;
}
if (enums.size() > 0 && enum_file_generation_content == "")
{
std::cerr << "\033[31m" << "Error code 11 - Found error in code generation. Aborting!" << "\033[0m" << std::endl;
exit(1);
}
// Generate all classes
std::vector<MetaClassPtr> classes = writer.getTypeClasses();
if (verbose)
{
std::cout << "Now exporting classes..." << std::endl;
}
auto w = CppWriterPtr(new CppWriter());
CppClass::Write(classes, w);
std::string new_file_content = w->getString();
std::string class_file_generation_content = simox::alg::remove_prefix(w->getString(), enum_file_generation_content);
if (verbose)
{
std::cout << "Now exporting classes... done!" << std::endl;
}
if (new_file_content == "")
if (classes.size() > 0 && class_file_generation_content == "")
{
std::cerr << "Found error in code generation. Aborting!" << std::endl;
std::cerr << "\033[31m" << "Error code 21 - Found error in code generation. Aborting!" << "\033[0m" << std::endl;
exit(1);
}
std::time_t current_time = std::time(0);
std::tm* now = std::localtime(&current_time);
std::string current_year = std::to_string(now->tm_year + 1900);
std::string new_file_header = "\
/* \n\
* This file is part of ArmarX. \n\
* \n\
* Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), \n\
* Copyright (C) 2012-" + current_year + ", High Performance Humanoid Technologies (H2T), \n\
* Karlsruhe Institute of Technology (KIT), all rights reserved. \n\
* \n\
* ArmarX is free software; you can redistribute it and/or modify \n\
@@ -228,7 +255,7 @@ int main(int argc, char* argv[])
************************************************************************* \n\
*/\n\n\n";
std::string new_file_full_content = new_file_header + new_file_content;
std::string new_file_full_content = new_file_header + w->getString();
std::string new_name_with_extension = input_file.filename().replace_extension("").string();
new_name_with_extension += ".aron.generated.h";
@@ -247,7 +274,7 @@ int main(int argc, char* argv[])
{
if (verbose)
{
std::cout << "File content not changed for <" + output_file.string() + ">" << std::endl;
std::cout << "\033[31m" << "Error code 31 - File content not changed for <" + output_file.string() + ">" << "\033[0m" << std::endl;
}
exit(0);
}
@@ -261,12 +288,12 @@ int main(int argc, char* argv[])
if (verbose)
{
std::cout << "Finished generating <" + output_file.string() + ">. The new file ist called <" << output_file.string() << ">" << std::endl;
std::cout << "\033[32m" << "Finished generating <" + output_file.string() + ">. The new file ist called <" << output_file.string() << ">" << "\033[0m" << std::endl;
}
}
catch (const cxxopts::OptionException& e)
{
std::cerr << "Error in parsing cxxopts options: " << e.what() << std::endl;
std::cerr << "\033[31m" << "Error code 01 - Error in parsing cxxopts options: " << e.what() << "\033[0m" << std::endl;
exit(1);
}
exit(0);
Loading