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


C++ SymbolString::size方法代码示例

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


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

示例1: getFirstAvailable

deque<Message*> MessageMap::findAll(SymbolString& master)
{
	deque<Message*> ret;

	if (master.size() < 5)
		return ret;
	unsigned char maxIdLength = master[4];
	if (maxIdLength > m_maxIdLength)
		maxIdLength = m_maxIdLength;
	if (master.size() < 5+maxIdLength)
		return ret;

	for (int idLength = maxIdLength; ret.size()==0 && idLength >= 0; idLength--) {
		int exp = 7;
		unsigned long long key = (unsigned long long)idLength << (8 * exp + 5);
		key |= (unsigned long long)getMasterNumber(master[0]) << (8 * exp--);
		key |= (unsigned long long)master[1] << (8 * exp--);
		key |= (unsigned long long)master[2] << (8 * exp--);
		key |= (unsigned long long)master[3] << (8 * exp--);
		for (unsigned char i = 0; i < idLength; i++)
			key |= (unsigned long long)master[5 + i] << (8 * exp--);

		map<unsigned long long , vector<Message*> >::iterator it = m_messagesByKey.find(key);
		if (it != m_messagesByKey.end()) {
			Message* message = getFirstAvailable(it->second);
			if (message)
				ret.push_back(message);
		}
		if ((key & ID_SOURCE_MASK) != 0) {
			key &= ~ID_SOURCE_MASK;
			it = m_messagesByKey.find(key & ~ID_SOURCE_MASK); // try again without specific source master
			if (it != m_messagesByKey.end()) {
				Message* message = getFirstAvailable(it->second);
				if (message)
					ret.push_back(message);
			}
		}
		it = m_messagesByKey.find(key | ID_SOURCE_ACTIVE_READ); // try again with special value for active read
		if (it != m_messagesByKey.end()) {
			Message* message = getFirstAvailable(it->second);
			if (message)
				ret.push_back(message);
		}
		it = m_messagesByKey.find(key | ID_SOURCE_ACTIVE_WRITE); // try again with special value for active write
		if (it != m_messagesByKey.end()) {
			Message* message = getFirstAvailable(it->second);
			if (message)
				ret.push_back(message);
		}
	}

	return ret;
}
开发者ID:Giermann,项目名称:ebusd,代码行数:53,代码来源:message.cpp

示例2: read

result_t SingleDataField::read(const PartType partType,
		SymbolString& data, unsigned char offset,
		unsigned int& output, const char* fieldName, signed char fieldIndex)
{
	if (partType != m_partType)
		return RESULT_EMPTY;

	switch (m_partType)
	{
	case pt_masterData:
		offset = (unsigned char)(offset + 5); // skip QQ ZZ PB SB NN
		break;
	case pt_slaveData:
		offset++; // skip NN
		break;
	default:
		return RESULT_ERR_INVALID_PART;
	}
	bool remainder = m_length==REMAIN_LEN && m_dataType->isAdjustableLength();
	if (offset + (remainder?1:m_length) > data.size()) {
		return RESULT_ERR_INVALID_POS;
	}
	if (isIgnored() || (fieldName != NULL && (m_name != fieldName || fieldIndex > 0))) {
		return RESULT_EMPTY;
	}
	return m_dataType->readRawValue(data, offset, m_length, output);
}
开发者ID:john30,项目名称:ebusd,代码行数:27,代码来源:data.cpp

示例3: scanAndWait

result_t BusHandler::scanAndWait(unsigned char dstAddress, SymbolString& slave)
{
	if (!isValidAddress(dstAddress) || isMaster(dstAddress))
		return RESULT_ERR_INVALID_ADDR;
	m_seenAddresses[dstAddress] |= SCAN_INIT;
	Message* scanMessage = m_messages->getScanMessage();
	if (scanMessage==NULL) {
		return RESULT_ERR_NOTFOUND;
	}
	istringstream input;
	SymbolString master;
	result_t result = scanMessage->prepareMaster(m_ownMasterAddress, master, input, UI_FIELD_SEPARATOR, dstAddress);
	if (result==RESULT_OK) {
		result = sendAndWait(master, slave);
		if (result==RESULT_OK) {
			Message* message = m_messages->getScanMessage(dstAddress);
			if (message!=NULL && message!=scanMessage) {
				scanMessage = message;
				scanMessage->storeLastData(pt_masterData, master, 0); // update the cache, expected to work since this is a clone
			}
		}
		if (result!=RESULT_ERR_NO_SIGNAL)
			m_seenAddresses[dstAddress] |= SCAN_DONE;
	}
	if (result != RESULT_OK || slave.size() == 0) // avoid "invalid position" during decode
		return result;

	return scanMessage->storeLastData(pt_slaveData, slave, 0); // update the cache
}
开发者ID:john30,项目名称:ebusd,代码行数:29,代码来源:bushandler.cpp

