本文整理汇总了C++中firebird::string::trim方法的典型用法代码示例。如果您正苦于以下问题:C++ string::trim方法的具体用法?C++ string::trim怎么用?C++ string::trim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类firebird::string
的用法示例。
在下文中一共展示了string::trim方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stuff_stack_trace
static void stuff_stack_trace(const jrd_req* request)
{
Firebird::string sTrace;
bool isEmpty = true;
for (const jrd_req* req = request; req; req = req->req_caller)
{
const JrdStatement* statement = req->getStatement();
Firebird::string name;
if (statement->triggerName.length())
{
name = "At trigger '";
name += statement->triggerName.c_str();
}
else if (statement->procedure)
{
name = statement->parentStatement ? "At sub procedure '" : "At procedure '";
name += statement->procedure->getName().toString().c_str();
}
else if (statement->function)
{
name = statement->parentStatement ? "At sub function '" : "At function '";
name += statement->function->getName().toString().c_str();
}
if (! name.isEmpty())
{
name.trim();
if (sTrace.length() + name.length() + 2 > MAX_STACK_TRACE)
break;
if (isEmpty)
{
isEmpty = false;
sTrace += name + "'";
}
else {
sTrace += "\n" + name + "'";
}
if (req->req_src_line)
{
Firebird::string src_info;
src_info.printf(" line: %"ULONGFORMAT", col: %"ULONGFORMAT,
req->req_src_line, req->req_src_column);
if (sTrace.length() + src_info.length() > MAX_STACK_TRACE)
break;
sTrace += src_info;
}
}
}
if (!isEmpty)
ERR_post_nothrow(Arg::Gds(isc_stack_trace) << Arg::Str(sTrace));
}
示例2:
SINT64 ConfigFile::Parameter::asInteger() const
{
if (value.isEmpty())
return 0;
SINT64 ret = 0;
int sign = 1;
int state = 1; // 1 - sign, 2 - numbers, 3 - multiplier
Firebird::string trimmed = value;
trimmed.trim(" \t");
if (trimmed.isEmpty())
return 0;
const char* ch = trimmed.c_str();
for (; *ch; ch++)
switch (*ch)
{
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
if (state > 2)
return 0;
state = 2;
ret = ret * 10 + (*ch - '0');
break;
case '-':
if (state > 1)
return 0;
sign = -sign;
break;
case ' ': case '\t':
if (state == 1)
break;
return 0;
case 'k': case 'K':
if (state != 2)
return 0;
state = 3;
ret = ret * 1024;
break;
case 'm': case 'M':
if (state != 2)
return 0;
state = 3;
ret = ret * 1024 * 1024;
break;
case 'g': case 'G':
if (state != 2)
return 0;
state = 3;
ret = ret * 1024 * 1024 * 1024;
break;
default:
return 0;
};
return sign * ret;
}