本文整理汇总了C++中stdString::length方法的典型用法代码示例。如果您正苦于以下问题:C++ stdString::length方法的具体用法?C++ stdString::length怎么用?C++ stdString::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stdString
的用法示例。
在下文中一共展示了stdString::length方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_names_for_pattern
// Iterate over names in index, fetch those
// that match the pattern.
void get_names_for_pattern(Index &index,
stdVector<stdString> &names,
const stdString &pattern)
{
if (verbose)
printf("Expanding pattern '%s'\n", pattern.c_str());
try
{
AutoPtr<RegularExpression> regex;
if (pattern.length() > 0)
regex.assign(new RegularExpression(pattern.c_str()));
Index::NameIterator name_iter;
if (!index.getFirstChannel(name_iter))
return; // No names
// Put all names in binary tree
BinaryTree<stdString> channels;
do
{
if (regex && !regex->doesMatch(name_iter.getName()))
continue; // skip what doesn't match regex
channels.add(name_iter.getName());
}
while (index.getNextChannel(name_iter));
// Sorted dump of names
channels.traverse(add_name2vector, (void *)&names);
}
catch (GenericException &e)
{
throw GenericException(__FILE__, __LINE__,
"Error expanding name pattern '%s':\n%s\n",
pattern.c_str(), e.what());
}
}
示例2: Save
int CSqEzdib::Save( const stdString &sFile )
{_STT();
if ( !m_ezimg || !sFile.length() )
return 0;
return oss::ezd_save( m_ezimg, oexStrToMb( sqbind::std2oex( sFile ) ).c_str() );
}
示例3: unescape
void CGIDemangler::unescape(stdString &text)
{
size_t total = text.length() + 1;
MemoryBuffer<char> buf(total);
memcpy(buf.mem(), text.c_str(), total);
unescape(buf.mem());
text = buf.mem();
}
示例4: getHeaderSize
size_t DataFile::getHeaderSize(const stdString &name,
DbrType dbr_type, DbrCount dbr_count,
size_t num_samples)
{
size_t raw_value_size = RawValue::getSize(dbr_type, dbr_count);
size_t buf_free = num_samples * raw_value_size;
// 'INFO' + name + '\0' + header info + data buffer
return 4 + name.length() + 1 +
sizeof(DataHeader::DataHeaderData) + buf_free;
}
示例5: setNumeric
void CtrlInfo::setNumeric(
int32_t prec, const stdString &units,
float disp_low, float disp_high,
float low_alarm, float low_warn, float high_warn, float high_alarm)
{
size_t len = units.length();
size_t size = sizeof(CtrlInfoData) + len;
_infobuf.reserve(size);
CtrlInfoData *info = _infobuf.mem();
info->type = Numeric;
info->size = size;
info->value.analog.disp_high = disp_high;
info->value.analog.disp_low = disp_low;
info->value.analog.low_warn = low_warn;
info->value.analog.low_alarm = low_alarm;
info->value.analog.high_warn = high_warn;
info->value.analog.high_alarm = high_alarm;
info->value.analog.prec = prec;
string2cp (info->value.analog.units, units, len+1);
}
示例6: Escape
stdString CSqSQLite::Escape( const stdString &sStr )
{_STT();
oex::CStr sEsc( sStr.c_str(), sStr.length() );
sEsc = CSQLite::Escape( sEsc );
return stdString().assign( sEsc.Ptr(), (stdString::size_type)sEsc.Length() );
}
示例7: dump_spreadsheet
// Create text file with spread-sheet formatted data.
void dump_spreadsheet(Index &index,
stdVector<stdString> names,
epicsTime *start, epicsTime *end,
bool raw_time,
bool status_text,
ReaderFactory::How how, double delta,
stdString output_name)
{
SpreadsheetReader sheet(index, how, delta);
bool ok = sheet.find(names, start);
size_t i;
stdString time, stat, val;
const RawValue::Data *value;
FILE *f = stdout;
AutoFilePtr file;
if (output_name.length() > 0)
{
file.open(output_name.c_str(), "wt");
if (file)
f = file;
else
throw GenericException(__FILE__, __LINE__,
"Cannot open %s", output_name.c_str());
}
fprintf(f, "# Generated by ArchiveExport " ARCH_VERSION_TXT "\n");
fprintf(f, "# Method: %s\n", ReaderFactory::toString(how, delta));
fprintf(f, "\n");
fprintf(f, "# Time ");
if (raw_time)
fprintf(f, "\tsecs");
for (i=0; i<sheet.getNum(); ++i)
{
if (sheet.found(i))
fprintf(f, "\t%s [%s]",
sheet.getName(i).c_str(),
sheet.getInfo(i).getUnits());
else
fprintf(f, "\t%s - NOT FOUND",
sheet.getName(i).c_str());
if (status_text)
fprintf(f, "\t");
}
fprintf(f, "\n");
while (ok)
{
if (end && sheet.getTime() >= *end)
break;
// '03/23/2004 10:48:48.032899334'
format_time(sheet.getTime(), time);
fprintf(f, "%s", time.c_str());
if (raw_time)
{
epicsTimeStamp stamp = sheet.getTime();
fprintf(f, "\t%lu", (unsigned long)stamp.secPastEpoch);
}
for (i=0; i<sheet.getNum(); ++i)
{
value = sheet.get(i);
if (value)
{
RawValue::getStatus(value, stat);
if (RawValue::isInfo(value))
{
fprintf(f, "\t#N/A");
if (status_text)
fprintf(f, "\t%s", stat.c_str());
}
else
{
RawValue::getValueString(
val, sheet.getType(i), sheet.getCount(i),
value, &sheet.getInfo(i), format, precision);
fprintf(f, "\t%s", val.c_str());
if (status_text)
fprintf(f, "\t%s", stat.c_str());
}
}
else
{
fprintf(f, "\t#N/A");
if (status_text)
fprintf(f, "\t<no data>");
}
}
fprintf(f, "\n");
ok = sheet.next();
}
}
示例8: out
void HTMLPage::out(const stdString &line)
{ out(line.c_str(), line.length ()); }
示例9: string2epicsTime
// Convert string "mm/dd/yyyy" or "mm/dd/yyyy 00:00:00" or
// "mm/dd/yyyy 00:00:00.000000000" into epicsTime
// Result: true for OK
bool string2epicsTime(const stdString &txt, epicsTime &time)
{
size_t i, tlen = txt.length();
// number check ("ab/cd/efgh" is caught here)
for (i=0; i<tlen; ++i)
if (!strchr("/0123456789 :.", txt[i]))
return false;
// 0123456789
// "mm/dd/yyyy" ?
if (tlen < 10 || txt[2] != '/' || txt[5] != '/')
{ // Special case for testing
epicsTimeStamp stamp;
stamp.secPastEpoch = atoi(txt.c_str());
stamp.nsec = 0;
time = stamp;
return stamp.secPastEpoch <= 1000;
}
struct local_tm_nano_sec tm;
memset(&tm, 0, sizeof(struct local_tm_nano_sec));
tm.ansi_tm.tm_isdst = -1; /* don't know if daylight saving or not */
tm.ansi_tm.tm_mon = (txt[0]-'0')*10 + (txt[1]-'0') - 1;
tm.ansi_tm.tm_mday = (txt[3]-'0')*10 + (txt[4]-'0');
tm.ansi_tm.tm_year = (txt[6]-'0')*1000 + (txt[7]-'0')*100 +
(txt[8]-'0')*10 + (txt[9]-'0') - 1900;
// 0123456789012345
// "mm/dd/yyyy ..." - check the space after the date.
if (tlen > 10 && txt[10] != ' ')
return false;
// 0123456789012345
// "mm/dd/yyyy 00:00" - check the ':' in the time.
if (tlen >= 16)
{
if (txt[13] != ':')
return false;
tm.ansi_tm.tm_hour = (txt[11]-'0')*10 + (txt[12]-'0');
tm.ansi_tm.tm_min = (txt[14]-'0')*10 + (txt[15]-'0');
}
// 0123456789012345678
// "mm/dd/yyyy 00:00:00" - are there seconds?
if (tlen >= 19)
{
if (txt[16] != ':')
return false;
tm.ansi_tm.tm_sec = (txt[17]-'0')*10 + (txt[18]-'0');
}
// 01234567890123456789012345678
// "mm/dd/yyyy 00:00:00.000" - are there milli but not nano seconds?
if (tlen == 23 && txt[19] == '.')
tm.nSec =
(txt[20]-'0')*100000000 +
(txt[21]-'0')*10000000 +
(txt[22]-'0')*1000000;
// 01234567890123456789012345678
// "mm/dd/yyyy 00:00:00.000000000" - are there nano seconds?
if (tlen == 29 && txt[19] == '.')
tm.nSec =
(txt[20]-'0')*100000000 +
(txt[21]-'0')*10000000 +
(txt[22]-'0')*1000000 +
(txt[23]-'0')*100000 +
(txt[24]-'0')*10000 +
(txt[25]-'0')*1000 +
(txt[26]-'0')*100 +
(txt[27]-'0')*10 +
(txt[28]-'0');
time = tm;
return true;
}