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


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

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


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

示例1: callback

void CALLBACK callback(MethodID methodID, int callID, wstring& address, Cause cause, wstring* callInfo) {
    static HANDLE hMutex = CreateMutex(NULL, FALSE, "callbackMutex");
    DWORD dwWaitResult = WaitForSingleObject(hMutex, 5000L);
	logger->debug("Entering callback method %d: callID=%d, address=%S...", methodID, callID, address.c_str());
    if(dwWaitResult == WAIT_OBJECT_0) {
	    try{
		    JNIEnv *localEnv = NULL;
		    g_javaVM->AttachCurrentThread((void**)&localEnv, NULL);
		    jclass cls = localEnv->GetObjectClass(g_thisObj);

            jmethodID callbackID = NULL;
			for (int retry = 0; callbackID == NULL && retry < 5; retry++) {
				callbackID = localEnv->GetMethodID(cls, "callback", "(IILjava/lang/String;I[Ljava/lang/String;)V");
				// if we have to try again, delay for 250 ms
				if (callbackID == NULL && retry < 5) {
					Sleep(250);
				}
				logger->debug("callback methodID: %p, retry=%d", callbackID, retry);
			}

		    if (callbackID == NULL) {
			    logger->fatal("Callback method not available.");
		    } else {
			    jint jMethodID = methodID;
			    jint jCallID = callID;
			    jstring jAddress = localEnv->NewString(((jchar *)address.c_str()), (jsize)address.length());
			    jint jCause = cause;

			    jobjectArray objCallInfo = NULL;
			    if(callInfo != NULL) {
				    logger->debug("Setting callInfo...");
				    jclass oCls = localEnv->FindClass("java/lang/String");
				    objCallInfo = localEnv->NewObjectArray(4, oCls, NULL);
				    for (int i=0; i<4; i++) {
					    jstring jInfo = localEnv->NewString(((jchar *)callInfo[i].c_str()), (jsize)callInfo[i].length());
					    localEnv->SetObjectArrayElement(objCallInfo, i, jInfo);
				    }
			    } else {
				    logger->debug("No callInfo for this callback.");
			    }
			    localEnv->CallVoidMethod(g_thisObj, callbackID, jMethodID, jCallID, jAddress, jCause, objCallInfo);
				g_javaVM->DetachCurrentThread();
			    logger->debug("Java callback successfully called.");
		    }
	    } catch(...){
		    logger->fatal("Callback failed.");
		}
        ReleaseMutex(hMutex);
    } else {
		logger->fatal("Cannot obtain callback mutex: dwWaitResult=%08X.", dwWaitResult);
    }
}
开发者ID:panoma-berlin,项目名称:tapi3provider,代码行数:52,代码来源:Tapi3Provider.cpp

示例2:

XercesString::XercesString(const wstring& in)
    : basic_string<XMLCh>()
{
    for(unsigned int i=0; i<in.length(); ++i) {
        wchar_t utf32 = in[i];
        if (utf32 >= 0x10000UL) {
            push_back(0xD800 - 0x40 + (utf32 >> 10));
            push_back(0xDC00 + (utf32 & 0x3FF));
        }
        else
开发者ID:cscott,项目名称:wikiserver,代码行数:10,代码来源:XercesString.cpp

示例3: WideCharToMultiByte

std::string W2Ansi( const wstring& wszIn )
{
	string szRet;
	if (wszIn.length() <= 0) 
	{
		return szRet;
	}
	LPCWSTR pwszSrc = wszIn.c_str();
	int nWLen = wszIn.length();
	int nLen = WideCharToMultiByte(CP_ACP, 0, pwszSrc, -1, NULL, 0, NULL, NULL);
	
	char* pszDst = new char[nLen+1];
	assert(NULL != pszDst);
	WideCharToMultiByte(CP_ACP, 0, pwszSrc, -1, pszDst, nLen, NULL, NULL);
	pszDst[nLen] = '\0';
	szRet =pszDst;
	delete [] pszDst;
	return szRet;
}
开发者ID:tianyx,项目名称:TxUIProject,代码行数:19,代码来源:StrConvert.cpp

示例4: Tidy

	wstring Tidy(wstring filename) {						//Changes uppercase to lowercase and removes trailing spaces to do what Windows filesystem does to filenames.	
		size_t endpos = filename.find_last_not_of(L" \t");
	
		if (filename.npos == endpos) return (L""); 			//sanity check for empty string
		else {
			filename = filename.substr(0, endpos+1);
			for (unsigned int i = 0; i < filename.length(); i++) filename[i] = tolower(filename[i]);
			return (filename);
		}
	}
开发者ID:Baron59,项目名称:boss,代码行数:10,代码来源:Helpers.cpp

示例5:

/**
 * predict MorphologicalInfo by suffix
 */
vector<MorphologicalInfo> SuffixModelTrie::getMorphologicalPredictionBySuffix(wstring _word)
{
	vector<MorphologicalInfo> result = vector<MorphologicalInfo>();
	SuffixModelNode* currentNode = root;
	int suffixLength = 0;
	for (int i = (int) _word.length() - 1; i >= 0; --i)
	{
		SuffixModelNode* tmpNode = currentNode->findChildNode(_word.at(i));
		if (tmpNode == NULL)
		{
			break;
		}
		currentNode = tmpNode;
		suffixLength++;
        //wcout << _word.at(i) << " : " << currentNode->getFeatureFrequencyMap().size() << endl;
	}
	if (suffixLength == 0)
	{
		return result;
	}
    //wcout << "Suffix length = " << suffixLength << endl;
	map<int, int> _featureFrequencyMap = currentNode->getFeatureFrequencyMap();
    //wcout << "_featureFrequencyMap's size = " << _featureFrequencyMap.size() << endl;
	map<int, int>::iterator iter;
    //@TODO : \u043f\u0435\u0440\u0440\u0441\u0441\u043e\u043d//here was cyrrilic symbols: перрссон
	for (iter = _featureFrequencyMap.begin(); iter != _featureFrequencyMap.end(); ++iter)
	{
		int _featureId = iter->first;
		int _frequency = iter->second;
		int _basicFeatureListId = _featureId / 1000;
		int _featureListId = _featureId % 1000;
		wstring _initial_form = suffixLength < (int) _word.length() ? L"-" + _word.substr(_word.length() - suffixLength) : _word;
		MorphologicalInfo _morphologicalInfo;
		_morphologicalInfo.basicFeatureListId = _basicFeatureListId;
		_morphologicalInfo.featureListId = _featureListId;
		_morphologicalInfo.frequency = _frequency;
		_morphologicalInfo.initial_form = _initial_form;
		_morphologicalInfo.lemmaId = 0;
		_morphologicalInfo.suffix_length = suffixLength;
		result.push_back(_morphologicalInfo);
	}
	return result;
}
开发者ID:Samsung,项目名称:veles.nlp,代码行数:46,代码来源:SuffixModelTrie.cpp

示例6:

void sbuf_stream::getUTF16(wstring &utf16_string) {
    sbuf.getUTF16(offset, utf16_string);
    size_t num_bytes = utf16_string.length() * 2;
    if (num_bytes > 0) {
        // if anything was read then also skip \U0000
        num_bytes += 2;
    }
    offset += num_bytes;
    return;
}
开发者ID:pombredanne,项目名称:be13_api,代码行数:10,代码来源:sbuf_stream.cpp

示例7: IsDigitalW

BOOL base_string::IsDigitalW(wstring wstrSrc)
{
	int nIndex = 0;
	size_t nPos = wstrSrc.find('.');
	if (wstrSrc.empty())
	{
		return FALSE;
	}
	else if (nPos == wstring::npos)
	{
		for (nIndex = 0; nIndex < wstrSrc.length(); nIndex++)
		{
			if (wstrSrc[nIndex] < '0' || wstrSrc[nIndex] > '9')
			{
				return FALSE;
			}
		}
	}
	else if (nPos == wstrSrc.length() - 1)
	{
		return FALSE;
	}
	else if (nPos != wstring::npos)
	{
		for (nIndex = 0; nIndex < nPos; nIndex++)
		{
			if (wstrSrc[nIndex] < '0' || wstrSrc[nIndex] > '9')
			{
				return FALSE;
			}
		}
		for (nIndex = nPos + 1; nIndex < wstrSrc.length(); nIndex++)
		{
			if (wstrSrc[nIndex] < '0' || wstrSrc[nIndex] > '9')
			{
				return FALSE;
			}
		}
	}

	return TRUE;
}
开发者ID:lynebetos,项目名称:BusStopTerminal,代码行数:42,代码来源:base_string.cpp

示例8: HexToARGB

COLORREF HexToARGB(const wstring& text) {
  int i = text.length() - 6;
  if (i < 0) return 0;

  unsigned int r, g, b;
  r = wcstoul(text.substr(i + 0, 2).c_str(), NULL, 16);
  g = wcstoul(text.substr(i + 2, 2).c_str(), NULL, 16);
  b = wcstoul(text.substr(i + 4, 2).c_str(), NULL, 16);

  return RGB(r, g, b);
}
开发者ID:Greathood,项目名称:taiga,代码行数:11,代码来源:gfx.cpp

示例9:

WinRegKeyExeption::WinRegKeyExeption(LONG errorcode, HKEY rootkey, wstring subkey, wstring label=L"")
:m_errorcode(errorcode),m_key(towstring<HKEY>(rootkey))
{
	m_key.append(L"\\");
	m_key.append(subkey);
	if(label.length()>0)
	{
		m_key.append(L"\\");
		m_key.append(label);
	}
}
开发者ID:12019,项目名称:svn.gov.pt,代码行数:11,代码来源:WinRegKey.cpp

示例10: disconnectFileName

wstring ConnectedShortcut::disconnectFileName(const wstring& shortcutName)
{
	const wstring suffix = L" + " SHORT_APP_NAME L".lnk";
	if (PathMatchSpec(shortcutName.data(), (L"*" + suffix).data()) == FALSE)
		return shortcutName;

	wstring newName = shortcutName;
	newName.erase(newName.length() - suffix.length());
	newName.append(L".lnk");
	return newName;
}
开发者ID:troiganto,项目名称:autosave,代码行数:11,代码来源:ConnectedShortcut.cpp

示例11: Trim

void Trim(wstring& str, const wchar_t trim_chars[],
          bool trim_left, bool trim_right) {
  if (str.empty())
    return;

  const size_t index_begin =
      trim_left ? str.find_first_not_of(trim_chars) : 0;
  const size_t index_end =
      trim_right ? str.find_last_not_of(trim_chars) : str.length() - 1;

  if (index_begin == wstring::npos || index_end == wstring::npos) {
    str.clear();
    return;
  }

  if (trim_right)
    str.erase(index_end + 1, str.length() - index_end + 1);
  if (trim_left)
    str.erase(0, index_begin);
}
开发者ID:vjcagay,项目名称:taiga,代码行数:20,代码来源:string.cpp

示例12: stringToNumber

double stringToNumber( wstring& text )
{
    wstring::size_type endptr;
    double number = std::stod( text, &endptr );
    // the conversion is successful only when no text remains after the number
    if( endptr != text.length() )
    {
        throw new std::invalid_argument( "stringToNumber called on a text that contains characters after the number" );
    }
    return( number );
}
开发者ID:Microsoft,项目名称:pict,代码行数:11,代码来源:strings.cpp

示例13:

wstring 
TransferRule::category_name(const wstring& lemma, const wstring& tags) {
  wstring catname=L"";

  if (lemma.length()>0)//TODO: codificar bien el caracter extraño
    catname+=StringUtils::substitute(StringUtils::substitute(StringUtils::substitute(lemma,L"#",L"_"),L"\u2019",L"_"),L"'",L"QUOT")+L"_";

  catname+=StringUtils::substitute(StringUtils::substitute(StringUtils::substitute(StringUtils::substitute(tags,L".",L""),L"*",L"_"),L"+",L"plus"),L"@",L"arroba");

  return catname;
}
开发者ID:sundetova,项目名称:kaz-eng-generalisation,代码行数:11,代码来源:TransferRule.C

示例14: OnException

void qtDLGDetailInfo::OnException(wstring functionName, wstring moduleName, quint64 exceptionOffset, quint64 exceptionCode, DWORD processID, DWORD threadID)
{
	qtDLGNanomite *pMainWindow = qtDLGNanomite::GetInstance();
	pMainWindow->lExceptionCount++;

	tblExceptions->insertRow(tblExceptions->rowCount());
		
	tblExceptions->setItem(tblExceptions->rowCount() - 1,0,
		new QTableWidgetItem(QString("%1").arg(exceptionOffset,16,16,QChar('0'))));
		
	tblExceptions->setItem(tblExceptions->rowCount() - 1,1,
		new QTableWidgetItem(QString("%1").arg(exceptionCode,8,16,QChar('0'))));

	tblExceptions->setItem(tblExceptions->rowCount() - 1,2,
		new QTableWidgetItem(QString().sprintf("%08X / %08X",processID,threadID)));

	if(functionName.length() > 0 )
		tblExceptions->setItem(tblExceptions->rowCount() - 1,3,
			new QTableWidgetItem(QString::fromStdWString(moduleName).append(".").append(QString::fromStdWString(functionName))));


	QString logMessage;

	if(functionName.length() > 0 && moduleName.length() > 0)
		logMessage = QString("[!] Exception - PID: %1 TID: %2 - ExceptionCode: %3 - ExceptionOffset: %4 - %[email protected]%6")
		.arg(processID,6,16,QChar('0'))
		.arg(threadID,6,16,QChar('0'))
		.arg(exceptionCode,8,16,QChar('0'))
		.arg(exceptionOffset,16,16,QChar('0'))
		.arg(QString::fromStdWString(functionName))
		.arg(QString::fromStdWString(moduleName));
	else
		logMessage = QString("[!] Exception - PID: %1 TID: %2 - ExceptionCode: %3 - ExceptionOffset: %4")
		.arg(processID,6,16,QChar('0'))
		.arg(threadID,6,16,QChar('0'))
		.arg(exceptionCode,8,16,QChar('0'))
		.arg(exceptionOffset,16,16,QChar('0'));

	pMainWindow->logView->OnLog(logMessage);
	pMainWindow->UpdateStateBar(1);
}
开发者ID:blaquee,项目名称:Nanomite,代码行数:41,代码来源:qtDLGDetailInfo.cpp

示例15: getWeightedFrequency

word_frequency_t getWeightedFrequency(wstring const &text)
{
    word_frequency_t freq;
    for(int i = 0; i < text.length() - WORD_MAXIMUM; i++) {
        wstring candidate = L"";
        for(int j = WORD_MINIMUM; j <= WORD_MAXIMUM; j++) {
            assert(i + j <= text.length() && "access violation");
            candidate.push_back(text[i + j - 1]);
            auto it = freq.find(candidate);
            if(it != freq.end())
                it->second += 1.0;
            else
                freq[candidate] = 1.0;
        }
    }
    for(auto &it : freq) {
        int len = it.first.length();
        it.second = it.second * len * len - 0.3;
    }
    return freq;
}
开发者ID:kjm19940711,项目名称:learn-js,代码行数:21,代码来源:words.cpp


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