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


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

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


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

示例1: wcsncpy

void Runtime::Debugger::ProcessArgs(Load* load) {
  // clear
  arguments.clear();
  arguments.push_back(L"obr");
  arguments.push_back(program_file);
  // parse arguments
  const wstring temp = load->GetFileName();
  wchar_t* buffer = (wchar_t*)calloc(sizeof(wchar_t), temp.size() + 1);
  wcsncpy(buffer, temp.c_str(), temp.size());
#ifdef WIN32
  wchar_t* token = wcstok(buffer, L" ");
#else
  wchar_t *state;
  wchar_t* token = wcstok(buffer, L" ", &state);
#endif
  while(token) {
    arguments.push_back(token);
#ifdef WIN32
    token = wcstok(NULL, L" ");
#else
    token = wcstok(NULL, L" ", &state);
#endif
  }
  wcout << L"program arguments sets." << endl;

  // clean up
  free(buffer);
  buffer = NULL;
}
开发者ID:8l,项目名称:objeck-lang,代码行数:29,代码来源:debugger.cpp

示例2: calc

 inline wstring calc( wstring const & s ) const
 {
     assert( _bufs.size() );
     wstring o;
     o.reserve( s.size() );
     int lastMatch;
     for( size_t offset = 0; offset < s.size(); ++offset )
     {
         lastMatch = -1;
         for( size_t i = 0; i < MIN( _maxLength, s.size() - offset ); ++i )
         {
             auto& v = _bufs[ i ][ s[ offset + i ] ];
             if( v == 0 ) break;
             else if( v == 1 ) lastMatch = (int)i;
         }
         if( lastMatch == -1 )
         {
             o.push_back( s[ offset ] );
         }
         else
         {
             o.append( lastMatch + 1, '*' );
             offset += lastMatch;    // for will + 1
         }
     }
     return o;
 }
开发者ID:denghe,项目名称:69net,代码行数:27,代码来源:Main.cpp

示例3: find_dir

UInt32 Archive::find_dir(const wstring& path) {
  if (file_list.empty())
    make_index();

  ArcFileInfo dir_info;
  dir_info.is_dir = true;
  dir_info.parent = c_root_index;
  size_t begin_pos = 0;
  while (begin_pos < path.size()) {
    size_t end_pos = begin_pos;
    while (end_pos < path.size() && !is_slash(path[end_pos])) end_pos++;
    if (end_pos != begin_pos) {
      dir_info.name.assign(path.data() + begin_pos, end_pos - begin_pos);
      FileIndexRange fi_range = equal_range(file_list_index.begin(), file_list_index.end(), -1, [&] (UInt32 left, UInt32 right) -> bool {
        const ArcFileInfo& fi_left = left == -1 ? dir_info : file_list[left];
        const ArcFileInfo& fi_right = right == -1 ? dir_info : file_list[right];
        return fi_left < fi_right;
      });
      if (fi_range.first == fi_range.second)
        FAIL(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND));
      dir_info.parent = *fi_range.first;
    }
    begin_pos = end_pos + 1;
  }
  return dir_info.parent;
}
开发者ID:landswellsong,项目名称:FAR,代码行数:26,代码来源:archive.cpp

示例4: iswspace

vector<IFilter*> IncludeFilterFactory::createFilter(const wstring& configPath, wstring& command, wstring& parameters)
{
	if (command == L"Include")
	{
		wstring value = parameters;
		while (value.length() > 0 && iswspace(value[0]))
			value = value.substr(1);

		wstring includePath;
		if (PathIsRelativeW(value.c_str()))
		{
			wchar_t filePath[MAX_PATH];
			configPath._Copy_s(filePath, sizeof(filePath) / sizeof(wchar_t), MAX_PATH);
			if (configPath.size() < MAX_PATH)
				filePath[configPath.size()] = L'\0';
			else
				filePath[MAX_PATH - 1] = L'\0';
			PathRemoveFileSpecW(filePath);
			PathAppendW(filePath, value.c_str());
			includePath = filePath;
		}
		else
			includePath = value;

		engine->loadConfigFile(includePath);
		command = L"";
	}

	return vector<IFilter*>();
}
开发者ID:Noiled,项目名称:equalizerapo,代码行数:30,代码来源:IncludeFilterFactory.cpp

