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


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

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


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

示例1: isRegisteringVariable

/**
 * This function tests if a given line (split into tokens) has the right components
 * to be registering a new variable.
 */
bool isRegisteringVariable(MavenCompiler* c, StringList tokens) {
	// what does it take to register a variable?
	// 1. must have a datatype.
	// 2. must not have brackets ().
	// 3. is allowed to have a default value, but be careful where its placed.
	// this function needs to be improved to work like dissectFunction()
	
	// skip other keywords
	int token;
	for(token = 0; token < tokens.length(); ++token)
		if(tokens[token] != "public" && tokens[token] != "private"
		   && tokens[token] != "static" && tokens[token] != "constant"
		   && tokens[token] != "constant" && tokens[token] != "writeonly")
			break;
	
	// check data type
	string rawtype = stripRawType(tokens[token]);
	if(!isDataType(rawtype) && !objectExists(c, rawtype) && !enumExists(c, rawtype))
		return false;
	
	// the rest
	for(int i = 0; i < tokens.length(); ++i) {
		for(int j = 0; j < tokens[i].length(); ++j) {
			if(tokens[i][j] == '=') return true;
			if(tokens[i][j] == '(' || tokens[i][j] == ')')
				return false;
		}
	}
	
	return true;
}
开发者ID:elliotchance,项目名称:maven,代码行数:35,代码来源:func_isRegisteringVariable.cpp

示例2: enumExists

bool enumExists(MavenCompiler* c, string name) {
	StringList items = split('.', name);
	int namespaceID = -1, objectID = -1;
	
	if(items.length() == 1) {
		// recognise ambiguous objects
		vector<int> found;
		for(namespaceID = 0; namespaceID < c->namespaces->length(); ++namespaceID) {
			objectID = findEnumID(c, namespaceID, items[0]);
			if(objectID >= 0)
				found.push_back(namespaceID);
		}
		--namespaceID;
		
		if(found.size() > 1)
			pushError(c, "Ambiguous enumerator '%s'", items[0]);
		return (found.size() == 1);
	} else if(items.length() == 2) {
		namespaceID = findNamespaceID(c, items[0]);
		if(namespaceID < 0)
			return false;
		objectID = findEnumID(c, namespaceID, items[1]);
		return (objectID >= 0);
	}
	
	return false;
}
开发者ID:elliotchance,项目名称:maven,代码行数:27,代码来源:func_enumExists.cpp

示例3: listToString

QString TAEval::listToString(StringList list){ // Parse a list of QStrings to a single QString
    QString result = QString("");
    for(int i=0; i<list.length();i++)
    {
        if(i==0) result += "~`";
        result += list[i];
        if(i==list.length()-1) result += "`~";
        else result += "~~";
    }
    return result;
}
开发者ID:Dunni,项目名称:taeval,代码行数:11,代码来源:taeval.cpp

示例4: throw

StringList *SWModule_impl::getKeyChildren() throw(CORBA::SystemException) {
	sword::SWKey *key = delegate->getKey();
	StringList *retVal = new StringList;
	int count = 0;

	sword::VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, key);
	if (vkey) {
		retVal->length(6);
		SWBuf num;
		num.appendFormatted("%d", vkey->Testament());
		(*retVal)[0] = CORBA::string_dup(num.c_str());
		num = "";
		num.appendFormatted("%d", vkey->Book());
		(*retVal)[1] = CORBA::string_dup(num.c_str());
		num = "";
		num.appendFormatted("%d", vkey->Chapter());
		(*retVal)[2] = CORBA::string_dup(num.c_str());
		num = "";
		num.appendFormatted("%d", vkey->Verse());
		(*retVal)[3] = CORBA::string_dup(num.c_str());
		num = "";
		num.appendFormatted("%d", vkey->getChapterMax());
		(*retVal)[4] = CORBA::string_dup(num.c_str());
		num = "";
		num.appendFormatted("%d", vkey->getVerseMax());
		(*retVal)[5] = CORBA::string_dup(num.c_str());
	}
	else {
		TreeKeyIdx *tkey = SWDYNAMIC_CAST(TreeKeyIdx, key);
		if (tkey) {
			if (tkey->firstChild()) {
				do {
					count++;
				}
				while (tkey->nextSibling());
				tkey->parent();
			}
			retVal->length(count);
			count = 0;
			if (tkey->firstChild()) {
				do {
					(*retVal)[count++] = CORBA::string_dup(tkey->getLocalName());
				}
				while (tkey->nextSibling());
				tkey->parent();
			}
		}
	}
	return retVal;
}
开发者ID:Jaden-J,项目名称:osstudybible,代码行数:50,代码来源:swordorb-impl.cpp

