本文整理汇总了C++中CVectorSString::size方法的典型用法代码示例。如果您正苦于以下问题:C++ CVectorSString::size方法的具体用法?C++ CVectorSString::size怎么用?C++ CVectorSString::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVectorSString
的用法示例。
在下文中一共展示了CVectorSString::size方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exportCsv
// generate .csv file based on actual filled structure
int exportCsv(const char *filename)
{
nlassert(fields.size() != 0);
uint i, j;
FILE *f = fopen(filename, "w");
if (f == NULL)
nlerror("Can't open file : %s", filename);
// print fields name
for (i=0 ; i<fields.size()-1 ; i++)
fprintf(f, "%s;", fields[i].c_str());
fprintf(f, "%s\n", fields[fields.size()-1].c_str());
// print values for each item
for (i=0 ; i<items.size() ; i++)
{
for (j=0 ; j<items[i].size()-1 ; j++)
fprintf(f, "%s;", items[i][j].c_str());
fprintf(f, "%s\n", items[i][items[i].size()-1].c_str());
}
fclose(f);
return 0;
}
示例2: lookUp
void CWords_dicDlg::lookUp( const CString& inputStr )
{
// Look up
CVectorSString resultVec;
Dico.lookup( CSString(inputStr), resultVec );
// Display results
clear();
if ( resultVec.empty() )
{
m_Results.AddString( "<no result>" );
return;
}
else
{
bool showAll = (((CButton*)(GetDlgItem( IDC_ShowAll )))->GetCheck() == 1);
bool lvlRemoved = false;
m_Results.SetRedraw( false );
for ( CVectorSString::const_iterator ivs=resultVec.begin(); ivs!=resultVec.end(); ++ivs )
{
const CSString& res = (*ivs);
if ( showAll || (res.find( "lvl" ) == string::npos) )
{
m_Results.AddString( res.c_str() );
}
else
lvlRemoved = true;
}
m_Results.SetRedraw( true );
CString s;
s.Format( "%u results found for \"%s\".%s", resultVec.size(), inputStr, lvlRemoved?" Results containing \"lvl\" not shown":"" );
GetDlgItem( IDC_Status )->SetWindowText( s );
}
}
示例3: updateItems
// update all items with new values
int updateItems(const char *filename)
{
// verify file
verifItemsFile(filename);
CSString data;
data.readFromFile(filename);
CVectorSString lines;
data.splitLines(lines);
for (uint itemIndex=0 ; itemIndex<items.size() ; itemIndex++)
{
nlassert(fields.size() >= items[itemIndex].size());
cout << "Updating item " << itemIndex << endl;
uint a, b;
getItemBounds(lines, itemIndex, a, b);
// no bound found, it's a new item
if (b == 0)
{
addNewItem(lines, itemIndex);
getItemBounds(lines, itemIndex, a, b);
}
for (uint fieldIndex=0 ; fieldIndex<items[itemIndex].size() ; fieldIndex++)
updateItemField(lines, itemIndex, fieldIndex, a, b);
}
// rewrite file
data.clear();
for (uint i=0 ; i<lines.size() ; i++)
data += lines[i] + "\n";
data.writeToFile(filename);
return 0;
}
示例4: cbExecCommandResult
static void cbExecCommandResult(CMessage &msgin, const std::string &serviceName, TServiceId sid)
{
// treat the rely message sent back from a service whom we asked to execute a command
NLMISC::InfoLog->displayNL("EXEC_COMMAND_RESULT' Received from: %3d: %s", sid.get() ,serviceName.c_str());
// retrieve the text from the input message
CSString txt;
msgin.serial(txt);
// divide the text into lines because NeL doesn't like long texts
CVectorSString lines;
txt.splitLines(lines);
// display the lines of text
for (uint32 i=0;i<lines.size();++i)
{
NLMISC::InfoLog->displayNL("%s",lines[i].c_str());
}
}
示例5: getItemBounds
// compute item boundary in the file (min and max lines)
void getItemBounds(const CVectorSString &lines, uint num, uint &a, uint &b)
{
a = b = 0;
uint i = -1;
bool ok = false;
while (++i < lines.size() && !ok)
{
if (lines[i].empty() || lines[i].find("//") != string::npos)
continue;
// get item number
uint n;
if (sscanf(lines[i].c_str(), "_Items#%d", &n) == 0)
continue;
// find it
if (n == num)
{
// frist line
if (a == 0)
a = b = i+1;
// more line
else
b++;
}
else
{
// end
if (a != 0)
ok = true;
}
}
// found it ?
if (a != 0)
{
ok = true;
b++;
}
}
示例6: runForFile
bool CCharacterScanJob::runForFile(const std::string& fileName)
{
// load the file into a pdr record
static CPersistentDataRecord pdr;
pdr.clear();
pdr.readFromFile(fileName.c_str());
// create a character representation and apply the pdr
CStatsScanCharacter c;
c.apply(pdr);
// iterate over the filters executing their core code
for (uint32 i=(uint32)_Filters.size();i--;)
{
if (!_Filters[i]->evaluate(&c))
return true;
}
// we've been accepted by the filters so add this file to the file list (if there is one)
if (_FileList!=NULL)
{
_FileList->addFile(fileName);
}
// iterate over the info extractors executing their core code
for (uint32 i=0;i<_InfoExtractors.size();++i)
{
_InfoExtractors[i]->execute(this,&c);
}
// flush the info collected by the info extractors to the output file
CVectorSString words;
CSString(fileName).splitFrom("account_").splitTo("_pdr.").splitBySeparator('_',words,false,true,true,true);
if (words.size()==2)
{
charTblFlushRow(words[0].atoi(),words[1].atoi());
}
return true;
}
示例7: processItemLine
// parse a line from source file
void processItemLine(const string &s)
{
// null or comment
if (s.empty() || s.find("//") == 0)
return;
// other stuff
if (s.find("_Items#") == string::npos)
return;
// get item number
int n;
sscanf(s.c_str(), "_Items#%d", &n);
// check fields
for (uint i=0 ; i<fields.size() ; i++)
{
string field = "_Items#" + toString(n) + "." + fields[i];
// compare line with field
if (s.find(fields[i]) != string::npos)
{
// check is next char is not valid because of names like Protection in Protection1
if (!CSString::isValidFileNameChar(s[field.size()]))
{
// get value
string::size_type pos = s.find("=");
nlassert(pos != string::npos);
string val(s, pos+1);
items[n][i] = (CSString(val).strtok("\n")).strip();
break;
}
}
}
}
示例8: main
int main(int argc, char *argv[])
{
string csvFile, itemsFile, scriptFile, curDir;
// check number of arguments
if (argc != 3)
nlerror("Bad arguments number !");
curDir = CPath::standardizePath(CPath::getCurrentPath());
// check extensions
{
string ext = CFile::getExtension(argv[2]);
if (ext == "csv")
csvFile = argv[2];
else if (ext == "script")
scriptFile = argv[2];
else
nlerror("Bad extension : %s (use .csv or .script)", ext.c_str());
itemsFile = argv[1];
}
// create a .csv file
if (scriptFile != "")
{
if (CFile::getFilename(scriptFile) == scriptFile)
scriptFile = curDir + scriptFile;
if (CFile::getFilename(itemsFile) == itemsFile)
itemsFile = curDir + itemsFile;
// auto-add : _LocSlot & _PhraseId & _SheetId & _Recommended
fields.push_back("_LocSlot");
fields.push_back("_PhraseId");
fields.push_back("_SheetId");
fields.push_back("_Recommended");
// add other fields from file
getFieldsFromFile(scriptFile.c_str());
// verify file
verifItemsFile(itemsFile.c_str());
// How many items ?
uint n = getNbItemFromFile(itemsFile.c_str()) + 1;
items.resize(n);
// reserve memory
for (uint i=0 ; i<n ; i++)
items[i].resize(fields.size());
// read values from items file
getItemsFromFile(itemsFile.c_str());
// generate the new file
string csv = CFile::getFilename(itemsFile);
string ext = CFile::getExtension(csv);
exportCsv((CSString(csv).replace(string('.' + ext).c_str(), ".csv")).c_str());
}
// create a .txt file
if (csvFile != "")
{
if (CFile::getFilename(csvFile) == csvFile)
csvFile = curDir + csvFile;
// load csv values
importCsv(csvFile.c_str());
if (!itemsFile.empty() && CFile::isExists(itemsFile.c_str()))
updateItems(itemsFile.c_str());
else
nlerror("Can't find file : %s", itemsFile.c_str());
}
return 0;
}
示例9: executeScriptBuf
//void executeScriptBuf(char *txt)
void executeScriptBuf(const string &text)
{
CSString buf = text;
CVectorSString lines;
vector<string> tmpLines;
NLMISC::explode(std::string(buf.c_str()), std::string("\n"), tmpLines, true);
lines.resize(tmpLines.size());
for (uint i=0; i<tmpLines.size();i++)
{
lines[i]= tmpLines[i];
}
for (uint i=0; i<lines.size(); ++i)
{
CSString line = lines[i];
line = line.strip();
if (line.empty() || line.find("//") == 0)
{
// comment or empty line, skip
continue;
}
CSString command = line.strtok(" \t");
line = line.strip();
if (command == "DFNPATH")
{
//CPath::getPathContent(args,true,false,true,files);
CPath::addSearchPath(line, true, false); // for the dfn files
}
else if (command == "PATH")
{
files.clear();
CPath::getPathContent(line, true,false,true,files);
CPath::addSearchPath(line, true, false); // for the dfn files
}
else if (command == "OUTPUT")
{
setOutputFile(line);
}
else if (command == "FIELD")
{
addField(line);
}
else if (command == "SOURCE")
{
addSource(line);
}
else if (command == "SCANFILES")
{
scanFiles(line);
}
else if (command == "SCRIPT")
{
executeScriptFile(line);
}
else
{
fprintf(stderr,"Unknown command: '%s' '%s'\n", command.c_str(), line.c_str());
}
}
}