How to hide the same code (not using MACRO) ?
Posted: Thu Oct 10, 2013 7:42 am
Client-side code:
How to hide the same code?
I'm not good in the C++, boost, BOOSTPP and other.
Code: Select all
// interface (C-style)
int NI_Print(const std::string & text);
int NI_PrintSL(const QStringList & text);
int NI_Print(const std::string & text)
{
int hr = NOERROR;
int xi = 0;
do {
try
{
hr = g_rcfclnt->Print(text);
}
catch (const RCF::Exception & e)
{
hr = E_FAIL;
if (!xi && e.getErrorId() != RCF::RcfError_ClientReadFail) xi++; // xi = 1;
xi++;
if (xi > 1) NI_SetLastErrorMsg(e);
}
if (xi > 1) break; // when an error number 31, try running the query again
} while (xi > 0);
return hr;
}
int NI_PrintSL(const QStringList & text)
{
int hr = NOERROR;
int xi = 0;
do {
try
{
hr = g_rcfclnt->PrintSL(text);
}
catch (const RCF::Exception & e)
{
hr = E_FAIL;
if (!xi && e.getErrorId() != RCF::RcfError_ClientReadFail) xi++; // xi = 1;
xi++;
if (xi > 1) NI_SetLastErrorMsg(e);
}
if (xi > 1) break; // when an error number 31, try running the query again
} while (xi > 0);
return hr;
}
I'm not good in the C++, boost, BOOSTPP and other.