tools/errmsg: generate the function to use when determining if a check should be done or not
This commit is contained in:
parent
31f95aeec9
commit
59a644b4b1
@ -9,12 +9,16 @@ private:
|
|||||||
std::string _funcname;
|
std::string _funcname;
|
||||||
std::string _msg;
|
std::string _msg;
|
||||||
std::string _par1;
|
std::string _par1;
|
||||||
|
unsigned int _settings;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Message(std::string funcname, std::string msg, std::string par1)
|
Message(std::string funcname, unsigned int settings, std::string msg, std::string par1)
|
||||||
: _funcname(funcname), _msg(msg), _par1(par1)
|
: _funcname(funcname), _settings(settings), _msg(msg), _par1(par1)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
static const unsigned int ALL = 1;
|
||||||
|
static const unsigned int STYLE = 2;
|
||||||
|
|
||||||
std::string msg() const
|
std::string msg() const
|
||||||
{
|
{
|
||||||
std::string ret("\"" + _msg + "\"");
|
std::string ret("\"" + _msg + "\"");
|
||||||
@ -34,12 +38,30 @@ public:
|
|||||||
|
|
||||||
void generateCode() const
|
void generateCode() const
|
||||||
{
|
{
|
||||||
|
// Error message..
|
||||||
std::cout << " static std::string " << _funcname << "(";
|
std::cout << " static std::string " << _funcname << "(";
|
||||||
if (! _par1.empty())
|
if (! _par1.empty())
|
||||||
std::cout << "const std::string &" << _par1;
|
std::cout << "const std::string &" << _par1;
|
||||||
std::cout << ") const\n";
|
std::cout << ") const\n";
|
||||||
|
|
||||||
std::cout << " { return " << msg() << "; }" << std::endl;
|
std::cout << " { return " << msg() << "; }" << std::endl;
|
||||||
|
|
||||||
|
// Settings..
|
||||||
|
std::cout << std::endl;
|
||||||
|
std::cout << " static bool " << _funcname << "(const Settings &s) const" << std::endl;
|
||||||
|
std::cout << " { return ";
|
||||||
|
if (_settings == 0)
|
||||||
|
std::cout << "true";
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_settings & ALL)
|
||||||
|
std::cout << "s._showAll";
|
||||||
|
if (_settings & (ALL | STYLE))
|
||||||
|
std::cout << " & ";
|
||||||
|
if (_settings & STYLE)
|
||||||
|
std::cout << "s._checkCodingStyle";
|
||||||
|
}
|
||||||
|
std::cout << "; }" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -51,7 +73,7 @@ int main()
|
|||||||
{
|
{
|
||||||
// Error messages..
|
// Error messages..
|
||||||
std::list<Message> err;
|
std::list<Message> err;
|
||||||
err.push_back(Message("memleak", "Memory leak: %1", "varname"));
|
err.push_back(Message("memleak", 0, "Memory leak: %1", "varname"));
|
||||||
|
|
||||||
// Generate code..
|
// Generate code..
|
||||||
for (std::list<Message>::const_iterator it = err.begin(); it != err.end(); ++it)
|
for (std::list<Message>::const_iterator it = err.begin(); it != err.end(); ++it)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user