当前位置: 首页>>代码示例>>C++>>正文


C++ StringList::clear方法代码示例

本文整理汇总了C++中StringList::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ StringList::clear方法的具体用法?C++ StringList::clear怎么用?C++ StringList::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringList的用法示例。


在下文中一共展示了StringList::clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TestKeepIf

bool TestKeepIf() {
    BEGIN_TEST;
    StringList list;
    const char* original[] = {"",     "foo",   "bar",    "baz",    "qux",
                              "quux", "corge", "grault", "garply", "waldo",
                              "fred", "plugh", "xyzzy",  "thud",   ""};

    const char* expected1[] = {"bar", "corge", "grault", "garply", "plugh"};

    const char* expected2[] = {"corge", "grault", "garply", "plugh"};

    const char* expected3[] = {"garply"};

    for (size_t i = 0; i < arraysize(original); ++i) {
        list.push_back(original[i]);
    }

    // Null string has no effect
    list.keep_if(nullptr);
    EXPECT_TRUE(Match(&list, original, 0, arraysize(original)));

    // Empty string matches everything
    list.keep_if("");
    EXPECT_TRUE(Match(&list, original, 0, arraysize(original)));

    // Match a string
    list.keep_if("g");
    EXPECT_TRUE(Match(&list, expected2, 0, arraysize(expected2)));

    // Match a string that would have matched elements in the original list
    list.keep_if("ar");
    EXPECT_TRUE(Match(&list, expected3, 0, arraysize(expected3)));

    // Use a string that doesn't match anything
    list.keep_if("zzz");
    EXPECT_TRUE(list.is_empty());

    // Reset and apply both matches at once with logical-or
    StringList substrs;
    substrs.push_back("g");
    substrs.push_back("ar");

    list.clear();
    for (size_t i = 0; i < arraysize(original); ++i) {
        list.push_back(original[i]);
    }
    list.keep_if_any(&substrs);
    EXPECT_TRUE(Match(&list, expected1, 0, arraysize(expected1)));

    // Reset and apply both matches at once with logical-and
    list.clear();
    for (size_t i = 0; i < arraysize(original); ++i) {
        list.push_back(original[i]);
    }
    list.keep_if_all(&substrs);
    EXPECT_TRUE(Match(&list, expected3, 0, arraysize(expected3)));

    END_TEST;
}
开发者ID:saltstar,项目名称:smartnix,代码行数:59,代码来源:string-list.cpp

示例2: GetFileListRecursive

void GetFileListRecursive(std::string dir, StringList& files, bool withQueriedDir /* = false */)
{
    std::stack<std::string> stk;

    if(withQueriedDir)
    {
        stk.push(dir);
        while(stk.size())
        {
            dir = stk.top();
            stk.pop();
            MakeSlashTerminated(dir);

            StringList li;
            GetFileList(dir.c_str(), li);
            for(std::deque<std::string>::iterator it = li.begin(); it != li.end(); ++it)
                files.push_back(dir + *it);

            li.clear();
            GetDirList(dir.c_str(), li, true);
            for(std::deque<std::string>::iterator it = li.begin(); it != li.end(); ++it)
                stk.push(dir + *it);
        }
    }
    else
    {
        std::string topdir = dir;
        MakeSlashTerminated(topdir);
        stk.push("");
        while(stk.size())
        {
            dir = stk.top();
            stk.pop();
            MakeSlashTerminated(dir);

            StringList li;
            dir = topdir + dir;
            GetFileList(dir.c_str(), li);
            for(std::deque<std::string>::iterator it = li.begin(); it != li.end(); ++it)
                files.push_back(dir + *it);

            li.clear();
            GetDirList(dir.c_str(), li, true);
            for(std::deque<std::string>::iterator it = li.begin(); it != li.end(); ++it)
                stk.push(dir + *it);
        }
    }
}
开发者ID:4nakin,项目名称:Aquaria_clean,代码行数:48,代码来源:VFSTools.cpp

示例3: readAddonGlobalExcludeFunctions