示例4: loadScanConfigFile

result_t loadScanConfigFile(MessageMap* messages, unsigned char address, SymbolString& data, string& relativeFile)
{
	PartType partType;
	if (isMaster(address)) {
		address = (unsigned char)(data[0]+5); // slave address of sending master
		partType = pt_masterData;
		if (data.size()<5+1+5+2+2) // skip QQ ZZ PB SB NN
			return RESULT_EMPTY;
	} else {
		partType = pt_slaveData;
		if (data.size()<1+1+5+2+2) // skip NN
			return RESULT_EMPTY;
	}
	DataFieldSet* identFields = DataFieldSet::getIdentFields();
	// MANUFACTURER/ZZ. ( C.S.H., C.H., C.S., S.H., C., S., H., "" ) .*csv
	string path, prefix, ident, sw, hw; // path: cfgpath/MANUFACTURER, prefix: ZZ., ident: C[C[C[C[C]]]], sw: xxxx, hw: xxxx
	ostringstream out;
	unsigned char offset = 0;
	size_t field = 0;
	result_t result = (*identFields)[field]->read(partType, data, offset, out, 0); // manufacturer name
	if (result==RESULT_ERR_NOTFOUND)
		result = (*identFields)[field]->read(partType, data, offset, out, OF_NUMERIC); // manufacturer name
	if (result==RESULT_OK) {
		path = out.str();
		transform(path.begin(), path.end(), path.begin(), ::tolower);
		path = string(opt.configPath) + "/" + path;
		out.str("");
		out << setw(2) << hex << setfill('0') << nouppercase << static_cast<unsigned>(address) << ".";
		prefix = out.str();
		out.str("");
		out.clear();
		offset = (unsigned char)(offset+(*identFields)[field++]->getLength(partType));
		result = (*identFields)[field]->read(partType, data, offset, out, 0); // identification string
	}
	if (result==RESULT_OK) {
		ident = out.str();
		out.str("");
		offset = (unsigned char)(offset+(*identFields)[field++]->getLength(partType));
		result = (*identFields)[field]->read(partType, data, offset, out, 0); // software version number
	}
	if (result==RESULT_OK) {
		sw = out.str();
		out.str("");
		offset = (unsigned char)(offset+(*identFields)[field++]->getLength(partType));
		result = (*identFields)[field]->read(partType, data, offset, out, 0); // hardware version number
	}
	if (result!=RESULT_OK) {
		logDebug(lf_main, "load scan config files: %s", getResultCode(result));
		return result;
	}
	vector<string> files;
	bool hasTemplates = false;
	if (result==RESULT_OK) {
		hw = out.str();
		result = collectConfigFiles(path, prefix, ".csv", files, NULL, &hasTemplates);
	}
	logDebug(lf_main, "found %d matching scan config files from %s with prefix %s: %s", files.size(), path.c_str(), prefix.c_str(), getResultCode(result));
	if (result!=RESULT_OK)
		return result;
	if (files.empty())
		return RESULT_ERR_NOTFOUND;

	// complete name: cfgpath/MANUFACTURER/ZZ[.C[C[C[C[C]]]]][.SWxxxx][.HWxxxx][.*].csv
	for (string::iterator it = ident.begin(); it!=ident.end(); it++) {
		if (::isspace(*it)) {
			ident.erase(it--);
		} else {
			*it = (char)::tolower(*it);
		}
	}
	size_t prefixLen = path.length()+1+prefix.length()-1;
	size_t bestMatch = 0;
	string best;
	for (vector<string>::iterator it = files.begin(); it!=files.end(); it++) {
		string name = *it;
		name = name.substr(prefixLen, name.length()-prefixLen+1-strlen(".csv")); // .*.
		size_t match = 1;
		if (name.length()>2) { // more than just "."
			size_t pos = name.rfind(".SW"); // check for ".SWxxxx."
			if (pos!=string::npos && name.find(".", pos+1)==pos+7) {
				if (name.substr(pos+3, 4)==sw)
					match += 6;
				else {
					continue; // SW mismatch
				}
			}
			pos = name.rfind(".HW"); // check for ".HWxxxx."
			if (pos!=string::npos && name.find(".", pos+1)==pos+7) {
				if (name.substr(pos+3, 4)==hw)
					match += 6;
				else {
					continue; // HW mismatch
				}
			}
			pos = name.find(".", 1); // check for ".C[C[C[C[C]]]]."
			if (ident.length()>0 && pos!=string::npos && pos>1 && pos<=6) { // up to 5 chars between two "."s, immediately after "ZZ."
				string check = name.substr(1, pos-1);
				string remain = ident;
				bool matches = false;
				while (remain.length()>0 && remain.length()>=check.length()) {
//.........这里部分代码省略.........
开发者ID:Giermann,项目名称:ebusd,代码行数:101,代码来源:main.cpp


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