本文整理汇总了C++中StrVec类的典型用法代码示例。如果您正苦于以下问题:C++ StrVec类的具体用法?C++ StrVec怎么用?C++ StrVec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StrVec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BenchDir
static void BenchDir(TCHAR *dir)
{
StrVec files;
ScopedMem<TCHAR> pattern(str::Format(_T("%s\\*.pdf"), dir));
CollectPathsFromDirectory(pattern, files, false);
for (size_t i = 0; i < files.Count(); i++) {
BenchFile(files.At(i), NULL);
}
}
示例2:
bool operator==(const StrVec &lhs, const StrVec &rhs)
{
if (lhs.size() != rhs.size())
return false;
for (auto pl = lhs.begin(), pr = rhs.begin(); pl != lhs.end(); )
if (*pl != *pr)
return false;
return true;
}
示例3: main
int main()
{
StrVec str;
str.push_back("adf");
str.push_back("sdfd");
for (auto i = str.begin(); i != str.end(); ++i)
cout << *i << ends;
cout << endl;
return 0;
}
示例4: getVec
StrVec getVec(std::istream &is)
{
StrVec svec;
std::string s;
while (is >> s)
svec.push_back(s);
// this is where move is necessary
return svec;
}
示例5: read_lists
StrVec read_lists (const StrVec& fnames)
{
StrVec rv;
StrVec::const_iterator itr = fnames.begin ();
while (itr != fnames.end ())
{
StrVec vals = read_list (*itr);
std::copy (vals.begin (), vals.end (), std::back_inserter (rv));
itr ++;
}
return rv;
}
示例6: make_temp_fname
std::string make_temp_fname (const char* tmpdir, const char* prefix)
{
// if directory not passed in, guess one
std::string tn = temp_dir (tmpdir);;
// if prefix not passed in, use default
if (!prefix) prefix = DEFAULT_TEMP_FILE_PREFIX;
// get temp directory listing
StrVec dircontent = listdir (tn);
// find all entries matching prefix and having numeric postfix, get list of numbers
UintSet postfixes;
unsigned prefix_len = prefix ? strlen (prefix) : 0;
for (StrVec::iterator ii = dircontent.begin (); ii != dircontent.end (); ii ++)
{
// check if prefix matches
if (prefix_len && (ii->substr (0, prefix_len) != prefix))
continue;
// check if postfix is numeric and get the number
unsigned number = 0;
std::string::iterator sitr;
for (sitr = ii->begin () + prefix_len; sitr != ii->end (); sitr ++)
{
number *= 10;
if (!isdigit (*sitr))
break;
else
number += *sitr - '0';
}
if (sitr != ii->end ())
continue;
// store number to postfixes set
postfixes.insert (number);
}
// now retrieve the numbers using first gap
// make a set for quick presence check
unsigned prev = 0;
for (UintSet::iterator nitr = postfixes.begin (); nitr != postfixes.end (); nitr ++)
if (prev + 1 < *nitr)
break; // found the gap in sequence
else
prev = *nitr;
if (prev == std::numeric_limits<unsigned>::max ()) // just for sanity :)
ers << "No more temp file names available for prefix " << (prefix ? prefix : "") << " in directory " << tn << Throw;
// prev + 1 is the right number
std::ostringstream name (tn, std::ios::out | std::ios::app);
name << PATH_SEPARATOR;
if (prefix) name << prefix;
name << prev + 1;
return name.str ();
}
示例7:
//! copy constructor
StrVec::StrVec(const StrVec &s)
{
/**
* @brief newData is a pair of pointers pointing to newly allocated and copied
* range : [b, e)
*/
std::pair<std::string*, std::string*>
newData = alloc_n_copy(s.begin(), s.end());
element = newData.first;
first_free = cap = newData.second;
}
示例8: if
bool operator< (const StrVec & s1,const StrVec &s2)
{
for(size_t i =0 ; i< s1.size() && i < s2.size(); i++)
{
if(*(s1.elements+i ) < *(s2.elements+i) )
return true ;
else if(*(s1.elements+i ) < *(s2.elements+i) )
return false;
}
if(s1.size() < s2.size())
return true ;
return false;
}
示例9:
bool operator==(const StrVec &s1 ,const StrVec &s2)
{
if(s1.size() == s2.size())
{
for(size_t i =0 ; i< s1.size() ; i++)
{
if(*(s1.elements+i ) != *(s2.elements+i) )
return false ;
}
return true;
}
return false ;
}
示例10: CopySelectionToClipboard
void CopySelectionToClipboard(WindowInfo *win)
{
if (!win->selectionOnPage) return;
CrashIf(win->selectionOnPage->Count() == 0);
if (win->selectionOnPage->Count() == 0) return;
CrashIf(!win->dm || !win->dm->engine);
if (!win->dm || !win->dm->engine) return;
if (!OpenClipboard(NULL)) return;
EmptyClipboard();
if (!win->dm->engine->IsCopyingTextAllowed())
ShowNotification(win, _TR("Copying text was denied (copying as image only)"));
else if (!win->dm->engine->IsImageCollection()) {
ScopedMem<TCHAR> selText;
bool isTextSelection = win->dm->textSelection->result.len > 0;
if (isTextSelection) {
selText.Set(win->dm->textSelection->ExtractText(_T("\r\n")));
}
else {
StrVec selections;
for (size_t i = 0; i < win->selectionOnPage->Count(); i++) {
SelectionOnPage *selOnPage = &win->selectionOnPage->At(i);
TCHAR *text = win->dm->GetTextInRegion(selOnPage->pageNo, selOnPage->rect);
if (text)
selections.Push(text);
}
selText.Set(selections.Join());
}
// don't copy empty text
if (!str::IsEmpty(selText.Get()))
CopyTextToClipboard(selText, true);
if (isTextSelection) {
// don't also copy the first line of a text selection as an image
CloseClipboard();
return;
}
}
/* also copy a screenshot of the current selection to the clipboard */
SelectionOnPage *selOnPage = &win->selectionOnPage->At(0);
RenderedBitmap * bmp = win->dm->engine->RenderBitmap(selOnPage->pageNo,
win->dm->ZoomReal(), win->dm->Rotation(), &selOnPage->rect, Target_Export);
if (bmp)
CopyImageToClipboard(bmp->GetBitmap(), true);
delete bmp;
CloseClipboard();
}
示例11: trimmedName
string trimmedName(string& s)
{
//printf("splitting %s\n",s.c_str());
StrVec vec;
int n=strsplit_slash(s, vec);
//for(int i=0;i<n;i++) printf(" '%s'\n",vec[i].c_str());
unsigned int i=0;
while(i<vec.size())
{
if(i>0)
{
if(vec[i]==".." && vec[i-1]!="..")
{
i--;
vec.erase(vec.begin()+i,vec.begin()+i+2);
continue;
}
}
i++;
}
if(!vec.size()) return "";
string ret="";
for(unsigned int i=0; i<vec.size(); i++)
{
ret+=vec[i];
if(i+1!=vec.size()) ret+="/";
}
return ret;
}
示例12: SetupPluginMode
static bool SetupPluginMode(CommandLineInfo& i)
{
if (!IsWindow(i.hwndPluginParent) || i.fileNames.Count() == 0)
return false;
gPluginURL = i.pluginURL;
if (!gPluginURL)
gPluginURL = i.fileNames.At(0);
assert(i.fileNames.Count() == 1);
while (i.fileNames.Count() > 1) {
free(i.fileNames.Pop());
}
i.reuseInstance = i.exitOnPrint = false;
// always display the toolbar when embedded (as there's no menubar in that case)
gGlobalPrefs.toolbarVisible = true;
// never allow esc as a shortcut to quit
gGlobalPrefs.escToExit = false;
// never show the sidebar by default
gGlobalPrefs.tocVisible = false;
if (DM_AUTOMATIC == gGlobalPrefs.defaultDisplayMode) {
// if the user hasn't changed the default display mode,
// display documents as single page/continuous/fit width
// (similar to Adobe Reader, Google Chrome and how browsers display HTML)
gGlobalPrefs.defaultDisplayMode = DM_CONTINUOUS;
gGlobalPrefs.defaultZoom = ZOOM_FIT_WIDTH;
}
// extract some command line arguments from the URL's hash fragment where available
// see http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf#nameddest=G4.1501531
if (i.pluginURL && str::FindChar(i.pluginURL, '#')) {
ScopedMem<TCHAR> args(str::Dup(str::FindChar(i.pluginURL, '#') + 1));
str::TransChars(args, _T("#"), _T("&"));
StrVec parts;
parts.Split(args, _T("&"), true);
for (size_t k = 0; k < parts.Count(); k++) {
TCHAR *part = parts.At(k);
int pageNo;
if (str::StartsWithI(part, _T("page=")) && str::Parse(part + 4, _T("=%d%$"), &pageNo))
i.pageNumber = pageNo;
else if (str::StartsWithI(part, _T("nameddest=")) && part[10])
str::ReplacePtr(&i.destName, part + 10);
else if (!str::FindChar(part, '=') && part[0])
str::ReplacePtr(&i.destName, part);
}
}
return true;
}
示例13: conn_get_table_list
static StrVec
conn_get_table_list (dbi_conn conn, const std::string& dbname,
const std::string& table)
{
StrVec retval;
const char* tableptr = (table.empty() ? nullptr : table.c_str());
auto tables = dbi_conn_get_table_list (conn, dbname.c_str(), tableptr);
while (dbi_result_next_row (tables) != 0)
{
std::string table_name {dbi_result_get_string_idx (tables, 1)};
retval.push_back(table_name);
}
dbi_result_free (tables);
return retval;
}
示例14: main
int main() {
StrVec words;
words.push_back("ss");
words.push_back("sb");
words.push_back("asf");
words.push_back("safasfd");
words.push_back("asfas");
std::cout<<words.size()<<std::endl;
//words = StrVec();
//words = words;
std::cout<<"cap "<<words.capacity()<<std::endl;
std::cout<<"sz "<<words.size()<<std::endl;
for_each(words.begin(), words.end(), [](const std::string &s){std::cout<<s<<std::endl;});
std::cout<<"exit"<<std::endl;
}
示例15: strsplit_slash
int strsplit_slash(string& st, StrVec& vec)
{
vec.clear();
int last_pos=0;
int pos=0;
int max_pos=st.size();
while(pos<max_pos)
{
last_pos=pos;
while(st[pos]!='/' && pos<max_pos) pos++;
vec.push_back(st.substr(last_pos,pos-last_pos));
while(st[pos]=='/' && pos<max_pos) pos++;
}
return vec.size();
}