/*
 * Read from file <szGlobalExcludeFunctionFileName>
 * the names of global functions, which don't need to replace.
 * In this file are function's names on each string.
 * After '#' write comments
 */
int LuaObfuscator::readAddonGlobalExcludeFunctions(const char *szGlobalExcludeFunctionFileName, StringList &FunctionsExclude)
{
	const int N = 1024;
	int res = 0;
	char buf[N];

	if (!szGlobalExcludeFunctionFileName || !szGlobalExcludeFunctionFileName[0])
		return -1;

	FILE *file = fopen(szGlobalExcludeFunctionFileName, "rt");
	if (!file)
		return -1;

	FunctionsExclude.clear();

	std::string str;
	while (feof(file) && fgets(buf, N, file)) {
		char *pName = strtrim(buf);
		if (char *p = strchr(pName, '\n'))
			*p = 0;
		if (pName[0] && pName[0] != '#') {
			str.assign(pName);
			FunctionsExclude.push_back(str);
		}
	}

	fclose(file);

	return res;
}
开发者ID:gracerpro,项目名称:luaob,代码行数:36,代码来源:obfuscator.cpp

示例4: parsePluginStringData

void Options::parsePluginStringData(const std::string &str, char separator1, char separator2)
{
    StringList valueList;

    split(str, valueList, separator1);
    if (valueList.size() > 0)
    {
        StringList keyAndValue;

        for (StringList::iterator itr = valueList.begin(); itr != valueList.end(); ++itr)
        {
            split(*itr, keyAndValue, separator2);
            if (keyAndValue.size() > 1)
            {
                setPluginStringData(keyAndValue.front(), keyAndValue.back());
            }
            else if (keyAndValue.size() > 0)
            {
                setPluginStringData(keyAndValue.front(), "true");
            }

            keyAndValue.clear();
        }
    }
}
开发者ID:hyyh619,项目名称:OpenSceneGraph-3.4.0,代码行数:25,代码来源:Options.cpp

示例5: readAddonTocFile

size_t LuaObfuscator::readAddonTocFile(char const *szTocFileName, StringList &luaFiles) {
	char buf[300];

	if (!szTocFileName || !szTocFileName[0])
		return 0;

	FILE *fileToc = fopen(szTocFileName, "rt");
	if (!fileToc) {
		print("Couldn't open the toc file %s\n", szTocFileName);
		return 0;
	}

	luaFiles.clear();
	//files.str("");
	while (!feof(fileToc) && fgets(buf, 300, fileToc)) {
		if (!buf[0])
			continue;
		char *pFile = strtrim(buf);
		char *pFileExt = strrchr(pFile, '.');
		bool bLuaFile = false;
		if (pFileExt) {
			strlwr(pFileExt);
			bLuaFile = !strcmp(pFileExt, ".lua");
		}
		if (pFile[0] && pFile[0] != '#' &&  bLuaFile) {
			luaFiles.push_back(pFile);
		}
	}
	fclose(fileToc);

	return luaFiles.size();
}
开发者ID:gracerpro,项目名称:luaob,代码行数:32,代码来源:obfuscator.cpp

示例6: getNames

void DefaultHttpHeader::getNames(StringList& names) const {
    names.clear();

    Entry* e = head->after;
    while (e != head) {
        names.push_back(e->key);
        e = e->after;
    }
}
开发者ID:frankee,项目名称:Cetty,代码行数:9,代码来源:DefaultHttpHeader.cpp

示例7: tail

//static
unsigned Log::tail(StringList & lout, unsigned num)
{
  lout.clear();
  unsigned i;
  p.lock();
  StringList::reverse_iterator it = p.logHistory.rbegin();
  for (i = 0; i < num && it != p.logHistory.rend(); ++i, ++it)
    lout.push_front(*it);
  p.unlock();
  return i;
}
开发者ID:ruby6117,项目名称:ccode,代码行数:12,代码来源:Log.cpp

示例8: split

