本文整理汇总了C++中StrVec::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ StrVec::clear方法的具体用法?C++ StrVec::clear怎么用?C++ StrVec::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StrVec
的用法示例。
在下文中一共展示了StrVec::clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: breakDir
void cGRASS::breakDir(string Dir)
{
StrVec Vec;
Vec.clear();
char dir[255];
strcpy(dir,Dir.c_str());
char * t;
string temp;
printf ("Splitting string \"%s\" into tokens:\n",dir);
t = strtok (dir,"/");
while (t != NULL)
{
temp = t;
Vec.push_back(temp);
t = strtok (NULL, "/");
}
MapSet = Vec[Vec.size()-1];
Location = Vec[Vec.size()-2];
GDBase = "";
for (uint i = 0; i < Vec.size()-2; i++)
{
GDBase = GDBase + "/" + Vec[i];
}
// printf(MapSet);
// printf(Location);
// printf(GDBase);
}
示例2: 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();
}
示例3: client
int
main(int argc, char** argv)
{
if (argc < 3) {
std::cerr << "Invalid arguments!\n" << "Usage: DemoClient host port" << std::endl;
return -1;
}
boost::shared_ptr<TTransport> socket(new TSocket(argv[1], boost::lexical_cast<int>(argv[2])));
boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
HbaseClient client(protocol);
try {
transport->open();
std::string t("demo_table");
//
// Scan all tables, look for the demo table and delete it.
//
std::cout << "scanning tables..." << std::endl;
StrVec tables;
client.getTableNames(tables);
for (StrVec::const_iterator it = tables.begin(); it != tables.end(); ++it) {
std::cout << " found: " << *it << std::endl;
if (t == *it) {
if (client.isTableEnabled(*it)) {
std::cout << " disabling table: " << *it << std::endl;
client.disableTable(*it);
}
std::cout << " deleting table: " << *it << std::endl;
client.deleteTable(*it);
}
}
//
// Create the demo table with two column families, entry: and unused:
//
ColVec columns;
columns.push_back(ColumnDescriptor());
columns.back().name = "entry:";
columns.back().maxVersions = 10;
columns.push_back(ColumnDescriptor());
columns.back().name = "unused:";
std::cout << "creating table: " << t << std::endl;
try {
client.createTable(t, columns);
} catch (const AlreadyExists &ae) {
std::cerr << "WARN: " << ae.message << std::endl;
}
ColMap columnMap;
client.getColumnDescriptors(columnMap, t);
std::cout << "column families in " << t << ": " << std::endl;
for (ColMap::const_iterator it = columnMap.begin(); it != columnMap.end(); ++it) {
std::cout << " column: " << it->second.name << ", maxVer: " << it->second.maxVersions << std::endl;
}
//
// Test UTF-8 handling
//
std::string invalid("foo-\xfc\xa1\xa1\xa1\xa1\xa1");
std::string valid("foo-\xE7\x94\x9F\xE3\x83\x93\xE3\x83\xBC\xE3\x83\xAB");
std::map<std::string, std::string> attrs;
// non-utf8 is fine for data
std::vector<Mutation> mutations;
mutations.push_back(Mutation());
mutations.back().column = "entry:foo";
mutations.back().value = invalid;
client.mutateRow(t, "foo", mutations, attrs);
// try empty strings
mutations.clear();
mutations.push_back(Mutation());
mutations.back().column = "entry:";
mutations.back().value = "";
client.mutateRow(t, "", mutations, attrs);
// this row name is valid utf8
mutations.clear();
mutations.push_back(Mutation());
mutations.back().column = "entry:foo";
mutations.back().value = valid;
client.mutateRow(t, valid, mutations, attrs);
// non-utf8 is now allowed in row names because HBase stores values as binary
mutations.clear();
mutations.push_back(Mutation());
mutations.back().column = "entry:foo";
mutations.back().value = invalid;
client.mutateRow(t, invalid, mutations, attrs);
// Run a scanner on the rows we just created
StrVec columnNames;
columnNames.push_back("entry:");
std::cout << "Starting scanner..." << std::endl;
//.........这里部分代码省略.........
示例4: ProcessComponent
bool ProcessComponent(const char* comp_name, const string& vc_name, const string& filter_modules, const string& filter_disabled, const string& filter_headers, const char* define)
{
ProjLines.clear();
ProjAssoc.clear();
int comp_len=strlen(comp_name);
char buf[1024];
printf("Processing %s...\n",comp_name);
FILE* vc_file=fopen(vc_name.c_str(),"r");
if(!vc_file)
{
printf("Couldn't open %s for reading.\n",vc_name.c_str());
return false;
}
BufState=0;
while(fgets(buf,1024,vc_file))
{
ParseBufVC(buf,filter_modules,filter_disabled,filter_headers);
}
fclose(vc_file);
string script_name=Map["ScriptsDirectory"];
script_name+="scripts.cfg";
FILE* script_file=fopen(script_name.c_str(),"r");
if(!script_file)
{
printf("Couldn't open %s for reading.\n",script_name.c_str());
return false;
}
Modules.clear();
DisabledModules.clear();
Headers.clear();
while(fgets(buf,1024,vc_file))
{
int pos=0;
bool enabled=false;
string line(buf);
StrVec vec;
int tok=strsplit(line,vec);
if(!tok) continue;
if(!vec[0].compare("@")) {
pos++;
enabled=true;
};
if(tok<pos+3) continue;
if(!vec[pos].compare(comp_name) && !vec[pos+1].compare("module"))
{
if(enabled) Modules.insert(stolower(vec[pos+2]+".fos"));
else DisabledModules.insert(stolower(vec[pos+2]+".fos"));
}
}
fclose(script_file);
for(StrSet::iterator it=Modules.begin(),end=Modules.end(); it!=end; ++it)
{
Defines.clear();
Defines.insert(string(define));
IgnoreDepth=0;
Depth=0;
string name=*it;
printf("Preprocessing %s...\n",name.c_str());
int idx=name.find_last_of("/");
string dir="";
if(idx!=-1)
{
dir=name.substr(0,idx+1);
name=name.substr(idx+1,name.length()-idx-1);
}
if(!RecursiveParse(name,dir))
{
printf("Failed to preprocess %s.\n",name.c_str());
return false;
}
}
// write the project file
vc_file=fopen(vc_name.c_str(),"w");
if(!vc_file)
{
printf("Couldn't open %s for writing.\n","test.log");
return false;
}
for(int i=0,j=ProjLines.size(); i<j; i++)
{
if(ProjAssoc.count(i))
{
string name=ProjAssoc[i];
StrSet* the_set=NULL;
if(!name.compare(filter_modules)) the_set=&Modules;
else if(!name.compare(filter_disabled)) the_set=&DisabledModules;
else if(!name.compare(filter_headers))
{
the_set=&Headers;
fprintf(vc_file,
"\t\t\t<File\n"
//.........这里部分代码省略.........