本文整理汇总了C++中firebird::string::assign方法的典型用法代码示例。如果您正苦于以下问题:C++ string::assign方法的具体用法?C++ string::assign怎么用?C++ string::assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类firebird::string
的用法示例。
在下文中一共展示了string::assign方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getString
void ExecuteStatement::getString(thread_db* tdbb,
Firebird::string& sql,
const dsc* desc,
const jrd_req* request)
{
MoveBuffer buffer;
UCHAR* ptr = NULL;
const SSHORT len = (desc && !(request->req_flags & req_null)) ?
MOV_make_string2(tdbb, desc, desc->getTextType(), &ptr, buffer) : 0; // !!! How call Msgs ?
if (!ptr)
{
ERR_post(Arg::Gds(isc_exec_sql_invalid_arg));
}
sql.assign((const char*) ptr, len);
}
示例2: readenv
//***************
// r e a d e n v
//***************
// Goes to read directly the environment variables from the operating system on Windows
// and provides a stub for UNIX.
bool readenv(const char* env_name, Firebird::string& env_value)
{
#ifdef WIN_NT
const DWORD rc = GetEnvironmentVariable(env_name, NULL, 0);
if (rc)
{
env_value.reserve(rc - 1);
DWORD rc2 = GetEnvironmentVariable(env_name, env_value.begin(), rc);
if (rc2 < rc && rc2 != 0)
{
env_value.recalculate_length();
return true;
}
}
#else
const char* p = getenv(env_name);
if (p)
return env_value.assign(p).length() != 0;
#endif
// Not found, clear the output var.
env_value.begin()[0] = 0;
env_value.recalculate_length();
return false;
}
示例3: exactNumericToStr
void exactNumericToStr(SINT64 value, int scale, Firebird::string& target, bool append)
{
if (value == 0)
{
if (append)
target.append("0", 1);
else
target.assign("0", 1);
return;
}
const int MAX_SCALE = 25;
const int MAX_BUFFER = 50;
if (scale < -MAX_SCALE || scale > MAX_SCALE)
{
fb_assert(false);
return; // throw exception here?
}
const bool neg = value < 0;
const bool dot = scale < 0; // Need the decimal separator or not?
char buffer[MAX_BUFFER];
int iter = MAX_BUFFER;
buffer[--iter] = '\0';
if (scale > 0)
{
while (scale-- > 0)
buffer[--iter] = '0';
}
bool dot_used = false;
FB_UINT64 uval = neg ? FB_UINT64(-(value + 1)) + 1 : value; // avoid problems with MIN_SINT64
while (uval != 0)
{
buffer[--iter] = static_cast<char>(uval % 10) + '0';
uval /= 10;
if (dot && !++scale)
{
buffer[--iter] = '.';
dot_used = true;
}
}
if (dot)
{
// if scale > 0 we have N.M
// if scale == 0 we have .M and we need 0.M
// if scale < 0 we have pending zeroes and need 0.{0+}M
if (!dot_used)
{
while (scale++ < 0)
buffer[--iter] = '0';
buffer[--iter] = '.';
buffer[--iter] = '0';
}
else if (!scale)
buffer[--iter] = '0';
}
if (neg)
buffer[--iter] = '-';
const FB_SIZE_T len = MAX_BUFFER - iter - 1;
if (append)
target.append(buffer + iter, len);
else
target.assign(buffer + iter, len);
}
示例4: typeBuffer
/**
typeBuffer
@brief Prints data, returned by service, using outputFunction
@param status
@param buf
@param offset
@param uData
@param outputFunction
@param functionArg
@param text
**/
static int typeBuffer(ISC_STATUS* status, char* buf, int offset,
Auth::UserData& uData, Firebird::IListUsers* callback,
Firebird::string& text)
{
const char* p = &buf[offset];
// Sanity checks
if (*p++ != isc_info_svc_get_users)
{
status[0] = isc_arg_gds;
status[1] = isc_gsec_params_not_allowed;
status[2] = isc_arg_end;
return -1;
}
FB_SIZE_T loop = static_cast<FB_SIZE_T>(isc_vax_integer (p, sizeof (USHORT)));
p += sizeof (USHORT);
if (p[loop] != isc_info_end)
{
status[0] = isc_arg_gds;
status[1] = isc_gsec_params_not_allowed;
status[2] = isc_arg_end;
return -1;
}
// No data - stop processing
if (! loop)
{
return -1;
}
// Old data left - use them
if (offset)
{
memmove(&buf[offset], p, loop + 1);
p = buf;
loop += offset;
offset = 0;
}
while (*p != isc_info_end)
{
fb_assert(p[loop] == isc_info_end);
try
{
switch (*p++)
{
case isc_spb_sec_username:
if (uData.user.get()[0])
{
LocalStatus status;
CheckStatusWrapper statusWrapper(&status);
if (callback)
{
setAttr(&statusWrapper, &uData);
check(&statusWrapper);
callback->list(&statusWrapper, &uData);
check(&statusWrapper);
}
uData.clear(&statusWrapper);
check(&statusWrapper);
}
parseString2(p, uData.user, loop);
break;
case isc_spb_sec_firstname:
parseString2(p, uData.first, loop);
break;
case isc_spb_sec_middlename:
parseString2(p, uData.middle, loop);
break;
case isc_spb_sec_lastname:
parseString2(p, uData.last, loop);
break;
case isc_spb_sec_groupid:
parseLong(p, uData.g, loop);
break;
case isc_spb_sec_userid:
parseLong(p, uData.u, loop);
break;
case isc_spb_sec_admin:
parseLong(p, uData.adm, loop);
break;
default: // give up - treat it as gsec error
text.assign(p - 1, loop + 1);
//.........这里部分代码省略.........