本文整理汇总了C++中ToStr函数的典型用法代码示例。如果您正苦于以下问题:C++ ToStr函数的具体用法?C++ ToStr怎么用?C++ ToStr使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ToStr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WCUpdateComboBox
//---------------------------------------------------------------------------
void WCUpdateComboBox(TComboBox* cmb,TTypeKeyVoc tkey)
{
cmb->Clear();
MYSQL_RES *result;
MYSQL_ROW row;
AnsiString myquery;
if (tkey==GROUPS)
myquery="SELECT title, num FROM "+opts.DBVocTable+" WHERE vkey="+ToStr(keys[tkey])+" AND deleted=0 ORDER BY title";
else
myquery="SELECT title, num FROM "+opts.DBVocTable+" WHERE vkey="+ToStr(keys[tkey])+" AND deleted=0 ORDER BY num";
mysql_query(mysql,myquery.c_str());
if (mysql_field_count(mysql))
{
result=mysql_store_result(mysql);
if (result && mysql_num_rows(result))
{
while (row = mysql_fetch_row(result))
{
cmb->Items->Add(AnsiString(row[0]));
}
}
mysql_free_result(result);
}
}
示例2: VGenerateXml
tinyxml2::XMLElement* AudioComponent::VGenerateXml(tinyxml2::XMLDocument* pDoc)
{
tinyxml2::XMLElement* pBaseElement = pDoc->NewElement(VGetName());
tinyxml2::XMLElement* pSoundNode = pDoc->NewElement("Sound");
tinyxml2::XMLText* pSoundText = pDoc->NewText(m_audioResource.c_str());
pSoundNode->LinkEndChild(pSoundText);
pBaseElement->LinkEndChild(pSoundNode);
tinyxml2::XMLElement* pLoopingNode = pDoc->NewElement("Looping");
tinyxml2::XMLText* pLoopingText = pDoc->NewText(m_looping ? "1" : "0");
pLoopingNode->LinkEndChild(pLoopingText);
pBaseElement->LinkEndChild(pLoopingNode);
tinyxml2::XMLElement* pFadeInNode = pDoc->NewElement("FadeIn");
tinyxml2::XMLText* pFadeInText = pDoc->NewText(ToStr(m_fadeInTime).c_str());
pFadeInNode->LinkEndChild(pFadeInText);
pBaseElement->LinkEndChild(pFadeInNode);
tinyxml2::XMLElement* pVolumeNode = pDoc->NewElement("Volume");
tinyxml2::XMLText* pVolumeText = pDoc->NewText(ToStr(m_volume).c_str());
pVolumeNode->LinkEndChild(pVolumeText);
pBaseElement->LinkEndChild(pVolumeNode);
return pBaseElement;
}
示例3:
vector<size_t> CbirGVT::FindCache(size_t in, size_t n, bool& hit) {
string msg = "FindCache("+ToStr(in)+","+ToStr(n)+") : ";
bool debugx = debug>1;
if (false && debugx)
cout << msg << endl;
pair<cache_t::iterator,cache_t::iterator> r = cache.equal_range(in);
for (cache_t::iterator i = r.first; i!=r.second; i++)
if (i->second.first>=n) {
hit = true;
vector<size_t> ret;
for (size_t j=0; j<n&&j<i->second.second.size(); j++)
ret.push_back(i->second.second[j]);
if (debugx)
cout << msg << "returning " << ret.size() << "/"
<< i->second.second.size() << " images" << endl;
return ret;
}
hit = false;
if (debugx)
cout << msg << " not found" << endl;
return vector<size_t>();
}
示例4: ToStr
string numstr::ToUnitStr(MPO_UINT64 u)
{
string result;
double d;
// if less than 1 k
if (u < 1024)
{
result = ToStr(u) + " B";
}
// less than 1 meg
else if (u < 1048576)
{
d = u * 0.0009765625; // same as dividing by 1024
result = ToStr(d, 0, 1, 2) + " KiB";
}
// less than 1 gig
else if (u < 1073741824)
{
d = u / (1048576.0); // convert to megs
result = ToStr(d, 0, 1, 2) + " MiB";
}
// else leave it as gigs, we won't go any higher for now
else
{
d = u / (1073741824.0); // convert to gigs
result = ToStr(d, 0, 1, 2) + " GiB";
}
return result;
}
示例5: CB_LOG
bool EventManager::RemoveListener(const EventListenerDelegate& eventDelegate, const EventType& type)
{
CB_LOG("Events", "Attempting to remove delegate listener from event type: " + ToStr(type, 16));
bool success = false;
// iterate the map looking this event type
auto findIt = m_EventListeners.find(type);
if (findIt != m_EventListeners.end())
{
// get the list of listeners for this event type
EventListenerList& listeners = findIt->second;
for (auto it = listeners.begin(); it != listeners.end(); ++it)
{
// if the delegate listener is found, remove it
if (eventDelegate == (*it))
{
listeners.erase(it);
CB_LOG("Events", "Successfully removed delegate listener from event type: " + ToStr(type, 16));
success = true;
// break because there cannot be duplicate delegates for an event type
break;
}
}
}
return success;
}
示例6: AddCache
void CbirGVT::AddCache(size_t in, size_t n, size_t out) {
string msg = "AddCache("+ToStr(in)+","+ToStr(n)+","+ToStr(out)+") : ";
bool debugx = debug>1;
if (false && debugx)
cout << msg << endl;
pair<cache_t::iterator,cache_t::iterator> r = cache.equal_range(in);
for (cache_t::iterator i = r.first; i!=r.second; i++)
if (i->second.first==n) {
i->second.second.push_back(out);
if (debugx)
cout << msg << " added in old " << i->second.second.size()
<< "/" << i->second.first << endl;
return;
}
vector<size_t> v;
v.push_back(out);
cache.insert(make_pair(in, make_pair(n, v)));
if (debugx)
cout << msg << "added new entry, total " << cache.size() << endl;
}
示例7: TiXmlElement
TiXmlElement* Vec2::GernerateXML( void ) const
{
TiXmlElement* pRetNode = ENG_NEW TiXmlElement( "Vector2" );
pRetNode->SetAttribute( "x", ToStr( x ).c_str() );
pRetNode->SetAttribute( "y", ToStr( y ).c_str() );
return pRetNode;
}
示例8: TiXmlElement
void SphereRenderComponent::CreateInheritedXmlElements(TiXmlElement* pBaseElement)
{
TiXmlElement* pMesh = CB_NEW TiXmlElement("Sphere");
pMesh->SetAttribute("radius", ToStr(m_Radius).c_str());
pMesh->SetAttribute("segments", ToStr(m_Segments).c_str());
pBaseElement->LinkEndChild(pMesh);
}
示例9: ToStr
void StatsView::Refresh(){
Glib::ustring cur;
cur = "Red Bases: ";
cur += ToStr(ps->red_bases);
rbl.set_label(cur);
cur = "Blue Bases: ";
cur += ToStr(ps->blue_bases);
bbl.set_label(cur);
}
示例10: if
WCHAR* ChmDoc::GetProperty(DocumentProperty prop) {
AutoFreeW result;
if (DocumentProperty::Title == prop && title)
result.Set(ToStr(title));
else if (DocumentProperty::CreatorApp == prop && creator)
result.Set(ToStr(creator));
// TODO: shouldn't it be up to the front-end to normalize whitespace?
if (result) {
// TODO: original code called str::RemoveChars(result, "\n\r\t")
str::NormalizeWS(result);
}
return result.StealData();
}
示例11: switch
std::string Variant::ToString() const
{
switch (Type())
{
case Types::Bool:
return Bool() ? "true" : "false";
case Types::Int:
return ToStr(Int());
case Types::Float:
return ToStr(Float());
}
return "";
}
示例12: memcpy
uint32_t JoinFlowHandler::WriteKeyNickSession(NE::Model::Capabilities& capabilities, Address32 address32,
WHartUniqueID uniqueID, Address32 parentAddress32, const NE::Model::SecurityKey& networkKey,
const NE::Model::SecurityKey& key)
{
C963_WriteSession_Req writeSessionLocal;
{ // write the session locally
writeSessionLocal.m_ulPeerNonceCounterValue = 0;
writeSessionLocal.m_unPeerNickname = (address32 & 0xFFFF);
memcpy(writeSessionLocal.m_aPeerUniqueID, uniqueID.bytes, 5); //TODO check if it is ok
memcpy(writeSessionLocal.m_aKeyValue, key.value, key.LENGTH);
writeSessionLocal.m_eSessionType = WHartSessionKey::sessionKeyed;
writeSessionLocal.m_ucReserved = 0;
memset(writeSessionLocal.m_tExecutionTime, 0, 5);
}
C2009_NM_WriteUniqueIdNickname_Req localAddressNick;
{
localAddressNick.nickname = (uint16_t) address32 & 0xFFFF;
localAddressNick.uniqueId = uniqueID;
localAddressNick.isTR = device.isBackbone;
}
WHartCommand arrayLocal[] = { { CMDID_C963_WriteSession, 0, &writeSessionLocal }, {
CMDID_C2009_NM_WriteUniqueIdNickname, 0, &localAddressNick } };
WHartCommandList listReqLocal = { sizeof(arrayLocal) / sizeof(arrayLocal[0]), arrayLocal };
//COULD trigger TransmitConfirm if there is a package in the stack for the peer address.
TransmitRequest(NetworkManager_Nickname(), listReqLocal, WHartSessionKey::joinKeyed);
try
{
keyNickSessionOperations.reset(new NE::Model::Operations::EngineOperations());
commonData.networkEngine.initJoinDevice(*keyNickSessionOperations, capabilities, address32, uniqueID,
parentAddress32, networkKey, key);
std::ostringstream stream;
stream << "Write session " << ToStr(address32) << ", parent=" << ToStr(parentAddress32);
keyNickSessionOperations->reasonOfOperations = stream.str();
SMState::SMStateLog::logOperations(keyNickSessionOperations->reasonOfOperations, *keyNickSessionOperations);
SendOperations(keyNickSessionOperations, keyNickSessionHandle, true);
}
catch (std::exception& ex)
{
LOG_ERROR("Error:" << ex.what());
}
return keyNickSessionHandle;
}
示例13: setOpt
int DmetEngine::parseArgv( const char * const * const argv, int start ){
vector<string> argvStrings;
for (const char* const * arg=argv;*arg!=NULL;arg++) {
argvStrings.push_back(*arg);
}
int argc = argvStrings.size();
// Parse DmetEngine Options
int argvPos = Options::parseArgv(argv, start);
vector<string> celFiles;
for(vector<const char *>::size_type i = 0; i < getArgCount(); i++)
celFiles.push_back(getArg(i));
setOpt("cels",celFiles);
// Allow user to override APS defaults
if(argc > argvPos) {
ProbesetSummarizeEngine pse;
int newArgvPos = pse.parseArgv(argv, argvPos+1);
Verbose::out(1,"Parsed " + ToStr(newArgvPos - argvPos - 1) + " extra options for ProbesetSummarizeEngine!");
m_ArgvPosAPS = argvPos + 1;
argvPos = newArgvPos;
} else {
m_ArgvPosAPS = -1;
}
// Allow user to override CN defaults
if(argc > argvPos) {
DmetCopyNumberEngine cde;
int newArgvPos = cde.parseArgv(argv,argvPos+1);
Verbose::out(1,"Parsed " + ToStr(newArgvPos - argvPos - 1) + " extra options for DmetCopyNumberEngine!");
m_ArgvPosCN = argvPos + 1;
argvPos = newArgvPos;
} else {
m_ArgvPosCN = -1;
}
// Allow user to override APG defaults
if(argc > argvPos) {
ProbesetGenotypeEngine pge;
int newArgvPos = pge.parseArgv(argv,argvPos+1);
Verbose::out(1,"Parsed " + ToStr(newArgvPos - argvPos - 1) + " extra options for ProbesetGenotypeEngine!");
m_ArgvPosAPG = argvPos + 1;
argvPos = newArgvPos;
} else {
m_ArgvPosAPG = -1;
}
m_argv = argv;
return argvPos;
}
示例14: strlen
// checks to see if the special lsrowimage.dat file exists in the experiment directory. If it does,
// this image is used to generate custom channel correction coefficients. If not, the method silently
// returns (and subsequent analysis uses the default correction).
void ImageTransformer::CalibrateChannelXTCorrection ( const char *exp_dir,const char *filename, bool wait_for_prerun )
{
// only allow this to be done once
if ( custom_correction_data != NULL )
return;
// LSRowImageProcessor can generate a correction for the 314, but application of the correction is much more
// difficult than for 316/318, and the expected benefit is not as high, so for now...we're skipping the 314
if ( ( ChipIdDecoder::GetGlobalChipId() != ChipId316 ) && ( ChipIdDecoder::GetGlobalChipId() != ChipId318 ) && ( ChipIdDecoder::GetGlobalChipId() != ChipId316v2 ) )
return;
int len = strlen ( exp_dir ) +strlen ( filename ) + 2;
char full_fname[len];
sprintf ( full_fname,"%s/%s",exp_dir,filename );
if ( wait_for_prerun ) {
std::string preRun = exp_dir;
preRun = preRun + "/prerun_0000.dat";
std::string acq0 = exp_dir;
acq0 = acq0 + "/acq_0000.dat";
uint32_t waitTime = RETRY_INTERVAL;
int32_t timeOut = TOTAL_TIMEOUT;
//--- Wait up to 3600 seconds for a file to be available
bool okToProceed = false;
while ( timeOut > 0 ) {
//--- do our checkpoint files exist?
if ( isFile ( preRun.c_str() ) || isFile ( acq0.c_str() ) ) {
okToProceed = true;
break;
}
fprintf ( stdout, "Waiting to load crosstalk params in %s\n", full_fname );
sleep ( waitTime );
timeOut -= waitTime;
}
if ( !okToProceed ) {
ION_ABORT ( "Couldn't find gateway files for: " + ToStr ( full_fname ) );
}
// We got the files we expected so if the xtalk file isn't there then warn.
if ( !isFile ( full_fname ) ) {
ION_WARN ( "Didn't find xtalk file: " + ToStr ( full_fname ) );
}
}
LSRowImageProcessor lsrowproc;
custom_correction_data = lsrowproc.GenerateCorrection ( full_fname );
if ( custom_correction_data != NULL )
selected_chip_xt_vectors = custom_correction_data->GetCorrectionDescriptor();
}
示例15: int
/**
* Go thru GC contrast values and find the mean and stdev
* go thru AT contrast values and count how many are within 2stdev of GC mean
* calculate the fraction of non-overlap
* @param ATcontrast Values
* @param GCcontrast Values
* @param GCstats vector to fill in with stats
*/
double
MultiChannelNonOverlapCelListener::calcNonOverlap(const std::vector<double> &ATcontrastValues,
const std::vector<double> &GCcontrastValues,
CumulativeStats<double> &GCstats)
{
for(int gcIx = 0; gcIx < GCcontrastValues.size(); gcIx++) {
float intensity = GCcontrastValues[gcIx];
GCstats.addData(intensity);
}
float gc_mean = GCstats.getMean();
float gc_stdev = GCstats.getStdev();
float gcthreshold = gc_mean + 2*gc_stdev;
int inGC = 0;
for (int atIx = 0; atIx< ATcontrastValues.size(); atIx++){
if (ATcontrastValues[atIx] < gcthreshold){
inGC++;
}
}
double result = (double) inGC / int(ATcontrastValues.size());
Verbose::out(4, "in GC fraction is " + ToStr(result));
result = 1.0-result;
return result;
}