static void split(const std::string &orig, const char *delims, StringList &output)
{
    output.clear();
    std::string workBuffer = orig;
    char *rawString = &workBuffer[0];
    for(char *token = strtok(rawString, delims); token != NULL; token = strtok(NULL, delims))
    {
        if(token[0])
            output.push_back(std::string(token));
    }
}
开发者ID:Adglgmut,项目名称:frisk,代码行数:11,代码来源:vsopen.cpp

示例9:

static inline StringList split2Str(const string& str, const string& separator)
{
	static StringList strs;
	strs.clear();

	size_t pos = str.find(separator);
	if (pos >= 0) {
		strs.push_back(str.substr(0, pos));
		strs.push_back(str.substr(pos + 1, str.size() - pos - 1));
	}
	return strs;
}
开发者ID:,项目名称:,代码行数:12,代码来源:

示例10: createAreaPages_createCircuitsAndReferencesTableSection

void WikiAreaPages::createAreaPages_createCircuitsAndReferencesTableSection( String wikiDir , MindArea *area ) {
	// skip circuits for target areas - will be in region pages
	if( area -> isTargetArea() )
		return;

	// collect circuits which reference any of area regions
	MindService *ms = MindService::getService();

	StringList circuits;
	wm -> circuitsxml.getCircuitList( circuits );

	MapStringToString circuitKeys;
	for( int k = 0; k < circuits.count(); k++ ) {
		String circuitId = circuits.get( k );
		XmlCircuitInfo& info = wm -> circuitsxml.getCircuitInfo( circuitId );

		String key = createAreaPages_getCircuitKey( area , info );
		if( key.isEmpty() )
			continue;

		circuitKeys.add( key , circuitId );
	}

	// add circuits section - sorted by relevance
	StringList lines;
	for( int k = circuitKeys.count() - 1; k >= 0; k-- ) {
		String circuitId = circuitKeys.getClassByIndex( k );
		XmlCircuitInfo& info = wm -> circuitsxml.getCircuitInfo( circuitId );
		createAreaPages_getCircuitLines( info , lines );
	}

	String sectionName = "Thirdparty Circuits";
	String wikiPage = wm -> getAreaPage( area -> getAreaId() );
	wm -> updateFileSection( wikiDir , wikiPage , sectionName , lines );
	lines.clear();

	// add unique and sorted references - sorted by relevance
	MapStringToClass<MindArea> refs;
	for( int k = circuitKeys.count() - 1; k >= 0; k-- ) {
		String circuitId = circuitKeys.getClassByIndex( k );
		XmlCircuitInfo& info = wm -> circuitsxml.getCircuitInfo( circuitId );

		if( !info.reference.equals( "UNKNOWN" ) )
			if( refs.get( info.reference ) == NULL ) {
				refs.add( info.reference , area );
				lines.add( String( "  * " ) + info.reference );
			}
	}

	sectionName = "References";
	wm -> updateFileSection( wikiDir , wikiPage , sectionName , lines );
}
开发者ID:sarbjit-longia,项目名称:ahuman,代码行数:52,代码来源:wikiareapages.cpp

示例11: List

  void File::List(StringList& rList, const std::string& sMask /*= "*" */,
                  int nAttrs /*= AttributeAnyFile | AttributeDirectory */)
  {
    rList.clear();
#ifdef WIN32
    _finddata_t stSearchData;         // search record
    intptr_t nFile = _findfirst((m_sPath + "\\" + sMask).c_str(), &stSearchData);

    if (nFile != -1)
    {
      do
      {
        if (!IsDots(stSearchData.name) &&
            (((nAttrs & AttributeDirectory) != 0)
                && (stSearchData.attrib & _A_SUBDIR) != 0) ||
            ((nAttrs & AttributeAnyFile) != 0))
        {
          rList.push_back(stSearchData.name);
        }
      }
      while (!_findnext(nFile, &stSearchData));

      _findclose(nFile);
    }
#else
    DIR* pDir = opendir(m_sPath.c_str());
    if (pDir)
    {
      struct stat stStat;
      dirent* pstDirent = NULL;
      unsigned nMask =
          ((nAttrs & AttributeDirectory) ? S_IFDIR : 0) |
          ((nAttrs & AttributeRegularFile) ? S_IFREG : 0) |
          ((nAttrs & AttributeOtherFile) ? (S_IFMT & (~(S_IFREG | S_IFDIR))) : 0);

      while((pstDirent = readdir(pDir)) != NULL)
      {
        if (!IsDots(pstDirent->d_name) &&
            !fnmatch(sMask.c_str(), pstDirent->d_name, 0) &&
            !lstat(((m_sPath + "/") + pstDirent->d_name).c_str(), &stStat) &&
            (stStat.st_mode & nMask) == (stStat.st_mode & S_IFMT))
        {
          rList.push_back(pstDirent->d_name);
        }
      }

      closedir(pDir);
    }
#endif
  }
