本文整理汇总了C++中stdString类的典型用法代码示例。如果您正苦于以下问题:C++ stdString类的具体用法?C++ stdString怎么用?C++ stdString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了stdString类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: seek_time
bool seek_time(const stdString &index_name,
const stdString &channel_name,
const stdString &start_txt)
{
epicsTime start;
if (!string2epicsTime(start_txt, start))
{
fprintf(stderr, "Cannot convert '%s' to time stamp\n",
start_txt.c_str());
return false;
}
IndexFile index(3);
index.open(index_name, true);
stdString directory;
AutoPtr<RTree> tree(index.getTree(channel_name, directory));
if (tree)
{
RTree::Datablock block;
RTree::Node node(tree->getM(), true);
int idx;
if (tree->searchDatablock(start, node, idx, block))
{
stdString s, e;
printf("Found block %s - %s\n",
epicsTimeTxt(node.record[idx].start, s),
epicsTimeTxt(node.record[idx].end, e));
}
else
printf("Nothing found\n");
}
else
fprintf(stderr, "Cannot find channel '%s'\n", channel_name.c_str());
return true;
}
开发者ID:epicsdeb,项目名称:channelarchiver,代码行数:34,代码来源:main.cpp
示例2: Update
int CSqSQLite::Update( const stdString &sTable, const stdString &sWhere, CSqMulti &mData )
{_STT();
if ( !mData.size() ) return 0;
oex::CPropertyBag pb;
SQBIND_MultiToPropertyBag( mData.list(), pb );
return CSQLite::Update( sTable.c_str(), sWhere.c_str(), pb );
}
开发者ID:wheresjames,项目名称:winglib,代码行数:7,代码来源:sq_sqlite.cpp
示例3: 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());
}
}
开发者ID:epicsdeb,项目名称:channelarchiver,代码行数:35,代码来源:main.cpp
示例4: makeDataFileName
void DataWriter::makeDataFileName(int serial, stdString &name)
{
int len;
char buffer[30];
if (data_file_name_base.length() > 0)
{
name = data_file_name_base;
if (serial > 0)
{
len = snprintf(buffer, sizeof(buffer), "-%d", serial);
if (len >= (int)sizeof(buffer))
len = sizeof(buffer)-1;
name.append(buffer, len);
}
return;
}
// Else: Create name based on "<today>[-serial]"
int year, month, day, hour, min, sec;
unsigned long nano;
epicsTime now = epicsTime::getCurrent();
epicsTime2vals(now, year, month, day, hour, min, sec, nano);
if (serial > 0)
len = snprintf(buffer, sizeof(buffer),
"%04d%02d%02d-%d", year, month, day, serial);
else
len = snprintf(buffer,sizeof(buffer),
"%04d%02d%02d", year, month, day);
if (len >= (int)sizeof(buffer))
len = sizeof(buffer)-1;
name.assign(buffer, len);
}
开发者ID:epicsdeb,项目名称:channelarchiver,代码行数:32,代码来源:DataWriter.cpp
示例5: 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();
}
开发者ID:EPICSTools,项目名称:ChannelArchiver,代码行数:8,代码来源:CGIDemangler.cpp
示例6: copy
// Copy samples from archive with index_name
// to new index copy_name.
// Uses all samples in source archive or [start ... end[ .
void copy(const stdString &index_name, const stdString ©_name,
int RTreeM, const epicsTime *start, const epicsTime *end,
const stdString &single_name)
{
IndexFile index(RTreeM), new_index(RTreeM);
IndexFile::NameIterator names;
size_t channel_count = 0, value_count = 0, back_count = 0;
BenchTimer timer;
stdString dir1, dir2;
Filename::getDirname(index_name, dir1);
Filename::getDirname(copy_name, dir2);
if (dir1 == dir2)
{
printf("You have to assert that the new index (%s)\n"
"is in a directory different from the old index\n"
"(%s)\n", copy_name.c_str(), index_name.c_str());
return;
}
index.open(index_name, true);
new_index.open(copy_name, false);
if (verbose)
printf("Copying values from '%s' to '%s'\n",
index_name.c_str(), copy_name.c_str());
RawDataReader reader(index);
if (single_name.empty())
{
bool ok = index.getFirstChannel(names);
while (ok)
{
copy_channel(names.getName(), start, end, index, reader,
new_index, channel_count, value_count, back_count);
ok = index.getNextChannel(names);
}
}
else
copy_channel(single_name, start, end, index, reader,
new_index, channel_count, value_count, back_count);
new_index.close();
index.close();
timer.stop();
if (verbose)
{
printf("Total: %lu channels, %lu values\n",
(unsigned long) channel_count, (unsigned long) value_count);
printf("Skipped %lu back-in-time values\n",
(unsigned long) back_count);
printf("Runtime: %s\n", timer.toString().c_str());
}
}
开发者ID:epicsdeb,项目名称:channelarchiver,代码行数:52,代码来源:main.cpp
示例7: dot_index
void dot_index(const stdString &index_name, const stdString channel_name,
const stdString &dot_name)
{
IndexFile index(3);
index.open(index_name, true);
stdString directory;
AutoPtr<RTree> tree(index.getTree(channel_name, directory));
if (!tree)
{
fprintf(stderr, "Cannot find '%s' in index '%s'.\n",
channel_name.c_str(), index_name.c_str());
return;
}
tree->makeDot(dot_name.c_str());
}
开发者ID:epicsdeb,项目名称:channelarchiver,代码行数:15,代码来源:main.cpp
示例8: NamedBase
GroupInfo::GroupInfo(const stdString &name)
: NamedBase(name.c_str()),
mutex("GroupInfo", EngineLocks::GroupInfo),
num_connected(0),
disable_count(0)
{
}
开发者ID:EPICSTools,项目名称:ChannelArchiver,代码行数:7,代码来源:GroupInfo.cpp
示例9: remove
// Remove name from directory file.
// Will not remove data but only "pointers" to the data!
bool OldDirectoryFile::remove(const stdString &name)
{
OldDirectoryFileIterator i(this);
HashTable::HashValue hash = HashTable::Hash(name.c_str());
FileOffset prev=0, offset = readHTEntry(hash);
// Follow the channel chain that hashes to this value:
while (offset != INVALID_OFFSET)
{
i.entry.read(_file, offset);
if (name == i.entry.data.name)
{
// unlink this entry from list of names that share 'hash'
if (prev == 0) // first entry in list?
{
// Make hash table point to the next channel,
// skipping this one
writeHTEntry(hash, i.entry.data.next_entry_offset);
return true;
}
else
{
// Make previous entry skip this one
offset = i.entry.data.next_entry_offset;
i.entry.read(_file, prev);
i.entry.data.next_entry_offset = offset;
i.entry.write(_file, prev);
return true;
}
}
prev = offset;
offset = i.entry.data.next_entry_offset;
}
return false;
}
开发者ID:EPICSTools,项目名称:ChannelArchiver,代码行数:37,代码来源:OldDirectoryFile.cpp
示例10: getNames
bool ArchiveDataClient::getNames(int key, const stdString &pattern,
stdVector<NameInfo> &names)
{
xmlrpc_value *result, *element;
const char *name;
xmlrpc_int32 start_sec, start_nano, end_sec, end_nano;
size_t count, i, len;
NameInfo info;
result = xmlrpc_client_call(&env, (char *)URL, "archiver.names", "(is)",
(xmlrpc_int32) key, pattern.c_str());
if (log_fault())
return false;
count = xmlrpc_array_size(&env, result);
names.reserve(count);
for (i=0; i<count; ++i)
{
element = xmlrpc_array_get_item(&env, result, i);
if (log_fault())
return false;
xmlrpc_parse_value(&env, element, "{s:s#,s:i,s:i,s:i,s:i,*}",
"name", &name, &len,
"start_sec", &start_sec,
"start_nano", &start_nano,
"end_sec", &end_sec,
"end_nano", &end_nano);
if (log_fault())
return false;
info.name.assign(name, len);
pieces2epicsTime(start_sec, start_nano, info.start);
pieces2epicsTime(end_sec, end_nano, info.end);
names.push_back(info);
}
xmlrpc_DECREF(result);
return true;
}
开发者ID:EPICSTools,项目名称:ChannelArchiver,代码行数:35,代码来源:ArchiveDataClient.cpp
示例11: add_name2vector
// Visitor for BinaryTree of channel names;
// see get_names_for_pattern().
static void add_name2vector(const stdString &name, void *arg)
{
stdVector<stdString> *names = (stdVector<stdString> *)arg;
if (verbose)
printf("%s\n", name.c_str());
names->push_back(name);
}
开发者ID:epicsdeb,项目名称:channelarchiver,代码行数:9,代码来源:main.cpp
示例12: GenericException
ArchiveException::ArchiveException(const char *sourcefile, size_t line,
Code code, const stdString &detail)
: GenericException(sourcefile, line,
"Archive Exception: %s,\n%s\n",
error_text[code], detail.c_str()),
code(code)
{}
开发者ID:EPICSTools,项目名称:ChannelArchiver,代码行数:7,代码来源:ArchiveException.cpp
示例13: 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() );
}
开发者ID:wheresjames,项目名称:winglib,代码行数:8,代码来源:sq_ezdib.cpp
示例14: open
bool OldDirectoryFile::open(const stdString &filename, bool for_write)
{
_filename = filename;
Filename::getDirname(_filename, _dirname);
_file_for_write = for_write;
_file = fopen(filename.c_str(), "r+b");
if (_file==0 && for_write)
_file = fopen(filename.c_str(), "w+b");
if (_file == 0)
return false;
// Does file contain HT?
fseek(_file, 0, SEEK_END);
_next_free_entry = ftell(_file);
if (_next_free_entry < FirstEntryOffset)
{
if (!for_write) // ... but it should
{
LOG_MSG("OldDirectoryFile::open(%s): Missing HT\n",
filename.c_str());
return false;
}
// Initialize HT:
for (HashTable::HashValue entry = 0;
entry < HashTable::HashTableSize; ++entry)
writeHTEntry(entry, INVALID_OFFSET);
// Next free entry = first entry after HT
_next_free_entry = FirstEntryOffset;
}
// Check if file size = HT + N full entries
FileOffset rest = (_next_free_entry - FirstEntryOffset)
% OldDirectoryFileEntry::DataSize;
if (rest)
LOG_MSG("Suspicious directory file %s has a 'tail' of %d Bytes\n",
filename.c_str(), rest);
#ifdef LOG_DIRFILE
if (_file.isReadonly())
LOG_MSG("(readonly) ");
LOG_MSG("OldDirectoryFile %s\n", _filename);
#endif
return true;
}
开发者ID:EPICSTools,项目名称:ChannelArchiver,代码行数:45,代码来源:OldDirectoryFile.cpp
示例15: output_ascii
void output_ascii(const stdString &archive_name,
const stdString &channel_name,
const epicsTime &start, const epicsTime &end)
{
Archive archive(new ARCHIVE_TYPE(archive_name));
ChannelIterator channel(archive);
ValueIterator value(archive);
if (! archive.findChannelByName(channel_name, channel))
{
printf("# Channel not found: %s\n", channel_name.c_str());
return;
}
printf("channel=%s\n", channel_name.c_str());
if (! channel->getValueAfterTime (start, value))
{
printf("# no values\n");
return;
}
CtrlInfo info;
double period=-1;
epicsTime last_time = nullTime;
while (value && (!isValidTime(end) || value->getTime() < end))
{
if (period != value.getPeriod())
{
period = value.getPeriod();
output_header(value);
}
if (info != *value->getCtrlInfo())
{
info = *value->getCtrlInfo();
output_info(&info);
}
if (isValidTime(last_time) && value->getTime() < last_time)
printf("Error: back in time:\n");
value->show(stdout);
fputs("\n", stdout);
last_time = value->getTime();
++value;
}
}
开发者ID:epicsdeb,项目名称:channelarchiver,代码行数:44,代码来源:ascii.cpp
示例16: input_ascii
void input_ascii(const stdString &archive_name, const stdString &file_name)
{
ArchiveParser parser;
if (! parser.open(file_name))
{
printf("Cannot open '%s'\n", file_name.c_str());
}
Archive archive(new BinArchive(archive_name, true));
parser.run(archive);
}
开发者ID:epicsdeb,项目名称:channelarchiver,代码行数:10,代码来源:ascii.cpp
示例17: 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;
}
开发者ID:epicsdeb,项目名称:channelarchiver,代码行数:10,代码来源:DataFile.cpp
示例18: fopen
// Attach DiskBasedHashTable to disk file of given name.
// a) new file: setup Hash Table
// b) existing file for read-only: check HT
// c) existing file for read-write: check HT
DirectoryFile::DirectoryFile(const stdString &filename, bool for_write)
{
_filename = filename;
Filename::getDirname(_filename, _dirname);
_file_for_write = for_write;
_file = fopen(filename.c_str(), "r+b");
if (_file==0 && for_write)
_file = fopen(filename.c_str(), "w+b");
if (_file == 0)
throwDetailedArchiveException(OpenError, filename);
// Does file contain HT?
fseek(_file, 0, SEEK_END);
_next_free_entry = ftell(_file);
if (_next_free_entry < FirstEntryOffset)
{
if (!for_write) // ... but it should
throwDetailedArchiveException(Invalid, "Missing HT");
// Initialize HT:
for (HashTable::HashValue entry = 0;
entry < HashTable::HashTableSize; ++entry)
writeHTEntry(entry, INVALID_OFFSET);
// Next free entry = first entry after HT
_next_free_entry = FirstEntryOffset;
}
// Check if file size = HT + N full entries
FileOffset rest = (_next_free_entry - FirstEntryOffset)
% BinChannel::getDataSize();
if (rest)
LOG_MSG("Suspicious directory file %s has a 'tail' of %d Bytes\n",
filename.c_str(), rest);
#ifdef LOG_DIRFILE
if (_file.isReadonly())
LOG_MSG("(readonly) ");
LOG_MSG("DirectoryFile %s\n", _filename);
#endif
}
开发者ID:EPICSTools,项目名称:ChannelArchiver,代码行数:45,代码来源:DirectoryFile.cpp
示例19: format_time
static void format_time(const epicsTime &time, stdString &text)
{
if (only_millisecs)
{
epicsTimeStamp stamp = time;
stamp.nsec = ((stamp.nsec + 500000) / 1000000) * 1000000;
epicsTime2string(epicsTime(stamp), text);
text = text.substr(0, 23);
return;
}
epicsTime2string(time, text);
}
开发者ID:epicsdeb,项目名称:channelarchiver,代码行数:12,代码来源:main.cpp
示例20: getState
void CtrlInfo::getState(size_t state, stdString &result) const
{
size_t len;
const char *text = getState(state, len);
if (text)
{
result.assign(text, len);
return;
}
char buffer[80];
sprintf(buffer, "<Undef: %u>", (unsigned int)state);
result = buffer;
}
开发者ID:EPICSTools,项目名称:ChannelArchiver,代码行数:14,代码来源:CtrlInfo.cpp
注:本文中的stdString类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论