first release of translation facility

* runtime - loading and translating
 * design-time - works with *.ts file (pip_tr utility)
 * compile-time - CMake macro for compile *.ts
This commit is contained in:
2024-11-05 13:49:00 +03:00
parent 73ed51e3d4
commit 57f8c1313e
52 changed files with 1571 additions and 480 deletions

View File

@@ -20,8 +20,7 @@
#include "picli.h"
#include "picodeparser.h"
#include "piiostream.h"
#include <iostream>
#include "pitranslator.h"
using namespace PICoutManipulators;
@@ -107,10 +106,6 @@ void help() {
piCout << help_string;
}
void printError(const PIString & msg) {
std::cerr << msg.data() << std::endl;
}
PIString toCName(const PIString & s) {
PIString ret(s.trimmed());
@@ -307,7 +302,7 @@ bool writeClassStreamMembersOut(PIIOTextStream & ts, const PICodeParser::Entity
++cnt;
if (m.meta.contains("id")) cnt = m.meta.value("id").toInt();
if (used_id[cnt]) {
printError("Error with \"" + e->name + "\" stream operator: ID " + PIString::fromNumber(cnt) + " already used");
piCerr << "Error with \"%1\" stream operator: ID %2 already used"_tr("pip_cmg").arg(e->name).arg(cnt);
return false;
}
if (m.dims.isEmpty()) {
@@ -361,7 +356,7 @@ bool writeClassStreamMembersIn(PIIOTextStream & ts, const PICodeParser::Entity *
++cnt;
if (m.meta.contains("id")) cnt = m.meta.value("id").toInt();
if (used_id[cnt]) {
printError("Error with \"" + e->name + "\" stream operator: ID " + PIString::fromNumber(cnt) + " already used");
piCerr << "Error with \"%1\" stream operator: ID %2 already used"_tr("pip_cmg").arg(e->name).arg(cnt);
return false;
}
used_id << cnt;
@@ -496,7 +491,7 @@ bool writeModel(PICodeParser & parser, PICLI & cli, const PIString out, bool met
PIFile f(out + ".cpp");
f.clear();
if (!f.open(PIIODevice::WriteOnly)) {
piCout << "Error: can`t open out file" << f.path();
piCerr << "Error: can`t open output file \"%1\""_tr("pip_cmg").arg(f.path());
return false;
}
PIIOTextStream ts(&f);
@@ -585,7 +580,7 @@ bool writeModel(PICodeParser & parser, PICLI & cli, const PIString out, bool met
f.setPath(out + ".h");
f.clear();
if (!f.open(PIIODevice::WriteOnly)) {
piCout << "Error: can`t open out file" << f.path();
piCerr << "Error: can`t open output file \"%1\""_tr("pip_cmg").arg(f.path());
return false;
}
ts << "// Generated by \"PIP Code model generator\" " << PIDateTime::current().toString("dd.MM.yyyy hh:mm:ss\n");