示例5: locate_path_root

void locate_path_root(const wstring& path, size_t& path_root_len, bool& is_unc_path) {
  unsigned prefix_len = 0;
  is_unc_path = false;
  if (substr_match(path, 0, L"\\\\")) {
    if (substr_match(path, 2, L"?\\UNC\\")) {
      prefix_len = 8;
      is_unc_path = true;
    }
    else if (substr_match(path, 2, L"?\\") || substr_match(path, 2, L".\\")) {
      prefix_len = 4;
    }
    else {
      prefix_len = 2;
      is_unc_path = true;
    }
  }
  if ((prefix_len == 0) && !substr_match(path, 1, L":")) {
    path_root_len = 0;
  }
  else {
    wstring::size_type p = path.find(L'\\', prefix_len);
    if (p == wstring::npos) {
      p = path.size();
    }
    if (is_unc_path) {
      p = path.find(L'\\', p + 1);
      if (p == wstring::npos) {
        p = path.size();
      }
    }
    path_root_len = p;
  }
}
开发者ID:FarManagerLegacy,项目名称:UnInstall,代码行数:33,代码来源:pathutils.cpp

示例6: alignSentence

wstring TokenizerRus::alignSentence(const wstring& sentence) const
{
    wstring alginedSentence = L"";
	bool shouldMakeSpace = false;
	for (size_t letterIndex = 0; letterIndex < sentence.size(); ++letterIndex)
	{
		if (sentence[letterIndex] == L' ') {
			shouldMakeSpace = true;
        } else if (Tools::IsPunctuation(sentence[letterIndex])) {
            if ((sentence[letterIndex] != L',' &&
                sentence[letterIndex] != L'.' &&
                sentence[letterIndex] != L'-' &&
                sentence[letterIndex] != L':') ||
                letterIndex == 0 || letterIndex + 1 >= sentence.size() || // Working with numbers: 12,6
                !std::iswdigit(sentence[letterIndex - 1]) ||
                !std::iswdigit(sentence[letterIndex + 1]))
            {
                shouldMakeSpace = shouldMakeSpace || (sentence[letterIndex] != L'-');
            }
			alginedSentence += sentence[letterIndex];
        } else if (std::iswdigit(sentence[letterIndex]) && // Deal with 2%
            letterIndex + 1 < sentence.size() &&
            sentence[letterIndex + 1] == L'%') {
               shouldMakeSpace = true;
               alginedSentence += sentence[letterIndex];
        } else {
			if (shouldMakeSpace) {
				alginedSentence += L" ";
            }
			alginedSentence += sentence[letterIndex];
			shouldMakeSpace = false;
		}
	}
    return alginedSentence;
}
开发者ID:Samsung,项目名称:veles.nlp,代码行数:35,代码来源:TokenizerRus.cpp

示例7: w

vector<int> get_classes(wstring s) {
	wstring b_string = L"b";
	wstring s_string = L"s";
	vector<int> w(classes_list.size());
	for (int k=0; k<s.size(); k++) {
		bool b = false;
		for (int i=0; not b and i<classes_list.size(); i++) {
			for (int j=0; not b and j<classes_list[i].size(); j++) {
				if (classes_list[i][j].size() == 1) {
					if (s[k] == classes_list[i][j][0]) {
						w[i]++;
						if (s[k] == b_string[0]) w[8]++; //to update [b,d] at the time I update [b,v]
						if (s[k] == s_string[0]) w[5]++; //to update [r,s,l] at the time I update [s,z,ce,ci,x]
						b = true;
					}
				}
				else {
					if (k<s.size()-1 and s[k] == classes_list[i][j][0] and s[k+1] == classes_list[i][j][1]) {
						w[i]++;
						b = true;
					}
				}
			}
		}
	}
	return w;
}
开发者ID:MartiMayo,项目名称:WordPrediction,代码行数:27,代码来源:p2.cpp

