本文整理汇总了C++中StdString::length方法的典型用法代码示例。如果您正苦于以下问题:C++ StdString::length方法的具体用法?C++ StdString::length怎么用?C++ StdString::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StdString
的用法示例。
在下文中一共展示了StdString::length方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getDateFormatString
StdString OracleWriter::getDateFormatString(StdString const &oValue, bool bTimestamp) const
{
StdString pattern = "0000-00-00 00:00:00";
if(oValue.length() == 10)
return "YYYY.MM.DD";
if(oValue.length() >= 19 || bTimestamp == false)
return "YYYY.MM.DD HH24:MI:SS";
pattern += ".";
StdString format = "YYYY.MM.DD HH24:MI:SS.";
StdString v = oValue.substr(pattern.length(), oValue.length());
for(size_t i = 0; i < v.length(); i++)
{
if(v[i] >= '0' && v[i] <= '9')
{
format += 'F';
continue;
}
break;
}
return format;
}
示例2: getBracket
StdChar CSVWriterConfigPanel::getBracket(StdChar &oClose) const
{
oClose = 0;
if(mGUI->mQuoteBtn->isChecked())
{
oClose = '"';
return '"';
}
if(mGUI->mParenthesisBtn->isChecked())
{
oClose = ')';
return '(';
}
if(mGUI->mBracketBtn->isChecked())
{
oClose = ']';
return '[';
}
if(mGUI->mCurlyBtn->isChecked())
{
oClose = '}';
return '{';
}
if(mGUI->mSignBtn->isChecked())
{
oClose = '>';
return '<';
}
if(mGUI->mCustomQuoteBtn->isChecked())
{
StdString s = spt::string::fromQt(mGUI->mSeparatorCustomTxt->text());
if(s.length() > 0)
{
if(s.length() > 1)
oClose = s[1];
else
{
switch(s[0])
{
case '\'':
case '"':
oClose = s[0];
break;
}
}
return s[0];
}
}
return 0;
}
示例3: selectorToQuery
StdString SociContainer::selectorToQuery(void)
{
StdString q = getSelector();
if(q.length() == 0)
return q;
if(q[0] == '{' && q != "{}" && q.length() > 1)
q = "select * from "+ q.substr(1, q.length()-2);
else
q = mQuery;
return q;
}
示例4: setSelector
void SociContainer::setSelector(StdString const &oId)
{
Progress prg("Loading from Table ...");
if(oId.length() > 0 && oId[0] == '{') // If it is a table we select it
{
mTablename = oId.substr(1, oId.length()-2);
selectTable(mTablename, false);
}
else
mTablename = "";
super::setSelector(oId);
refreshPreview(selectorToQuery(), mPreviewLimit);
}
示例5: readColumnsFromQuery
std::vector<DatabaseColumn *> SociContainer::readColumnsFromTable(StdString const &oTablename)
{
if(oTablename.length() == 0)
return std::vector<DatabaseColumn *>();
return readColumnsFromQuery("select * from " +oTablename+" limit 1", false);
}
示例6: prepareOpen
bool OracleWriter::prepareOpen(std::vector<DatabaseColumn *> const &oColumns)
{
setSQLLog(createConfigPanel()->getPath(), createConfigPanel()->getExportSQL(), createConfigPanel()->getExportSQLOnly());
if(!SociContainer::prepareOpen(oColumns))
return false;
OracleWriterPanel *wp = createConfigPanel();
setAutocommit(wp->getAutoCommitCount());
StdString table = getTablename();
if(table.length() == 0)
{
ErrorMessage(spt::logging::LoggingItem::LOG_ERROR, MODULENAME, "No target table selected!");
return false;
}
if(getSession() == NULL)
{
ErrorMessage(spt::logging::LoggingItem::LOG_ERROR, MODULENAME, "Database session not initialized!");
return false;
}
if(mAllowTruncate)
{
#warning TODO: Implement truncate
}
if(mAllowModifyColumns)
{
#warning TODO: Implement modify columns
}
return true;
}
示例7: getClassPathExt
long Universe::getClassPathExt(vector<StdString>& tokens,
const StdString& arg) const {
#define EXT_TOKENS 2
long result = ERR_SUCCESS;
long fpIndex = arg.find_last_of(fileSeparator);
long ssepIndex = arg.find(".som");
if (fpIndex == StdString::npos) { //no new path
//different from CSOM (see also HandleArguments):
//we still want to strip the suffix from the filename, so
//we set the start to -1, in order to start the substring
//from character 0. npos is -1 too, but this is to make sure
fpIndex = -1;
//instead of returning here directly, we have to remember that
//there is no new class path and return it later
result = ERR_FAIL;
} else
tokens[0] = arg.substr(0, fpIndex);
//adding filename (minus ".som" if present) to second slot
ssepIndex =
((ssepIndex != StdString::npos) && (ssepIndex > fpIndex)) ?
(ssepIndex - 1) : arg.length();
tokens[1] = arg.substr(fpIndex + 1, ssepIndex - (fpIndex));
return result;
}
示例8: getSeparator
StdChar CSVWriterConfigPanel::getSeparator(void)
{
if(mGUI->mSeparatorSemicolonBtn->isChecked())
return ';';
if(mGUI->mSeparatorColonBtn->isChecked())
return ':';
if(mGUI->mSeparatorSpaceBtn->isChecked())
return ' ';
if(mGUI->mSeparatorTabBtn->isChecked())
return '\t';
if(mGUI->mSeparatorCommaBtn->isChecked())
return ',';
if(mGUI->mSeparatorCustomBtn->isChecked())
{
StdString s = spt::string::fromQt(mGUI->mSeparatorCustomTxt->text());
if(s.length() > 0)
return s[0];
}
return ';';
}
示例9: connect
bool SociContainer::connect(StdString const &oConnectString)
{
StdString con = getConnectString();
if(oConnectString.length() > 0)
{
if(con != oConnectString)
{
disconnect();
con = oConnectString;
}
}
if(mSession != NULL) // Same connect string and session already exists.
return true;
if(con.length() == 0)
return false;
setConnectString(con);
bool rc = true;
Progress prg("Connecting to database");
prg->setLabelText("Connecting to database ...");
prg->setMaximum(prg->maximum()+1);
QApplication::processEvents();
StdString connectStr = sociConnectString(con);
try
{
mSession = new soci::session(sociFactory(), connectStr);
mSociConnectString = connectStr;
refreshTables();
}
catch(std::runtime_error const &e)
{
mSociConnectString = "";
ErrorMessage(spt::logging::LoggingItem::LOG_ERROR, MODULENAME, e.what());
rc = false;
}
prg->setValue(prg->value()+1);
return rc;
}
示例10: isTable
bool SociContainer::isTable(void)
{
StdString t = getSelector();
if(t.length() == 0)
return true;
if(t[0] == '{')
return true;
return false;
}
示例11: connect
bool CSVContainer::connect(StdString const &oFilename)
{
StdString fn = oFilename;
if(fn.length() == 0)
fn = getConnectString();
if(fn.length() == 0)
return false;
bool rc = super::connect(fn);
if(rc == false)
return false;
Progress prg("Open CSV", "Opening File");
setRownum(0);
CSV &csv = getCSV();
if(fn.length() > 0)
{
CSV::ErrorCode rc;
disconnect();
csv.setFilename(fn);
CSV::Openmode md = getOpenmode();
if((rc = csv.open(md)) != CSV::ErrorCode::CSV_OK)
{
ErrorMessage(spt::logging::LoggingItem::LOG_ERROR, "CSV", "Unable to open "+fn);
csv.setFilename("");
return false;
}
}
else
return false;
csv.rewind();
return true;
}
示例12: CloseProjectSettings
bool CProjectSettings::CloseProjectSettings()
{
// check bool if settings have changed
if ( IsChangedSinceLastSave )
{
// popup to ask if save - yes/no/(cancel)
int answer = AfxMessageBox( "Do you want to save the changes in the project?", MB_YESNOCANCEL );
// do what the user clicked
if (answer == IDCANCEL)
{
// Cancel: we dont want to do anything...
return FALSE;
}
else if ( answer == IDYES )
{
// get the filename
StdString fileName = getSaveFileName();
// check if it is a valid path
if ( fileName.length() == 0 )
{
// Selecting a file
StdString typeExtension( _T("gdsprj") );
StdString filterStr = "GDS project files (*." + typeExtension + ")|*." + typeExtension + "||";
CFileDialog myFileDialog(FALSE, typeExtension, NULL, OFN_ENABLESIZING|OFN_EXPLORER|OFN_OVERWRITEPROMPT, filterStr);
// set the file selector default dir to project dir
myFileDialog.m_ofn.lpstrInitialDir = GetDirectory();
// Adding it to the listBox
if ( myFileDialog.DoModal() == IDOK )
{
// get the selected file with path
fileName = myFileDialog.GetPathName();
// saving the filename in the object as well
setSaveFileName( fileName );
}
else
{
// the user clicked cancel: exiting save dialog
return FALSE;
}
}
// send message to make projectloader serialize us.
CHashString hszProjectLoader(_T("CProjectLoadSave"));
CHashString hszNewParticleSaveFilepath( fileName );
static DWORD msgHash_SaveFile = CHashString(_T("SaveFile")).GetUniqueID();
DWORD result = EngineGetToolBox()->SendMessage(msgHash_SaveFile, sizeof(TCHAR *), (void *)hszNewParticleSaveFilepath.GetString(), 0, &hszProjectLoader);
// mark settings as saved
IsChangedSinceLastSave = FALSE;
}
else
{
// we are here, if the user clicked NO SAVE
// then we don't save anything, but return TRUE
// that will lead to close GDS
return TRUE;
}
}
// Closing project destroys consistency
SetSettingsStateConsistency( FALSE );
return TRUE;
}
示例13: prg
std::vector<std::vector<StdString>> SociContainer::fetchRows(std::vector<DatabaseColumn *> &oColumns, StdString const &oQuery, bool &bException, int nCount)
{
StdString t;
StdString sql;
std::vector<std::vector<StdString>> rows;
bException = false;
if(oQuery.length() == 0)
return rows;
Progress prg("Fetching rows ...");
int n = 0;
if(mSession == NULL)
{
connect();
if(mSession == NULL)
{
ErrorMessage(spt::logging::LoggingItem::LOG_ERROR, MODULENAME, "Unable to connect to "+getConnectString());
return rows;
}
}
prg->setLabelText("Fetching rows ...");
if(nCount > 0)
{
prg->setMaximum(prg->maximum()+nCount+1);
sql = limitQuery(oQuery, nCount);
}
else
{
prg->setMaximum(prg->maximum()+1);
sql = oQuery;
}
try
{
soci::rowset<soci::row> rs = (mSession->prepare << sql);
for(soci::row const &row : rs)
{
QApplication::processEvents();
if(prg->wasCanceled())
break;
n++;
std::stringstream ss;
ss << "Row "<< n << " ...";
prg->setLabelText(spt::string::toQt(ss.str()));
if(nCount)
prg->setValue(prg->value()+1);
rows.push_back(fromRow(oColumns, row));
if(n >= nCount)
break;
}
}
catch(std::exception &e)
{
bException = true;
ErrorMessage(spt::logging::LoggingItem::LOG_ERROR, MODULENAME, sql);
ErrorMessage(spt::logging::LoggingItem::LOG_ERROR, MODULENAME, e.what());
}
n -= nCount;
prg->setValue(prg->value()+1+n);
return rows;
}