exec/constants.cpp.sh
author František Kučera <franta-hg@frantovo.cz>
Sat, 11 Jan 2020 01:02:01 +0100
branchv_0
changeset 2 dace11211dc9
permissions -rwxr-xr-x
exec: protocol update + constants generator

#!/bin/bash

CSV="$(cat)";

echo "// This file was generated from the specification.

#include <map>
#include <string>

namespace relpipe {
namespace in {
namespace filesystem {

class ExecMsg {
public:
";

echo "$CSV" | relpipe-in-csv constants | relpipe-tr-sql --relation 'constants' "SELECT '	static const int ' || message || ';' FROM constants WHERE code > 0" | relpipe-out-nullbyte | xargs -0 -n1 echo

echo "
	static std::map<int, std::wstring> getMessageNames() {
		std::map<int, std::wstring> m;
";

echo "$CSV" | relpipe-in-csv constants | relpipe-tr-sql --relation 'constants' "SELECT '		m[' || message || '] = L\"' || message || '\";' FROM constants WHERE code > 0" | relpipe-out-nullbyte | xargs -0 -n1 echo

echo "
		return m;
	}

};
"

echo "$CSV" | relpipe-in-csv constants | relpipe-tr-sql --relation 'constants' "SELECT 'const int ExecMsg::' || message || ' = ' || code || ';' FROM constants WHERE code > 0" | relpipe-out-nullbyte | xargs -0 -n1 echo

echo "
}
}
}";