示例8: word_wrap

wstring word_wrap(const wstring& str, wstring::size_type wrap_bound) {
  wstring result;
  wstring::size_type begin_pos = 0;
  while (begin_pos < str.size()) {
    wstring::size_type end_pos = begin_pos + wrap_bound;
    if (end_pos < str.size()) {
      for (wstring::size_type i = end_pos; i > begin_pos; i--) {
        if (str[i - 1] == L' ') {
          end_pos = i;
          break;
        }
      }
    }
    else {
      end_pos = str.size();
    }
    wstring::size_type trim_pos = end_pos;
    while (trim_pos > begin_pos && str[trim_pos - 1] == L' ') trim_pos--;
    if (trim_pos > begin_pos) {
      if (!result.empty())
        result.append(1, L'\n');
      result.append(str.data() + begin_pos, trim_pos - begin_pos);
    }
    begin_pos = end_pos;
  }
  return result;
}
开发者ID:AKKF,项目名称:altWinDirStat,代码行数:27,代码来源:strutils.cpp

示例9: WideCharToMultiByte

string Gosu::wstringToUTF8(const wstring& ws)
{
	unsigned size = WideCharToMultiByte(CP_UTF8, 0, ws.c_str(), ws.size(), 0, 0, 0, 0);
	vector<char> buffer(size + 1);
	WideCharToMultiByte(CP_UTF8, 0, ws.c_str(), ws.size(), &buffer[0], buffer.size(), 0, 0);
	return &buffer[0];
}
开发者ID:HakubJozak,项目名称:gosu,代码行数:7,代码来源:Utility.cpp

示例10: has_accent

bool has_accent(wstring s) {
	for (int i=0; i<s.size(); i++)
		for (int j=5; j<vowels_list.size(); j++) 
			if (s[i] == vowels_list[j]) return true;
		
	return false;
}
开发者ID:MartiMayo,项目名称:WordPrediction,代码行数:7,代码来源:p2.cpp

示例11: length_error

    string toUtf8String(const wstring& wide) {
        if (wide.size() > boost::integer_traits<int>::const_max)
            throw length_error(
                "Wide string cannot be more than INT_MAX characters long.");
        if (wide.size() == 0)
            return "";

        // Calculate necessary buffer size
        int len = ::WideCharToMultiByte(
                      CP_UTF8, 0, wide.c_str(), static_cast<int>(wide.size()),
                      NULL, 0, NULL, NULL);

        // Perform actual conversion
        if (len > 0) {
            vector<char> buffer(len);
            len = ::WideCharToMultiByte(
                      CP_UTF8, 0, wide.c_str(), static_cast<int>(wide.size()),
                      &buffer[0], static_cast<int>(buffer.size()), NULL, NULL);
            if (len > 0) {
                assert(len == static_cast<int>(buffer.size()));
                return string(&buffer[0], buffer.size());
            }
        }

        throw boost::system::system_error(
            ::GetLastError(), boost::system::system_category());
    }
开发者ID:Andrew8305,项目名称:SequoiaDB,代码行数:27,代码来源:text.cpp

示例12: unhex

void unhex(const wstring& str, Buffer<unsigned char>& buf) {
  buf.resize(str.size() / 2);
  for (unsigned i = 0; i < str.size(); i += 2) {
    unsigned char b = (unhex(str[i]) << 4) | unhex(str[i + 1]);
    buf.data()[i / 2] = b;
  }
}
开发者ID:AshWilliams,项目名称:ConEmu,代码行数:7,代码来源:customact.cpp

示例13: AddComma