示例5: keywordCatch

string keywordCatch(MavenCompiler* c, string line, MavenVariable& catchVar) {
	// strip out the catch
	string newCatch = line.substr(line.find('(') + 1, line.length() - line.find('(') - 2);
	
	// this can only be 2 words
	StringList words = split(' ', newCatch);
	if(words.length() != 2) {
		pushError(c, "Expecting two words in catch");
		return MAVEN_INVALID;
	}
	
	// make sure the first word is the name of a class
	// bug #26: and its extended from maven.Exception
	int namespaceID, objectID;
	findClass(c, words[0], namespaceID, objectID);
	if(namespaceID < 0 || objectID < 0) {
		pushError(c, "Unknown exception class %s", words[0]);
		return MAVEN_INVALID;
	}
	
	// make catchVar
	catchVar.name = words[1];
	catchVar.type = c->namespaces->at(namespaceID).name + "." + c->namespaces->at(namespaceID).objects->at(objectID)->name;
	
	// build C++ version of catch
	newCatch = c->namespaces->at(namespaceID).name + "::" + c->namespaces->at(namespaceID).objects->at(objectID)->name + "* " + words[1];
	return "catch(" + newCatch + ")";
}
开发者ID:elliotchance,项目名称:maven,代码行数:28,代码来源:func_keywordCatch.cpp

示例6: setTypes

StringList StringList::setTypes(string str) {
	list.clear();
	StringList split = splitCommas(str);
	for(int i = 0; i < split.length(); ++i)
		list.push_back(split[i]);
	return *this;
}
开发者ID:elliotchance,项目名称:maven,代码行数:7,代码来源:struct_StringList.cpp

示例7: 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

示例8: getHeadOfCue

/*
 * Verifies that a single subclass can be attached to a cue text voice start tag.
 * From http://dev.w3.org/html5/webvtt/#webvtt-cue-span-start-tag (11/27/2012)
 *	Cue span start tags consist of the following:
 *		1. A "<" character representing the beginning of the start tag.
 *		2. The tag name.
 *		3. Zero or more the following sequence representing a subclasses of the start tag
 *			3.1. A full stop "." character.
 *			3.2. A sequence of non-whitespace characters.
 *		4. If the start tag requires an annotation then a space or tab character followed by a sequence of 
 *		   non-whitespace characters representing the annotation.
 *		5. A ">" character repsenting the end of the start tag.
 */
TEST_F(PayloadVoiceTag,DISABLED_VoiceTagSingleSubclass)
{
	loadVtt( "payload/v-tag/v-tag-single-subclass.vtt" );

	const InternalNode *head = getHeadOfCue( 0 );

	ASSERT_TRUE( head->childCount() == 3 );
	ASSERT_EQ( Node::Voice, head->child( 1 )->kind() );

	StringList cssClasses = head->child( 1 )->toInternalNode()->cssClasses();
	String expectedString = String( (const byte *)"class", 5 );

	ASSERT_TRUE( cssClasses.length() == 1 );
	ASSERT_EQ(  expectedString.text(), cssClasses.stringAtIndex( 0 ).text() );
}
开发者ID:limed3,项目名称:webvtt,代码行数:28,代码来源:plvoicetag_unittest.cpp

示例9: basename

string basename(string path) {
	StringList parts = split('/', path);
	return parts[parts.length() - 1];
}
开发者ID:elliotchance,项目名称:maven,代码行数:4,代码来源:func_basename.cpp

示例10: getLastEntity

string getLastEntity(string str) {
	StringList items = split('.', str);
	return items[items.length() - 1];
}
开发者ID:elliotchance,项目名称:maven,代码行数:4,代码来源:func_getLastEntity.cpp


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