开发者ID:AmesianX,项目名称:staff,代码行数:50,代码来源:File.cpp

示例12: TestClear

bool TestClear() {
    BEGIN_TEST;

    StringList list;
    list.push_front("bar");

    EXPECT_NONNULL(list.first());
    list.clear();
    EXPECT_NULL(list.next());
    EXPECT_NULL(list.first());
    EXPECT_EQ(list.length(), 0);

    END_TEST;
}
开发者ID:saltstar,项目名称:smartnix,代码行数:14,代码来源:string-list.cpp

示例13: gets

void DefaultHttpHeader::gets(const std::string& name, StringList& headers) const {
    if (name.empty()) {
        return;
    }
    headers.clear();

    int h = hash(name);
    int i = index(h);
    Entry* e = entries[i];
    while (e != NULL) {
        if (e->hash == h && eq(name, e->key)) {
            headers.push_back(e->value);
        }
        e = e->next;
    }
}
开发者ID:frankee,项目名称:Cetty,代码行数:16,代码来源:DefaultHttpHeader.cpp

示例14: setProperty

//プロパティを設定する
void XML::setProperty(Tag &tag, String source){
	StringList result;
	String name;
	String value;

	while(source != ""){
		name = "";
		value = "";
		result.clear();

		source.FrontStrip(' ');
		result = source.FrontSplit('=');
		source = result[1];
		result[0].EndStrip(' ');
		result = result[0].FrontSplit(' ');
		if(result[1] != ""){
			tag.setProperty(result[0],value);
			source = result[1]+source;
			continue;
		}
		//名前
		name = result[0];
		//値
		if(source != ""){
			source.FrontStrip('=');
			source.FrontStrip(' ');
			result = source.FrontSplit('\"');
			if(result[1] == ""){
				result = source.FrontSplit('\'');
				if(result[1] != ""){
					//シングルクォーテーションで囲われている
					result[1].FrontStrip('\'');
					result = result[1].FrontSplit('\'');
					result[1].FrontStrip('\'');
				}
			}else{
				//ダブルクォーテーションで囲われている
				result[1].FrontStrip('\"');
				result = result[1].FrontSplit('\"');
				result[1].FrontStrip('\"');
			}
			value = result[0];
			source = result[1];
		}
		tag.setProperty(name,value);
	}
}
开发者ID:leftfelt,项目名称:LeftFelt,代码行数:48,代码来源:XMLClass.cpp

示例15: TEST

    TEST(StringUtilsTest, join) {
        StringList components;
        ASSERT_EQ(String(""), join(components, "/"));

        components.push_back("");
        ASSERT_EQ(String(""), join(components, "/"));
        
        components.push_back("");
        ASSERT_EQ(String("/"), join(components, "/"));
        
        components.clear();
        components.push_back("asdf");
        ASSERT_EQ(String("asdf"), join(components, "/"));

        components.push_back("yo");
        ASSERT_EQ(String("asdf/yo"), join(components, "/"));
    }
开发者ID:Gustavo6046,项目名称:TrenchBroom,代码行数:17,代码来源:StringUtilsTest.cpp


注:本文中的StringList::clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。