wstring AddComma(const wstring& source)
{
	PWCHAR pBuf = (PWCHAR)malloc(source.size() * 4);
	if (pBuf == NULL)
	{
		return L"";
	}

	size_t len, i, j;
	for (len = source.size(), i = 0, j = 0; i < len; i++, j++)
	{
		if (!((len - i) % 3) && i != 0)
		{
			if (j > 0 && pBuf[j - 1] != L'-')
			{
				pBuf[j++] = L',';
			}
		}

		pBuf[j] = source[i];
	}
	pBuf[j] = 0;

	wstring s(pBuf);
	free(pBuf);
	return s;
}
开发者ID:poorboy,项目名称:ProcessFileSystem,代码行数:27,代码来源:StringHelper.cpp

示例14: LTEXT

/*!
	sakura.iniの1行を処理する.

	1行の読み込みが完了するごとに呼ばれる.
	
	@param line [in] 読み込んだ行
*/
void CProfile::ReadOneline(
	const wstring& line
)
{
	//	空行を読み飛ばす
	if( line.empty() )
		return;

	//コメント行を読みとばす
	if( 0 == line.compare( 0, 2, LTEXT("//") ))
		return;

	// セクション取得
	//	Jan. 29, 2004 genta compare使用
	if( line.compare( 0, 1, LTEXT("[") ) == 0 
			&& line.find( LTEXT("=") ) == line.npos
			&& line.find( LTEXT("]") ) == ( line.size() - 1 ) ) {
		Section Buffer;
		Buffer.strSectionName = line.substr( 1, line.size() - 1 - 1 );
		m_ProfileData.push_back( Buffer );
	}
	// エントリ取得
	else if( !m_ProfileData.empty() ) {	//最初のセクション以前の行のエントリは無視
		wstring::size_type idx = line.find( LTEXT("=") );
		if( line.npos != idx ) {
			m_ProfileData.back().mapEntries.insert( PAIR_STR_STR( line.substr(0,idx), line.substr(idx+1) ) );
		}
	}
}
开发者ID:beru,项目名称:sakura,代码行数:36,代码来源:CProfile.cpp

示例15: WinMain

int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParamarg, int cmdShow) {
	openLog();

#ifdef _NEED_WIN_GENERATE_DUMP
	_oldWndExceptionFilter = SetUnhandledExceptionFilter(_exceptionFilter);
#endif

	writeLog(L"Updaters started..");

	LPWSTR *args;
	int argsCount;

	bool needupdate = false, autostart = false, debug = false;
	args = CommandLineToArgvW(GetCommandLine(), &argsCount);
	if (args) {
		for (int i = 1; i < argsCount; ++i) {
			if (equal(args[i], L"-update")) {
				needupdate = true;
			} else if (equal(args[i], L"-autostart")) {
				autostart = true;
			} else if (equal(args[i], L"-debug")) {
				debug = _debug = true;
				openLog();
			}
		}
		if (needupdate) writeLog(L"Need to update!");
		if (autostart) writeLog(L"From autostart!");

		exeName = args[0];
		writeLog(L"Exe name is: " + exeName);
		if (exeName.size() > 11) {
			if (equal(exeName.substr(exeName.size() - 11), L"Updater.exe")) {
				exeDir = exeName.substr(0, exeName.size() - 11);
				writeLog(L"Exe dir is: " + exeDir);
				if (needupdate && update()) {
					updateRegistry();
				}
			} else {
				writeLog(L"Error: bad exe name!");
			}
		} else {
			writeLog(L"Error: short exe name!");
		}
		LocalFree(args);
	} else {
		writeLog(L"Error: No command line arguments!");
	}

	wstring targs = L"-noupdate";
	if (autostart) targs += L" -autostart";
	if (debug) targs += L" -debug";

	ShellExecute(0, 0, (exeDir + L"Telegram.exe").c_str(), targs.c_str(), 0, SW_SHOWNORMAL);

	writeLog(L"Executed Telegram.exe, closing log and quiting..");
	closeLog();

	return 0;
}
开发者ID:600rr,项目名称:tdesktop,代码行数:59,代码来源:updater.cpp


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